ElectricWell.vue 17 KB

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