开始做工作台,调整用电查询分页
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 */
|
Reference in New Issue
Block a user