@@ -12,6 +12,20 @@ import { nodeDict } from '@/workflow/common/data'
1212import { isActive , connect , disconnect } from './teleport'
1313import { t } from '@/locales'
1414import { 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+ }
1529class AppNode extends HtmlResize . view {
1630 isMounted
1731 r ?: any
@@ -32,23 +46,14 @@ class AppNode extends HtmlResize.view {
3246 if ( props . model . properties . noRender ) {
3347 delete props . model . properties . noRender
3448 } 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 ,
3854 )
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- }
5155 }
56+
5257 props . model . properties . config = nodeDict [ props . model . type ] . properties . config
5358 if ( props . model . properties . height ) {
5459 props . model . height = props . model . properties . height
0 commit comments