MainEquipmentDetail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. <template>
  2. <div class='main-equipment-detail'>
  3. <!-- 顶部条 -->
  4. <van-nav-bar :title='title' left-arrow @click-left='backPage' @click-right='handleRightClick'>
  5. <template #right>
  6. <i class='iconfont wanda-scan'></i>
  7. </template>
  8. </van-nav-bar>
  9. <!-- 搜索框 -->
  10. <div class='equipment-search-container'>
  11. <van-search class='equipment-search' v-model='keyword' placeholder='请输入设备名称或内码' @search='onSearch'></van-search>
  12. </div>
  13. <!-- 设备列表 -->
  14. <div class='equipment-list' v-if='list.length'>
  15. <van-list v-model='loading' :finished='finished' finished-text='没有更多了' :offset='20' :immediate-check='false' @load='onLoad'>
  16. <div class='equipment' v-for='(item,index) in list' :key='index'>
  17. <p class='title'>{{item.sbqc}}</p>
  18. <div class='assetnum-attribution'>
  19. <div class='assetnum'>
  20. <div class='label'>设备内码:</div>
  21. <div class='value'>{{item.assetnum}}</div>
  22. </div>
  23. <div class='attribution'>
  24. <div class='label'>管理归属:</div>
  25. <div class='value'>{{item.sbglgs}}</div>
  26. </div>
  27. </div>
  28. <div class='brand'>
  29. <div class='label'>{{'品\u3000\u3000牌:'}}</div>
  30. <div class='value'>{{item.brand || '--'}}</div>
  31. </div>
  32. <div class='manufacturer'>
  33. <div class='label'>生产厂商:</div>
  34. <div class='value'>{{item.manufacturer}}</div>
  35. </div>
  36. <div class='floor-status'>
  37. <div class='floor'>
  38. <div class='label'>
  39. <i class='iconfont wanda-dingwei1' style='color:#C3C7CB;'></i>
  40. <span>楼层:</span>
  41. </div>
  42. <div class='value'>{{item.floorcode}}</div>
  43. </div>
  44. <div class='status run' v-if='item.sb_status === "运行"'>运行</div>
  45. <div class='status wx' v-else-if='item.sb_status === "维修"'>维修</div>
  46. <div class='status wb' v-else-if='item.sb_status === "维保"'>维保</div>
  47. </div>
  48. <div class='divider'></div>
  49. </div>
  50. </van-list>
  51. </div>
  52. <!-- 无数据 -->
  53. <van-empty class='m-empty' v-if='finished &&!list.length' description='暂无数据'>
  54. <template #image>
  55. <img class='no-data' src='../../assets/images/search_null.png' alt />
  56. </template>
  57. </van-empty>
  58. <!-- 点击头部筛选,出现的右侧弹窗 -->
  59. <van-popup class='m-popup-container' v-model='showPopup' position='right'>
  60. <div class='m-popup'>
  61. <!-- 系统 -->
  62. <div class='system'>
  63. <h1 class='title'>楼层</h1>
  64. <div class='system-btn-container'>
  65. <div class='system-btn' v-for='(item,index) in floorList' :key='index'>
  66. <van-button class='m-btn' :class='item.active' @click='changeFloor(item)'>{{item.code}}</van-button>
  67. </div>
  68. </div>
  69. </div>
  70. <div class='divider'></div>
  71. <!-- 设备设施 -->
  72. <div class='sbss'>
  73. <h1 class='title'>管理归属</h1>
  74. <div class='system-btn-container'>
  75. <div class='system-btn' v-for='(item,index) in attributionList' :key='index'>
  76. <van-button class='m-btn' :class='item.active' @click='changeAttribution(item)'>{{item.text}}</van-button>
  77. </div>
  78. </div>
  79. </div>
  80. <div class='footer'>
  81. <van-button size='large' color='#025BAA' plain type='info' @click='reset'>重置</van-button>
  82. <van-button size='large' color='#025BAA' type='info' @click='confirm'>确定</van-button>
  83. </div>
  84. </div>
  85. </van-popup>
  86. </div>
  87. </template>
  88. <script>
  89. /**
  90. * 主要设备清单
  91. */
  92. import Vue from 'vue'
  93. import { NavBar, Search, List, Cell, Icon, Popup, Button, Empty } from 'vant'
  94. Vue.use(NavBar).use(Search).use(List).use(Cell).use(Icon).use(Popup).use(Button).use(Empty)
  95. import { mapGetters } from 'vuex'
  96. import { queryOptions } from '@/api/public'
  97. import { queryEquipmentList } from '@/api/equipmentList'
  98. import { sleep } from '@/utils/util'
  99. import { cloneDeep } from 'lodash'
  100. export default {
  101. name: 'mainEquipment',
  102. props: {},
  103. data() {
  104. return {
  105. title: '',
  106. // 查询下拉菜单,主列表使用
  107. type_code: '', //自定义分类内码
  108. brand: '', //品牌
  109. classstructureid: '', //设备分类
  110. manufacturer: '', //生产厂商
  111. sbxh: '', //设备类型
  112. keyword: '',
  113. page: 1,
  114. size: 10,
  115. list: [],
  116. loading: false,
  117. finished: false,
  118. showPopup: false,
  119. floorList: [],
  120. attributionList: [{ text: '全部', id: '全部', active: 'active' }],
  121. currentFloor: '全部',
  122. currentAttribution: '全部',
  123. // 弹窗中使用数据
  124. modalData: {
  125. floor: '',
  126. attribution: '',
  127. },
  128. // 弹窗中使用备份数据
  129. modalDataBak: {
  130. floor: '',
  131. attribution: '',
  132. },
  133. }
  134. },
  135. computed: {
  136. ...mapGetters(['plazaId', 'smsxt', 'categoryId', 'floorsArr']),
  137. },
  138. components: {},
  139. created() {
  140. // 从路由中获取参数
  141. // brand, 品牌如果没有传递‘--’
  142. // classstructureid, 设备分类
  143. // manufacturer, 生产厂商 如果没有传递‘--’
  144. // sbxh, 设备类型 如果没有传递‘--’
  145. // type_code 自定义分类内码
  146. // TODO: 参数修改
  147. console.log(this.$route)
  148. let { type_name, sl, type_code, brand, classstructureid, manufacturer, sbxh } = this.$route.params
  149. this.title = `${type_name}(${sl})`
  150. this.type_code = type_code
  151. this.brand = brand || '--'
  152. this.classstructureid = classstructureid
  153. this.manufacturer = manufacturer || '--'
  154. this.sbxh = sbxh || '--'
  155. // 设置 筛选抽屉中的 楼层
  156. let floorList = [{ code: '全部', gcname: '全部', gcode: '全部', gname: '全部', seq: null, active: 'active' }]
  157. this.floorsArr.map(({ code, gcname, gcode, gname, seq }) => {
  158. floorList.push({ code, gcname, gcode, gname, seq, active: '' })
  159. })
  160. this.floorList = floorList
  161. // 查询列表
  162. this.onLoad()
  163. // 查询归属管理
  164. this.getOptions()
  165. },
  166. beforeMount() {},
  167. mounted() {},
  168. methods: {
  169. /**
  170. * 查询管理归属下拉菜单
  171. */
  172. async getOptions() {
  173. let data = {
  174. plazaId: this.plazaId,
  175. onlyMainAsset: true,
  176. }
  177. let postParams = [{ columnName: { sbglgs: 'sbglgs' }, params: { type_code: this.type_code }, tableName: 'sms_asset' }]
  178. let res = await queryOptions({ data, postParams })
  179. if (!res?.data?.data) {
  180. this.attributionList = [{ text: '全部', id: '全部', active: 'active' }]
  181. return false
  182. }
  183. let attributionList = res.data.data.sms_asset.sbglgs
  184. // value,key --> text,id
  185. attributionList.map((item) => {
  186. item.text = item.value
  187. item.id = item.key
  188. item.active = false
  189. })
  190. this.attributionList = [{ text: '全部', id: '全部', active: 'active' }, ...attributionList]
  191. },
  192. backPage() {
  193. this.$router.go(-1)
  194. },
  195. /**
  196. * 点击右侧筛选
  197. */
  198. handleRightClick() {
  199. this.showPopup = true
  200. // 设置选中的专业系统
  201. this.changeFloor({ gname: this.currentFloor })
  202. },
  203. /**
  204. * 搜索
  205. */
  206. onSearch() {
  207. // 初始化数据,查询列表
  208. this.initData()
  209. this.onLoad()
  210. },
  211. /**
  212. * 初始化数据
  213. */
  214. initData() {
  215. this.list = []
  216. this.page = 1
  217. this.count = 0
  218. this.finished = false
  219. },
  220. async onLoad() {
  221. // console.log('onload')
  222. if (this.page > 1) {
  223. // await sleep(1000)
  224. }
  225. await this.getList()
  226. this.page++
  227. this.loading = false
  228. if (this.list.length >= this.count) {
  229. this.finished = true
  230. }
  231. },
  232. async getList() {
  233. let queryData = {
  234. data: {
  235. plazaId: this.plazaId,
  236. page: this.page,
  237. size: this.size,
  238. onlyMainAsset: true,
  239. },
  240. postParams: {
  241. brand: this.brand,
  242. classstructureid: this.classstructureid,
  243. manufacturer: this.manufacturer,
  244. sbxh: this.sbxh,
  245. type_code: this.type_code,
  246. },
  247. }
  248. // 关键字搜索
  249. if (this.keyword) {
  250. queryData.data.keyword = `${this.keyword}:sbjc,assetnum;`
  251. }
  252. // 筛选楼层
  253. if (this.currentFloor && this.currentFloor !== '全部') {
  254. queryData.postParams.gname = this.currentFloor
  255. }
  256. // 筛选管理归属
  257. if (this.currentAttribution && this.currentAttribution !== '全部') {
  258. queryData.postParams.sbglgs = this.currentAttribution
  259. }
  260. let res = await queryEquipmentList(queryData)
  261. if (!res?.data?.data) {
  262. return false
  263. }
  264. let resData = res.data.data || []
  265. this.list = [...this.list, ...resData]
  266. this.count = res.data.count
  267. },
  268. /**
  269. * popup 更改楼层
  270. */
  271. changeFloor(data) {
  272. let floorList = this.floorList
  273. floorList.map((item) => {
  274. item.active = ''
  275. if (item.gname === data.gname) {
  276. item.active = 'active'
  277. }
  278. })
  279. // 弹窗选中的系统
  280. this.$set(this.modalDataBak, 'floor', data.gname)
  281. },
  282. /**
  283. * 更改管理归属
  284. */
  285. changeAttribution(data) {
  286. let { attributionList } = this
  287. attributionList.map((item) => {
  288. item.active = ''
  289. if (item.text === data.text) {
  290. item.active = 'active'
  291. }
  292. })
  293. this.$set(this.modalDataBak, 'attribution', data.text)
  294. },
  295. /**
  296. * 重置
  297. */
  298. reset() {
  299. this.modalDataBak = {
  300. floor: '',
  301. wellType: '',
  302. }
  303. this.modalData = {
  304. floor: '',
  305. wellType: '',
  306. }
  307. let attributionList = cloneDeep(this.attributionList)
  308. attributionList.map((item) => {
  309. item.active = ''
  310. item.text === '全部' && (item.active = 'active')
  311. })
  312. this.attributionList = attributionList
  313. this.currentFloor = '全部'
  314. this.currentAttribution = '全部'
  315. this.showPopup = false
  316. // 初始化数据,查询列表
  317. this.initData()
  318. this.onLoad()
  319. },
  320. /**
  321. * 确定
  322. */
  323. confirm() {
  324. this.modalData = cloneDeep(this.modalDataBak)
  325. this.showPopup = false
  326. this.currentFloor = this.modalData.floor
  327. this.currentAttribution = this.modalData.attribution
  328. // 初始化数据,查询列表
  329. this.initData()
  330. this.onLoad()
  331. },
  332. },
  333. }
  334. </script>
  335. <style lang='less' scoped>
  336. .main-equipment-detail {
  337. width: 100%;
  338. height: 100%;
  339. background-color: #f5f6f7;
  340. // 返回箭头修改
  341. /deep/ .van-nav-bar .van-icon {
  342. color: #000;
  343. }
  344. // 搜索
  345. .equipment-search-container {
  346. width: 100%;
  347. height: 55px;
  348. // background-color: #fff;
  349. text-align: center;
  350. .equipment-search {
  351. width: 80%;
  352. margin: 0 auto;
  353. background: none;
  354. }
  355. .van-search__content {
  356. background: #fff;
  357. border-radius: 50px;
  358. }
  359. }
  360. // 设备列表
  361. .equipment-list {
  362. width: 100%;
  363. max-height: calc(100% - 100px);
  364. overflow: auto;
  365. background-color: #fff;
  366. .equipment {
  367. width: 100%;
  368. position: relative;
  369. padding: 16px 10px 0;
  370. .title {
  371. // height: 44px;
  372. font-size: 16px;
  373. font-weight: 500;
  374. color: #333333;
  375. line-height: 22px;
  376. margin-bottom: 12px;
  377. }
  378. .assetnum-attribution {
  379. margin-bottom: 8px;
  380. display: flex;
  381. width: 100%;
  382. height: 20px;
  383. line-height: 20px;
  384. justify-content: space-between;
  385. .assetnum,
  386. .attribution {
  387. display: flex;
  388. }
  389. }
  390. .brand,
  391. .manufacturer {
  392. display: flex;
  393. margin-bottom: 8px;
  394. width: 100%;
  395. height: 20px;
  396. line-height: 20px;
  397. }
  398. .floor-status {
  399. margin: 12px 0 16px;
  400. display: flex;
  401. justify-content: space-between;
  402. width: 100%;
  403. height: 20px;
  404. line-height: 20px;
  405. .floor {
  406. display: flex;
  407. height: 20px;
  408. line-height: 20px;
  409. .label {
  410. display: flex;
  411. align-items: center;
  412. span {
  413. display: inline-block;
  414. margin-left: 5px;
  415. }
  416. }
  417. }
  418. .status {
  419. background: #d9f5d6;
  420. width: 44px;
  421. height: 24px;
  422. line-height: 24px;
  423. text-align: center;
  424. font-size: 14px;
  425. font-weight: 400;
  426. }
  427. .run {
  428. background: #d9f5d6;
  429. color: #237b19;
  430. }
  431. // 维修
  432. .wx {
  433. background: #fbeceb;
  434. color: #d83931;
  435. }
  436. // 维保
  437. .wb {
  438. background: #e6f3fc;
  439. color: #0481e1;
  440. }
  441. }
  442. .label {
  443. color: #666;
  444. // margin-right: 10px;
  445. width: 70px;
  446. font-size: 14px;
  447. min-width: 70px;
  448. max-width: 70px;
  449. }
  450. .value {
  451. color: #333;
  452. font-size: 14px;
  453. }
  454. // 底部1px边框
  455. .divider {
  456. width: 100%;
  457. height: 1px;
  458. margin: 0 auto;
  459. background: #e6e6e6;
  460. }
  461. }
  462. }
  463. // 空状态
  464. .m-empty {
  465. // position: fixed;
  466. // top: 0;
  467. // left: 0;
  468. // width: 100%;
  469. // height: 100%;
  470. display: flex;
  471. align-items: center;
  472. /deep/ .van-empty__image {
  473. display: flex;
  474. justify-content: center;
  475. align-items: flex-end;
  476. img {
  477. width: auto !important;
  478. height: auto !important;
  479. }
  480. }
  481. }
  482. // 筛选弹窗
  483. .m-popup-container {
  484. width: 80%;
  485. height: 100%;
  486. padding: 35px 20px 10px 20px;
  487. .m-popup {
  488. width: 100%;
  489. height: calc(100% - 80px);
  490. display: flex;
  491. flex-direction: column;
  492. .title {
  493. font-size: 16px;
  494. font-weight: 500;
  495. color: #333333;
  496. margin-bottom: 15px;
  497. }
  498. // 专业
  499. .system {
  500. width: 100%;
  501. height: auto;
  502. // 专业系统按钮
  503. .system-btn-container {
  504. display: flex;
  505. width: 100%;
  506. flex-wrap: wrap;
  507. flex-flow: wrap;
  508. .system-btn {
  509. width: 33% !important;
  510. min-width: 33% !important;
  511. max-width: 33% !important;
  512. height: 40px;
  513. box-sizing: border-box;
  514. padding: 5px 10px 5px 0;
  515. .m-btn {
  516. width: 100%;
  517. height: 32px !important;
  518. text-align: center;
  519. background: #eff0f1;
  520. border-radius: 2px;
  521. }
  522. }
  523. }
  524. .active {
  525. background-color: #025baa !important;
  526. color: #fff;
  527. }
  528. }
  529. // 电井类型
  530. .sbss {
  531. flex: 1;
  532. display: flex;
  533. flex-direction: column;
  534. overflow: auto;
  535. .title {
  536. width: 100%;
  537. height: 25px;
  538. }
  539. .system-btn-container {
  540. display: flex;
  541. width: 100%;
  542. flex-wrap: wrap;
  543. flex-flow: wrap;
  544. .system-btn {
  545. width: 33% !important;
  546. min-width: 33% !important;
  547. max-width: 33% !important;
  548. height: 50px;
  549. box-sizing: border-box;
  550. padding: 5px 10px 5px 0;
  551. .m-btn {
  552. width: 100%;
  553. height: 32px !important;
  554. text-align: center;
  555. background: #eff0f1;
  556. border-radius: 2px;
  557. padding: 0 !important;
  558. }
  559. }
  560. }
  561. .active {
  562. background-color: #025baa !important;
  563. color: #fff;
  564. }
  565. .load-more {
  566. width: 80px;
  567. height: 25px;
  568. line-height: 25px;
  569. text-align: center;
  570. margin: 0 auto;
  571. color: #025baa;
  572. background: #e5eef6;
  573. }
  574. }
  575. .divider {
  576. border-bottom: 1px solid #e6e6e6;
  577. margin: 20px 0;
  578. }
  579. .footer {
  580. position: absolute;
  581. bottom: 30px;
  582. right: 0;
  583. width: 100%;
  584. height: 35px;
  585. display: flex;
  586. justify-content: space-around;
  587. .van-button {
  588. width: 40%;
  589. height: 100%;
  590. max-width: 40%;
  591. min-width: 40%;
  592. }
  593. }
  594. }
  595. }
  596. }
  597. </style>