MainEquipmentDetail.vue 20 KB

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