diff --git a/packages/core/client/src/locale/zh_CN.ts b/packages/core/client/src/locale/zh_CN.ts index f01a58a5f..5b3344e92 100644 --- a/packages/core/client/src/locale/zh_CN.ts +++ b/packages/core/client/src/locale/zh_CN.ts @@ -871,6 +871,7 @@ export default { 'Sync successfully': '同步成功', 'Sync from form fields': '同步表单字段', 'Select all': '全选', + 'UnSelect all':'取消全选', 'Determine whether a record exists by the following fields': '通过以下字段判断记录是否存在', 'Cascade Select': '级联选择', Execute: '执行', diff --git a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx index 8ea1bdb16..216f913a5 100644 --- a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx @@ -1,5 +1,5 @@ import { ArrayTable } from '@formily/antd-v5'; -import { onFieldValueChange } from '@formily/core'; +import { onFieldValueChange, onFieldInputValueChange } from '@formily/core'; import { connect, ISchema, mapProps, useField, useFieldSchema, useForm, useFormEffects } from '@formily/react'; import { isValid, uid } from '@formily/shared'; import { Alert, Tree as AntdTree } from 'antd'; @@ -21,16 +21,36 @@ import { requestSettingsSchema } from './utils'; const Tree = connect( AntdTree, mapProps((props, field: any) => { + useEffect(() => { + field.value = props.defaultCheckedKeys || []; + }, []); const [checkedKeys, setCheckedKeys] = useState(props.defaultCheckedKeys || []); const onCheck = (checkedKeys) => { setCheckedKeys(checkedKeys); field.value = checkedKeys; }; field.onCheck = onCheck; + const form = useForm(); return { ...props, checkedKeys, onCheck, + treeData: props?.treeData.map((v: any) => { + if (form.values.duplicateMode === 'quickDulicate') { + const children = v?.children?.map((k) => { + return { + ...k, + disabled: false, + }; + }); + return { + ...v, + disabled: false, + children, + }; + } + return v; + }), }; }), ); @@ -265,6 +285,17 @@ function DuplicationMode() { }, }; }; + const useUnSelectAllFields = (form) => { + return { + async run() { + form.query('duplicateFields').take((f) => { + f.componentProps.defaultCheckedKeys = []; + f.setInitialValue([]); + f?.onCheck([]); + }); + }, + }; + }; return ( 0 }}`, + }, + }, + }, + ], + 'x-component-props': { + type: 'primary', + style: { float: 'right', position: 'relative', zIndex: 1200, marginRight: '10px' }, + useAction: () => { + const from = useForm(); + return useUnSelectAllFields(from); + }, + }, + }, duplicateFields: { type: 'array', title: '{{ t("Data fields") }}', @@ -392,7 +448,7 @@ function DuplicationMode() { }, 'x-reactions': [ { - dependencies: ['.collection'], + dependencies: ['.collection', '.duplicateMode'], fulfill: { state: { disabled: '{{ !$deps[0] }}', @@ -415,7 +471,7 @@ function DuplicationMode() { fieldSchema['x-component-props'].duplicateMode = duplicateMode; fieldSchema['x-component-props'].duplicateFields = fields; fieldSchema['x-component-props'].duplicateCollection = collection; - fieldSchema['x-component-props'].treeData = treeData; + fieldSchema['x-component-props'].treeData = treeData || field.componentProps?.treeData; dn.emit('patch', { schema: { ['x-uid']: fieldSchema['x-uid'],