修改用电查询

This commit is contained in:
2025-05-12 14:04:17 +08:00
parent 028d695deb
commit 4d665588ac
5 changed files with 79 additions and 201 deletions

View File

@@ -1,6 +1,7 @@
// pages/electricQuery/index.js
import { exportElectricityList, getAccountingList, getElectricityList, getMeterReadingList } from "../../../service/accounting";
import { getTenementMeterList } from "../../../service/meter";
import { getParkInfoByTime } from "../../../service/park";
import dayjs from "../../../utils/dayjs";
import request from '../../../utils/request';
import * as echarts from '../../components/echarts/echarts';
@@ -29,11 +30,18 @@ Page({
header: [
{ key: 'address', title: '电表地址', renderBody: (item) => item.meter?.address },
// { key: 'address', title: '电表地址', renderBody: (item) => item.meter?.address },
{ title: '时间',renderBody: (item) => { return item.time } },
{ key: 'number', title: '耗量' },
],
valleyHeader: [
// { key: 'address', title: '电表地址', renderBody: (item) => item.meter?.address },
{ title: '时间',renderBody: (item) => { return item.time } },
{ key: 'number', title: '尖' },
{ key: 'number', title: '峰' },
{ key: 'number', title: '平' },
{ key: 'number', title: '谷' },
],
list: [],
visible: false,
@@ -76,7 +84,7 @@ Page({
},
changeTimeType(e) {
const { type } = e.currentTarget.dataset
const { type } = e.currentTarget.dataset;
const that = this;
this.setData({ timeType: type }, () => {
loadingFunc(async () => {
@@ -235,15 +243,39 @@ Page({
alertInfo(message)
return;
}
const first = data?.[0]
this.setData({
meterList: data || [],
meterId: first?.id,
meterAddress: first?.address,
meterCode: first?.code,
}, () => {
const { queryType, } = this.data;
switch(queryType) {
case 1:
loadingFunc(async () => {
await this.getReadingList();
})
break;
case 2:
loadingFunc(async () => {
await this.getAccountingBalanceList();
})
break;
default:
loadingFunc(async () => {
await this.init();
})
break;
}
})
},
clickMeter() {
this.setData({
type: "meter",
columns: [{ id: "", name: "全部", code: "" }, ...this.data.meterList.map(item => ({ id: item.id, name: `${item.code}-${item.address}`, code: item.code }))],
columns: [
// { id: "", name: "全部", code: "" },
...this.data.meterList.map(item => ({ id: item.id, name: `${item.code}-${item.address}`, code: item.code }))],
show: true,
title: "表计"
})
@@ -257,11 +289,12 @@ Page({
})
},
onOk(e) {
const { id, code } = e.detail.value;
const { id, code, address } = e.detail.value;
this.setData({
// year: currentYear,
meterId: id,
meterCode: code,
meterAddress: address,
type: "",
show: false,
title: ""
@@ -339,8 +372,31 @@ Page({
*/
onShow() {
this.getMeters()
this.getParkInfo()
},
async getParkInfo() {
const park = wx.getStorageSync('park');
const { timeType, yearMonthDay, yearMonth, year } = this.data;
let time = ''
switch(timeType) {
case 0:
time = yearMonthDay;
break;
case 1:
time = yearMonth;
break;
case 2:
time = year;
}
const { data, code, message } = await getParkInfoByTime(park?.id, `${time}`, `${timeType}`,)
if (code !== OK) {
alertInfo(message)
return;
}
this.setData({
parkInfo: data
})
},
/**
* 生命周期函数--监听页面隐藏
*/