| | |
| | | |
| | | @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) { |
| | | |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |