!8 [修复]分页组件中每页数量变化时触发limit事件,[新增] limits 参数,用于设定可选的每页数量大小

Merge pull request !8 from 鄢鹏权/develop
This commit is contained in:
就眠儀式
2021-12-27 08:50:00 +00:00
committed by Gitee
2 changed files with 73 additions and 10 deletions

View File

@@ -31,11 +31,7 @@
</a>
<span v-if="showLimit" class="layui-laypage-limits">
<select v-model="inlimit">
<option value="10">10 /</option>
<option value="20">20 /</option>
<option value="30">30 /</option>
<option value="40">40 /</option>
<option value="50">50 /</option>
<option v-for="val of limits" :key="val" :value="val">{{ val }} /</option>
</select>
</span>
<a v-if="showRefresh" href="javascript:;" class="layui-laypage-refresh">
@@ -65,7 +61,8 @@ const props = withDefaults(
showLimit?: boolean | string;
showInput?: boolean | string;
showRefresh?: boolean | string;
pages?: number
pages?: number,
limits?: number[]
}>(),
{
limit: 10,
@@ -76,11 +73,13 @@ const props = withDefaults(
showLimit: true,
showInput: false,
showRefresh: false,
pages: 10
pages: 10,
limits: () => [10, 20, 30, 40, 50]
}
);
const limits = ref(props.limits);
const pages = props.pages / 2
const inlimit = ref(props.limit);
const inlimit = computed({ get() { return props.limit }, set(v: number) { emit('limit', v) } })
const maxPage = ref(Math.ceil(props.total / props.limit));
const totalPage = computed(() => {
let r: number[] = [], end = maxPage.value
@@ -99,7 +98,7 @@ const totalPage = computed(() => {
const currentPage: Ref<number> = ref(1);
const currentPageShow: Ref<number> = ref(currentPage.value);
const emit = defineEmits(["jump"]);
const emit = defineEmits(["jump", "limit"]);
const prev = function () {
if (currentPage.value === 1) {