meterManagement.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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" v-if="query.meterId&&query.item" >
  10. <view class="title">
  11. <view class="icon">
  12. <image class="img" src="@/assets/img/meter@3x.png" mode=""></image>
  13. </view>
  14. <view class="text">
  15. {{query.item.name}}
  16. </view>
  17. </view>
  18. <view class="content">
  19. <view class="details">
  20. <view class="details-item">
  21. <view class="details-title">
  22. 电表状态
  23. </view>
  24. <view class="details-value">
  25. <span class="spanradius" :class="{
  26. normal:query.item.online
  27. }" ></span>
  28. {{query.item.online?'电表在线':'电表离线'}}
  29. </view>
  30. </view>
  31. <view class="details-item">
  32. <view class="details-title">
  33. 设备编号
  34. </view>
  35. <view class="details-value">
  36. {{query.item.deviceNo}}
  37. </view>
  38. </view>
  39. <view class="details-item">
  40. <view class="details-title">
  41. 地址简称
  42. </view>
  43. <view class="details-value">
  44. {{query.item.installationAddressSimple}}
  45. </view>
  46. </view>
  47. <view class="details-item">
  48. <view class="details-title">
  49. 设备地址
  50. </view>
  51. <view class="details-value">
  52. {{query.item.installationAddress}}
  53. </view>
  54. </view>
  55. <view class="details-item" v-if="queryList.length>1">
  56. <view class="details-title">
  57. 所属合同
  58. </view>
  59. <view class="details-value">
  60. {{query.remark}}
  61. </view>
  62. </view>
  63. </view>
  64. <view class="unbind"
  65. @click="getScanCode(query)">
  66. <view class="icon">
  67. <image class="img" src="@/assets/img/iconPark-link-interrupt 1@3x.png" mode=""></image>
  68. </view>
  69. <view class="text">
  70. 更换
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="meter-info" v-else >
  76. <view class="content">
  77. <view class="details">
  78. <view class="details-item">
  79. <view class="details-title">
  80. 绑定电表
  81. </view>
  82. </view>
  83. <view class="details-item">
  84. <view class="details-value2">
  85. {{!timeEnd(query.contractEndTime)?'未绑定电表,点击绑定':'合同已到期,无法绑定'}}
  86. </view>
  87. </view>
  88. <view class="details-item" v-if="queryList.length>1" >
  89. <view class="details-title">
  90. 所属合同
  91. </view>
  92. <view class="details-value">
  93. {{query.remark}}
  94. </view>
  95. </view>
  96. </view>
  97. <view class="unbind" v-if="!timeEnd(query.contractEndTime)"
  98. @click="getScanCode(query)">
  99. <view class="icon">
  100. <image class="img" src="@/assets/img/iconPark-link-interrupt 1@3x.png" mode=""></image>
  101. </view>
  102. <view class="text">
  103. 绑定
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. <u-divider :isnone="queryList.length==0" nonetext="没有找到相关内容"
  110. border-color="#CFD2D5">已经到底了</u-divider>
  111. </view>
  112. <!-- 底部 -->
  113. <!-- 账户信息弹窗 -->
  114. <view class="modal">
  115. <u-modal v-model="bindShow" :show-title="false" :show-cancel-button="true"
  116. @confirm="submit"
  117. cancel-text="取消"
  118. confirm-text="确认绑定">
  119. <view class="headline">
  120. 请确认您要绑定的电表信息
  121. </view>
  122. <view class="infos">
  123. <view class="item">
  124. <view class="title">
  125. 设备名称
  126. </view>
  127. <view class="value">
  128. {{findByMeter.name}}
  129. </view>
  130. </view>
  131. <view class="item">
  132. <view class="title">
  133. 电表编号
  134. </view>
  135. <view class="value">
  136. {{findByMeter.deviceNo}}
  137. </view>
  138. </view>
  139. <view class="item">
  140. <view class="title">
  141. 设备类型
  142. </view>
  143. <view class="value">
  144. {{findByMeter.deviceTypeN}}
  145. </view>
  146. </view>
  147. </view>
  148. </u-modal>
  149. </view>
  150. <!-- 确认解绑弹窗 -->
  151. <u-popup v-model="unbindShow" mode="bottom" border-radius="24">
  152. <view class="unbind-popup">
  153. <view class="headline">
  154. 确认解绑
  155. </view>
  156. <view class="affirm">
  157. 您确定要解绑该电表?
  158. </view>
  159. <view class="button-box">
  160. <button class="think" @click="closeShow=false">我在想想</button>
  161. <button class="confirm" @click="closeWorkOrder">确认解绑</button>
  162. </view>
  163. </view>
  164. </u-popup>
  165. </view>
  166. </template>
  167. <script>
  168. import * as API_Electricity from '@/apis/pagejs/tenantElectricityMeter.js'
  169. import * as WxJsApi from '@/apis/utils/wxJsApi.js'
  170. import * as API from '@/apis/pagejs/deduction.js'
  171. export default {
  172. data() {
  173. return {
  174. bindShow:false,
  175. unbindShow:false,
  176. findByMeter:{},
  177. queryList:[],
  178. electricity:{
  179. },
  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. timeEnd(contractEndTime){
  197. return new Date()>new Date(contractEndTime)
  198. },
  199. contractList() {
  200. API.contractList(this.formData).then((response) => {
  201. uni.hideLoading();
  202. this.queryList = response.data.data;
  203. if(this.queryList.length){
  204. this.getElectricityMeterList()
  205. }
  206. }).catch(error => {
  207. uni.hideLoading();
  208. uni.showToast({
  209. icon: "none",
  210. title: error
  211. })
  212. })
  213. },
  214. submit(){
  215. uni.showLoading({
  216. title: "加载中",
  217. mask: true,
  218. })
  219. API_Electricity.bindMeter({
  220. meterNo:this.meterNo,
  221. contractId:this.contractId,
  222. }).then((response) => {
  223. uni.hideLoading()
  224. uni.showModal({
  225. showCancel:false,
  226. content:"操作成功",
  227. title:"提示"
  228. })
  229. this.contractList()
  230. }).catch(error => {
  231. uni.showToast({
  232. title: error,
  233. icon: "none"
  234. })
  235. })
  236. },
  237. getScanCode(item) {
  238. this.contractId=item.id;
  239. this.getScanCode1()
  240. // var code="CODE_128,23456556121223"
  241. // this.getScanCode2(code)
  242. },
  243. getScanCode1() {
  244. WxJsApi.scanQRCode(1,null,["qrCode","barCode"]).then(res => {
  245. //("scanQRCode------" + res)
  246. if (res) {
  247. this.getScanCode2(res)
  248. }
  249. }).catch(error => {
  250. })
  251. },
  252. getScanCode2(code) {
  253. if(code){
  254. if(code.indexOf(",")>-1){
  255. var sz= code.split(",")
  256. if(sz.length==2){
  257. this.findByMeterNo(sz[1]);
  258. }
  259. }else{
  260. this.findByMeterNo(code);
  261. }
  262. }
  263. },
  264. findByMeterNo(meterNo){
  265. uni.showLoading({
  266. title: "加载中",
  267. mask: true,
  268. })
  269. this.meterNo=meterNo
  270. API_Electricity.findByMeterNo({
  271. meterNo:this.meterNo
  272. }).then((response) => {
  273. uni.hideLoading()
  274. console.log(response)
  275. this.bindShow=true;
  276. this.findByMeter=response.data.meter;
  277. }).catch(error => {
  278. uni.hideLoading()
  279. uni.showModal({
  280. showCancel:false,
  281. content:error,
  282. title:"提示"
  283. })
  284. })
  285. },
  286. getElectricityMeterList(){
  287. uni.showLoading({
  288. title: "加载中",
  289. mask: true,
  290. })
  291. API_Electricity.electricityMeterList().then((response) => {
  292. uni.hideLoading()
  293. this.electricityMeterList=response.data.meterList
  294. for(var i in this.queryList){
  295. var item= this.queryList[i]
  296. if(item.meterId){
  297. this.queryList[i].item=this.electricityMeterList.find(op=>{
  298. if(op.id==item.meterId){
  299. return 1
  300. }else{
  301. return 0
  302. }
  303. })
  304. }
  305. }
  306. this.$forceUpdate()
  307. }).catch(error => {
  308. uni.showToast({
  309. title: error,
  310. icon: "none"
  311. })
  312. })
  313. },
  314. }
  315. }
  316. </script>
  317. <style lang="scss" scoped>
  318. .background{
  319. height: 400rpx;
  320. background: linear-gradient(180deg, rgba(203,234,255,1) 0%,rgba(203,234,255,0) 100%);
  321. padding: 24rpx 32rpx;
  322. .meter-title{
  323. .icon{
  324. width: 10rpx;
  325. height: 40rpx;
  326. background-color: #1677ff;
  327. color: #1677ff;
  328. margin: 0 12rpx 0 0rpx;
  329. display: inline-block;
  330. }
  331. display: flex;
  332. align-items: center;
  333. color: #333333;
  334. font-size: 36rpx;
  335. margin-left: 16rpx;
  336. margin-bottom: 24rpx;
  337. }
  338. .meter-info{
  339. border-radius: 8px;
  340. background-color: rgba(255,255,255,1);
  341. padding: 24rpx;
  342. margin-bottom: 24rpx;
  343. .title{
  344. display: flex;
  345. align-items: center;
  346. color: rgba(51,51,51,1);
  347. font-size: 36rpx;
  348. font-weight: bold;
  349. .icon{
  350. width: 48rpx;
  351. height: 48rpx;
  352. margin-right: 8rpx;
  353. .img{
  354. width: 100%;
  355. height: 100%;
  356. }
  357. }
  358. }
  359. .content{
  360. display: flex;
  361. .details{
  362. .details-item{
  363. display: flex;
  364. margin-top: 8rpx;
  365. }
  366. .details-title{
  367. width: 112rpx;
  368. color: rgba(119,119,119,1);
  369. }
  370. .details-value2{
  371. width: 390rpx;
  372. color: rgba(51,51,51,1);
  373. }
  374. .details-value{
  375. width: 390rpx;
  376. color: rgba(51,51,51,1);
  377. margin-left: 24rpx;
  378. .spanradius{
  379. width: 20rpx;
  380. height: 20rpx;
  381. background-color: #FF7B00 ;
  382. color: #FF7B00 ;
  383. margin-right: 4rpx;
  384. border-radius: 50%; /* 将正方形变成圆形 */
  385. display: inline-block;
  386. }
  387. .normal{
  388. background-color: #00B962 ;
  389. color: #00B962 ;
  390. }
  391. }
  392. }
  393. .unbind{
  394. margin-left: auto;
  395. font-weight: bold;
  396. .icon{
  397. width: 40rpx;
  398. height: 40rpx;
  399. margin: auto;
  400. .img{
  401. width: 100%;
  402. height: 100%;
  403. }
  404. }
  405. color: rgba(22,119,255,1);
  406. }
  407. }
  408. }
  409. }
  410. // 底部
  411. .bottom{
  412. position: fixed;
  413. bottom: 0;
  414. left: 0;
  415. right: 0;
  416. z-index: 999;
  417. background-color: #fff;
  418. padding: 24rpx 32rpx;
  419. .bind{
  420. display: flex;
  421. justify-content: center;
  422. align-items: center;
  423. line-height: 80rpx;
  424. border-radius: 50px;
  425. color: #fff;
  426. font-size: 36rpx;
  427. background: linear-gradient(-88.46deg, rgba(34,109,198,1) 2.59%,rgba(9,158,237,1) 97.02%);
  428. .img{
  429. width: 40rpx;
  430. height: 40rpx;
  431. margin-right: 8rpx;
  432. }
  433. }
  434. }
  435. // 账户信息弹窗
  436. .modal {
  437. .headline {
  438. text-align: center;
  439. background: linear-gradient(90deg, rgba(49, 110, 207, 1) 2%, rgba(20, 73, 159, 1) 100%);
  440. color: #fff;
  441. height: 144rpx;
  442. line-height: 144rpx;
  443. font-size: 36rpx;
  444. }
  445. .infos {
  446. padding: 40rpx 48rpx 26rpx;
  447. .item {
  448. display: flex;
  449. justify-content: space-between;
  450. margin-bottom: 24rpx;
  451. .title {
  452. color: rgba(119, 119, 119, 1);
  453. font-size: 32rpx;
  454. width: 138rpx;
  455. }
  456. .value {
  457. color: #333333;
  458. font-size: 32rpx;
  459. width: 388rpx;
  460. margin-left: 16rpx;
  461. }
  462. }
  463. }
  464. }
  465. // 确认解绑弹窗
  466. .unbind-popup{
  467. padding: 32rpx;
  468. text-align: center;
  469. .headline{
  470. color: rgba(16,16,16,1);
  471. font-size: 36rpx;
  472. font-weight: bold;
  473. }
  474. .affirm{
  475. color: rgba(16,16,16,1);
  476. font-size: 32rpx;
  477. margin-top: 40rpx;
  478. font-weight: bold;
  479. }
  480. .button-box {
  481. display: flex;
  482. margin-top: 84rpx;
  483. .think {
  484. width: 328rpx;
  485. line-height: 80rpx;
  486. font-size: 32rpx;
  487. border-radius: 4px;
  488. background-color: rgba(222, 225, 228, 1);
  489. color: rgba(51, 51, 51, 1);
  490. }
  491. .confirm {
  492. width: 328rpx;
  493. line-height: 80rpx;
  494. font-size: 32rpx;
  495. border-radius: 4px;
  496. background-color: rgba(255, 68, 68, 1);
  497. color: rgba(255, 255, 255, 1);
  498. }
  499. }
  500. }
  501. </style>