ElectricWell.vue 22 KB

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