123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- <template>
- <view>
- <u-navbar title="用电量明细 (度)" title-color="#101010"></u-navbar>
- <view class="dropdown">
- <view class="dropdown-item" @click="show1=true">
- <view class="text">
- {{electricMeter}}
- </view>
- <view class="item-icon">
- <u-icon name="arrow-down" color="#999999" v-if="show1==false"></u-icon>
- <u-icon name="arrow-up" color="#999999" v-else></u-icon>
- </view>
- </view>
- <view class="dropdown-item" @click="show2=true">
- <view class="text">
- {{month}}
- </view>
- <view class="icon">
- <u-icon name="arrow-down" color="#999999" v-if="show2==false"></u-icon>
- <u-icon name="arrow-up" color="#999999" v-else></u-icon>
- </view>
- </view>
- </view>
-
- <u-select title="设备选择" v-model="show1" mode="mutil-column-auto" :list="electricMeterList"
- @confirm="electricMeterChange" cancel-text="重置" @cancel="electricMeterReset">
- </u-select>
- <u-select v-model="show2" mode="single-column" :list="monthList" @confirm="monthChange"></u-select>
-
- <u-picker mode="time" :defaultTime="defaultTime" v-model="show3" :params="params" @confirm="timeChange"></u-picker>
- <view class="table-box">
- <table class="table1">
- <tr class="tr1">
- <td class="td1"></td>
- <td class="td2">起止码</td>
- <td class="td3">度数</td>
- </tr>
- <tr class="tr2">
- <td class="td1">{{kwhMap.meterName}}</td>
- <td class="td2">
- {{kwhMap.startMeter!=null ? kwhMap.startMeter : '0'}}-{{kwhMap.endMeter!=null ? kwhMap.endMeter : '0'}}
- </td>
- <td class="td3">{{kwhMap.kwh}}度</td>
- </tr>
-
- <tr v-for="(item,i) in childMap" :key="i" v-if="Object.keys(childMap).length!=0">
- <td class="td1">{{item.meterName}}</td>
- <td class="td2">
- {{item.startMeter!=null ? item.startMeter : '0'}}-{{item.endMeter!=null ? item.endMeter : '0'}}
- </td>
- <td class="td3">{{item.kwh}}度</td>
- </tr>
- <tr class="tr2" v-if="Object.keys(childMap).length!=0" style="height: 40px;">
- <td class="td1" colspan="2">{{childLevel}}合计用电</td>
- <td>{{childKwh}}度</td>
- </tr>
- <tr class="tr3" v-if="Object.keys(childMap).length!=0">
- <td class="td1" colspan="2">扣除后用电量</td>
- <td>{{subKwh}}度</td>
- </tr>
- </table>
- </view>
- </view>
- </template>
- <script>
- import * as API_electricityMeter from '@/apis/pagejs/electricityMeter.js'
- import * as API from '@/apis/pagejs/index.js'
- export default {
- data() {
- return {
- childLevel: '',
- childKwh: 0,
- childMap: {},
- kwhMap: {},
- subKwh: 0,
- id: '',
- meterName: '',
- meterId: '',
- type: '2',
- queryDate: '',
- electricMeter: '11楼公摊电表',
- month: '上月',
- show1: false,
- show2: false,
- electricMeterList: [],
- monthList: [{
- value: '1',
- label: '本月'
- }, {
- value: '4',
- label: '今日'
- }, {
- value: '2',
- label: '上月'
- }, {
- value: '3',
- label: '本年'
- }, {
- value: '0',
- label: '合计'
- }, {
- value: '10',
- label: '指定月份'
- }],
- show3: false, // 时间选择
- defaultTime: '',
- params: {
- year: true,
- month: true,
- day: false,
- hour: false,
- minute: false,
- second: false,
- timestamp: false
- },
- }
- },
- onLoad(op) {
- if(op.id) {
- this.meterId = op.id;
- this.electricMeter = op.name;
- this.type = op.type;
- for (var i = 0; i < this.monthList.length; i++) {
- if(this.type == this.monthList[i].value) {
- this.month = this.monthList[i].label;
- }
- }
-
- this.id = op.id;
- this.meterName = op.name;
-
- this.getElectricityStatisticsDetails();
- this.getCompanyInfoList();
- }
-
- var date = new Date();
- var year = date.getFullYear();
- var month = date.getMonth()+1 >= 10 ? date.getMonth()+1 : '0'+(date.getMonth()+1);
- this.defaultTime = year + '-' + month;
- },
- methods: {
- timeChange(params) {
- // console.log(params)
- this.month = params.year + '-' + params.month;
- this.queryDate = params.year + '-' + params.month + '-01';
-
- this.getElectricityStatisticsDetails();
- },
- electricMeterReset() {
- this.meterId = this.id;
- this.electricMeter = this.meterName;
-
- this.getElectricityStatisticsDetails();
- },
- electricMeterChange(e) {
- this.meterId = e[2].value;
- this.electricMeter = e[2].label;
-
- this.getElectricityStatisticsDetails();
- },
- monthChange(e) {
- this.type = e[0].value;
-
- if(e[0].value == '10') {
- this.show3 = true;
- } else {
- this.month = e[0].label;
- this.getElectricityStatisticsDetails();
- }
- },
- getElectricityStatisticsDetails() {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API_electricityMeter.electricityStatisticsDetails({
- meterId: this.meterId,
- type: this.type,
- queryDate: this.queryDate,
- }).then((res) => {
- uni.hideLoading();
- this.childKwh = res.data.childKwh;
- this.childMap = res.data.childMap;
- this.kwhMap = res.data.kwhMap;
- this.subKwh = res.data.subKwh;
- this.childLevel = res.data.childLevel;
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- getCompanyInfoList() {
- // uni.showLoading({
- // title: "加载中",
- // mask: true,
- // })
- API.deviceCompanyList().then((response) => {
- // uni.hideLoading();
- var list = response.data.companyInfoList;
- this.electricMeterList = [];
- this.electricMeterList = list.map(item => {
- if (item.remoteReadingMeterList.length != 0 && item.remoteMonitorMeterList.length != 0) {
- return {
- label: item.name,
- value: item.id,
- children: [{
- label: '抄表',
- value: '1',
- children: item.remoteReadingMeterList.map(item => {
- return {
- label: item.name,
- value: item.id,
- }
- })
- },
- {
- label: '监控表',
- value: '1',
- children: item.remoteMonitorMeterList.map(item => {
- return {
- label: item.name,
- value: item.id,
- }
- })
- }
- ]
- }
- } else if (item.remoteReadingMeterList.length != 0 && item.remoteMonitorMeterList.length == 0) {
- return {
- label: item.name,
- value: item.id,
- children: [{
- label: '抄表',
- value: '1',
- children: item.remoteReadingMeterList.map(item => {
- return {
- label: item.name,
- value: item.id,
- }
- })
- }]
- }
- } else if (item.remoteReadingMeterList.length == 0 && item.remoteMonitorMeterList.length != 0) {
- return {
- label: item.name,
- value: item.id,
- children: [{
- label: '监控表',
- value: '1',
- children: item.remoteMonitorMeterList.map(item => {
- return {
- label: item.name,
- value: item.id,
- }
- })
- }]
- }
- } else {
-
- }
- })
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- background-color: #fff;
- }
- .dropdown {
- background-color: #fff;
- position: sticky;
- top: 88rpx;
- z-index: 999;
- padding: 18rpx 46rpx;
- display: flex;
- border-bottom: 1px solid rgba(245, 245, 245, 1);
- .dropdown-item {
- width: 50%;
- text-align: center;
- height: 60rpx;
- line-height: 60rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- .text {
- max-width: 80%;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- }
- }
- .table-box {
- padding: 24rpx 32rpx;
- }
- .table1 {
- padding-bottom: 20rpx;
- width: 100%;
- border-collapse: collapse;
- td {
- border: 1px solid #e7e7e7;
- text-align: end;
- padding: 2px 8px;
- height: 60rpx;
- }
- .td1 {
- text-align: start;
- width: 264rpx;
- }
- .td2 {
- width: 270rpx;
- }
- .td3 {
- width: 170rpx;
- white-space: pre;
- }
- tr {
- background-color: #f5f5f6;
- }
- .tr1 {
- text-align: end;
- font-weight: bold;
- }
-
- .tr2 {
- background-color: #fff;
- }
-
- .tr3 {
- font-weight: bold;
- height: 40px;
- background-color: rgba(22,119,255,1);
- color: rgba(255,255,255,1);
- }
- // tr:nth-child(even) {
- // background-color: #fff;
- // }
- }
- </style>
|