refactor: tree collection support presetFieldsDisabledIncludes (#4371)

* refactor: tree collection presetFieldsDisabled

* refactor: tree collection support presetFieldsDisabledIncludes
This commit is contained in:
Katherine 2024-05-17 14:28:09 +08:00 committed by GitHub
parent 0366a93ed1
commit caffcc4b9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 1 deletions

View File

@ -211,6 +211,7 @@ export const AddCollectionAction = (props) => {
record, record,
showReverseFieldConfig: true, showReverseFieldConfig: true,
presetFieldsDisabled: currentTemplate?.presetFieldsDisabled, presetFieldsDisabled: currentTemplate?.presetFieldsDisabled,
presetFieldsDisabledIncludes: currentTemplate?.presetFieldsDisabledIncludes,
...scope, ...scope,
}} }}
/> />

View File

@ -204,7 +204,7 @@ export const PresetFields = observer(
selectedRowKeys, selectedRowKeys,
getCheckboxProps: (record) => ({ getCheckboxProps: (record) => ({
name: record.name, name: record.name,
disabled: props?.disabled, disabled: props?.disabled || props?.presetFieldsDisabledIncludes?.includes?.(record.name),
}), }),
onChange: (_, selectedRows) => { onChange: (_, selectedRows) => {
const fields = getDefaultCollectionFields(selectedRows, form.values); const fields = getDefaultCollectionFields(selectedRows, form.values);

View File

@ -75,6 +75,7 @@ export const defaultConfigurableProperties = {
'x-component': PresetFields, 'x-component': PresetFields,
'x-component-props': { 'x-component-props': {
disabled: '{{ presetFieldsDisabled }}', disabled: '{{ presetFieldsDisabled }}',
presetFieldsDisabledIncludes: '{{presetFieldsDisabledIncludes}}',
}, },
}, },
}; };

View File

@ -72,6 +72,7 @@ export class TreeCollectionTemplate extends CollectionTemplate {
}, },
], ],
}; };
presetFieldsDisabledIncludes = ['id'];
events = { events = {
beforeSubmit(values) { beforeSubmit(values) {
if (Array.isArray(values?.fields)) { if (Array.isArray(values?.fields)) {