fix: error when editing fields in external data source (#6402)

This commit is contained in:
Katherine 2025-03-10 17:04:15 +08:00 committed by GitHub
parent 1320b59b2f
commit a8532e874a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 54 additions and 3 deletions

View File

@ -39,10 +39,36 @@ const getSchema = (schema: IField, record: any, compile) => {
if (!schema) { if (!schema) {
return; return;
} }
const properties = schema.getConfigureFormProperties();
const properties = cloneDeep(schema.properties) as any;
if (properties?.foreignKey) { if (properties?.foreignKey) {
properties.foreignKey['x-component'] = ForeignKey; properties.foreignKey['x-component'] = ForeignKey;
} }
if (schema.hasDefaultValue === true) {
properties['defaultValue'] = cloneDeep(schema?.default?.uiSchema);
properties.defaultValue.required = false;
properties['defaultValue']['title'] = compile('{{ t("Default value") }}');
properties['defaultValue']['x-decorator'] = 'FormItem';
properties['defaultValue']['x-reactions'] = {
dependencies: [
'uiSchema.x-component-props.gmt',
'uiSchema.x-component-props.showTime',
'uiSchema.x-component-props.dateFormat',
'uiSchema.x-component-props.timeFormat',
],
fulfill: {
state: {
componentProps: {
gmt: '{{$deps[0]}}',
showTime: '{{$deps[1]}}',
dateFormat: '{{$deps[2]}}',
timeFormat: '{{$deps[3]}}',
},
},
},
};
}
const initialValue: any = { const initialValue: any = {
name: `f_${uid()}`, name: `f_${uid()}`,
...cloneDeep(schema.default), ...cloneDeep(schema.default),

View File

@ -49,11 +49,36 @@ const getSchema = ({
if (!schema) { if (!schema) {
return; return;
} }
const properties = schema.getConfigureFormProperties(); const properties = cloneDeep(schema.properties) as any;
if (properties?.name) { if (properties?.name) {
properties.name['x-disabled'] = true; properties.name['x-disabled'] = true;
} }
if (schema.hasDefaultValue === true) {
properties['defaultValue'] = cloneDeep(schema.default.uiSchema) || {};
properties.defaultValue.required = false;
properties['defaultValue']['title'] = compile('{{ t("Default value") }}');
properties['defaultValue']['x-decorator'] = 'FormItem';
properties['defaultValue']['x-reactions'] = {
dependencies: [
'uiSchema.x-component-props.gmt',
'uiSchema.x-component-props.showTime',
'uiSchema.x-component-props.dateFormat',
'uiSchema.x-component-props.timeFormat',
],
fulfill: {
state: {
componentProps: {
gmt: '{{$deps[0]}}',
showTime: '{{$deps[1]}}',
dateFormat: '{{$deps[2]}}',
timeFormat: '{{$deps[3]}}',
},
},
},
};
properties['defaultValue']['x-disabled'] = true;
}
return { return {
type: 'object', type: 'object',
properties: { properties: {