102 lines
2.6 KiB
JavaScript
102 lines
2.6 KiB
JavaScript
// childPackage/pages/electricQuery/components/reading/index.js
|
|
import { exportElectricityList, getAccountingList, getElectricityList, getMeterReadingList } from "../../../../../service/accounting";
|
|
import { getTenementMeterList } from "../../../../../service/meter";
|
|
import dayjs from "../../../../../utils/dayjs";
|
|
import request from '../../../../../utils/request';
|
|
import { alertInfo, getPixelRatio, loadingFunc } from "../../../../../utils/index";
|
|
const { OK } = request;
|
|
Component({
|
|
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
meter: String,
|
|
},
|
|
observers: {
|
|
'meter': function() {
|
|
loadingFunc(async () => {
|
|
await this.getReadingList();
|
|
})
|
|
}
|
|
},
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
readingDetailShow: false,
|
|
readingDetail: {},
|
|
meterReadingHeader: [
|
|
{ key: 'address', title: '电表地址', renderBody: (item) => item.meter?.address },
|
|
{ title: '倍率', key: 'ratio' },
|
|
{ key: 'number', title: '抄表记录' },
|
|
],
|
|
meterReadingList: [],
|
|
yearMonthDayReading: dayjs().format("YYYY-MM-DD"),
|
|
yearMonthDayReadingStamp: new Date().getTime(),
|
|
readingPage: 1,
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
clickReadingTime() {
|
|
this.setData({
|
|
readingVisible: true
|
|
})
|
|
},
|
|
async getReadingList() {
|
|
const { meter, yearMonthDayReading, readingPage } = this.data;
|
|
const { code, message, data, total } = await getMeterReadingList({
|
|
id: meter,
|
|
time: yearMonthDayReading,
|
|
page: readingPage
|
|
})
|
|
if (code !== OK) {
|
|
alertInfo(message)
|
|
return;
|
|
}
|
|
this.setData({ meterReadingList: data, totalPage: Math.ceil(total / 20) })
|
|
},
|
|
onReadingTimeClose() {
|
|
this.setData({ readingVisible: false })
|
|
},
|
|
onReadingTimeCancel() {
|
|
this.setData({ readingVisible: false })
|
|
},
|
|
onReadingTimeConfirm(e) {
|
|
const { time } = e.detail;
|
|
|
|
this.setData({
|
|
yearMonthDayReading: time,
|
|
yearMonthDayReadingStamp: new Date(time).getTime(),
|
|
readingVisible: false,
|
|
readingPage: 1,
|
|
}, () => {
|
|
loadingFunc(async () => {
|
|
await this.getReadingList();
|
|
})
|
|
})
|
|
|
|
},
|
|
showDetail(e) {
|
|
const { index, data = {} } = e.detail;
|
|
this.setData({
|
|
readingDetailShow: true,
|
|
readingDetail: data || {}
|
|
})
|
|
},
|
|
async onChangePage(e) {
|
|
const page = e.detail.currentIndex;
|
|
const that = this;
|
|
this.setData({
|
|
readingPage: page
|
|
}, () => {
|
|
loadingFunc(async () => {
|
|
await that.getReadingList();
|
|
})
|
|
})
|
|
},
|
|
}
|
|
}) |