MainEquipmentDetail.vue 21 KB

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