|
|
@ -152,19 +152,23 @@ export function useFormEvents({ |
|
|
/** |
|
|
/** |
|
|
* @description: Insert after a certain field, if not insert the last |
|
|
* @description: Insert after a certain field, if not insert the last |
|
|
*/ |
|
|
*/ |
|
|
async function appendSchemaByField(schema: FormSchema, prefixField?: string, first = false) { |
|
|
async function appendSchemaByField( |
|
|
|
|
|
schema: FormSchema | FormSchema[], |
|
|
|
|
|
prefixField?: string, |
|
|
|
|
|
first = false, |
|
|
|
|
|
) { |
|
|
const schemaList: FormSchema[] = cloneDeep(unref(getSchema)); |
|
|
const schemaList: FormSchema[] = cloneDeep(unref(getSchema)); |
|
|
|
|
|
|
|
|
const index = schemaList.findIndex((schema) => schema.field === prefixField); |
|
|
const index = schemaList.findIndex((schema) => schema.field === prefixField); |
|
|
|
|
|
const _schemaList = isObject(schema) ? [schema as FormSchema] : (schema as FormSchema[]); |
|
|
if (!prefixField || index === -1 || first) { |
|
|
if (!prefixField || index === -1 || first) { |
|
|
first ? schemaList.unshift(schema) : schemaList.push(schema); |
|
|
first ? schemaList.unshift(..._schemaList) : schemaList.push(..._schemaList); |
|
|
schemaRef.value = schemaList; |
|
|
schemaRef.value = schemaList; |
|
|
_setDefaultValue(schema); |
|
|
_setDefaultValue(schema); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
if (index !== -1) { |
|
|
if (index !== -1) { |
|
|
schemaList.splice(index + 1, 0, schema); |
|
|
schemaList.splice(index + 1, 0, ..._schemaList); |
|
|
} |
|
|
} |
|
|
_setDefaultValue(schema); |
|
|
_setDefaultValue(schema); |
|
|
|
|
|
|
|
|
|