@@ -12,6 +12,20 @@ import { nodeDict } from '@/workflow/common/data'
12
12
import { isActive , connect , disconnect } from './teleport'
13
13
import { t } from '@/locales'
14
14
import { type Dict } from '@/api/type/common'
15
+ const getNodeName = ( nodes : Array < any > , baseName : string ) => {
16
+ let index = 0
17
+ let name = baseName
18
+ while ( true ) {
19
+ if ( index > 0 ) {
20
+ name = baseName + index
21
+ console . log ( name )
22
+ }
23
+ if ( ! nodes . some ( ( node : any ) => node . properties . stepName === name . trim ( ) ) ) {
24
+ return name
25
+ }
26
+ index ++
27
+ }
28
+ }
15
29
class AppNode extends HtmlResize . view {
16
30
isMounted
17
31
r ?: any
@@ -32,23 +46,14 @@ class AppNode extends HtmlResize.view {
32
46
if ( props . model . properties . noRender ) {
33
47
delete props . model . properties . noRender
34
48
} else {
35
- const filterNodes = props . graphModel . nodes . filter ( ( v : any ) => v . type === props . model . type )
36
- const filterNameSameNodes = filterNodes . filter (
37
- ( v : any ) => v . properties . stepName === props . model . properties . stepName ,
49
+ console . log ( 'ss' , props . model . properties . stepName )
50
+ console . log ( props . graphModel . nodes , this )
51
+ props . model . properties . stepName = getNodeName (
52
+ props . graphModel . nodes . filter ( ( node : any ) => node . id !== props . model . id ) ,
53
+ props . model . properties . stepName ,
38
54
)
39
- if ( filterNameSameNodes . length - 1 > 0 ) {
40
- getNodesName ( filterNameSameNodes . length - 1 )
41
- }
42
- }
43
- function getNodesName ( num : number ) {
44
- const number = num
45
- const name = props . model . properties . stepName + number
46
- if ( ! props . graphModel . nodes ?. some ( ( node : any ) => node . properties . stepName === name . trim ( ) ) ) {
47
- props . model . properties . stepName = name
48
- } else {
49
- getNodesName ( number + 1 )
50
- }
51
55
}
56
+
52
57
props . model . properties . config = nodeDict [ props . model . type ] . properties . config
53
58
if ( props . model . properties . height ) {
54
59
props . model . height = props . model . properties . height
0 commit comments