Commit fa9375be authored by 吴永生#A02208's avatar 吴永生#A02208

feat: 图表修改

parent 667a0357
...@@ -37,11 +37,13 @@ ...@@ -37,11 +37,13 @@
.swContent { .swContent {
display: flex; display: flex;
height: calc(100vh - 56px);
} }
.swFormBox { .swFormBox {
background-color: #fff; background-color: #fff;
border-right: 1xp solid rgba(235, 237, 240, 1); border-right: 1xp solid rgba(235, 237, 240, 1);
width: 608px; width: 608px;
overflow-y: scroll;
box-sizing: border-box; box-sizing: border-box;
padding: 36px; padding: 36px;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com * @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-06-21 20:03:56 * @Date: 2022-06-21 20:03:56
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com * @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-06-24 18:11:17 * @LastEditTime: 2022-06-26 10:26:48
* @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/index.tsx * @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/index.tsx
* @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
*/ */
......
...@@ -46,11 +46,13 @@ ...@@ -46,11 +46,13 @@
.swContent { .swContent {
display: flex; display: flex;
height: calc(100vh - 56px);
} }
.swFormBox { .swFormBox {
background-color: #fff; background-color: #fff;
border-right: 1xp solid rgba(235, 237, 240, 1); border-right: 1xp solid rgba(235, 237, 240, 1);
width: 608px; width: 608px;
overflow-y: scroll;
box-sizing: border-box; box-sizing: border-box;
padding: 36px; padding: 36px;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com * @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-06-21 20:03:56 * @Date: 2022-06-21 20:03:56
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com * @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-06-24 18:10:26 * @LastEditTime: 2022-06-26 17:24:46
* @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/index.tsx * @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/index.tsx
* @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
*/ */
...@@ -23,11 +23,10 @@ import { IResponse } from "@/api/http"; ...@@ -23,11 +23,10 @@ import { IResponse } from "@/api/http";
import { templateConfigJson } from "./mock"; import { templateConfigJson } from "./mock";
import { useMessage } from "@/components/MySnackbar"; import { useMessage } from "@/components/MySnackbar";
const ProjectSubmitWork = () => { const ProjectSubmitWork = () => {
const Message = useMessage() const Message = useMessage();
const [templateConfigInfo, setTemplateConfigInfo] = const [templateConfigInfo, setTemplateConfigInfo] =
useState<ITemplateConfig>(templateConfigJson as ITemplateConfig); useState<ITemplateConfig>();
const location: any = useLocation(); const location: any = useLocation();
const navigate = useNavigate(); const navigate = useNavigate();
let configFormRef: any = React.createRef(); let configFormRef: any = React.createRef();
...@@ -56,9 +55,9 @@ const ProjectSubmitWork = () => { ...@@ -56,9 +55,9 @@ const ProjectSubmitWork = () => {
tack.parameters.forEach((parameter) => { tack.parameters.forEach((parameter) => {
if (parameter.name === parameterName) { if (parameter.name === parameterName) {
parameter.value = value; parameter.value = value;
const checkResult = getCheckResult(parameter,value) const checkResult = getCheckResult(parameter, value);
parameter.error = checkResult.error parameter.error = checkResult.error;
parameter.helperText = checkResult.helperText parameter.helperText = checkResult.helperText;
} else { } else {
return; return;
} }
...@@ -71,29 +70,30 @@ const ProjectSubmitWork = () => { ...@@ -71,29 +70,30 @@ const ProjectSubmitWork = () => {
}; };
const handleSubmitForm = () => { const handleSubmitForm = () => {
let check = true let check = true;
const {name, outputPath, nameAndOutputPathCheck} = configFormRef.current.getNameAndPath() const { name, outputPath, nameAndOutputPathCheck } =
configFormRef.current.getNameAndPath();
if (!nameAndOutputPathCheck) { if (!nameAndOutputPathCheck) {
check = false check = false;
} }
const result: ITemplateConfig = _.cloneDeep(templateConfigInfo); const result: ITemplateConfig = _.cloneDeep(templateConfigInfo);
result.tasks.forEach((tack) => { result.tasks.forEach((tack) => {
tack.parameters.forEach((parameter) => { tack.parameters.forEach((parameter) => {
const checkResult = getCheckResult(parameter,parameter.value) const checkResult = getCheckResult(parameter, parameter.value);
parameter.error = checkResult.error parameter.error = checkResult.error;
parameter.helperText = checkResult.helperText parameter.helperText = checkResult.helperText;
if (checkResult.error) { if (checkResult.error) {
check = false check = false;
} }
}); });
}); });
setTemplateConfigInfo(result); setTemplateConfigInfo(result);
if (check) { if (check) {
console.log('提交任务') console.log("提交任务");
} else { } else {
Message.error('请完善左侧表单再提交') Message.error("请完善左侧表单再提交");
} }
} };
return ( return (
<div className={styles.swBox}> <div className={styles.swBox}>
...@@ -133,7 +133,10 @@ const ProjectSubmitWork = () => { ...@@ -133,7 +133,10 @@ const ProjectSubmitWork = () => {
<div className={styles.swHeaderGoback}></div> <div className={styles.swHeaderGoback}></div>
</div> </div>
<div className={styles.swHeaderRight}> <div className={styles.swHeaderRight}>
<ButtonComponent text="提交任务" click={handleSubmitForm}></ButtonComponent> <ButtonComponent
text="提交任务"
click={handleSubmitForm}
></ButtonComponent>
</div> </div>
</div> </div>
<div className={styles.swContent}> <div className={styles.swContent}>
......
...@@ -32,3 +32,8 @@ ...@@ -32,3 +32,8 @@
border-radius: 8px; border-radius: 8px;
margin-left: 8px; margin-left: 8px;
} }
.selectedBatchBox {
border: 1px solid #1370ff;
border-left: 4px solid #1370ff;
}
...@@ -7,8 +7,9 @@ import ReactFlow, { ...@@ -7,8 +7,9 @@ import ReactFlow, {
Handle, Handle,
Position, Position,
ReactFlowProps, ReactFlowProps,
Node,
} from "react-flow-renderer"; } from "react-flow-renderer";
import { useCallback, useMemo } from "react"; import { useCallback, useEffect, useMemo, useState } from "react";
import classNames from "classnames"; import classNames from "classnames";
import { IBatchNode, ILine } from "./interface"; import { IBatchNode, ILine } from "./interface";
...@@ -33,6 +34,7 @@ const BatchNode = (props: IBatchNode) => { ...@@ -33,6 +34,7 @@ const BatchNode = (props: IBatchNode) => {
<div <div
className={classNames({ className={classNames({
[styles.batchNode]: true, [styles.batchNode]: true,
[styles.selectedBatchBox]: false,
[styles.selectBatchNode]: false, [styles.selectBatchNode]: false,
})} })}
style={style} style={style}
...@@ -96,7 +98,7 @@ const FlowNode = (props: any) => { ...@@ -96,7 +98,7 @@ const FlowNode = (props: any) => {
const Flow = (props: IProps) => { const Flow = (props: IProps) => {
const { tasks } = props; const { tasks } = props;
const [selectedNodeId, setSelectedNodeId] = useState<string>("");
/** 自定义的节点类型 */ /** 自定义的节点类型 */
const nodeTypes = useMemo(() => { const nodeTypes = useMemo(() => {
return { batchNode: BatchNode, flowNode: FlowNode }; return { batchNode: BatchNode, flowNode: FlowNode };
...@@ -192,7 +194,7 @@ const Flow = (props: IProps) => { ...@@ -192,7 +194,7 @@ const Flow = (props: IProps) => {
padding: isFlowNode(item.id) ? "20px" : "12px 20px", padding: isFlowNode(item.id) ? "20px" : "12px 20px",
}, },
}, },
position: item.position, position: { x: Number(item.position.x), y: Number(item.position.y) },
...(item.type === "BATCH" ? { style: { zIndex: -1 } } : {}), ...(item.type === "BATCH" ? { style: { zIndex: -1 } } : {}),
...(item.parentNode ? { parentNode: item.parentNode } : {}), ...(item.parentNode ? { parentNode: item.parentNode } : {}),
...(item.type === "BATCH" ? { extent: "parent" } : {}), ...(item.type === "BATCH" ? { extent: "parent" } : {}),
...@@ -208,19 +210,48 @@ const Flow = (props: IProps) => { ...@@ -208,19 +210,48 @@ const Flow = (props: IProps) => {
tasks.forEach((item) => { tasks.forEach((item) => {
val.push(...item.edges); val.push(...item.edges);
}); });
val.map((item: ILine) => { return val.map((item: ILine) => {
return { return {
id: item.id, id: item.id,
label: <div style={{ color: "#8A9099" }}>{item.label}</div>,
source: item.source, source: item.source,
target: item.target, target: item.target,
type: "step",
style: { stroke: "#1370FF" },
animated: true,
labelStyle: { fill: "#8A9099" },
labelBgStyle: { fill: "#F7F8FA " },
label: item.label ? `(${item.label})` : "",
rectStyle: {},
}; };
}); });
return val;
}, [tasks]); }, [tasks]);
const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes); /** flowNode点击事件 */
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges); const onNodeClick = (e: any, node: Node) => {
tasks?.forEach((item) => {
if (item.id === node.id) {
if (item.parentNode) {
setSelectedNodeId(item.parentNode);
} else {
setSelectedNodeId(node.id);
}
}
});
};
/** node节点 */
const [nodes, setNodes] = useNodesState(initialNodes);
/** 连线数组 */
const [edges, setEdges] = useEdgesState(initialEdges);
useEffect(() => {
setEdges(initialEdges);
}, [initialEdges, setEdges]);
useEffect(() => {
console.log(initialNodes, "initialNodes");
setNodes(initialNodes);
}, [initialNodes, setNodes]);
return ( return (
<ReactFlow <ReactFlow
...@@ -229,6 +260,7 @@ const Flow = (props: IProps) => { ...@@ -229,6 +260,7 @@ const Flow = (props: IProps) => {
fitView fitView
proOptions={{ hideAttribution: true, account: "" }} proOptions={{ hideAttribution: true, account: "" }}
nodeTypes={nodeTypes} nodeTypes={nodeTypes}
onNodeClick={onNodeClick}
{...props} {...props}
> >
<Controls /> <Controls />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment