修改用电查询电表选择问题

This commit is contained in:
qiaomu 2024-05-07 13:50:33 +08:00
parent 19ba67134f
commit 1e92bb8bcf
5 changed files with 55 additions and 37 deletions

View File

@ -4,6 +4,7 @@ import { getTenementMeterList } from "../../service/meter";
import dayjs from "../../utils/dayjs";
import request from '../../utils/request';
import * as echarts from '../../components/echarts/echarts';
import { alertInfo } from "../../utils/index";
const { OK } = request;
Page({
@ -37,7 +38,9 @@ Page({
list: [],
visible: false,
meterReadingList: [],
accountingList: []
accountingList: [],
electricNumber: 0,
meterNumber: 0,
},
changeQueryType(e) {
const { type } = e.currentTarget.dataset
@ -90,26 +93,38 @@ Page({
time = yearMonthDay;
break;
}
const { code, message, data } = await getElectricityList({ type: timeType, meter: meterId, time: time })
this.setData({ list: data })
const { code, message, data, electricNumber, meterNumber } = await getElectricityList({ type: timeType, meter: meterId, time: time })
if (code !== OK) {
alertInfo(message)
return;
}
this.setData({ list: data, electricNumber, meterNumber })
},
async getReadingList() {
const { meterId } = this.data;
const { code, message, data } = await getMeterReadingList(meterId)
if (code !== OK) {
alertInfo(message)
return;
}
this.setData({ meterReadingList: data })
},
async getAccountingBalanceList() {
const { meterId } = this.data;
const { code, message, data } = await getAccountingList(meterId)
if (code !== OK) {
alertInfo(message)
return;
}
this.setData({ accountingList: data })
},
async getMeters() {
const { id } = wx.getStorageSync('tenement')
const { code, message, data } = await getTenementMeterList(id);
// if (code !== OK) {
// alertInfo(message)
// return;
// }
if (code !== OK) {
alertInfo(message)
return;
}
this.setData({
meterList: data || [],
@ -133,12 +148,13 @@ Page({
},
onOk(e) {
const { type, value = {} } = e.detail;
const { id, code } = e;
const { id, code } = e.detail.value;
console.log('e', e)
const { year } = this.data;
// const currentYear = years[Number(e)]
this.setData({
// year: currentYear,
codeId: id,
meterId: id,
meterCode: code,
type: "",
show: false,

View File

@ -74,7 +74,7 @@
<empty bind:refresh="init" wx:else />
</view>
<view class="sum">
合计:表计数量:10耗电量100
合计:表计数量:{{meterNumber}},耗电量:{{electricNumber}}
</view>
</view>
<view wx:if="{{queryType === 1}}">
@ -86,9 +86,11 @@
</view>
<view wx:if="{{queryType === 2}}">
<view style="margin: 30rpx;">
<accountingCard wx:for="{{accountingList}}" data="{{item}}" />
<view wx:if="{{accountingList.length}}">
<accountingCard wx:for="{{accountingList}}" data="{{item}}" />
</view>
<!-- <table header="{{meterReadingHeader}}" list="{{accountingList}}" wx:if="{{accountingList.length}}" /> -->
<!-- <empty bind:refresh="init" wx:else /> -->
<empty bind:refresh="getAccountingBalanceList" wx:else />
</view>
</view>

View File

@ -23,6 +23,7 @@ page {
margin-bottom: 30rpx;
margin-left: 30rpx;
margin-right: 30rpx;
padding-bottom: 50rpx;
}
.query {

View File

@ -1,5 +1,5 @@
import { getInvoiceInfoDetail, downloadInvoice } from "../../service/invoice";
import { alertInfo } from "../../utils/index";
import { alertInfo, loadingFunc } from "../../utils/index";
import request from '../../utils/request'
const { OK } = request;
// pages/invoiceInfo/index.js
@ -33,34 +33,34 @@ Page({
})
},
download() {
// console.log('---------')
const that = this;
wx.showActionSheet({
itemList: ['发票XML文件下载', '发票PDF文件下载'],
async success(res) {
console.log('res', res.tapIndex)
const { code, message, data } = await downloadInvoice(that.data.id, res.tapIndex);
if (code !== OK) {
alertInfo(message)
return;
}
wx.downloadFile({
url: data,
success(res) {
if (res.statusCode === 200) {
wx.openDocument({
filePath: res.tempFilePath,
fileType: [res.tapIndex === 0 ? 'xml' : "pdf"], // 3. 这个必须写合法类型,不然下载不了
success: function (res) {
console.log('打开文档成功')
},
fail: function (e) {
console.log(e.errMsg);
}
})
}
loadingFunc(async () => {
const { code, message, data } = await downloadInvoice(that.data.id, res.tapIndex);
if (code !== OK) {
alertInfo(message)
return;
}
wx.downloadFile({
url: data,
success(res) {
if (res.statusCode === 200) {
wx.openDocument({
filePath: res.tempFilePath,
fileType: [res.tapIndex === 0 ? 'xml' : "pdf"], // 3. 这个必须写合法类型,不然下载不了
success: function (res) {
},
fail: function (e) {
}
})
}
}
})
})

View File

@ -20,7 +20,6 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log('options', options)
const { id } = options;
this.getDetail(id)
},