开始做工作台,调整用电查询分页
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
// childPackage/pages/electricQuery/components/listTable/index.js
|
||||
Component({
|
||||
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
list: {
|
||||
type: Array,
|
||||
watch(newVal) {
|
||||
console.log("newVal ------", newVal)
|
||||
}
|
||||
},
|
||||
header: Array,
|
||||
totalPage: Number,
|
||||
},
|
||||
observers: {
|
||||
'list': function(val) {
|
||||
this.setData({
|
||||
tempList: (this.data.list || [])?.slice(0, 20),
|
||||
page: 1,
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
page: 1,
|
||||
tempList: [],
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
console.log('this.data', this.data.list)
|
||||
this.setData({
|
||||
tempList: (this.data.list || [])?.slice(0, 20),
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
async onChangePage(e) {
|
||||
const page = e.detail.currentIndex;
|
||||
const that = this;
|
||||
this.setData({
|
||||
page,
|
||||
tempList: (this.data.list || [])?.slice((page - 1) * 20, page * 20)
|
||||
})
|
||||
},
|
||||
}
|
||||
})
|
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"table": "/components/table/table",
|
||||
"empty": "/components/empty/index",
|
||||
"pagination": "/components/pagination/index"
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
<!--childPackage/pages/electricQuery/components/listTable/index.wxml-->
|
||||
|
||||
<view wx:if="{{list.length}}">
|
||||
<table header="{{header}}" list="{{tempList}}" />
|
||||
<pagination
|
||||
currentIndex="{{page}}"
|
||||
totalPage="{{totalPage}}"
|
||||
bind:pagingChange="onChangePage"
|
||||
/>
|
||||
</view>
|
||||
<empty bind:refresh="init" wx:else />
|
@@ -0,0 +1 @@
|
||||
/* childPackage/pages/electricQuery/components/listTable/index.wxss */
|
@@ -48,13 +48,20 @@ Page({
|
||||
this.setData({ queryType: type },() => {
|
||||
switch(type) {
|
||||
case 0:
|
||||
this.init()
|
||||
loadingFunc(async () => {
|
||||
await this.init()
|
||||
})
|
||||
break;
|
||||
case 1:
|
||||
this.getReadingList();
|
||||
loadingFunc(async () => {
|
||||
await this.getReadingList();
|
||||
})
|
||||
break;
|
||||
case 2:
|
||||
this.getAccountingBalanceList();
|
||||
loadingFunc(async () => {
|
||||
await this.getAccountingBalanceList();
|
||||
})
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -69,8 +76,11 @@ Page({
|
||||
},
|
||||
changeTimeType(e) {
|
||||
const { type } = e.currentTarget.dataset
|
||||
const that = this;
|
||||
this.setData({ timeType: type }, () => {
|
||||
this.init()
|
||||
loadingFunc(async () => {
|
||||
await that.init()
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
@@ -78,7 +88,9 @@ Page({
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.init()
|
||||
loadingFunc(async () => {
|
||||
await this.init()
|
||||
})
|
||||
},
|
||||
async init() {
|
||||
const { queryType, timeType, meterId, year, yearMonth, yearMonthDay, page } = this.data;
|
||||
@@ -251,13 +263,20 @@ Page({
|
||||
const { queryType, } = this.data;
|
||||
switch(queryType) {
|
||||
case 1:
|
||||
this.getReadingList();
|
||||
loadingFunc(async () => {
|
||||
await this.getReadingList();
|
||||
})
|
||||
break;
|
||||
case 2:
|
||||
this.getAccountingBalanceList();
|
||||
loadingFunc(async () => {
|
||||
await this.getAccountingBalanceList();
|
||||
})
|
||||
break;
|
||||
default:
|
||||
this.init();
|
||||
loadingFunc(async () => {
|
||||
await this.init();
|
||||
})
|
||||
|
||||
break;
|
||||
}
|
||||
})
|
||||
@@ -273,13 +292,17 @@ Page({
|
||||
switch(type) {
|
||||
case "year":
|
||||
this.setData({ year: time, visible: false, }, () => {
|
||||
this.init();
|
||||
loadingFunc(async () => {
|
||||
await this.init();
|
||||
})
|
||||
});
|
||||
break;
|
||||
case "month":
|
||||
const [year, month] = time.split("-")
|
||||
this.setData({ yearMonth: time, yearMonthStamp: new Date(Number(year), Number(month) - 1, 1).getTime(), visible: false }, () => {
|
||||
this.init();
|
||||
loadingFunc(async () => {
|
||||
await this.init();
|
||||
})
|
||||
});
|
||||
break;
|
||||
case "day":
|
||||
@@ -289,7 +312,9 @@ Page({
|
||||
visible: false,
|
||||
page: 1,
|
||||
}, () => {
|
||||
this.init();
|
||||
loadingFunc(async () => {
|
||||
await this.init();
|
||||
})
|
||||
})
|
||||
break;
|
||||
}
|
||||
|
@@ -11,7 +11,8 @@
|
||||
"timePicker": "/components/timePicker/index",
|
||||
"accountingCard": "./components/accountingCard/index",
|
||||
"pagination": "/components/pagination/index",
|
||||
"echarts": "/childPackage/components/echarts/ec-canvas"
|
||||
"echarts": "/childPackage/components/echarts/ec-canvas",
|
||||
"listTable": "./components/listTable/index"
|
||||
},
|
||||
"navigationStyle": "custom"
|
||||
}
|
@@ -70,7 +70,7 @@
|
||||
</view>
|
||||
<view wx:if="{{queryType === 0}}">
|
||||
<view style="margin: 30rpx;">
|
||||
<view wx:if="{{list.length}}">
|
||||
<!-- <view wx:if="{{list.length}}">
|
||||
<table header="{{header}}" list="{{list}}" />
|
||||
<pagination
|
||||
currentIndex="{{page}}"
|
||||
@@ -79,7 +79,9 @@
|
||||
wx:if="{{timeType === 0}}"
|
||||
/>
|
||||
</view>
|
||||
<empty bind:refresh="init" wx:else />
|
||||
<empty bind:refresh="init" wx:else /> -->
|
||||
|
||||
<listTable list="{{list}}" header="{{header}}" totalPage="{{totalPage}}" />
|
||||
</view>
|
||||
<view class="sum">
|
||||
合计:表计数量:{{meterNumber}},耗电量:{{electricNumber}}
|
||||
@@ -87,7 +89,7 @@
|
||||
</view>
|
||||
<view wx:if="{{queryType === 1}}">
|
||||
<view style="margin: 30rpx;">
|
||||
<view wx:if="{{meterReadingList.length}}" >
|
||||
<view wx:if="{{meterReadingList.length}}">
|
||||
<table
|
||||
header="{{meterReadingHeader}}"
|
||||
list="{{meterReadingList}}"
|
||||
|
Reference in New Issue
Block a user