mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-24 18:40:22 +08:00
feat:不允许可重复添加同一field的表单项 (#2923)
This commit is contained in:
parent
b30270a3fb
commit
3b0b8d0baa
@ -210,7 +210,13 @@ export function useFormEvents({
|
||||
first = false,
|
||||
) {
|
||||
const schemaList: FormSchema[] = cloneDeep(unref(getSchema));
|
||||
|
||||
const addSchemaIds: string[] = Array.isArray(schema)
|
||||
? schema.map((item) => item.field)
|
||||
: [schema.field];
|
||||
if (schemaList.find((item) => addSchemaIds.includes(item.field))) {
|
||||
error('There are schemas that have already been added');
|
||||
return;
|
||||
}
|
||||
const index = schemaList.findIndex((schema) => schema.field === prefixField);
|
||||
const _schemaList = isObject(schema) ? [schema as FormSchema] : (schema as FormSchema[]);
|
||||
if (!prefixField || index === -1 || first) {
|
||||
|
Loading…
Reference in New Issue
Block a user