electricityConsumptionDetail.vue 7.9 KB

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