mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-09-16 17:06:31 +00:00
将字段挂载时的 model 写入迁移至 registerField effect, 渲染与无渲染校验共用 applyMountValueEffects; nested 重命名为 innerConfig 以区分配置派生与值写入。
31 lines
722 B
TypeScript
31 lines
722 B
TypeScript
import { computed, type Ref, ref } from 'vue';
|
|
|
|
import { getDataByPage } from '@form/utils/form';
|
|
|
|
import type { TableProps } from './type';
|
|
|
|
export const usePagination = (props: TableProps, modelName: Ref<string | number>) => {
|
|
const pageSize = ref(10);
|
|
/**
|
|
* 当前页码
|
|
*/
|
|
const currentPage = ref(0);
|
|
|
|
const paginationData = computed(() => getDataByPage(props.model[modelName.value], currentPage.value, pageSize.value));
|
|
const handleSizeChange = (val: number) => {
|
|
pageSize.value = val;
|
|
};
|
|
|
|
const handleCurrentChange = (val: number) => {
|
|
currentPage.value = val - 1;
|
|
};
|
|
|
|
return {
|
|
pageSize,
|
|
currentPage,
|
|
paginationData,
|
|
handleSizeChange,
|
|
handleCurrentChange,
|
|
};
|
|
};
|