ElectricWell.vue 20 KB

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