|
@@ -11,7 +11,7 @@
|
|
|
|
|
|
</view>
|
|
|
<!-- 标签 -->
|
|
|
- <view class="tabs-box" v-if="list.length >2">
|
|
|
+ <view class="tabs-box" v-if="companyList.length >2">
|
|
|
<view class="tabs">
|
|
|
<u-tabs :list="merchantList1" :is-scroll="false" inactive-color="#999999" active-color="#666666" :current="current"
|
|
|
@change="change"></u-tabs>
|
|
@@ -36,21 +36,21 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</u-popup>
|
|
|
- <view class="tatol-main">
|
|
|
+ <view class="tatol-main" v-for="(m, i) in kWhList" :key="i" style="margin-bottom: 15px;">
|
|
|
<!-- 用电量合计 -->
|
|
|
- <view class="total" v-if="false">
|
|
|
+ <view class="total">
|
|
|
<view class="company">
|
|
|
<view class="name">
|
|
|
- {{c.companyName}}
|
|
|
+ {{m.companyName}}
|
|
|
</view>
|
|
|
<view class="amount">
|
|
|
- 共 {{c.deviceList.length}} 台设备
|
|
|
+ 共 {{m.deviceList.length}} 台设备
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="infos">
|
|
|
<view class="infos-item">
|
|
|
<view class="number">
|
|
|
- {{c.thisDayKwh.toFixed(2)}}
|
|
|
+ {{m.thisDayKwh.toFixed(2)}}
|
|
|
</view>
|
|
|
<view class="time">
|
|
|
今日
|
|
@@ -58,7 +58,7 @@
|
|
|
</view>
|
|
|
<view class="infos-item">
|
|
|
<view class="number">
|
|
|
- {{c.thisMonthKwh}}
|
|
|
+ {{m.thisMonthKwh.toFixed(2)}}
|
|
|
</view>
|
|
|
<view class="time">
|
|
|
本月
|
|
@@ -66,7 +66,7 @@
|
|
|
</view>
|
|
|
<view class="infos-item">
|
|
|
<view class="number">
|
|
|
- {{c.lastMonthKwh}}
|
|
|
+ {{m.lastMonthKwh.toFixed(2)}}
|
|
|
</view>
|
|
|
<view class="time">
|
|
|
上月
|
|
@@ -76,7 +76,7 @@
|
|
|
</view>
|
|
|
|
|
|
<view class="main">
|
|
|
- <view class="item" v-for="(item, index) in kWhList" :key="index" @click="toElectronicMonitoring(item)">
|
|
|
+ <view class="item" v-for="(item, index) in m.deviceList" :key="index" @click="toElectronicMonitoring(item)">
|
|
|
<view class="icon">
|
|
|
<image class="img" src="@/assets/img/energyMeter.svg" mode=""></image>
|
|
|
</view>
|
|
@@ -127,10 +127,7 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
@@ -140,13 +137,12 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- companyList: [],
|
|
|
- merchantList1: [], // 商户
|
|
|
+ companyList: [], // 商户
|
|
|
+ merchantList1: [],
|
|
|
merchantList2: [],
|
|
|
- kWhList: [],
|
|
|
+ kWhList: [], //设备
|
|
|
companyId: '',
|
|
|
popShow: false,
|
|
|
- list: [],
|
|
|
current: 0
|
|
|
}
|
|
|
},
|
|
@@ -165,15 +161,15 @@
|
|
|
})
|
|
|
API.deviceCompanyList().then((response) => {
|
|
|
uni.hideLoading();
|
|
|
- this.list = response.data.companyInfoList;
|
|
|
- for (var i = 0; i < this.list.length; i++) {
|
|
|
- this.list[i].name = this.list[i].fullName;
|
|
|
+ this.companyList = response.data.companyInfoList;
|
|
|
+ for (var i = 0; i < this.companyList.length; i++) {
|
|
|
+ this.companyList[i].name = this.companyList[i].fullName;
|
|
|
}
|
|
|
- if (this.list.length > 3) {
|
|
|
- this.merchantList1.push(this.list.slice(0, 3));
|
|
|
- this.merchantList2.push(this.list.slice(3));
|
|
|
+ if (this.companyList.length > 3) {
|
|
|
+ this.merchantList1.push(this.companyList.slice(0, 3));
|
|
|
+ this.merchantList2.push(this.companyList.slice(3));
|
|
|
} else {
|
|
|
- this.merchantList1 = this.list;
|
|
|
+ this.merchantList1 = this.companyList;
|
|
|
}
|
|
|
this.merchantList1.unshift({
|
|
|
id: '',
|
|
@@ -198,34 +194,34 @@
|
|
|
};
|
|
|
API.homePageKwh(data).then((res) => {
|
|
|
uni.hideLoading()
|
|
|
- this.kWhList = res.data.data;
|
|
|
- // var idList = [];
|
|
|
- // var list = []
|
|
|
- // for (var i = 0; i < this.kWhList.length; i++) {
|
|
|
- // idList.push(this.kWhList[i].companyId);
|
|
|
- // }
|
|
|
- // idList = Array.from(new Set(idList));
|
|
|
- // for (var m = 0; m < idList.length; m++) {
|
|
|
- // list.push({
|
|
|
- // companyId: idList[m],
|
|
|
- // companyName: '',
|
|
|
- // thisDayKwh: 0,
|
|
|
- // thisMonthKwh: 0,
|
|
|
- // lastMonthKwh: 0,
|
|
|
- // deviceList: []
|
|
|
- // });
|
|
|
- // for (var n = 0; n < this.kWhList .length; n++) {
|
|
|
- // if(this.kWhList[n].companyId == idList[m]) {
|
|
|
- // list[m].companyName = this.kWhList[n].companyName;
|
|
|
- // list[m].deviceList.push(this.kWhList[n]);
|
|
|
- // list[m].thisDayKwh += this.kWhList[n].thisDayKwh;
|
|
|
- // list[m].thisMonthKwh += this.kWhList[n].thisMonthKwh;
|
|
|
- // list[m].lastMonthKwh += this.kWhList[n].lastMonthKwh;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
+ var dataList = res.data.data;
|
|
|
+ var idList = [];
|
|
|
+ var list = []
|
|
|
+ for (var i = 0; i < dataList.length; i++) {
|
|
|
+ idList.push(dataList[i].companyId);
|
|
|
+ }
|
|
|
+ idList = Array.from(new Set(idList));
|
|
|
+ for (var m = 0; m < idList.length; m++) {
|
|
|
+ list.push({
|
|
|
+ companyId: idList[m],
|
|
|
+ companyName: '',
|
|
|
+ thisDayKwh: 0,
|
|
|
+ thisMonthKwh: 0,
|
|
|
+ lastMonthKwh: 0,
|
|
|
+ deviceList: []
|
|
|
+ });
|
|
|
+ for (var n = 0; n < dataList.length; n++) {
|
|
|
+ if(dataList[n].companyId == idList[m]) {
|
|
|
+ list[m].companyName = dataList[n].companyName;
|
|
|
+ list[m].deviceList.push(dataList[n]);
|
|
|
+ list[m].thisDayKwh += dataList[n].thisDayKwh;
|
|
|
+ list[m].thisMonthKwh += dataList[n].thisMonthKwh;
|
|
|
+ list[m].lastMonthKwh += dataList[n].lastMonthKwh;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// console.log(list)
|
|
|
- // this.companyList = list;
|
|
|
+ this.kWhList = list;
|
|
|
}).catch(error => {
|
|
|
uni.showToast({
|
|
|
title: error,
|
|
@@ -238,15 +234,15 @@
|
|
|
var n = this.merchantList1[this.current];
|
|
|
this.merchantList1[this.current] = m;
|
|
|
this.merchantList2[index] = n;
|
|
|
-
|
|
|
this.companyId = item.id;
|
|
|
- this.getList();
|
|
|
-
|
|
|
this.popShow = false;
|
|
|
+
|
|
|
+ this.getList();
|
|
|
},
|
|
|
change(index) {
|
|
|
this.current = index;
|
|
|
this.companyId = this.merchantList1[index].id;
|
|
|
+
|
|
|
this.getList();
|
|
|
},
|
|
|
backStatistics() {
|