meterManagement.vue 17 KB

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