diff --git a/client/src/components/studio/domain-core/graph-construct/add-nodes-edges/index.tsx b/client/src/components/studio/domain-core/graph-construct/add-nodes-edges/index.tsx index b591e305..e21960bf 100644 --- a/client/src/components/studio/domain-core/graph-construct/add-nodes-edges/index.tsx +++ b/client/src/components/studio/domain-core/graph-construct/add-nodes-edges/index.tsx @@ -30,6 +30,7 @@ interface EditColumnsType extends ColumnsType { }; editable: boolean; } + export const AddNodesEdges: React.FC = ({ type, data = [], @@ -39,13 +40,15 @@ export const AddNodesEdges: React.FC = ({ }) => { const [form] = Form.useForm(); const { visible, onShow, onClose } = useVisible({ defaultVisible: true }); - const isNode = type === 'node'; + const [state, updateState] = useImmer<{ startList: Array; attrList: Array; configList: Array; + isNode: boolean; }>({ startList: [], + isNode: true, attrList: [ { id: 'primary-key', @@ -58,13 +61,20 @@ export const AddNodesEdges: React.FC = ({ configList: [], }); const { startList, attrList, configList } = state; + const isAllow = (record: any): boolean => { + return state?.isNode && record?.primaryField; + }; useEffect(() => { onSwitch?.(onShow, onClose); }, []); useEffect(() => { onVisible?.(visible); }, [visible]); - + useEffect(() => { + updateState(draft => { + draft.isNode = type === 'node'; + }); + }, [type]); const propertyList = () => { const attrPropertyNames = map( filter(attrList, attr => !attr.optional && !attr.primaryField), @@ -195,10 +205,10 @@ export const AddNodesEdges: React.FC = ({ inputType: EditType.SELECT, prop: { defaultValue: false, - disabled: record.primaryField, + disabled: isAllow(record), options: [ { - label: record.primaryField ? '否(主键)' : '否', + label: isAllow(record) ? '否(主键)' : '否', value: false, }, { label: '是', value: true }, @@ -211,8 +221,8 @@ export const AddNodesEdges: React.FC = ({ title: '操作', dataIndex: 'operate', key: 'operate', - render: (_, record: any) => - record.primaryField ? ( + render: (_, record: any) => { + return isAllow(record) ? (