保誠-保戶業務員媒合平台
劉鈞霖
2021-12-28 6bbef91c402eaa58b8a4d8f11c466a39802ca0ca
PAMapp/components/Ui/UiPagination.vue
@@ -16,18 +16,35 @@
@Component
export default class UiPagination extends Vue {
    @Prop() totalList!: Consultant[];
    @Prop()
    totalList!: Consultant[];
    @Prop({default: 5}) pageSize!: number;
    currentPage = 1;
    pageList: Consultant[] = [];
    //////////////////////////////////////////////////////////////////
    @Emit('changePage')
    changePage(): Consultant[] {
        return this.pageList
    }
    @Watch('totalList')
    watchTotalList(newValue: Consultant[]) {
        if (newValue) {
            this.handleCurrentChange(this.currentPage);
        }
    }
    //////////////////////////////////////////////////////////////////
    mounted() {
        this.handleCurrentChange(this.currentPage);
    }
    @Emit('changePage') changePage(): Consultant[] {
        return this.pageList
    }
    //////////////////////////////////////////////////////////////////
    handleCurrentChange(currentPage: number) {
@@ -38,12 +55,6 @@
        if (this.totalList) {
            this.pageList = this.totalList.slice(this.pageSize * currentPage - this.pageSize, this.pageSize * currentPage)
            this.changePage();
        }
    }
    @Watch('totalList') watchTotalList(newValue: Consultant[]) {
        if (newValue) {
            this.handleCurrentChange(this.currentPage);
        }
    }
}