ElectricWell.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <template>
  2. <div class='electric-well-page'>
  3. <!-- 顶部条 -->
  4. <van-nav-bar 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='search-container'>
  11. <van-search class='search' v-model='keyword' placeholder='请输入电井间或商铺编号' @search='onSearch'></van-search>
  12. </div>
  13. <!-- 电井列表 -->
  14. <div class='electric-well-list' v-if='list.length'>
  15. <div class='floor' v-for='(item,index) in list' :key='`${index}_${item.floor}`'>
  16. <!-- 楼层 -->
  17. <div class='title'>
  18. <div class='floor-left'>
  19. <i class='iconfont wanda-floor-func-active'></i>
  20. {{item.floor}}
  21. </div>
  22. <div class='floor-right' @click='goToMapView(item.floor)'>
  23. 查看平面图
  24. <van-icon name='arrow' />
  25. </div>
  26. </div>
  27. <!-- 电井 -->
  28. <div class='well-container'>
  29. <div class='well' v-for='(detail) in item.data.slice(0,2)' :key='detail.meterbox'>
  30. <div class='well-title'>{{detail.welldes}}</div>
  31. <div class='meterbox'>
  32. <span class='well-left'>商铺电表数:</span>
  33. <span class='value'>{{detail.meterbox}}</span>
  34. </div>
  35. <div class='meterbox'>
  36. <span class='well-left'>商铺信息:</span>
  37. <span class='value'>
  38. <i v-for='(info,infoIndex) in detail.brandList' :key='infoIndex'>
  39. {{ info.brandname || 'xxx' }}
  40. -
  41. {{ info.shopsnumList ?info.shopsnumList.replaceAll(',','、'): 'xxx' }}
  42. {{infoIndex===detail.brandList.length-1? '':',' }}
  43. </i>
  44. </span>
  45. </div>
  46. </div>
  47. <!-- 第三条以上 -->
  48. <div v-show='item.loadMore && item.data.length>2' :key='key'>
  49. <div class='well' v-for='(detail) in item.data.slice(2)' :key='detail.meterbox'>
  50. <div class='well-title'>{{detail.welldes}}</div>
  51. <div class='meterbox'>
  52. <span class='well-left'>商铺电表数:</span>
  53. <span class='value'>{{detail.meterbox}}</span>
  54. </div>
  55. <div class='meterbox'>
  56. <span class='well-left'>商铺信息:</span>
  57. <span class='value'>
  58. <i v-for='(info,infoIndex) in detail.brandList' :key='infoIndex'>
  59. {{ info.brandname || 'xxx' }}
  60. -
  61. {{ info.shopsnumList ? info.shopsnumList.replaceAll(',','、') : 'xxx' }}
  62. {{ infoIndex === detail.brandList.length - 1 ? '' : ',' }}
  63. </i>
  64. </span>
  65. </div>
  66. </div>
  67. </div>
  68. <!-- </div> -->
  69. </div>
  70. <!-- 加载更多 -->
  71. <div class='load-more-container' v-show='!item.loadMore && item.data.length>2' @click='loadMore(item)'>
  72. <div class='load-more'>加载更多</div>
  73. </div>
  74. </div>
  75. </div>
  76. <!-- 无数据 -->
  77. <van-empty class='m-empty' v-if='!list.length' description='暂无数据'>
  78. <template #image>
  79. <img src='../../assets/images/search_null.png' alt />
  80. </template>
  81. </van-empty>
  82. <!-- 点击头部筛选,出现的右侧弹窗 -->
  83. <van-popup class='m-popup-container' v-model='showPopup' position='right'>
  84. <div class='m-popup'>
  85. <!-- 系统 -->
  86. <div class='system'>
  87. <h1 class='title'>楼层</h1>
  88. <div class='system-btn-container'>
  89. <div class='system-btn' v-for='(item,index) in floorList' :key='index'>
  90. <van-button class='m-btn' :class='item.active' @click='changeFloor(item)'>{{item.code}}</van-button>
  91. </div>
  92. </div>
  93. </div>
  94. <div class='divider'></div>
  95. <!-- 设备设施 -->
  96. <div class='sbss'>
  97. <h1 class='title'>电井类型</h1>
  98. <div class='system-btn-container'>
  99. <div class='system-btn' v-for='(item,index) in wellTypeList' :key='index'>
  100. <van-button class='m-btn' :class='item.active' @click='changeWellType(item)'>{{item.text}}</van-button>
  101. </div>
  102. </div>
  103. </div>
  104. <div class='footer'>
  105. <van-button size='large' color='#025BAA' plain type='info' @click='reset'>重置</van-button>
  106. <van-button size='large' color='#025BAA' type='info' @click='confirm'>确定</van-button>
  107. </div>
  108. </div>
  109. </van-popup>
  110. </div>
  111. </template>
  112. <script>
  113. /**
  114. * 电井间控制商铺范围
  115. */
  116. import Vue from 'vue'
  117. import { NavBar, Search, List, Cell, Icon, Popup, Button, Empty } from 'vant'
  118. Vue.use(NavBar).use(Search).use(List).use(Cell).use(Icon).use(Popup).use(Button).use(Empty)
  119. import { mapGetters, mapMutations } from 'vuex'
  120. import { queryShops, queryBrand } from '@/api/equipmentList'
  121. import { sleep } from '@/utils/util'
  122. import { cloneDeep } from 'lodash'
  123. export default {
  124. name: 'ElectricWell',
  125. props: {},
  126. data() {
  127. return {
  128. keyword: '',
  129. page: 1,
  130. size: 20,
  131. list: [],
  132. key: new Date().getTime(),
  133. loading: false,
  134. showPopup: false,
  135. floorList: [],
  136. wellTypeList: [
  137. { text: '全部', id: '全部', active: 'active' },
  138. { text: '强电井', id: '强电井', active: '' },
  139. { text: '弱电井', id: '弱电井', active: '' },
  140. { text: '强弱电井', id: '强弱电井', active: '' },
  141. ],
  142. currentFloor: '全部',
  143. currentWellType: '全部',
  144. // 弹窗中使用数据
  145. modalData: {
  146. floor: '',
  147. wellType: '',
  148. },
  149. // 弹窗中使用备份数据
  150. modalDataBak: {
  151. floor: '',
  152. wellType: '',
  153. },
  154. }
  155. },
  156. computed: {
  157. ...mapGetters(['plazaId', 'smsxt', 'categoryId', 'floorsArr', 'oldSmsxt', 'oldCategoryId', 'isGlobal']),
  158. },
  159. components: {},
  160. created() {
  161. // code:"F6"
  162. // gcname:"f6"
  163. // gcode:"6F"
  164. // gname:"f6"
  165. // seq:600
  166. let floorList = [{ code: '全部', gcname: '全部', gcode: '全部', gname: '全部', seq: null, active: 'active' }]
  167. this.floorsArr.map(({ code, gcname, gcode, gname, seq }) => {
  168. floorList.push({ code, gcname, gcode, gname, seq, active: '' })
  169. })
  170. this.floorList = floorList
  171. console.log(this.floorList)
  172. this.getList()
  173. },
  174. beforeMount() {},
  175. mounted() {},
  176. methods: {
  177. ...mapMutations(['SETCATEGORYID', 'SETSMSXT', 'SETOLDCATEGORYID', 'SETOLDSMSXT']),
  178. backPage() {
  179. // 如果是全局搜索进入时,修改smsxt,categoryId为进入全局搜索之前的,
  180. // 并将oldSmsxt, oldCategoryId设置为''
  181. if (this.isGlobal) {
  182. this.SETSMSXT(this.oldSmsxt)
  183. this.SETCATEGORYID(this.oldCategoryId)
  184. this.SETOLDCATEGORYID('')
  185. this.SETOLDSMSXT('')
  186. }
  187. this.$router.go(-1)
  188. },
  189. /**
  190. * 点击右侧筛选
  191. */
  192. handleRightClick() {
  193. this.showPopup = true
  194. // 设置选中的专业系统
  195. this.changeFloor({ gname: this.currentFloor })
  196. },
  197. /**
  198. * 获取电井列表
  199. */
  200. async getList() {
  201. console.log('getList')
  202. let getParams = {
  203. orderBy: `floor,1;welldesm,1;meterbox,1;`,
  204. plazaId: this.plazaId,
  205. }
  206. // 输入框搜索关键字
  207. if (this.keyword) {
  208. getParams.keyword = `${this.keyword}:welldes,meterbox,shopsnumList,brandname;`
  209. }
  210. // 右侧弹窗 筛选楼层的类型
  211. if (this.currentFloor && this.currentFloor !== '全部') {
  212. getParams.floor = this.currentFloor
  213. }
  214. // 右侧弹窗 筛选的电井类型
  215. if (this.currentWellType && this.currentWellType !== '全部') {
  216. getParams.keyword = getParams.keyword || ''
  217. getParams.keyword += `${this.currentWellType}:welldes;`
  218. }
  219. let resData = await queryBrand({ getParams })
  220. if (!resData && !resData?.data) {
  221. this.list = []
  222. return false
  223. }
  224. let res_data = resData.data[0] || []
  225. let list = []
  226. for (const item in res_data) {
  227. console.log(item)
  228. list.push({
  229. floor: item,
  230. seq: res_data[item][0].seq,
  231. data: res_data[item],
  232. })
  233. }
  234. // 楼层降序排序 RF,F6-F1,B1
  235. list = list.sort((a, b) => b.seq - a.seq)
  236. this.list = list
  237. console.log(this.list)
  238. // console.log(JSON.stringify(res_data, null, 2))
  239. },
  240. /**
  241. * 点击的楼层,跳转楼层平面图
  242. */
  243. goToMapView(chooseFloor) {
  244. let { floorsArr } = this
  245. let currentFloor = floorsArr.filter((v) => v.code === chooseFloor)[0]
  246. let floor = {
  247. FloorId: currentFloor.gname,
  248. FloorName: currentFloor.code,
  249. }
  250. this.$router.push({ name: 'MapView', params: { floor } })
  251. },
  252. /**
  253. * 点击加载更多,显示该楼层下的更多数据
  254. */
  255. loadMore(item) {
  256. item.loadMore = true
  257. this.key = new Date().getTime()
  258. },
  259. /**
  260. * 搜索
  261. */
  262. onSearch() {
  263. // 初始化数据,查询列表
  264. this.initData()
  265. this.getList()
  266. },
  267. /**
  268. * 初始化数据,查询列表
  269. */
  270. initData() {
  271. this.list = []
  272. },
  273. /**
  274. * popup 更改楼层
  275. */
  276. changeFloor(data) {
  277. console.log(data)
  278. let floorList = this.floorList
  279. floorList.map((item) => {
  280. item.active = ''
  281. if (item.gname === data.gname) {
  282. item.active = 'active'
  283. }
  284. })
  285. // 弹窗选中的系统
  286. this.$set(this.modalDataBak, 'floor', data.gname)
  287. },
  288. changeWellType(data) {
  289. let { wellTypeList } = this
  290. wellTypeList.map((item) => {
  291. item.active = ''
  292. if (item.text === data.text) {
  293. item.active = 'active'
  294. }
  295. })
  296. this.$set(this.modalDataBak, 'wellType', data.text)
  297. },
  298. /**
  299. * 重置
  300. */
  301. reset() {
  302. this.modalDataBak = {
  303. floor: '',
  304. wellType: '',
  305. }
  306. this.modalData = {
  307. floor: '',
  308. wellType: '',
  309. }
  310. this.wellTypeList = [
  311. { text: '全部', id: '全部', active: 'active' },
  312. { text: '强电井', id: '强电井', active: '' },
  313. { text: '弱电井', id: '弱电井', active: '' },
  314. { text: '强弱电井', id: '强弱电井', active: '' },
  315. ]
  316. this.currentFloor = '全部'
  317. this.currentWellType = '全部'
  318. this.showPopup = false
  319. // 初始化数据,查询列表
  320. this.initData()
  321. this.getList()
  322. },
  323. /**
  324. * 弹窗确认
  325. */
  326. confirm() {
  327. this.modalData = cloneDeep(this.modalDataBak)
  328. this.showPopup = false
  329. this.currentFloor = this.modalData.floor
  330. this.currentWellType = this.modalData.wellType
  331. // 初始化数据,查询列表
  332. this.initData()
  333. this.getList()
  334. },
  335. },
  336. }
  337. </script>
  338. <style lang='less' scoped>
  339. .electric-well-page {
  340. width: 100%;
  341. height: 100%;
  342. // display: flex;
  343. // flex-direction: column;
  344. background-color: #f5f6f7;
  345. // 返回箭头修改
  346. /deep/ .van-nav-bar .van-icon {
  347. color: #000;
  348. }
  349. // 搜索
  350. .search-container {
  351. width: 100%;
  352. height: 55px;
  353. // background-color: #fff;
  354. text-align: center;
  355. .search {
  356. width: 100%;
  357. padding-left: 15px;
  358. padding-right: 15px;
  359. margin: 0 auto;
  360. background: none;
  361. }
  362. .van-search__content {
  363. background: #fff;
  364. border-radius: 50px;
  365. }
  366. }
  367. // 设备列表
  368. .electric-well-list {
  369. width: 100%;
  370. // flex: 1;
  371. height: calc(100% - 100px);
  372. // padding: 0 10px;
  373. background-color: #fff;
  374. overflow: auto;
  375. font-size: 14px;
  376. font-weight: 400;
  377. color: #333333;
  378. .floor {
  379. width: 100%;
  380. max-height: 410px;
  381. overflow: auto;
  382. display: flex;
  383. flex-direction: column;
  384. // 楼层title
  385. .title {
  386. width: 100%;
  387. height: 40px;
  388. min-height: 40px;
  389. max-height: 40px;
  390. padding: 0 15px;
  391. background: #dce5ee;
  392. display: flex;
  393. justify-content: space-between;
  394. align-items: center;
  395. .floor-left {
  396. color: #025baa;
  397. font-size: 16px;
  398. }
  399. .floor-right {
  400. color: #025baa;
  401. display: flex;
  402. align-items: center;
  403. i {
  404. margin-left: 5px;
  405. }
  406. }
  407. }
  408. // 电井列表
  409. .well-container {
  410. padding: 0 15px;
  411. flex: 1;
  412. overflow: auto;
  413. .well {
  414. width: 100%;
  415. // height: 130px;
  416. padding: 15px 0;
  417. border-bottom: 1px solid #e6e6e6;
  418. .well-title {
  419. font-size: 16px;
  420. font-weight: 500;
  421. color: #333;
  422. }
  423. .meterbox,
  424. .shopsnumList {
  425. width: 100%;
  426. height: auto;
  427. margin-top: 8px;
  428. display: flex;
  429. color: #666;
  430. .well-left {
  431. width: 80px !important;
  432. }
  433. .value {
  434. flex: 1;
  435. height: auto;
  436. word-break: break-word;
  437. i {
  438. padding: 2px 0;
  439. }
  440. }
  441. }
  442. }
  443. }
  444. .load-more-container {
  445. width: 100%;
  446. height: 50px;
  447. background: #f5f6f7;
  448. text-align: center;
  449. padding-top: 12px;
  450. .load-more {
  451. width: 80px;
  452. height: 25px;
  453. line-height: 25px;
  454. text-align: center;
  455. margin: 0 auto;
  456. color: #025baa;
  457. background: #e5eef6;
  458. }
  459. }
  460. }
  461. }
  462. // 空状态
  463. .m-empty {
  464. // position: fixed;
  465. // top: 0;
  466. // left: 0;
  467. // width: 100%;
  468. // height: 100%;
  469. display: flex;
  470. align-items: center;
  471. /deep/ .van-empty__image {
  472. display: flex;
  473. justify-content: center;
  474. align-items: flex-end;
  475. img {
  476. width: auto;
  477. height: auto;
  478. }
  479. }
  480. }
  481. // 筛选弹窗
  482. .m-popup-container {
  483. width: 80%;
  484. height: 100%;
  485. padding: 10px 15px;
  486. .m-popup {
  487. width: 100%;
  488. height: calc(100% - 80px);
  489. display: flex;
  490. flex-direction: column;
  491. .title {
  492. font-size: 16px;
  493. font-weight: 500;
  494. color: #333333;
  495. margin-bottom: 15px;
  496. }
  497. // 专业
  498. .system {
  499. width: 100%;
  500. height: auto;
  501. // 专业系统按钮
  502. .system-btn-container {
  503. display: flex;
  504. width: 100%;
  505. flex-wrap: wrap;
  506. flex-flow: wrap;
  507. .system-btn {
  508. width: calc(33.333% - 5.34px) !important;
  509. min-width: calc(33.333% - 5.34px) !important;
  510. max-width: calc(33.333% - 5.34px) !important;
  511. height: 32px;
  512. margin-bottom: 8px;
  513. box-sizing: border-box;
  514. .m-btn {
  515. width: 100%;
  516. height: 32px !important;
  517. text-align: center;
  518. background: #eff0f1;
  519. border-radius: 2px;
  520. }
  521. }
  522. .system-btn:not(:nth-child(3n)) {
  523. margin-right: 8px;
  524. }
  525. }
  526. .active {
  527. background-color: #025baa !important;
  528. color: #fff;
  529. }
  530. }
  531. // 电井类型
  532. .sbss {
  533. flex: 1;
  534. display: flex;
  535. flex-direction: column;
  536. overflow: auto;
  537. .title {
  538. width: 100%;
  539. height: 25px;
  540. }
  541. .system-btn-container {
  542. display: flex;
  543. width: 100%;
  544. flex-wrap: wrap;
  545. flex-flow: wrap;
  546. .system-btn {
  547. width: calc(33.333% - 5.34px) !important;
  548. min-width: calc(33.333% - 5.34px) !important;
  549. max-width: calc(33.333% - 5.34px) !important;
  550. height: 32px;
  551. margin-bottom: 8px;
  552. box-sizing: border-box;
  553. .m-btn {
  554. width: 100%;
  555. height: 32px !important;
  556. text-align: center;
  557. background: #eff0f1;
  558. border-radius: 2px;
  559. padding: 0 !important;
  560. }
  561. }
  562. .system-btn:not(:nth-child(3n)) {
  563. margin-right: 8px;
  564. }
  565. }
  566. .active {
  567. background-color: #025baa !important;
  568. color: #fff;
  569. }
  570. .load-more {
  571. width: 80px;
  572. height: 25px;
  573. line-height: 25px;
  574. text-align: center;
  575. margin: 0 auto;
  576. color: #025baa;
  577. background: #e5eef6;
  578. }
  579. }
  580. .divider {
  581. border-bottom: 1px solid #e6e6e6;
  582. margin: 20px 0;
  583. }
  584. .footer {
  585. position: absolute;
  586. bottom: 30px;
  587. right: 0;
  588. width: 100%;
  589. height: 35px;
  590. display: flex;
  591. justify-content: space-between;
  592. padding: 0 15px;
  593. .van-button {
  594. width: calc(50% - 7px) !important;
  595. min-width: calc(50% - 7px) !important;
  596. max-width: calc(50% - 7px) !important;
  597. height: 100%;
  598. }
  599. .van-button:first-child {
  600. margin-right: 14px;
  601. }
  602. }
  603. }
  604. }
  605. }
  606. </style>