|
@@ -10,7 +10,7 @@
|
|
layout="prev, pager, next,total, jumper"
|
|
layout="prev, pager, next,total, jumper"
|
|
:total="count"
|
|
:total="count"
|
|
:page-size="rows"
|
|
:page-size="rows"
|
|
- @current-change="currentChange"
|
|
|
|
|
|
+ @current-change="page => load(page)"
|
|
/>
|
|
/>
|
|
</template>
|
|
</template>
|
|
<template v-else-if="count === 0 && !hideTip">
|
|
<template v-else-if="count === 0 && !hideTip">
|
|
@@ -47,37 +47,27 @@ export default class extends Vue {
|
|
@PropSync("total") totalSync!: number;
|
|
@PropSync("total") totalSync!: number;
|
|
|
|
|
|
private count: number | null = null;
|
|
private count: number | null = null;
|
|
- private page = 0;
|
|
|
|
private items: any[] = [];
|
|
private items: any[] = [];
|
|
@Watch("params", { immediate: true, deep: true })
|
|
@Watch("params", { immediate: true, deep: true })
|
|
reload() {
|
|
reload() {
|
|
- if (this.page === 1) return this.load();
|
|
|
|
- this.page = 1;
|
|
|
|
|
|
+ if (!this.params) return;
|
|
|
|
+ return this.load(1);
|
|
}
|
|
}
|
|
- @Watch("count", { immediate: true })
|
|
|
|
|
|
+ @Watch("count")
|
|
totalChange() {
|
|
totalChange() {
|
|
this.totalSync = this.count || 0;
|
|
this.totalSync = this.count || 0;
|
|
}
|
|
}
|
|
- @Watch("page", { immediate: true })
|
|
|
|
- async load() {
|
|
|
|
|
|
+ @Emit("getItems")
|
|
|
|
+ async load(pageNum: number) {
|
|
const [err, { rows = [], total = 0 }] = await this.$post<IPageResult>(
|
|
const [err, { rows = [], total = 0 }] = await this.$post<IPageResult>(
|
|
this.url,
|
|
this.url,
|
|
Object.assign({}, this.params, {
|
|
Object.assign({}, this.params, {
|
|
- pageNum: this.page,
|
|
|
|
|
|
+ pageNum,
|
|
pageSize: this.rows
|
|
pageSize: this.rows
|
|
})
|
|
})
|
|
);
|
|
);
|
|
- if (err) console.error("列表加载失败");
|
|
|
|
- // if (err) this.$message.error("列表加载失败"); //throw Error("loadMore fail");
|
|
|
|
this.count = total;
|
|
this.count = total;
|
|
- this.setItems(rows);
|
|
|
|
- }
|
|
|
|
- currentChange(page: number) {
|
|
|
|
- this.page = page;
|
|
|
|
- }
|
|
|
|
- @Emit("getItems")
|
|
|
|
- private setItems(items: any[]) {
|
|
|
|
- return (this.items = items);
|
|
|
|
|
|
+ return (this.items = rows);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|