fix(web): copy node id update
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-03 15:39:59
|
* @Date: 2026-02-03 15:39:59
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-03-02 17:06:41
|
* @Last Modified time: 2026-03-16 16:11:28
|
||||||
*/
|
*/
|
||||||
import { type FC, useEffect, useState, useMemo } from "react";
|
import { type FC, useEffect, useState, useMemo } from "react";
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
@@ -88,7 +88,7 @@ const Properties: FC<PropertiesProps> = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedNode && form) {
|
if (selectedNode && form) {
|
||||||
const { type = 'default', name = '', config } = selectedNode.getData() || {}
|
const { type = 'default', name = '', config, id } = selectedNode.getData() || {}
|
||||||
const initialValue: Record<string, any> = {}
|
const initialValue: Record<string, any> = {}
|
||||||
Object.keys(config || {}).forEach(key => {
|
Object.keys(config || {}).forEach(key => {
|
||||||
if (config && config[key] && 'defaultValue' in config[key]) {
|
if (config && config[key] && 'defaultValue' in config[key]) {
|
||||||
@@ -98,7 +98,7 @@ const Properties: FC<PropertiesProps> = ({
|
|||||||
|
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
type,
|
type,
|
||||||
id: selectedNode.id,
|
id,
|
||||||
name,
|
name,
|
||||||
...initialValue,
|
...initialValue,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-03 15:17:48
|
* @Date: 2026-02-03 15:17:48
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-03-07 15:23:39
|
* @Last Modified time: 2026-03-16 16:11:01
|
||||||
*/
|
*/
|
||||||
import { useRef, useEffect, useState } from 'react';
|
import { useRef, useEffect, useState } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
@@ -593,6 +593,13 @@ export const useWorkflowGraph = ({
|
|||||||
if (!graphRef.current) return false;
|
if (!graphRef.current) return false;
|
||||||
const selectedNodes = graphRef.current.getNodes().filter(node => node.getData()?.isSelected);
|
const selectedNodes = graphRef.current.getNodes().filter(node => node.getData()?.isSelected);
|
||||||
if (selectedNodes.length) {
|
if (selectedNodes.length) {
|
||||||
|
selectedNodes.forEach(node => {
|
||||||
|
const data = node.getData();
|
||||||
|
node.setData({
|
||||||
|
...data,
|
||||||
|
id: `${(data.type as string).replace(/-/g, '_')}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
||||||
|
});
|
||||||
|
});
|
||||||
graphRef.current.copy(selectedNodes);
|
graphRef.current.copy(selectedNodes);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user