meterManagement.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. <template>
  2. <view>
  3. <u-navbar title="电表管理" title-color="#101010"></u-navbar>
  4. <view class="background">
  5. <view v-for="(query,i) in queryList" :key="i">
  6. <!-- <view class="meter-title" v-if="queryList.length>1">
  7. <span class="icon"></span>
  8. {{query.remark}} </view> -->
  9. <view class="meter-info" @click="gotoInfo(query)" >
  10. <view class="titleMain" >
  11. <view class="title">
  12. <view class="icon">
  13. <image class="img"
  14. src="@/assets/img/meter@3x.png" mode=""></image>
  15. </view>
  16. <view class="text" v-if="query.meterId">
  17. {{query.item.name}}
  18. </view>
  19. <view class="text" style="color:#777777 ;" v-else>
  20. 未绑定
  21. </view>
  22. </view>
  23. <view class="unbind"
  24. @click.stop.prevent="getScanCode(query)">
  25. <view class="text" :class="{
  26. meterId:query.meterId
  27. }">
  28. <image class="img" v-if="query.meterId" src="@/assets/img/riLine-link-unlink.svg" mode=""></image>
  29. <image class="img" v-else src="@/assets/img/riLine-qr-scan-2-line 1.svg" mode=""></image>
  30. {{query.meterId?'换绑电表':'绑定电表'}}
  31. </view>
  32. </view>
  33. </view>
  34. <view class="content">
  35. <view class="details">
  36. <view class="details-item">
  37. <view class="details-title">
  38. 电表状态
  39. </view>
  40. <view class="details-value" v-if="query.meterId">
  41. <span class="spanradius" :class="{
  42. normal:query.item.online
  43. }" ></span>
  44. {{query.item.online?'电表在线':'电表离线'}}
  45. </view>
  46. <view class="details-value" v-else>
  47. </view>
  48. </view>
  49. <view class="details-item">
  50. <view class="details-title">
  51. 设备编号
  52. </view>
  53. <view class="details-value">
  54. {{query.item.deviceNo}}
  55. </view>
  56. </view>
  57. <view class="details-item">
  58. <view class="details-title">
  59. 地址简称
  60. </view>
  61. <view class="details-value">
  62. {{query.item.installationAddressSimple}}
  63. </view>
  64. </view>
  65. <view class="details-item">
  66. <view class="details-title">
  67. 设备地址
  68. </view>
  69. <view class="details-value">
  70. {{query.item.installationAddress}}
  71. </view>
  72. </view>
  73. <view class="details-item" v-if="queryList.length>1">
  74. <view class="details-title">
  75. 租住地址
  76. </view>
  77. <view class="details-value">
  78. {{query.address}}
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. <u-divider :isnone="queryList.length==0" nonetext="没有找到相关内容"
  86. border-color="#CFD2D5">已经到底了</u-divider>
  87. </view>
  88. <!-- 底部 -->
  89. <!-- 账户信息弹窗 -->
  90. <view class="modal">
  91. <u-modal v-model="bindShow" :show-title="false" :show-cancel-button="true"
  92. @confirm="submit"
  93. cancel-text="取消"
  94. confirm-text="确认绑定">
  95. <view class="headline">
  96. 请确认您要绑定的电表信息
  97. </view>
  98. <view class="infos">
  99. <view class="item">
  100. <view class="title">
  101. 设备名称
  102. </view>
  103. <view class="value">
  104. <u-input v-model="updateByMeter.name" :border="true" ></u-input>
  105. </view>
  106. </view>
  107. <view class="item">
  108. <view class="title">
  109. 设备地址
  110. </view>
  111. <view class="value">
  112. <u-input v-model="updateByMeter.installationAddress"
  113. type="textarea"
  114. :border="true" ></u-input>
  115. </view>
  116. </view>
  117. <view class="item">
  118. <view class="title">
  119. 地址简称
  120. </view>
  121. <view class="value">
  122. <u-input v-model="updateByMeter.installationAddressSimple" :border="true" ></u-input>
  123. </view>
  124. </view>
  125. <view class="item">
  126. <view class="title">
  127. 电表编号
  128. </view>
  129. <view class="value">
  130. {{findByMeter.deviceNo}}
  131. </view>
  132. </view>
  133. <view class="item">
  134. <view class="title">
  135. 设备类型
  136. </view>
  137. <view class="value">
  138. {{findByMeter.deviceTypeN}}
  139. </view>
  140. </view>
  141. </view>
  142. </u-modal>
  143. </view>
  144. <!-- 确认解绑弹窗 -->
  145. <u-popup v-model="unbindShow" mode="bottom" border-radius="24">
  146. <view class="unbind-popup">
  147. <view class="headline">
  148. 确认解绑
  149. </view>
  150. <view class="affirm">
  151. 您确定要解绑该电表?
  152. </view>
  153. <view class="button-box">
  154. <button class="think" @click="closeShow=false">我在想想</button>
  155. <button class="confirm" @click="closeWorkOrder">确认解绑</button>
  156. </view>
  157. </view>
  158. </u-popup>
  159. </view>
  160. </template>
  161. <script>
  162. import {
  163. parseUnixTime
  164. } from '@/apis/utils'
  165. import * as API_Electricity from '@/apis/pagejs/tenantElectricityMeter.js'
  166. import * as WxJsApi from '@/apis/utils/wxJsApi.js'
  167. import * as API from '@/apis/pagejs/deduction.js'
  168. export default {
  169. data() {
  170. return {
  171. bindShow:false,
  172. unbindShow:false,
  173. findByMeter:{},
  174. updateByMeter:{},
  175. queryList:[],
  176. electricity:{
  177. },
  178. meterDetail:{},
  179. equipmentInfosShow:false,
  180. electricityMeterList:[],
  181. contractId:"",
  182. meterNo:"",
  183. }
  184. },
  185. onLoad() {
  186. WxJsApi.getWxConfig([ 'scanQRCode']).then((res) => {
  187. // //(res)
  188. }).catch(error => {
  189. //(res)
  190. })
  191. },
  192. onShow(){
  193. this.contractList();
  194. },
  195. methods: {
  196. getMeterDetails(meterId){
  197. uni.showLoading({
  198. title: "加载中",
  199. mask: true,
  200. })
  201. API_Electricity.meterDetails({
  202. meterId:meterId
  203. }).then((response) => {
  204. uni.hideLoading()
  205. this.meterDetail=response.data.meter;
  206. this.equipmentInfosShow=true;
  207. }).catch(error => {
  208. uni.showToast({
  209. title: error,
  210. icon: "none"
  211. })
  212. })
  213. },
  214. thisparseUnixTime(time){
  215. return parseUnixTime(new Date(time),'{y}年{m}月{d}日')
  216. },
  217. gotoInfo(query){
  218. if(query.meterId){
  219. //this.getMeterDetails(query.meterId)
  220. this.gotoUrl('/pages/meterManagement/equipmentDetails?id='+query.meterId)
  221. }
  222. },
  223. timeEnd(contractEndTime){
  224. return new Date()>new Date(contractEndTime)
  225. },
  226. contractList() {
  227. uni.showLoading({
  228. title: "加载中",
  229. mask: true,
  230. })
  231. API.contractList(this.formData).then((response) => {
  232. uni.hideLoading();
  233. var queryList = response.data.data;
  234. if(queryList.length){
  235. this.getElectricityMeterList(queryList)
  236. }
  237. }).catch(error => {
  238. uni.hideLoading();
  239. uni.showToast({
  240. icon: "none",
  241. title: error
  242. })
  243. })
  244. },
  245. updateByMeterMethod(){
  246. var sz=['name','installationAddress','installationAddressSimple']
  247. var sz2=['name','address','addressSimple']
  248. var bl=false;
  249. var obj={
  250. id:this.updateByMeter.id
  251. };
  252. for(var i in sz){
  253. var key=sz[i]
  254. var key2=sz2[i]
  255. //console.log(key,this.updateByMeter[key],this.findByMeter[key])
  256. if(this.updateByMeter[key]!=this.findByMeter[key]){
  257. bl=true;
  258. //console.log('aaa')
  259. }
  260. obj[key2]=this.updateByMeter[key]
  261. }
  262. if(bl){
  263. uni.showLoading({
  264. title: "加载中",
  265. mask: true,
  266. })
  267. API_Electricity.updateMeter(obj).then((response) => {
  268. this.contractList()
  269. }).catch(error => {
  270. uni.showToast({
  271. title: error,
  272. icon: "none"
  273. })
  274. })
  275. }else{
  276. this.contractList()
  277. }
  278. },
  279. submit(){
  280. uni.showLoading({
  281. title: "加载中",
  282. mask: true,
  283. })
  284. API_Electricity.bindMeter({
  285. meterNo:this.meterNo,
  286. contractId:this.contractId,
  287. }).then((response) => {
  288. uni.hideLoading()
  289. uni.showModal({
  290. showCancel:false,
  291. content:"操作成功",
  292. title:"提示"
  293. })
  294. this.updateByMeterMethod()
  295. }).catch(error => {
  296. uni.showToast({
  297. title: error,
  298. icon: "none"
  299. })
  300. })
  301. },
  302. getScanCode(item) {
  303. if(this.timeEnd(item.endTime)){
  304. uni.showModal({
  305. showCancel:false,
  306. content:"缴费有效期已结束,不可修改",
  307. title:"提示"
  308. })
  309. return
  310. }
  311. this.contractId=item.id;
  312. //console.log(item)
  313. if(!(process.env.NODE_ENV === "development") ){
  314. this.getScanCode1()
  315. }else{
  316. var code="CODE_128,2"
  317. this.getScanCode2(code)
  318. }
  319. },
  320. getScanCode1() {
  321. WxJsApi.scanQRCode(1,null,["qrCode","barCode"]).then(res => {
  322. //("scanQRCode------" + res)
  323. if (res) {
  324. this.getScanCode2(res)
  325. }
  326. }).catch(error => {
  327. })
  328. },
  329. getScanCode2(code) {
  330. if(code){
  331. if(code.indexOf(",")>-1){
  332. var sz= code.split(",")
  333. if(sz.length==2){
  334. this.findByMeterNo(sz[1]);
  335. }
  336. }else{
  337. this.findByMeterNo(code);
  338. }
  339. }
  340. },
  341. findByMeterNo(meterNo){
  342. uni.showLoading({
  343. title: "加载中",
  344. mask: true,
  345. })
  346. this.meterNo=meterNo
  347. API_Electricity.findByMeterNo({
  348. meterNo:this.meterNo
  349. }).then((response) => {
  350. uni.hideLoading()
  351. console.log(response)
  352. this.bindShow=true;
  353. this.findByMeter=response.data.meter;
  354. this.updateByMeter={
  355. ...this.findByMeter
  356. };
  357. }).catch(error => {
  358. uni.hideLoading()
  359. uni.showModal({
  360. showCancel:false,
  361. content:error,
  362. title:"提示"
  363. })
  364. })
  365. },
  366. getElectricityMeterList(queryList){
  367. uni.showLoading({
  368. title: "加载中",
  369. mask: true,
  370. })
  371. API_Electricity.electricityMeterList().then((response) => {
  372. uni.hideLoading()
  373. this.electricityMeterList=response.data.meterList
  374. for(var i in queryList){
  375. var item= queryList[i]
  376. queryList[i].item={}
  377. if(item.meterId){
  378. queryList[i].item=this.electricityMeterList.find(op=>{
  379. if(op.id==item.meterId){
  380. return 1
  381. }else{
  382. return 0
  383. }
  384. })
  385. }
  386. }
  387. this.queryList=queryList;
  388. this.$forceUpdate()
  389. }).catch(error => {
  390. uni.showToast({
  391. title: error,
  392. icon: "none"
  393. })
  394. })
  395. },
  396. }
  397. }
  398. </script>
  399. <style lang="scss" scoped>
  400. .background{
  401. height: 400rpx;
  402. background: linear-gradient(180deg, rgba(203,234,255,1) 0%,rgba(203,234,255,0) 100%);
  403. padding: 24rpx 32rpx;
  404. .meter-title{
  405. .icon{
  406. width: 10rpx;
  407. height: 40rpx;
  408. background-color: #1677ff;
  409. color: #1677ff;
  410. margin: 0 12rpx 0 0rpx;
  411. display: inline-block;
  412. }
  413. display: flex;
  414. align-items: center;
  415. color: #333333;
  416. font-size: 36rpx;
  417. margin-left: 16rpx;
  418. margin-bottom: 24rpx;
  419. }
  420. .meter-info{
  421. border-radius: 8px;
  422. background-color: rgba(255,255,255,1);
  423. padding: 24rpx;
  424. margin-bottom: 24rpx;
  425. .titleMain{
  426. display: flex;
  427. align-items: center;
  428. }
  429. .unbind{
  430. margin-left: auto;
  431. font-weight: bold;
  432. font-size: 24rpx;
  433. .img{
  434. width: 32rpx;
  435. height: 32rpx;
  436. margin: auto;
  437. margin-right: 4rpx;
  438. }
  439. color: #fff;
  440. .text{
  441. white-space: pre;
  442. border-radius: 50px;
  443. display: flex;
  444. align-items: center;
  445. padding: 6rpx 12rpx;
  446. background-color: rgba(0,185,98,1);
  447. }
  448. .meterId{
  449. background-color: rgba(22,119,255,1);
  450. }
  451. }
  452. .title{
  453. display: flex;
  454. align-items: center;
  455. color: rgba(51,51,51,1);
  456. font-size: 36rpx;
  457. font-weight: bold;
  458. .icon{
  459. width: 48rpx;
  460. height: 48rpx;
  461. margin-right: 8rpx;
  462. .img{
  463. width: 100%;
  464. height: 100%;
  465. width: 48rpx;
  466. height: 48rpx;
  467. }
  468. }
  469. }
  470. .content{
  471. display: flex;
  472. padding: 8rpx 0;
  473. .details{
  474. .details-item{
  475. display: flex;
  476. margin-top: 16rpx;
  477. }
  478. .details-title{
  479. width: 112rpx;
  480. color: rgba(119,119,119,1);
  481. }
  482. .details-value2{
  483. width: 390rpx;
  484. color: rgba(51,51,51,1);
  485. }
  486. .details-value{
  487. width: 390rpx;
  488. color: rgba(51,51,51,1);
  489. margin-left: 24rpx;
  490. .spanradius{
  491. width: 20rpx;
  492. height: 20rpx;
  493. background-color: #FF7B00 ;
  494. color: #FF7B00 ;
  495. margin-right: 4rpx;
  496. border-radius: 50%; /* 将正方形变成圆形 */
  497. display: inline-block;
  498. }
  499. .normal{
  500. background-color: #00B962 ;
  501. color: #00B962 ;
  502. }
  503. }
  504. }
  505. }
  506. }
  507. }
  508. // 底部
  509. .bottom{
  510. position: fixed;
  511. bottom: 0;
  512. left: 0;
  513. right: 0;
  514. z-index: 999;
  515. background-color: #fff;
  516. padding: 24rpx 32rpx;
  517. .bind{
  518. display: flex;
  519. justify-content: center;
  520. align-items: center;
  521. line-height: 80rpx;
  522. border-radius: 50px;
  523. color: #fff;
  524. font-size: 36rpx;
  525. background: linear-gradient(-88.46deg, rgba(34,109,198,1) 2.59%,rgba(9,158,237,1) 97.02%);
  526. .img{
  527. width: 40rpx;
  528. height: 40rpx;
  529. margin-right: 8rpx;
  530. }
  531. }
  532. }
  533. // 账户信息弹窗
  534. .modal {
  535. .headline {
  536. text-align: center;
  537. background: linear-gradient(90deg, rgba(49, 110, 207, 1) 2%, rgba(20, 73, 159, 1) 100%);
  538. color: #fff;
  539. height: 104rpx;
  540. line-height: 104rpx;
  541. font-size: 36rpx;
  542. }
  543. .infos {
  544. padding: 40rpx 48rpx 26rpx;
  545. .item {
  546. display: flex;
  547. justify-content: space-between;
  548. margin-bottom: 24rpx;
  549. align-items: center;
  550. .title {
  551. color: rgba(119, 119, 119, 1);
  552. font-size: 32rpx;
  553. width: 138rpx;
  554. }
  555. .value {
  556. color: #333333;
  557. font-size: 32rpx;
  558. width: 388rpx;
  559. margin-left: 16rpx;
  560. }
  561. }
  562. }
  563. }
  564. // 确认解绑弹窗
  565. .unbind-popup{
  566. padding: 32rpx;
  567. text-align: center;
  568. .headline{
  569. color: rgba(16,16,16,1);
  570. font-size: 36rpx;
  571. font-weight: bold;
  572. }
  573. .affirm{
  574. color: rgba(16,16,16,1);
  575. font-size: 32rpx;
  576. margin-top: 40rpx;
  577. font-weight: bold;
  578. }
  579. .button-box {
  580. display: flex;
  581. margin-top: 84rpx;
  582. .think {
  583. width: 328rpx;
  584. line-height: 80rpx;
  585. font-size: 32rpx;
  586. border-radius: 4px;
  587. background-color: rgba(222, 225, 228, 1);
  588. color: rgba(51, 51, 51, 1);
  589. }
  590. .confirm {
  591. width: 328rpx;
  592. line-height: 80rpx;
  593. font-size: 32rpx;
  594. border-radius: 4px;
  595. background-color: rgba(255, 68, 68, 1);
  596. color: rgba(255, 255, 255, 1);
  597. }
  598. }
  599. }
  600. // 设备信息弹窗
  601. .equipment-popup {
  602. .content {
  603. padding: 32rpx;
  604. .headline {
  605. color: rgba(16, 16, 16, 1);
  606. font-size: 36rpx;
  607. text-align: center;
  608. font-weight: bold;
  609. margin-bottom: 24rpx;
  610. }
  611. .infos {
  612. padding-bottom: 100rpx;
  613. .item:last-of-type {
  614. border: none;
  615. }
  616. .item {
  617. display: flex;
  618. align-items: center;
  619. line-height: 48rpx;
  620. padding: 24rpx 0;
  621. border-bottom: 1px solid #cccccc;
  622. .item-title {
  623. color: rgba(51, 51, 51, 1);
  624. width: 200rpx;
  625. }
  626. .item-value {
  627. color: #666666;
  628. flex: 1;
  629. margin-left: 16rpx;
  630. display: flex;
  631. align-items: center;
  632. justify-content: space-between;
  633. .img{
  634. width: 32rpx;
  635. height: 32rpx;
  636. transform: rotate(90deg);
  637. margin-left: 96rpx;
  638. }
  639. }
  640. }
  641. }
  642. .get {
  643. height: 80rpx;
  644. line-height: 80rpx;
  645. border-radius: 4px;
  646. background-color: rgba(22, 119, 255, 1);
  647. color: rgba(255, 255, 255, 1);
  648. font-size: 32rpx;
  649. }
  650. }
  651. }
  652. </style>