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
2fe9ce8c
Commit
2fe9ce8c
authored
Aug 11, 2022
by
chenshouchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增自定义算子交互优化 流节点展示多个输入输出
parent
d227acf4
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
70 additions
and
44 deletions
+70
-44
index.tsx
src/views/CustomOperator/components/OperatorList/index.tsx
+1
-1
index.tsx
src/views/CustomOperator/components/SaveOperator/index.tsx
+9
-2
index.tsx
src/views/CustomOperator/index.tsx
+1
-0
index.tsx
...ct/components/Flow/components/BatchOperatorFlow/index.tsx
+0
-4
index.tsx
...ews/Project/components/Flow/components/FlowNode/index.tsx
+7
-6
index.tsx
src/views/Project/components/Flow/index.tsx
+34
-24
index.tsx
src/views/WorkFlowEdit/components/OperatorList/index.tsx
+14
-6
interface.ts
src/views/WorkFlowEdit/components/OperatorList/interface.ts
+2
-0
index.tsx
src/views/WorkFlowEdit/index.tsx
+2
-1
No files found.
src/views/CustomOperator/components/OperatorList/index.tsx
View file @
2fe9ce8c
...
@@ -113,7 +113,7 @@ const OperatorList = (props: IProps) => {
...
@@ -113,7 +113,7 @@ const OperatorList = (props: IProps) => {
productId
:
productId
as
string
,
productId
:
productId
as
string
,
keyword
,
keyword
,
page
,
page
,
size
:
5
,
size
:
20
,
});
});
// size: 20 todo
// size: 20 todo
},
},
...
...
src/views/CustomOperator/components/SaveOperator/index.tsx
View file @
2fe9ce8c
...
@@ -16,9 +16,15 @@ interface IProps {
...
@@ -16,9 +16,15 @@ interface IProps {
saveFormDialog
:
boolean
;
saveFormDialog
:
boolean
;
setSaveFormDialog
:
(
val
:
boolean
)
=>
void
;
setSaveFormDialog
:
(
val
:
boolean
)
=>
void
;
operatorList
:
ITask
[];
operatorList
:
ITask
[];
setShowCustomOperator
:
any
;
}
}
const
SaveOperator
=
(
props
:
IProps
)
=>
{
const
SaveOperator
=
(
props
:
IProps
)
=>
{
const
{
saveFormDialog
,
setSaveFormDialog
,
operatorList
}
=
props
;
const
{
saveFormDialog
,
setSaveFormDialog
,
operatorList
,
setShowCustomOperator
,
}
=
props
;
const
{
currentProjectStore
}
=
useStores
();
const
{
currentProjectStore
}
=
useStores
();
const
Message
=
useMessage
();
const
Message
=
useMessage
();
const
productId
=
toJS
(
currentProjectStore
.
currentProductInfo
.
id
);
const
productId
=
toJS
(
currentProjectStore
.
currentProductInfo
.
id
);
...
@@ -30,8 +36,9 @@ const SaveOperator = (props: IProps) => {
...
@@ -30,8 +36,9 @@ const SaveOperator = (props: IProps) => {
const
{
run
:
saveBatchActorRun
}
=
useMyRequest
(
saveBatchActor
,
{
const
{
run
:
saveBatchActorRun
}
=
useMyRequest
(
saveBatchActor
,
{
onSuccess
:
(
res
)
=>
{
onSuccess
:
(
res
)
=>
{
Message
.
success
(
"保存算子成功"
);
Message
.
success
(
"保存算子成功"
);
setSaveFormDialog
(
false
);
sessionStorage
.
setItem
(
"operatorList"
,
"[]"
);
sessionStorage
.
setItem
(
"operatorList"
,
"[]"
);
setSaveFormDialog
(
false
);
setShowCustomOperator
();
console
.
log
(
"res"
,
res
);
console
.
log
(
"res"
,
res
);
},
},
});
});
...
...
src/views/CustomOperator/index.tsx
View file @
2fe9ce8c
...
@@ -168,6 +168,7 @@ const CustomOperator = observer((props: IProps) => {
...
@@ -168,6 +168,7 @@ const CustomOperator = observer((props: IProps) => {
saveFormDialog=
{
saveFormDialog
}
saveFormDialog=
{
saveFormDialog
}
setSaveFormDialog=
{
setSaveFormDialog
}
setSaveFormDialog=
{
setSaveFormDialog
}
operatorList=
{
operatorList
}
operatorList=
{
operatorList
}
setShowCustomOperator=
{
setShowCustomOperator
}
></
SaveOperator
>
></
SaveOperator
>
</
div
>
</
div
>
<
div
className=
{
styles
.
coContent
}
id=
"customOperatorFlow"
>
<
div
className=
{
styles
.
coContent
}
id=
"customOperatorFlow"
>
...
...
src/views/Project/components/Flow/components/BatchOperatorFlow/index.tsx
View file @
2fe9ce8c
...
@@ -90,7 +90,6 @@ const BatchOperatorFlow = (props: IProps) => {
...
@@ -90,7 +90,6 @@ const BatchOperatorFlow = (props: IProps) => {
/** 删除流节点或者线 */
/** 删除流节点或者线 */
const
deleteSelectFlowNode
=
useCallback
(
const
deleteSelectFlowNode
=
useCallback
(
(
e
:
any
)
=>
{
(
e
:
any
)
=>
{
console
.
log
(
tasks
);
if
(
e
.
keyCode
===
8
&&
ListenState
)
{
if
(
e
.
keyCode
===
8
&&
ListenState
)
{
/** 删除流节点逻辑 */
/** 删除流节点逻辑 */
if
(
inSideFlowNodeId
)
{
if
(
inSideFlowNodeId
)
{
...
@@ -216,7 +215,6 @@ const BatchOperatorFlow = (props: IProps) => {
...
@@ -216,7 +215,6 @@ const BatchOperatorFlow = (props: IProps) => {
const
onNodeClick
=
(
e
:
any
,
node
:
Node
)
=>
{
const
onNodeClick
=
(
e
:
any
,
node
:
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
);
}
}
});
});
...
@@ -362,8 +360,6 @@ const BatchOperatorFlow = (props: IProps) => {
...
@@ -362,8 +360,6 @@ 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
(
""
);
...
...
src/views/Project/components/Flow/components/FlowNode/index.tsx
View file @
2fe9ce8c
...
@@ -68,6 +68,7 @@ const FlowNode = (props: any) => {
...
@@ -68,6 +68,7 @@ const FlowNode = (props: any) => {
[]
[]
);
);
},
[
parameters
]);
},
[
parameters
]);
return
(
return
(
<
div
<
div
style=
{
flowNodeStyle
}
style=
{
flowNodeStyle
}
...
@@ -76,14 +77,14 @@ const FlowNode = (props: any) => {
...
@@ -76,14 +77,14 @@ const FlowNode = (props: any) => {
[
styles
.
selectedFlowBox
]:
selectedStatus
,
[
styles
.
selectedFlowBox
]:
selectedStatus
,
})
}
})
}
>
>
{
dotStatus
?.
isInput
?
(
{
/* {
dotStatus?.isInput ? (
<Handle
<Handle
className={styles.handleBox}
className={styles.handleBox}
style={inStyle}
style={inStyle}
type="target"
type="target"
position={Position.Top}
position={Position.Top}
/>
/>
)
:
null
}
) : null}
*/
}
{
inParamsArr
?.
length
{
inParamsArr
?.
length
?
inParamsArr
.
map
((
item
:
any
,
index
:
number
)
=>
{
?
inParamsArr
.
map
((
item
:
any
,
index
:
number
)
=>
{
return
(
return
(
...
@@ -94,8 +95,8 @@ const FlowNode = (props: any) => {
...
@@ -94,8 +95,8 @@ const FlowNode = (props: any) => {
style=
{
{
style=
{
{
background
:
"#fff "
,
background
:
"#fff "
,
border
:
"1px solid #D1D6DE"
,
border
:
"1px solid #D1D6DE"
,
left
:
index
*
24
+
20
,
...
inStyle
,
...
inStyle
,
left
:
index
*
24
+
16
,
}
}
}
}
type=
"target"
type=
"target"
position=
{
Position
.
Top
}
position=
{
Position
.
Top
}
...
@@ -120,14 +121,14 @@ const FlowNode = (props: any) => {
...
@@ -120,14 +121,14 @@ const FlowNode = (props: any) => {
/>
/>
)
}
)
}
</
div
>
</
div
>
{
dotStatus
?.
isOutput
?
(
{
/* {
dotStatus?.isOutput ? (
<Handle
<Handle
className={styles.handleBox}
className={styles.handleBox}
style={outStyle}
style={outStyle}
type="source"
type="source"
position={Position.Bottom}
position={Position.Bottom}
/>
/>
)
:
null
}
) : null}
*/
}
{
outParamsArr
?.
length
{
outParamsArr
?.
length
?
outParamsArr
.
map
((
item
:
any
,
index
:
number
)
=>
{
?
outParamsArr
.
map
((
item
:
any
,
index
:
number
)
=>
{
return
(
return
(
...
@@ -138,8 +139,8 @@ const FlowNode = (props: any) => {
...
@@ -138,8 +139,8 @@ const FlowNode = (props: any) => {
style=
{
{
style=
{
{
background
:
"#fff "
,
background
:
"#fff "
,
border
:
"1px solid #D1D6DE"
,
border
:
"1px solid #D1D6DE"
,
left
:
index
*
24
+
20
,
...
outStyle
,
...
outStyle
,
left
:
index
*
24
+
16
,
}
}
}
}
type=
"source"
type=
"source"
position=
{
Position
.
Bottom
}
position=
{
Position
.
Bottom
}
...
...
src/views/Project/components/Flow/index.tsx
View file @
2fe9ce8c
...
@@ -145,9 +145,12 @@ const Flow = (props: IProps) => {
...
@@ -145,9 +145,12 @@ const Flow = (props: IProps) => {
[];
[];
// 删除节点时同时删除相关的线
// 删除节点时同时删除相关的线
newVal
?.
forEach
((
task
)
=>
{
newVal
?.
forEach
((
task
)
=>
{
task
.
edges
=
task
.
edges
.
filter
(
task
.
edges
=
(
task
?.
edges
?.
length
&&
task
.
edges
.
filter
(
(
edge
)
=>
edge
.
target
!==
inSideBatchNodeId
(
edge
)
=>
edge
.
target
!==
inSideBatchNodeId
);
))
||
[];
});
});
setTasks
&&
setTasks
(
newVal
);
setTasks
&&
setTasks
(
newVal
);
}
}
...
@@ -157,7 +160,14 @@ const Flow = (props: IProps) => {
...
@@ -157,7 +160,14 @@ const Flow = (props: IProps) => {
}
}
}
}
},
},
[
inSideBatchNodeId
,
selectedEdge
,
setTasks
,
tasks
,
tasksDeleteLine
]
[
inSideBatchNodeId
,
selectedEdge
,
setTasks
,
tasks
,
tasksDeleteLine
,
ListenState
,
]
);
);
/** 监听鼠标按下事件 */
/** 监听鼠标按下事件 */
...
@@ -169,25 +179,25 @@ const Flow = (props: IProps) => {
...
@@ -169,25 +179,25 @@ const Flow = (props: IProps) => {
},
[
deleteSelectBatchNode
]);
},
[
deleteSelectBatchNode
]);
/** 获取是否有输入节点或者是否有输出节点 */
/** 获取是否有输入节点或者是否有输出节点 */
const
nodesInputAndOutputStatus
=
useCallback
(
//
const nodesInputAndOutputStatus = useCallback(
(
id
:
string
)
=>
{
//
(id: string) => {
/** 所有的连线 */
//
/** 所有的连线 */
const
lineArr
:
IEdge
[]
=
[];
//
const lineArr: IEdge[] = [];
tasks
?.
length
&&
//
tasks?.length &&
tasks
.
forEach
((
item
)
=>
{
//
tasks.forEach((item) => {
item
.
edges
?.
length
&&
lineArr
.
push
(...
item
.
edges
);
//
item.edges?.length && lineArr.push(...item.edges);
});
//
});
/** 所有的输入节点ID */
//
/** 所有的输入节点ID */
const
isInput
=
lineArr
?.
some
((
item
)
=>
item
.
target
===
id
);
//
const isInput = lineArr?.some((item) => item.target === id);
/** 所有的输出节点ID */
//
/** 所有的输出节点ID */
const
isOutput
=
lineArr
?.
some
((
item
)
=>
item
.
source
===
id
);
//
const isOutput = lineArr?.some((item) => item.source === id);
return
{
//
return {
isInput
,
//
isInput,
isOutput
,
//
isOutput,
};
//
};
},
//
},
[
tasks
]
//
[tasks]
);
//
);
/** 获取是否有流节点 */
/** 获取是否有流节点 */
const
isFlowNode
=
useCallback
(
const
isFlowNode
=
useCallback
(
...
@@ -264,7 +274,7 @@ const Flow = (props: IProps) => {
...
@@ -264,7 +274,7 @@ const Flow = (props: IProps) => {
}
}
:
{
selectedStatus
:
inSideFlowNodeId
===
item
.
id
}),
:
{
selectedStatus
:
inSideFlowNodeId
===
item
.
id
}),
/** 输入输出圆点状态 */
/** 输入输出圆点状态 */
dotStatus
:
nodesInputAndOutputStatus
(
item
.
id
),
//
dotStatus: nodesInputAndOutputStatus(item.id),
/** 样式 */
/** 样式 */
style
:
{
style
:
{
...
@@ -296,7 +306,7 @@ const Flow = (props: IProps) => {
...
@@ -296,7 +306,7 @@ const Flow = (props: IProps) => {
selectedBatchNodeId
,
selectedBatchNodeId
,
inSideBatchNodeId
,
inSideBatchNodeId
,
inSideFlowNodeId
,
inSideFlowNodeId
,
nodesInputAndOutputStatus
,
//
nodesInputAndOutputStatus,
getBatchStyle
,
getBatchStyle
,
]);
]);
...
...
src/views/WorkFlowEdit/components/OperatorList/index.tsx
View file @
2fe9ce8c
...
@@ -156,7 +156,8 @@ const OperatorItem = (props: IOperatorItemProps) => {
...
@@ -156,7 +156,8 @@ const OperatorItem = (props: IOperatorItemProps) => {
const
OperatorList
=
observer
((
props
:
IOperatorListProps
)
=>
{
const
OperatorList
=
observer
((
props
:
IOperatorListProps
)
=>
{
const
{
currentProjectStore
}
=
useStores
();
const
{
currentProjectStore
}
=
useStores
();
const
productId
=
toJS
(
currentProjectStore
.
currentProductInfo
.
id
);
const
productId
=
toJS
(
currentProjectStore
.
currentProductInfo
.
id
);
const
{
templateConfigInfo
,
setTemplateConfigInfo
}
=
props
;
const
{
templateConfigInfo
,
setTemplateConfigInfo
,
showCustomOperator
}
=
props
;
const
[
operatorListData
,
setOperatorListData
]
=
useState
<
ITask
[]
>
([]);
const
[
operatorListData
,
setOperatorListData
]
=
useState
<
ITask
[]
>
([]);
const
[
keyword
,
setKeyword
]
=
useState
<
string
>
(
""
);
const
[
keyword
,
setKeyword
]
=
useState
<
string
>
(
""
);
...
@@ -168,22 +169,29 @@ const OperatorList = observer((props: IOperatorListProps) => {
...
@@ -168,22 +169,29 @@ const OperatorList = observer((props: IOperatorListProps) => {
});
});
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
showCustomOperator
)
{
run
({
run
({
owner
:
"root"
,
owner
:
"root"
,
productId
:
"cadd"
||
""
,
productId
:
productId
as
string
,
});
});
},
[
productId
,
run
]);
}
},
[
productId
,
run
,
showCustomOperator
]);
/** 处理回车键 */
/** 处理回车键 */
const
handleEnterCode
=
(
e
:
React
.
KeyboardEvent
<
HTMLInputElement
>
)
=>
{
const
handleEnterCode
=
(
e
:
React
.
KeyboardEvent
<
HTMLInputElement
>
)
=>
{
if
(
e
.
keyCode
===
13
)
{
if
(
e
.
keyCode
===
13
)
{
getOperatorList
();
}
};
const
getOperatorList
=
useCallback
(()
=>
{
run
({
run
({
owner
:
"root"
,
owner
:
"root"
,
productId
:
"cadd"
||
""
,
productId
:
productId
as
string
,
keyword
,
keyword
,
});
});
}
},
[
run
,
keyword
,
productId
]);
};
return
(
return
(
<
div
className=
{
styles
.
operatorListBox
}
>
<
div
className=
{
styles
.
operatorListBox
}
>
<
div
className=
{
styles
.
searchBox
}
>
<
div
className=
{
styles
.
searchBox
}
>
...
...
src/views/WorkFlowEdit/components/OperatorList/interface.ts
View file @
2fe9ce8c
...
@@ -19,4 +19,5 @@ export interface IOperatorItemProps {
...
@@ -19,4 +19,5 @@ export interface IOperatorItemProps {
export
interface
IOperatorListProps
{
export
interface
IOperatorListProps
{
templateConfigInfo
:
ITask
[]
templateConfigInfo
:
ITask
[]
setTemplateConfigInfo
:
(
val
:
ITask
[])
=>
void
setTemplateConfigInfo
:
(
val
:
ITask
[])
=>
void
showCustomOperator
:
boolean
}
}
\ No newline at end of file
src/views/WorkFlowEdit/index.tsx
View file @
2fe9ce8c
...
@@ -218,6 +218,7 @@ const WorkFlowEdit = observer((props: IProps) => {
...
@@ -218,6 +218,7 @@ const WorkFlowEdit = observer((props: IProps) => {
</
div
>
</
div
>
{
leftContentType
===
"list"
&&
(
{
leftContentType
===
"list"
&&
(
<
OperatorList
<
OperatorList
showCustomOperator=
{
showCustomOperator
}
templateConfigInfo=
{
templateConfigInfo
}
templateConfigInfo=
{
templateConfigInfo
}
setTemplateConfigInfo=
{
setTemplateConfigInfo
}
setTemplateConfigInfo=
{
setTemplateConfigInfo
}
/>
/>
...
@@ -242,7 +243,7 @@ const WorkFlowEdit = observer((props: IProps) => {
...
@@ -242,7 +243,7 @@ const WorkFlowEdit = observer((props: IProps) => {
setTasks=
{
setTemplateConfigInfo
}
setTasks=
{
setTemplateConfigInfo
}
type=
"edit"
type=
"edit"
onFlowNodeClick=
{
handleNodeClick
}
onFlowNodeClick=
{
handleNodeClick
}
ListenState=
{
!
saveFormDialog
}
ListenState=
{
!
saveFormDialog
&&
!
showCustomOperator
}
/>
/>
</
div
>
</
div
>
</
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