diff --git a/packages/core/client/src/collection-manager/Configuration/AddFieldAction.tsx b/packages/core/client/src/collection-manager/Configuration/AddFieldAction.tsx index 03dab46d3..ec7163add 100644 --- a/packages/core/client/src/collection-manager/Configuration/AddFieldAction.tsx +++ b/packages/core/client/src/collection-manager/Configuration/AddFieldAction.tsx @@ -90,35 +90,35 @@ const useCreateCollectionField = () => { return { async run() { await form.submit(); - const options = form?.values?.uiSchema?.enum?.slice() || []; - if (options?.length) { - form.setValuesIn( - 'uiSchema.enum', - options.map((option) => { - return { - value: uid(), - ...option, - }; - }), - ); - } - function recursiveChildren(children = [], prefix = 'children') { - children.forEach((item, index) => { - const itemOptions = item.uiSchema?.enum?.slice() || []; - form.setValuesIn( - `${prefix}[${index}].uiSchema.enum`, - itemOptions.map((option) => { - return { - value: uid(), - ...option, - }; - }), - ); - recursiveChildren(item.children, `${prefix}[${index}].children`); - }); - } + // const options = form?.values?.uiSchema?.enum?.slice() || []; + // if (options?.length) { + // form.setValuesIn( + // 'uiSchema.enum', + // options.map((option) => { + // return { + // value: uid(), + // ...option, + // }; + // }), + // ); + // } + // function recursiveChildren(children = [], prefix = 'children') { + // children.forEach((item, index) => { + // const itemOptions = item.uiSchema?.enum?.slice() || []; + // form.setValuesIn( + // `${prefix}[${index}].uiSchema.enum`, + // itemOptions.map((option) => { + // return { + // value: uid(), + // ...option, + // }; + // }), + // ); + // recursiveChildren(item.children, `${prefix}[${index}].children`); + // }); + // } - recursiveChildren(form?.values?.children); + // recursiveChildren(form?.values?.children); if (['obo', 'oho', 'o2o', 'o2m', 'm2o', 'm2m', 'linkTo'].includes(form?.values?.interface) && title) { form.setValuesIn('reverseField.uiSchema.title', title); diff --git a/packages/core/client/src/collection-manager/interfaces/properties/index.ts b/packages/core/client/src/collection-manager/interfaces/properties/index.ts index 6c1261d59..fa3a5b5a6 100644 --- a/packages/core/client/src/collection-manager/interfaces/properties/index.ts +++ b/packages/core/client/src/collection-manager/interfaces/properties/index.ts @@ -1,5 +1,6 @@ +import { Field } from '@formily/core'; import { ISchema } from '@formily/react'; - +import { uid } from '@formily/shared'; export * as operators from './operators'; export const type: ISchema = { @@ -29,7 +30,7 @@ export const type: ISchema = { ], }; -export const relationshipType: ISchema ={ +export const relationshipType: ISchema = { type: 'string', title: '{{t("Relationship type")}}', required: true, @@ -127,12 +128,18 @@ export const dataSource: ISchema = { type: 'void', 'x-component': 'ArrayTable.Column', 'x-component-props': { title: '{{t("Option value")}}' }, - 'x-hidden': true, + // 'x-hidden': true, properties: { value: { type: 'string', + required: true, 'x-decorator': 'FormItem', 'x-component': 'Input', + 'x-reactions': (field: Field) => { + if (!field.initialValue) { + field.initialValue = uid(); + } + }, }, }, }, @@ -143,6 +150,7 @@ export const dataSource: ISchema = { properties: { label: { type: 'string', + required: true, 'x-decorator': 'FormItem', 'x-component': 'Input', }, diff --git a/packages/core/client/src/locale/zh_CN.ts b/packages/core/client/src/locale/zh_CN.ts index 562862c7f..56e3ec286 100644 --- a/packages/core/client/src/locale/zh_CN.ts +++ b/packages/core/client/src/locale/zh_CN.ts @@ -255,7 +255,7 @@ export default { "Options": "选项", "Option value": "选项值", - "Option label": "选项", + "Option label": "选项标签", "Color": "颜色", "Add option": "添加选项", "Related collection": "关系表",