fix(form): table 分页

This commit is contained in:
roymondchen 2022-11-07 16:23:57 +08:00
parent 617b025ce1
commit 929d7c463f
3 changed files with 14 additions and 4 deletions

View File

@ -27,10 +27,10 @@ const uiProps = computed(() => uiComponent.props(props));
const emit = defineEmits(['size-change', 'current-change']);
const handleSizeChange = (args: any[]) => {
const handleSizeChange = (...args: any[]) => {
emit('size-change', ...args);
};
const handleCurrentChange = (args: any[]) => {
const handleCurrentChange = (...args: any[]) => {
emit('current-change', ...args);
};
</script>

View File

@ -7,7 +7,7 @@
v-if="model[modelName]"
ref="tMagicTable"
style="width: 100%"
:data="model[modelName]"
:data="data"
:border="config.border"
:max-height="config.maxHeight"
:default-expand-all="true"
@ -143,7 +143,7 @@
<TMagicButton v-if="importable" size="small" type="warning" plain @click="clearHandler()">清空</TMagicButton>
</div>
<div class="bottom" style="text-align: right">
<div class="bottom" style="text-align: right" v-if="config.pagination">
<TMagicPagination
layout="total, sizes, prev, pager, next, jumper"
:hide-on-single-page="model[modelName].length < pagesize"
@ -220,6 +220,15 @@ const isFullscreen = ref(false);
const modelName = computed(() => props.name || props.config.name || '');
const data = computed(() =>
props.config.pagination
? props.model[modelName.value].filter(
(item: any, index: number) =>
index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value,
)
: props.model[modelName.value],
);
const sortChange = ({ prop, order }: SortProp) => {
if (order === 'ascending') {
props.model[modelName.value] = props.model[modelName.value].sort((a: any, b: any) => a[prop] - b[prop]);

View File

@ -610,6 +610,7 @@ export interface TableConfig extends FormItem {
border?: boolean;
/** 显示行号 */
showIndex?: boolean;
pagination?: boolean;
enum?: any[];
/** 是否显示添加按钮 */
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;