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
c79013ca
Commit
c79013ca
authored
Aug 09, 2022
by
chenshouchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 自定义批算子删除流算子、删除线逻辑修改
parent
e20a8772
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
66 deletions
+16
-66
index.tsx
src/views/CustomOperator/index.tsx
+3
-8
index.tsx
...ct/components/Flow/components/BatchOperatorFlow/index.tsx
+10
-58
index.tsx
src/views/WorkFlowEdit/index.tsx
+3
-0
No files found.
src/views/CustomOperator/index.tsx
View file @
c79013ca
...
@@ -13,18 +13,13 @@ import styles from "./index.module.css";
...
@@ -13,18 +13,13 @@ import styles from "./index.module.css";
type
IProps
=
{
type
IProps
=
{
setShowCustomOperator
:
any
;
setShowCustomOperator
:
any
;
initOperatorList
:
ITask
[];
};
};
const
CustomOperator
=
observer
((
props
:
IProps
)
=>
{
const
CustomOperator
=
observer
((
props
:
IProps
)
=>
{
const
{
setShowCustomOperator
}
=
props
;
const
{
setShowCustomOperator
,
initOperatorList
}
=
props
;
const
Message
=
useMessage
();
const
Message
=
useMessage
();
const
sessionStorageOperatorList
=
JSON
.
parse
(
const
[
operatorList
,
setOperatorList
]
=
useState
<
ITask
[]
>
(
initOperatorList
);
sessionStorage
.
getItem
(
"operatorList"
)
||
"[]"
);
console
.
log
(
"sessionStorageOperatorList"
,
sessionStorageOperatorList
);
const
[
operatorList
,
setOperatorList
]
=
useState
<
ITask
[]
>
(
sessionStorageOperatorList
);
const
[
saveFormDialog
,
setSaveFormDialog
]
=
useState
(
false
);
const
[
saveFormDialog
,
setSaveFormDialog
]
=
useState
(
false
);
// const [showCustomOperator, setShowCustomOperator] = useState(false);
// const [showCustomOperator, setShowCustomOperator] = useState(false);
...
...
src/views/Project/components/Flow/components/BatchOperatorFlow/index.tsx
View file @
c79013ca
...
@@ -13,11 +13,7 @@ import ReactFlow, {
...
@@ -13,11 +13,7 @@ import ReactFlow, {
import
{
useCallback
,
useEffect
,
useMemo
,
useState
}
from
"react"
;
import
{
useCallback
,
useEffect
,
useMemo
,
useState
}
from
"react"
;
import
{
uuid
}
from
"@/utils/util"
;
import
{
uuid
}
from
"@/utils/util"
;
import
{
import
{
IParameter
,
ITask
}
from
"../../../../ProjectSubmitWork/interface"
;
IEdge
,
IParameter
,
ITask
,
}
from
"../../../../ProjectSubmitWork/interface"
;
import
{
ILine
}
from
"../../interface"
;
import
{
ILine
}
from
"../../interface"
;
import
BatchNode
from
"../BatchNode"
;
import
BatchNode
from
"../BatchNode"
;
import
FlowNode
from
"../FlowNode"
;
import
FlowNode
from
"../FlowNode"
;
...
@@ -68,46 +64,18 @@ const BatchOperatorFlow = (props: IProps) => {
...
@@ -68,46 +64,18 @@ const BatchOperatorFlow = (props: IProps) => {
const
result
=
const
result
=
(
tasks
?.
length
&&
(
tasks
?.
length
&&
tasks
.
map
((
item
)
=>
{
tasks
.
map
((
item
)
=>
{
/** 删除batch起始的edges中的一项 === 等于删除了一根连线 */
/
/ /
** 删除batch起始的edges中的一项 === 等于删除了一根连线 */
if
(
item
.
id
===
connection
.
source
&&
item
.
type
===
"BATCH"
)
{
if
(
item
.
id
===
connection
.
source
)
{
const
newEdges
=
const
newEdges
=
(
item
.
edges
?.
length
&&
(
item
.
edges
?.
length
&&
item
.
edges
?.
filter
(
item
.
edges
?.
filter
(
(
every
)
=>
every
.
sourceHandle
!==
connection
.
sourceHandle
(
every
)
=>
every
.
sourceHandle
!==
connection
.
sourceHandle
))
||
))
||
[];
[];
return
{
return
{
...
item
,
...
item
,
edges
:
newEdges
,
edges
:
newEdges
,
};
};
/** 选中batch结束位置&&更新校验值 */
}
else
if
(
item
.
id
===
connection
.
target
&&
item
.
type
===
"BATCH"
)
{
const
newParameters
=
(
item
.
parameters
?.
length
&&
item
.
parameters
.
map
((
every
)
=>
{
if
(
every
.
name
===
connection
.
targetHandle
)
{
const
{
error
,
helperText
}
=
getCustomTemplateParameterCheckResult
({
...
every
,
linked
:
false
,
hidden
:
false
,
});
return
{
...
every
,
hidden
:
false
,
error
,
helperText
,
};
}
else
{
return
every
;
}
}))
||
[];
return
{
...
item
,
parameters
:
newParameters
,
};
}
else
{
}
else
{
return
item
;
return
item
;
}
}
...
@@ -123,8 +91,6 @@ const BatchOperatorFlow = (props: IProps) => {
...
@@ -123,8 +91,6 @@ const BatchOperatorFlow = (props: IProps) => {
(
e
:
any
)
=>
{
(
e
:
any
)
=>
{
if
(
e
.
keyCode
===
8
&&
ListenState
)
{
if
(
e
.
keyCode
===
8
&&
ListenState
)
{
/** 删除流节点逻辑 */
/** 删除流节点逻辑 */
// inSideFlowNodeId
console
.
log
(
inSideFlowNodeId
);
if
(
inSideFlowNodeId
)
{
if
(
inSideFlowNodeId
)
{
const
newVal
=
const
newVal
=
(
tasks
?.
length
&&
(
tasks
?.
length
&&
...
@@ -156,7 +122,7 @@ const BatchOperatorFlow = (props: IProps) => {
...
@@ -156,7 +122,7 @@ const BatchOperatorFlow = (props: IProps) => {
return
()
=>
{
return
()
=>
{
window
.
removeEventListener
(
"keyup"
,
deleteSelectFlowNode
);
window
.
removeEventListener
(
"keyup"
,
deleteSelectFlowNode
);
};
};
},
[]);
},
[
deleteSelectFlowNode
]);
/** 生成初始化node节点 */
/** 生成初始化node节点 */
const
initialNodes
=
useMemo
(()
=>
{
const
initialNodes
=
useMemo
(()
=>
{
...
@@ -165,7 +131,7 @@ const BatchOperatorFlow = (props: IProps) => {
...
@@ -165,7 +131,7 @@ const BatchOperatorFlow = (props: IProps) => {
tasks
.
forEach
((
item
)
=>
{
tasks
.
forEach
((
item
)
=>
{
val
.
push
({
val
.
push
({
id
:
item
.
id
,
id
:
item
.
id
,
type
:
item
.
type
===
"BATCH"
?
"batchNode"
:
"flowNode"
,
type
:
"flowNode"
,
/** 每一项的数据 */
/** 每一项的数据 */
data
:
{
data
:
{
info
:
item
,
info
:
item
,
...
@@ -201,15 +167,11 @@ const BatchOperatorFlow = (props: IProps) => {
...
@@ -201,15 +167,11 @@ const BatchOperatorFlow = (props: IProps) => {
* extent: "parent" 跟随父节点移动
* extent: "parent" 跟随父节点移动
* draggable: false 节点不可移动
* draggable: false 节点不可移动
*/
*/
...(
item
.
type
===
"BATCH"
draggable
:
flowNodeDraggable
,
?
{
style
:
{
zIndex
:
-
1
},
extent
:
"parent"
}
:
{
draggable
:
flowNodeDraggable
}),
/** parentNode 父节点ID */
// ...(item.parentNode ? { parentNode: item.parentNode } : {}),
});
});
});
});
return
val
;
return
val
;
},
[
tasks
,
flowType
,
inSideFlowNodeId
,
flowNodeDraggable
]);
},
[
tasks
,
inSideFlowNodeId
,
flowNodeDraggable
]);
/** 生成初始化的连线节点 */
/** 生成初始化的连线节点 */
const
initialEdges
=
useMemo
(()
=>
{
const
initialEdges
=
useMemo
(()
=>
{
...
@@ -220,7 +182,6 @@ const BatchOperatorFlow = (props: IProps) => {
...
@@ -220,7 +182,6 @@ const BatchOperatorFlow = (props: IProps) => {
item
?.
edges
.
forEach
((
every
)
=>
{
item
?.
edges
.
forEach
((
every
)
=>
{
const
newLine
=
{
const
newLine
=
{
...
every
,
...
every
,
batchId
:
item
.
parentNode
?
item
.
parentNode
:
item
.
id
,
};
};
val
.
push
(
newLine
);
val
.
push
(
newLine
);
},
[]);
},
[]);
...
@@ -242,21 +203,11 @@ const BatchOperatorFlow = (props: IProps) => {
...
@@ -242,21 +203,11 @@ const BatchOperatorFlow = (props: IProps) => {
});
});
},
[
selectedEdge
?.
id
,
tasks
]);
},
[
selectedEdge
?.
id
,
tasks
]);
/** 设置nodeId方法 */
// const setNodeIdFun = useCallback(
// (id: string) => {
// setInSideFlowNodeId("");
// document.getElementById(`point${id}`)?.scrollIntoView(true);
// },
// []
// );
/** flowNode点击事件 */
/** flowNode点击事件 */
const
onNodeClick
=
(
e
:
any
,
node
:
Node
)
=>
{
const
onNodeClick
=
(
e
:
any
,
node
:
Node
)
=>
{
console
.
log
(
tasks
);
console
.
log
(
node
);
tasks
?.
forEach
((
item
)
=>
{
tasks
?.
forEach
((
item
)
=>
{
if
(
item
.
id
===
node
.
id
)
{
if
(
item
.
id
===
node
.
id
)
{
console
.
log
(
"setInSideFlowNodeId"
,
node
.
id
);
setInSideFlowNodeId
(
node
.
id
);
setInSideFlowNodeId
(
node
.
id
);
}
}
});
});
...
@@ -402,6 +353,8 @@ const BatchOperatorFlow = (props: IProps) => {
...
@@ -402,6 +353,8 @@ const BatchOperatorFlow = (props: IProps) => {
/** 点击连线 */
/** 点击连线 */
const
onEdgeClick
=
useCallback
((
e
:
any
,
val
:
Edge
)
=>
{
const
onEdgeClick
=
useCallback
((
e
:
any
,
val
:
Edge
)
=>
{
console
.
log
(
e
);
console
.
log
(
val
);
setSelectedEdge
(
val
);
setSelectedEdge
(
val
);
/** 点击连线清除选中的node ID */
/** 点击连线清除选中的node ID */
setInSideFlowNodeId
(
""
);
setInSideFlowNodeId
(
""
);
...
@@ -425,7 +378,6 @@ const BatchOperatorFlow = (props: IProps) => {
...
@@ -425,7 +378,6 @@ const BatchOperatorFlow = (props: IProps) => {
edges=
{
edges
}
edges=
{
edges
}
fitView=
{
flowType
===
"default"
?
true
:
false
}
fitView=
{
flowType
===
"default"
?
true
:
false
}
{
...
reactFlowParams
}
{
...
reactFlowParams
}
// proOptions={{ hideAttribution: true, account: "" }}
nodeTypes=
{
nodeTypes
}
nodeTypes=
{
nodeTypes
}
onPaneClick=
{
handlePaneClick
}
onPaneClick=
{
handlePaneClick
}
onNodeClick=
{
onNodeClick
}
onNodeClick=
{
onNodeClick
}
...
...
src/views/WorkFlowEdit/index.tsx
View file @
c79013ca
...
@@ -259,6 +259,9 @@ const WorkFlowEdit = observer((props: IProps) => {
...
@@ -259,6 +259,9 @@ const WorkFlowEdit = observer((props: IProps) => {
{
showCustomOperator
&&
(
{
showCustomOperator
&&
(
<
CustomOperator
<
CustomOperator
setShowCustomOperator=
{
()
=>
setShowCustomOperator
(
false
)
}
setShowCustomOperator=
{
()
=>
setShowCustomOperator
(
false
)
}
initOperatorList=
{
JSON
.
parse
(
sessionStorage
.
getItem
(
"operatorList"
)
||
"[]"
)
}
/>
/>
)
}
)
}
</
div
>
</
div
>
...
...
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