monthlyPush.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <view>
  3. <u-navbar title="电费月度账单" :isBack="isBack" title-color="#101010"></u-navbar>
  4. <view class="background">
  5. <view class="recharge-details1">
  6. <view class="headline">
  7. {{thisparseUnixTime(queryYearMonth)}}电费月度账单
  8. </view>
  9. <view class="sum">
  10. {{detail.kwhMap.fee}}<span>元</span>
  11. </view>
  12. <view class="details">
  13. <view class="item">
  14. <view class="item-title">
  15. 承租方
  16. </view>
  17. <view class="item-value">
  18. {{detail.tenantInfo.name}}
  19. </view>
  20. </view>
  21. <view class="item">
  22. <view class="item-title">
  23. 租住地址
  24. </view>
  25. <view class="item-value">
  26. {{detail.tenantContract.address}}
  27. </view>
  28. </view>
  29. <!-- <view class="item">
  30. <view class="item-title">
  31. 收费标准
  32. </view>
  33. <view class="item-value">
  34. {{detail.kwhMap.kwh}}元/度
  35. </view>
  36. </view> -->
  37. <template v-if="detail.childKwhMap">
  38. <table class="table1" >
  39. <tr class="tr1">
  40. <td></td>
  41. <td>起止码</td>
  42. <td>度数</td>
  43. </tr>
  44. <tr>
  45. <td class="td1">{{detail.meter.name}}</td>
  46. <td>
  47. {{detail.kwhMap.startMeter}}-{{detail.kwhMap.endMeter}}
  48. </td>
  49. <td class="td3" >{{detail.kwhMap.totalKwh}}度</td>
  50. </tr>
  51. <tr v-for="(item,i) in detail.childKwhMap" :key="i">
  52. <td class="td1">{{i}}</td>
  53. <td>{{item.startMeter}}-{{item.endMeter}}</td>
  54. <td class="td3">{{item.kwh}}度</td>
  55. </tr>
  56. <tr style="font-weight: bold;" >
  57. <td class="td1" colspan="2">扣除后用电量</td>
  58. <td>{{detail.kwhMap.kwh}}度</td>
  59. </tr>
  60. </table>
  61. </template>
  62. <template v-else>
  63. <view class="item">
  64. <view class="item-title">
  65. 用电量
  66. </view>
  67. <view class="item-value">
  68. {{detail.kwhMap.kwh}}度
  69. </view>
  70. </view>
  71. <view class="item">
  72. <view class="item-title">
  73. 起止码
  74. </view>
  75. <view class="item-value">
  76. {{detail.kwhMap.startMeter}}-{{detail.kwhMap.endMeter}}
  77. </view>
  78. </view>
  79. </template>
  80. <view class="item">
  81. <view class="item-title">
  82. 可用余额
  83. </view>
  84. <view class="item-value">
  85. {{detail.balance}}元
  86. </view>
  87. </view>
  88. <view class="item">
  89. <view class="item-title">
  90. 统计截止日期
  91. </view>
  92. <view class="item-value">
  93. {{detail.endTime}}
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 返回 -->
  99. <!-- <button class="back">返回</button> -->
  100. <view class="recharge-details2">
  101. <view class="details">
  102. <view class="title">
  103. {{thisparseUnixTime(queryYearMonth)}}用电量趋势
  104. </view>
  105. <view id="pieEcharts">
  106. </view>
  107. </view>
  108. </view>
  109. <u-divider nonetext="没有找到相关内容" style="margin-top: 20rpx;"
  110. border-color="#CFD2D5">已经到底了</u-divider>
  111. </view>
  112. </view>
  113. </template>
  114. <script>
  115. import * as API from '@/apis/pagejs/deduction.js'
  116. import {
  117. parseUnixTime,newDate
  118. } from '@/apis/utils'
  119. import * as echarts from "echarts";
  120. export default {
  121. data() {
  122. return {
  123. isBack: false,
  124. id: "",
  125. queryYearMonth: "",
  126. detail: {
  127. tenantInfo: {},
  128. tenantContract: {},
  129. kwhMap: {},
  130. endTime: {},
  131. balance: {},
  132. childKwhMap:null,
  133. meter:{},
  134. },
  135. myChart: null,
  136. }
  137. },
  138. onLoad(op) {
  139. if (op.site) {
  140. this.isBack = true
  141. }
  142. if (op.id) {
  143. this.id = op.id
  144. this.queryYearMonth = op.m
  145. this.getDetail()
  146. }
  147. },
  148. methods: {
  149. thisparseUnixTime(time) {
  150. if (!time) {
  151. return ''
  152. }
  153. return parseUnixTime(newDate(time), '{y}年{m}月')
  154. },
  155. getDetail() {
  156. uni.showLoading({
  157. mask: true,
  158. title: '加载中...'
  159. })
  160. API.monthlyElectricity({
  161. contractId: this.id,
  162. queryYearMonth: this.queryYearMonth
  163. }).then((response) => {
  164. uni.hideLoading();
  165. this.detail = response.data;
  166. if(JSON.stringify(this.detail.childKwhMap)=="{}"){
  167. this.detail.childKwhMap=null
  168. }
  169. this.getPle(this.detail.graphMap)
  170. //this.transferAccountsInfo=this.detail.accountInfo;
  171. }).catch(error => {
  172. uni.hideLoading();
  173. uni.showToast({
  174. title: error
  175. })
  176. })
  177. },
  178. getPle(list) {
  179. if (!this.myChart) {
  180. this.myChart = echarts.init(document.getElementById('pieEcharts'), null, {
  181. width: uni.upx2px(650),
  182. height: uni.upx2px(420)
  183. });
  184. }
  185. var data1 = [];
  186. var data2 = [];
  187. this.myChart.clear();
  188. for (var i in list) {
  189. data1.push(i)
  190. data2.push(list[i].kwh)
  191. }
  192. var headitemby = ""
  193. var showkey = "";
  194. var option = {
  195. tooltip: {
  196. trigger: 'axis',
  197. formatter: (value) => {
  198. var time=this.thisparseUnixTime(this.queryYearMonth);
  199. var name = value[0].name;
  200. var obj = list[name]
  201. var text = `<p>${time}${name}日</p>`
  202. if (obj.kwh != undefined) {
  203. text += `<p>电量:${obj.kwh}度</p>`
  204. }
  205. if (obj.fee != undefined) {
  206. text += ` <p>电费:${obj.fee}元</p>`
  207. }
  208. return text
  209. }
  210. },
  211. grid: {
  212. top: 40,
  213. left: 5,
  214. right: 5,
  215. bottom: 20,
  216. containLabel: true
  217. },
  218. xAxis: {
  219. type: 'category',
  220. data: data1,
  221. axisLabel: {
  222. textStyle: {
  223. color: "#333"
  224. }
  225. },
  226. },
  227. yAxis: {
  228. type: 'value',
  229. name: '电量',
  230. },
  231. series: [{
  232. name: '电量',
  233. data: data2,
  234. type: 'line'
  235. }]
  236. }
  237. console.log(option)
  238. this.myChart.setOption(option);
  239. },
  240. }
  241. }
  242. </script>
  243. <style lang="scss" scoped>
  244. .table1{
  245. padding-bottom: 20rpx;
  246. width: 100%;
  247. border-collapse: collapse;
  248. td{
  249. border: 1px solid #e7e7e7;
  250. text-align: end;
  251. padding: 2px 8px;
  252. }
  253. .td1{
  254. text-align: start;
  255. min-width: 20%;
  256. max-width: 30%;
  257. }
  258. .td3{
  259. white-space: pre;
  260. }
  261. tr{
  262. background-color:#f5f5f6
  263. }
  264. .tr1{
  265. text-align: end;
  266. font-weight: bold;
  267. }
  268. tr:nth-child(even) {
  269. background-color: #fff;
  270. }
  271. }
  272. .background {
  273. padding: 24rpx 24rpx;
  274. height: 400rpx;
  275. background: linear-gradient(180deg, rgba(203, 234, 255, 1) 0%, rgba(203, 234, 255, 0) 100%);
  276. .recharge-details1 {
  277. padding: 40rpx 32rpx;
  278. border-radius: 8px 8px 0 0;
  279. }
  280. .recharge-details2 {
  281. border-radius: 0 0 8px 8px;
  282. padding: 5rpx 20rpx 40rpx 20rpx;
  283. .details {
  284. border-radius: 8px ;
  285. background: linear-gradient(180deg, rgba(208,236,255,1) 0%,rgba(208,236,236,0) 100%);
  286. }
  287. #pieEcharts{
  288. text-align: start;
  289. }
  290. }
  291. .recharge-details1,
  292. .recharge-details2 {
  293. background-color: #fff;
  294. text-align: center;
  295. .headline {
  296. color: rgb(16, 16, 16);
  297. font-size: 36rpx;
  298. }
  299. .sum {
  300. color: rgb(16, 16, 16);
  301. font-size: 48rpx;
  302. margin-top: 32rpx;
  303. span{
  304. font-size: 28rpx;
  305. }
  306. }
  307. .details {
  308. margin-top: 40rpx;
  309. padding-top: 40rpx;
  310. border-top: 1px solid rgba(241, 241, 241, 1);
  311. .item {
  312. display: flex;
  313. align-items: center;
  314. justify-content: space-between;
  315. margin-bottom: 16rpx;
  316. .item-title {
  317. color: rgb(119, 119, 119);
  318. white-space: pre;
  319. }
  320. .item-value {
  321. color: rgb(48, 48, 48);
  322. }
  323. }
  324. .chart-box {
  325. background-color: rgba(208, 236, 255, 1);
  326. border-radius: 8px;
  327. .title {
  328. text-align: left;
  329. padding: 24rpx 28rpx;
  330. color: rgba(16, 16, 16, 1);
  331. }
  332. }
  333. .img {
  334. width: 622rpx;
  335. height: 304rpx;
  336. }
  337. }
  338. }
  339. }
  340. // 返回
  341. .back {
  342. border: 1px solid rgba(205, 205, 205, 1);
  343. line-height: 88rpx;
  344. border-radius: 8px;
  345. background-color: rgba(255, 255, 255, 1);
  346. color: rgba(119, 119, 119, 1);
  347. font-size: 32rpx;
  348. margin-top: 24rpx;
  349. }
  350. </style>