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
sunyihao
bkunyun
Commits
da2aca10
Commit
da2aca10
authored
Jun 27, 2022
by
吴永生#A02208
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加onBatchClick回调
parent
f7c62d0a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
24 deletions
+54
-24
index.tsx
src/views/ConsoleLayout/index.tsx
+6
-7
index.tsx
src/views/Project/components/Flow/index.tsx
+38
-16
interface.ts
src/views/Project/components/Flow/interface.ts
+10
-1
No files found.
src/views/ConsoleLayout/index.tsx
View file @
da2aca10
...
@@ -106,13 +106,12 @@ const ConsoleLayout = observer(() => {
...
@@ -106,13 +106,12 @@ const ConsoleLayout = observer(() => {
horizontal
:
"right"
,
horizontal
:
"right"
,
}
}
}
}
>
>
<
Box
className=
{
style
.
topRightItem
}
>
<
img
<
img
className=
{
style
.
topRightItem
}
src=
{
uploadIcon
}
src=
{
uploadIcon
}
alt=
""
alt=
""
style=
{
{
verticalAlign
:
"middle"
}
}
style=
{
{
verticalAlign
:
"middle"
}
}
/>
/>
</
Box
>
</
MyPopover
>
</
MyPopover
>
<
Box
className=
{
style
.
topRightItem
}
>
<
Box
className=
{
style
.
topRightItem
}
>
<
Box
<
Box
...
...
src/views/Project/components/Flow/index.tsx
View file @
da2aca10
...
@@ -24,18 +24,20 @@ import styles from "./index.module.css";
...
@@ -24,18 +24,20 @@ import styles from "./index.module.css";
*/
*/
interface
IProps
extends
ReactFlowProps
{
interface
IProps
extends
ReactFlowProps
{
tasks
?:
ITask
[];
tasks
?:
ITask
[];
/** 点击batch事件 */
onBatchClick
?:
(
val
:
string
)
=>
void
;
}
}
/** 自定义batch节点 */
/** 自定义batch节点 */
const
BatchNode
=
(
props
:
IBatchNode
)
=>
{
const
BatchNode
=
(
props
:
IBatchNode
)
=>
{
const
{
data
}
=
props
;
const
{
data
}
=
props
;
const
{
dotStatus
,
style
,
isFlowNode
,
label
}
=
data
;
const
{
dotStatus
,
style
,
isFlowNode
,
label
,
selectedStatus
}
=
data
;
return
(
return
(
<
div
<
div
className=
{
classNames
({
className=
{
classNames
({
[
styles
.
batchNode
]:
true
,
[
styles
.
batchNode
]:
true
,
[
styles
.
selectedBatchBox
]:
false
,
[
styles
.
selectedBatchBox
]:
selectedStatus
,
[
styles
.
selectBatchNode
]:
false
,
[
styles
.
selectBatchNode
]:
selectedStatus
,
})
}
})
}
style=
{
style
}
style=
{
style
}
>
>
...
@@ -82,7 +84,7 @@ const FlowNode = (props: any) => {
...
@@ -82,7 +84,7 @@ const FlowNode = (props: any) => {
)
:
null
}
)
:
null
}
<
div
style=
{
{
display
:
"flex"
,
alignItems
:
"center"
}
}
>
<
div
style=
{
{
display
:
"flex"
,
alignItems
:
"center"
}
}
>
{
data
?.
label
||
""
}
{
data
?.
label
||
""
}
<
span
className=
{
styles
.
successDot
}
></
span
>
{
data
.
isCheck
&&
<
span
className=
{
styles
.
successDot
}
></
span
>
}
</
div
>
</
div
>
{
data
?.
dotStatus
?.
isOutput
?
(
{
data
?.
dotStatus
?.
isOutput
?
(
<
Handle
<
Handle
...
@@ -97,7 +99,7 @@ const FlowNode = (props: any) => {
...
@@ -97,7 +99,7 @@ const FlowNode = (props: any) => {
};
};
const
Flow
=
(
props
:
IProps
)
=>
{
const
Flow
=
(
props
:
IProps
)
=>
{
const
{
tasks
}
=
props
;
const
{
tasks
,
onBatchClick
}
=
props
;
const
[
selectedNodeId
,
setSelectedNodeId
]
=
useState
<
string
>
(
""
);
const
[
selectedNodeId
,
setSelectedNodeId
]
=
useState
<
string
>
(
""
);
/** 自定义的节点类型 */
/** 自定义的节点类型 */
const
nodeTypes
=
useMemo
(()
=>
{
const
nodeTypes
=
useMemo
(()
=>
{
...
@@ -162,7 +164,7 @@ const Flow = (props: IProps) => {
...
@@ -162,7 +164,7 @@ const Flow = (props: IProps) => {
const
val
=
positionXArr
[
positionXArr
.
length
-
1
]
+
150
;
const
val
=
positionXArr
[
positionXArr
.
length
-
1
]
+
150
;
width
=
val
>
176
?
val
:
width
;
width
=
val
>
176
?
val
:
width
;
}
}
if
(
position
X
Arr
?.
length
)
{
if
(
position
Y
Arr
?.
length
)
{
const
val
=
positionYArr
[
positionYArr
.
length
-
1
];
const
val
=
positionYArr
[
positionYArr
.
length
-
1
];
height
=
val
>
22
?
val
:
height
;
height
=
val
>
22
?
val
:
height
;
}
}
...
@@ -184,8 +186,15 @@ const Flow = (props: IProps) => {
...
@@ -184,8 +186,15 @@ const Flow = (props: IProps) => {
type
:
item
.
type
===
"BATCH"
?
"batchNode"
:
"flowNode"
,
type
:
item
.
type
===
"BATCH"
?
"batchNode"
:
"flowNode"
,
data
:
{
data
:
{
label
:
item
.
title
||
""
,
label
:
item
.
title
||
""
,
/** 是否有流节点 */
isFlowNode
:
isFlowNode
(
item
.
id
),
...(
item
.
type
===
"BATCH"
?
{
/** 是否有流节点 */
isFlowNode
:
isFlowNode
(
item
.
id
),
/** 选中状态 */
selectedStatus
:
selectedNodeId
===
item
.
id
,
}
:
{
isCheck
:
item
.
isCheck
}),
/** 输入输出圆点状态 */
/** 输入输出圆点状态 */
dotStatus
:
nodesInputAndOutputStatus
(
item
.
id
),
dotStatus
:
nodesInputAndOutputStatus
(
item
.
id
),
/** 样式 */
/** 样式 */
...
@@ -201,30 +210,42 @@ const Flow = (props: IProps) => {
...
@@ -201,30 +210,42 @@ const Flow = (props: IProps) => {
});
});
});
});
return
val
;
return
val
;
},
[
tasks
,
getBatchStyle
,
isFlowNode
,
nodesInputAndOutputStatus
]);
},
[
tasks
,
isFlowNode
,
selectedNodeId
,
nodesInputAndOutputStatus
,
getBatchStyle
,
]);
/** 生成初始化的连线节点 */
/** 生成初始化的连线节点 */
const
initialEdges
=
useMemo
(()
=>
{
const
initialEdges
=
useMemo
(()
=>
{
const
val
:
ILine
[]
=
[];
const
val
:
ILine
[]
=
[];
tasks
?.
length
&&
tasks
?.
length
&&
tasks
.
forEach
((
item
)
=>
{
tasks
.
forEach
((
item
)
=>
{
val
.
push
(...
item
.
edges
);
item
.
edges
.
forEach
((
every
)
=>
{
const
newLine
=
{
...
every
,
batchId
:
item
.
parentNode
?
item
.
parentNode
:
item
.
id
,
};
val
.
push
(
newLine
);
},
[]);
});
});
return
val
.
map
((
item
:
ILine
)
=>
{
return
val
.
map
((
item
:
ILine
)
=>
{
return
{
return
{
id
:
item
.
id
,
id
:
item
.
id
,
source
:
item
.
source
,
source
:
item
.
source
,
target
:
item
.
target
,
target
:
item
.
target
,
type
:
"step"
,
type
:
"smoothstep"
,
style
:
{
stroke
:
"#1370FF"
},
...(
item
?.
batchId
===
selectedNodeId
animated
:
true
,
?
{
style
:
{
stroke
:
"#1370FF"
},
animated
:
true
}
:
{}),
labelStyle
:
{
fill
:
"#8A9099"
},
labelStyle
:
{
fill
:
"#8A9099"
},
labelBgStyle
:
{
fill
:
"#F7F8FA "
},
labelBgStyle
:
{
fill
:
"#F7F8FA "
},
label
:
item
.
label
?
`(
${
item
.
label
}
)`
:
""
,
label
:
item
.
label
?
`(
${
item
.
label
}
)`
:
""
,
rectStyle
:
{},
};
};
});
});
},
[
tasks
]);
},
[
selectedNodeId
,
tasks
]);
/** flowNode点击事件 */
/** flowNode点击事件 */
const
onNodeClick
=
(
e
:
any
,
node
:
Node
)
=>
{
const
onNodeClick
=
(
e
:
any
,
node
:
Node
)
=>
{
...
@@ -232,8 +253,10 @@ const Flow = (props: IProps) => {
...
@@ -232,8 +253,10 @@ const Flow = (props: IProps) => {
if
(
item
.
id
===
node
.
id
)
{
if
(
item
.
id
===
node
.
id
)
{
if
(
item
.
parentNode
)
{
if
(
item
.
parentNode
)
{
setSelectedNodeId
(
item
.
parentNode
);
setSelectedNodeId
(
item
.
parentNode
);
onBatchClick
&&
onBatchClick
(
item
.
parentNode
);
}
else
{
}
else
{
setSelectedNodeId
(
node
.
id
);
setSelectedNodeId
(
node
.
id
);
onBatchClick
&&
onBatchClick
(
item
.
parentNode
||
""
);
}
}
}
}
});
});
...
@@ -249,7 +272,6 @@ const Flow = (props: IProps) => {
...
@@ -249,7 +272,6 @@ const Flow = (props: IProps) => {
},
[
initialEdges
,
setEdges
]);
},
[
initialEdges
,
setEdges
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
console
.
log
(
initialNodes
,
"initialNodes"
);
setNodes
(
initialNodes
);
setNodes
(
initialNodes
);
},
[
initialNodes
,
setNodes
]);
},
[
initialNodes
,
setNodes
]);
...
...
src/views/Project/components/Flow/interface.ts
View file @
da2aca10
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-06-23 11:00:29
* @Date: 2022-06-23 11:00:29
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-06-2
3 11:19:5
9
* @LastEditTime: 2022-06-2
7 15:32:2
9
* @FilePath: /bkunyun/src/views/Project/components/Flow/interface.ts
* @FilePath: /bkunyun/src/views/Project/components/Flow/interface.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
*/
...
@@ -13,20 +13,29 @@ import { CSSProperties } from "react";
...
@@ -13,20 +13,29 @@ import { CSSProperties } from "react";
export
interface
ILine
{
export
interface
ILine
{
id
:
string
,
id
:
string
,
label
:
string
,
label
:
string
,
batchId
?:
string
,
source
:
string
,
source
:
string
,
target
:
string
,
target
:
string
,
}
}
export
interface
IDotStatus
{
export
interface
IDotStatus
{
/** 是否为输入 */
isInput
:
boolean
;
isInput
:
boolean
;
/** 是否为输出 */
isOutput
:
boolean
isOutput
:
boolean
}
}
export
interface
IBatchNodeData
{
export
interface
IBatchNodeData
{
/** label 文案 */
label
:
string
;
label
:
string
;
/** 是否存在flow节点 */
isFlowNode
:
boolean
;
isFlowNode
:
boolean
;
/** 连线圆点状态 */
dotStatus
:
IDotStatus
;
dotStatus
:
IDotStatus
;
/** 样式 */
style
?:
CSSProperties
;
style
?:
CSSProperties
;
/** 是否选中状态 */
selectedStatus
?:
boolean
;
}
}
export
interface
IBatchNode
{
export
interface
IBatchNode
{
data
:
IBatchNodeData
data
:
IBatchNodeData
...
...
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