Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bkunyun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bkunyun
Commits
a624bb6f
Commit
a624bb6f
authored
Jul 12, 2022
by
吴永生#A02208
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 点击按delete删除线
parent
923c9a71
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
40 deletions
+59
-40
index.tsx
src/views/Project/components/Flow/index.tsx
+59
-40
No files found.
src/views/Project/components/Flow/index.tsx
View file @
a624bb6f
...
@@ -61,24 +61,61 @@ const Flow = (props: IProps) => {
...
@@ -61,24 +61,61 @@ const Flow = (props: IProps) => {
const
[
inSideBatchNodeId
,
setInSideBatchNodeId
]
=
useState
<
string
>
(
""
);
const
[
inSideBatchNodeId
,
setInSideBatchNodeId
]
=
useState
<
string
>
(
""
);
/** 内部维护的选择的flow节点Id */
/** 内部维护的选择的flow节点Id */
const
[
inSideFlowNodeId
,
setInSideFlowNodeId
]
=
useState
<
string
>
(
""
);
const
[
inSideFlowNodeId
,
setInSideFlowNodeId
]
=
useState
<
string
>
(
""
);
/** 选中的线 */
const
[
selectedEdge
,
setSelectedEdge
]
=
useState
<
Edge
>
();
const
Message
=
useMessage
();
const
Message
=
useMessage
();
/** 删除批或者线节点 */
/** 原始数据删除线 */
const
tasksDeleteLine
=
useCallback
(
(
connection
:
Connection
|
Edge
)
=>
{
const
result
=
(
tasks
?.
length
&&
tasks
.
map
((
item
)
=>
{
if
(
item
.
id
===
connection
.
source
&&
item
.
type
===
"BATCH"
)
{
const
newEdges
=
(
item
.
edges
?.
length
&&
item
.
edges
?.
filter
(
(
every
)
=>
every
.
sourceHandle
!==
connection
.
sourceHandle
))
||
[];
return
{
...
item
,
edges
:
newEdges
,
};
}
else
{
return
item
;
}
}))
||
[];
return
result
;
},
[
tasks
]
);
/** 删除批节点或者线 */
const
deleteSelectBatchNode
=
useCallback
(
const
deleteSelectBatchNode
=
useCallback
(
(
e
:
any
)
=>
{
(
e
:
any
)
=>
{
if
(
e
.
keyCode
===
8
)
{
if
(
e
.
keyCode
===
8
)
{
const
val
=
let
val
:
ITask
[]
=
[];
tasks
?.
length
&&
/** 删除批节点逻辑 */
tasks
.
filter
((
item
)
=>
{
if
(
inSideBatchNodeId
)
{
return
(
val
=
item
.
id
!==
inSideBatchNodeId
&&
(
tasks
?.
length
&&
item
.
parentNode
!==
inSideBatchNodeId
tasks
.
filter
((
item
)
=>
{
);
return
(
});
item
.
id
!==
inSideBatchNodeId
&&
setTasks
&&
setTasks
(
val
||
[]);
item
.
parentNode
!==
inSideBatchNodeId
);
}))
||
[];
}
if
(
selectedEdge
)
{
val
=
tasksDeleteLine
(
selectedEdge
);
}
setTasks
&&
setTasks
(
val
);
}
}
},
},
[
inSideBatchNodeId
,
se
tTasks
,
tasks
]
[
inSideBatchNodeId
,
se
lectedEdge
,
setTasks
,
tasks
,
tasksDeleteLine
]
);
);
/** 监听鼠标按下事件 */
/** 监听鼠标按下事件 */
...
@@ -239,6 +276,14 @@ const Flow = (props: IProps) => {
...
@@ -239,6 +276,14 @@ const Flow = (props: IProps) => {
return
{
return
{
...
item
,
...
item
,
// type: "smoothstep",
// type: "smoothstep",
/** 点击线选中 */
...(
selectedEdge
?.
id
===
item
.
id
?
{
style
:
{
stroke
:
"#1370FF"
,
strokeWidth
:
2
},
animated
:
true
,
}
:
{}),
/** 点击batch节点选中 */
...(
item
?.
batchId
===
newSelectId
...(
item
?.
batchId
===
newSelectId
?
{
style
:
{
stroke
:
"#1370FF"
},
animated
:
true
}
?
{
style
:
{
stroke
:
"#1370FF"
},
animated
:
true
}
:
{}),
:
{}),
...
@@ -247,7 +292,7 @@ const Flow = (props: IProps) => {
...
@@ -247,7 +292,7 @@ const Flow = (props: IProps) => {
label
:
item
.
label
?
`(
${
item
.
label
}
)`
:
""
,
label
:
item
.
label
?
`(
${
item
.
label
}
)`
:
""
,
};
};
});
});
},
[
inSideBatchNodeId
,
selectedBatchNodeId
,
tasks
]);
},
[
inSideBatchNodeId
,
selectedBatchNodeId
,
selectedEdge
?.
id
,
tasks
]);
/** 设置nodeId方法 */
/** 设置nodeId方法 */
const
setNodeIdFun
=
useCallback
(
const
setNodeIdFun
=
useCallback
(
...
@@ -284,6 +329,7 @@ const Flow = (props: IProps) => {
...
@@ -284,6 +329,7 @@ const Flow = (props: IProps) => {
:
setInSideBatchNodeId
(
""
);
:
setInSideBatchNodeId
(
""
);
setInSideFlowNodeId
(
""
);
setInSideFlowNodeId
(
""
);
onBatchClick
&&
onBatchClick
(
""
);
onBatchClick
&&
onBatchClick
(
""
);
setSelectedEdge
(
undefined
);
};
};
/** node节点 */
/** node节点 */
...
@@ -335,33 +381,6 @@ const Flow = (props: IProps) => {
...
@@ -335,33 +381,6 @@ const Flow = (props: IProps) => {
[]
[]
);
);
/** 原始数据删除线 */
const
tasksDeleteLine
=
useCallback
(
(
connection
:
Connection
)
=>
{
const
result
=
(
tasks
?.
length
&&
tasks
.
map
((
item
)
=>
{
if
(
item
.
id
===
connection
.
source
)
{
const
newEdges
=
(
item
.
edges
?.
length
&&
item
.
edges
?.
filter
(
(
every
)
=>
every
.
sourceHandle
!==
connection
.
sourceHandle
))
||
[];
return
{
...
item
,
edges
:
newEdges
,
};
}
else
{
return
item
;
}
}))
||
[];
return
result
;
},
[
tasks
]
);
/** 获取连接线的端点类型 */
/** 获取连接线的端点类型 */
const
getClassType
=
useCallback
(
const
getClassType
=
useCallback
(
(
connection
:
Connection
)
=>
{
(
connection
:
Connection
)
=>
{
...
@@ -438,7 +457,7 @@ const Flow = (props: IProps) => {
...
@@ -438,7 +457,7 @@ const Flow = (props: IProps) => {
/** 点击连线 */
/** 点击连线 */
const
onEdgeClick
=
useCallback
((
e
:
any
,
val
:
Edge
)
=>
{
const
onEdgeClick
=
useCallback
((
e
:
any
,
val
:
Edge
)
=>
{
console
.
log
(
val
,
"1111"
);
setSelectedEdge
(
val
);
},
[]);
},
[]);
return
(
return
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment