mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-08-26 16:29:48 +08:00
fix(form): table 分页
This commit is contained in:
parent
617b025ce1
commit
929d7c463f
@ -27,10 +27,10 @@ const uiProps = computed(() => uiComponent.props(props));
|
|||||||
|
|
||||||
const emit = defineEmits(['size-change', 'current-change']);
|
const emit = defineEmits(['size-change', 'current-change']);
|
||||||
|
|
||||||
const handleSizeChange = (args: any[]) => {
|
const handleSizeChange = (...args: any[]) => {
|
||||||
emit('size-change', ...args);
|
emit('size-change', ...args);
|
||||||
};
|
};
|
||||||
const handleCurrentChange = (args: any[]) => {
|
const handleCurrentChange = (...args: any[]) => {
|
||||||
emit('current-change', ...args);
|
emit('current-change', ...args);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
v-if="model[modelName]"
|
v-if="model[modelName]"
|
||||||
ref="tMagicTable"
|
ref="tMagicTable"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
:data="model[modelName]"
|
:data="data"
|
||||||
:border="config.border"
|
:border="config.border"
|
||||||
:max-height="config.maxHeight"
|
:max-height="config.maxHeight"
|
||||||
:default-expand-all="true"
|
:default-expand-all="true"
|
||||||
@ -143,7 +143,7 @@
|
|||||||
<TMagicButton v-if="importable" size="small" type="warning" plain @click="clearHandler()">清空</TMagicButton>
|
<TMagicButton v-if="importable" size="small" type="warning" plain @click="clearHandler()">清空</TMagicButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="bottom" style="text-align: right">
|
<div class="bottom" style="text-align: right" v-if="config.pagination">
|
||||||
<TMagicPagination
|
<TMagicPagination
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
:hide-on-single-page="model[modelName].length < pagesize"
|
: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 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) => {
|
const sortChange = ({ prop, order }: SortProp) => {
|
||||||
if (order === 'ascending') {
|
if (order === 'ascending') {
|
||||||
props.model[modelName.value] = props.model[modelName.value].sort((a: any, b: any) => a[prop] - b[prop]);
|
props.model[modelName.value] = props.model[modelName.value].sort((a: any, b: any) => a[prop] - b[prop]);
|
||||||
|
@ -610,6 +610,7 @@ export interface TableConfig extends FormItem {
|
|||||||
border?: boolean;
|
border?: boolean;
|
||||||
/** 显示行号 */
|
/** 显示行号 */
|
||||||
showIndex?: boolean;
|
showIndex?: boolean;
|
||||||
|
pagination?: boolean;
|
||||||
enum?: any[];
|
enum?: any[];
|
||||||
/** 是否显示添加按钮 */
|
/** 是否显示添加按钮 */
|
||||||
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
|
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user