fix(form): group-list上移下移行为不对

This commit is contained in:
roymondchen 2023-08-08 16:34:23 +08:00
parent 26cd37be23
commit aabc77d903
4 changed files with 12 additions and 2 deletions

View File

@ -132,6 +132,7 @@ const toggleMode = () => {
text: null, text: null,
}))) as any; }))) as any;
}; };
const onAddDiffCount = () => emit('addDiffCount'); const onAddDiffCount = () => emit('addDiffCount');
const getLastValues = (item: any, index: number) => item?.[index] || {}; const getLastValues = (item: any, index: number) => item?.[index] || {};

View File

@ -88,7 +88,13 @@ const title = computed(() => {
return props.model[props.config.titleKey]; return props.model[props.config.titleKey];
} }
return `${String(props.index)}`; if (props.config.title) {
return filterFunction(mForm, props.config.title, props);
}
const titlePrefix = props.config.titlePrefix || '组';
return `${titlePrefix} ${String(props.index + 1)}`;
}); });
const length = computed(() => props.groupModel?.length || 0); const length = computed(() => props.groupModel?.length || 0);
@ -113,7 +119,7 @@ const showDelete = (index: number) => {
}; };
// //
const changeOrder = (offset = 0) => emit('swap-item', props.index, `${String(props.index)}${offset}`); const changeOrder = (offset = 0) => emit('swap-item', props.index, props.index + offset);
const movable = () => { const movable = () => {
const { movable } = props.config; const { movable } = props.config;

View File

@ -680,6 +680,8 @@ export interface GroupListConfig extends FormItem {
groupItems?: FormConfig; groupItems?: FormConfig;
tableItems?: FormConfig; tableItems?: FormConfig;
titleKey?: string; titleKey?: string;
titlePrefix?: string;
title?: string | FilterFunction;
itemExtra?: string | FilterFunction; itemExtra?: string | FilterFunction;
expandAll?: boolean; expandAll?: boolean;
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean; addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;

View File

@ -193,6 +193,7 @@ export const filterFunction = (mForm: FormState | undefined, config: any, props:
formValue: mForm?.values || props.model, formValue: mForm?.values || props.model,
prop: props.prop, prop: props.prop,
config: props.config, config: props.config,
index: props.index,
}); });
}; };