electricityConsumptionDetail.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <view>
  3. <u-navbar title="用电量明细 (度)" title-color="#101010"></u-navbar>
  4. <view class="dropdown">
  5. <view class="dropdown-item" @click="show1=true">
  6. <view class="text">
  7. {{electricMeter}}
  8. </view>
  9. <view class="item-icon">
  10. <u-icon name="arrow-down" color="#999999" v-if="show1==false"></u-icon>
  11. <u-icon name="arrow-up" color="#999999" v-else></u-icon>
  12. </view>
  13. </view>
  14. <view class="dropdown-item" @click="show2=true">
  15. <view class="text">
  16. {{month}}
  17. </view>
  18. <view class="icon">
  19. <u-icon name="arrow-down" color="#999999" v-if="show2==false"></u-icon>
  20. <u-icon name="arrow-up" color="#999999" v-else></u-icon>
  21. </view>
  22. </view>
  23. </view>
  24. <u-select title="设备选择" v-model="show1" mode="mutil-column-auto" :list="electricMeterList"
  25. @confirm="electricMeterChange" cancel-text="重置" @cancel="electricMeterReset">
  26. </u-select>
  27. <u-select v-model="show2" mode="single-column" :list="monthList" @confirm="monthChange"></u-select>
  28. <u-picker mode="time" :defaultTime="defaultTime" v-model="show3" :params="params" @confirm="timeChange"></u-picker>
  29. <view class="table-box">
  30. <table class="table1">
  31. <tr class="tr1">
  32. <td class="td1"></td>
  33. <td class="td2">起止码</td>
  34. <td class="td3">度数</td>
  35. </tr>
  36. <tr class="tr2">
  37. <td class="td1">{{kwhMap.meterName}}</td>
  38. <td class="td2">
  39. {{kwhMap.startMeter!=null ? kwhMap.startMeter : '0'}}-{{kwhMap.endMeter!=null ? kwhMap.endMeter : '0'}}
  40. </td>
  41. <td class="td3">{{kwhMap.kwh}}度</td>
  42. </tr>
  43. <tr v-for="(item,i) in childMap" :key="i" v-if="Object.keys(childMap).length!=0">
  44. <td class="td1">{{item.meterName}}</td>
  45. <td class="td2">
  46. {{item.startMeter!=null ? item.startMeter : '0'}}-{{item.endMeter!=null ? item.endMeter : '0'}}
  47. </td>
  48. <td class="td3">{{item.kwh}}度</td>
  49. </tr>
  50. <tr class="tr2" v-if="Object.keys(childMap).length!=0" style="height: 40px;">
  51. <td class="td1" colspan="2">{{childLevel}}合计用电</td>
  52. <td>{{childKwh}}度</td>
  53. </tr>
  54. <tr class="tr3" v-if="Object.keys(childMap).length!=0">
  55. <td class="td1" colspan="2">扣除后用电量</td>
  56. <td>{{subKwh}}度</td>
  57. </tr>
  58. </table>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import * as API_electricityMeter from '@/apis/pagejs/electricityMeter.js'
  64. import * as API from '@/apis/pagejs/index.js'
  65. export default {
  66. data() {
  67. return {
  68. childLevel: '',
  69. childKwh: 0,
  70. childMap: {},
  71. kwhMap: {},
  72. subKwh: 0,
  73. id: '',
  74. meterName: '',
  75. meterId: '',
  76. type: '2',
  77. queryDate: '',
  78. electricMeter: '11楼公摊电表',
  79. month: '上月',
  80. show1: false,
  81. show2: false,
  82. electricMeterList: [],
  83. monthList: [{
  84. value: '1',
  85. label: '本月'
  86. }, {
  87. value: '4',
  88. label: '今日'
  89. }, {
  90. value: '2',
  91. label: '上月'
  92. }, {
  93. value: '3',
  94. label: '本年'
  95. }, {
  96. value: '0',
  97. label: '合计'
  98. }, {
  99. value: '10',
  100. label: '指定月份'
  101. }],
  102. show3: false, // 时间选择
  103. defaultTime: '',
  104. params: {
  105. year: true,
  106. month: true,
  107. day: false,
  108. hour: false,
  109. minute: false,
  110. second: false,
  111. timestamp: false
  112. },
  113. }
  114. },
  115. onLoad(op) {
  116. if(op.id) {
  117. this.meterId = op.id;
  118. this.electricMeter = op.name;
  119. this.type = op.type;
  120. for (var i = 0; i < this.monthList.length; i++) {
  121. if(this.type == this.monthList[i].value) {
  122. this.month = this.monthList[i].label;
  123. }
  124. }
  125. this.id = op.id;
  126. this.meterName = op.name;
  127. this.getElectricityStatisticsDetails();
  128. this.getCompanyInfoList();
  129. }
  130. var date = new Date();
  131. var year = date.getFullYear();
  132. var month = date.getMonth()+1 >= 10 ? date.getMonth()+1 : '0'+(date.getMonth()+1);
  133. this.defaultTime = year + '-' + month;
  134. },
  135. methods: {
  136. timeChange(params) {
  137. // console.log(params)
  138. this.month = params.year + '-' + params.month;
  139. this.queryDate = params.year + '-' + params.month + '-01';
  140. this.getElectricityStatisticsDetails();
  141. },
  142. electricMeterReset() {
  143. this.meterId = this.id;
  144. this.electricMeter = this.meterName;
  145. this.getElectricityStatisticsDetails();
  146. },
  147. electricMeterChange(e) {
  148. this.meterId = e[2].value;
  149. this.electricMeter = e[2].label;
  150. this.getElectricityStatisticsDetails();
  151. },
  152. monthChange(e) {
  153. this.type = e[0].value;
  154. if(e[0].value == '10') {
  155. this.show3 = true;
  156. } else {
  157. this.month = e[0].label;
  158. this.getElectricityStatisticsDetails();
  159. }
  160. },
  161. getElectricityStatisticsDetails() {
  162. uni.showLoading({
  163. title: "加载中",
  164. mask: true,
  165. })
  166. API_electricityMeter.electricityStatisticsDetails({
  167. meterId: this.meterId,
  168. type: this.type,
  169. queryDate: this.queryDate,
  170. }).then((res) => {
  171. uni.hideLoading();
  172. this.childKwh = res.data.childKwh;
  173. this.childMap = res.data.childMap;
  174. this.kwhMap = res.data.kwhMap;
  175. this.subKwh = res.data.subKwh;
  176. this.childLevel = res.data.childLevel;
  177. }).catch(error => {
  178. uni.showToast({
  179. title: error,
  180. icon: "none"
  181. })
  182. })
  183. },
  184. getCompanyInfoList() {
  185. // uni.showLoading({
  186. // title: "加载中",
  187. // mask: true,
  188. // })
  189. API.deviceCompanyList().then((response) => {
  190. // uni.hideLoading();
  191. var list = response.data.companyInfoList;
  192. this.electricMeterList = [];
  193. this.electricMeterList = list.map(item => {
  194. if (item.remoteReadingMeterList.length != 0 && item.remoteMonitorMeterList.length != 0) {
  195. return {
  196. label: item.name,
  197. value: item.id,
  198. children: [{
  199. label: '抄表',
  200. value: '1',
  201. children: item.remoteReadingMeterList.map(item => {
  202. return {
  203. label: item.name,
  204. value: item.id,
  205. }
  206. })
  207. },
  208. {
  209. label: '监控表',
  210. value: '1',
  211. children: item.remoteMonitorMeterList.map(item => {
  212. return {
  213. label: item.name,
  214. value: item.id,
  215. }
  216. })
  217. }
  218. ]
  219. }
  220. } else if (item.remoteReadingMeterList.length != 0 && item.remoteMonitorMeterList.length == 0) {
  221. return {
  222. label: item.name,
  223. value: item.id,
  224. children: [{
  225. label: '抄表',
  226. value: '1',
  227. children: item.remoteReadingMeterList.map(item => {
  228. return {
  229. label: item.name,
  230. value: item.id,
  231. }
  232. })
  233. }]
  234. }
  235. } else if (item.remoteReadingMeterList.length == 0 && item.remoteMonitorMeterList.length != 0) {
  236. return {
  237. label: item.name,
  238. value: item.id,
  239. children: [{
  240. label: '监控表',
  241. value: '1',
  242. children: item.remoteMonitorMeterList.map(item => {
  243. return {
  244. label: item.name,
  245. value: item.id,
  246. }
  247. })
  248. }]
  249. }
  250. } else {
  251. }
  252. })
  253. }).catch(error => {
  254. uni.showToast({
  255. title: error,
  256. icon: "none"
  257. })
  258. })
  259. },
  260. }
  261. }
  262. </script>
  263. <style lang="scss" scoped>
  264. page {
  265. background-color: #fff;
  266. }
  267. .dropdown {
  268. background-color: #fff;
  269. position: sticky;
  270. top: 88rpx;
  271. z-index: 999;
  272. padding: 18rpx 46rpx;
  273. display: flex;
  274. border-bottom: 1px solid rgba(245, 245, 245, 1);
  275. .dropdown-item {
  276. width: 50%;
  277. text-align: center;
  278. height: 60rpx;
  279. line-height: 60rpx;
  280. display: flex;
  281. align-items: center;
  282. justify-content: center;
  283. .text {
  284. max-width: 80%;
  285. white-space: nowrap;
  286. overflow: hidden;
  287. text-overflow: ellipsis;
  288. }
  289. }
  290. }
  291. .table-box {
  292. padding: 24rpx 32rpx;
  293. }
  294. .table1 {
  295. padding-bottom: 20rpx;
  296. width: 100%;
  297. border-collapse: collapse;
  298. td {
  299. border: 1px solid #e7e7e7;
  300. text-align: end;
  301. padding: 2px 8px;
  302. height: 60rpx;
  303. }
  304. .td1 {
  305. text-align: start;
  306. width: 264rpx;
  307. }
  308. .td2 {
  309. width: 270rpx;
  310. }
  311. .td3 {
  312. width: 170rpx;
  313. white-space: pre;
  314. }
  315. tr {
  316. background-color: #f5f5f6;
  317. }
  318. .tr1 {
  319. text-align: end;
  320. font-weight: bold;
  321. }
  322. .tr2 {
  323. background-color: #fff;
  324. }
  325. .tr3 {
  326. font-weight: bold;
  327. height: 40px;
  328. background-color: rgba(22,119,255,1);
  329. color: rgba(255,255,255,1);
  330. }
  331. // tr:nth-child(even) {
  332. // background-color: #fff;
  333. // }
  334. }
  335. </style>