Commit ddc8a8e1 authored by 邓超's avatar 邓超

fix: 修改工作流编辑器交互方式,节点字体

parent a6b9a0ca
Pipeline #63822 passed with stages
...@@ -48,7 +48,6 @@ const Workflow = () => { ...@@ -48,7 +48,6 @@ const Workflow = () => {
}, []); }, []);
useEffect(() => { useEffect(() => {
if (flag === 2) { if (flag === 2) {
console.log(treeData, 'treeData');
if (treeData.length === 0) { if (treeData.length === 0) {
return; return;
} }
...@@ -64,10 +63,9 @@ const Workflow = () => { ...@@ -64,10 +63,9 @@ const Workflow = () => {
res.data.Nodes.forEach(item => { res.data.Nodes.forEach(item => {
item.nodeDetail = JSON.stringify(item); item.nodeDetail = JSON.stringify(item);
}); });
console.log(res.data, 'res.dasta'); setFlowData({ ...res.data, flowName: treeData[0].children[0].FlowName });
setFlowData(res.data);
} else { } else {
setFlowData({ Nodes: [], Lines: [] }); setFlowData({ Nodes: [], Lines: [], flowName: '' });
notification.error({ notification.error({
title: '提示', title: '提示',
duration: 3, duration: 3,
...@@ -182,6 +180,8 @@ const Workflow = () => { ...@@ -182,6 +180,8 @@ const Workflow = () => {
// 组节点不触发选中 // 组节点不触发选中
if (prop[0]) { if (prop[0]) {
// 选中节点处理 // 选中节点处理
setTreeVisible(false);
setCurrentSelectId(prop[0]); setCurrentSelectId(prop[0]);
setTreeId(prop[0]); setTreeId(prop[0]);
setChartLoading(true); setChartLoading(true);
...@@ -191,9 +191,9 @@ const Workflow = () => { ...@@ -191,9 +191,9 @@ const Workflow = () => {
res.data.Nodes.forEach(item => { res.data.Nodes.forEach(item => {
item.nodeDetail = JSON.stringify(item); item.nodeDetail = JSON.stringify(item);
}); });
setFlowData(res.data); setFlowData({ ...res.data, flowName: treeNode.node.flowName });
} else { } else {
setFlowData({ Nodes: [], Lines: [] }); setFlowData({ Nodes: [], Lines: [], flowName: '' });
notification.error({ notification.error({
title: '提示', title: '提示',
duration: 3, duration: 3,
...@@ -208,7 +208,8 @@ const Workflow = () => { ...@@ -208,7 +208,8 @@ const Workflow = () => {
// 点击节点树触发 // 点击节点树触发
const onSelect = (prop, treeNode) => { const onSelect = (prop, treeNode) => {
// 如果没有保存弹是否保存弹窗 // 如果没有保存弹是否保存弹窗
if (!canSelect) {
if (!canSelect && !treeNode.node.children) {
confirm({ confirm({
title: '已编辑流程未发布,确定要离开吗?', title: '已编辑流程未发布,确定要离开吗?',
icon: <ExclamationCircleOutlined />, icon: <ExclamationCircleOutlined />,
...@@ -272,6 +273,7 @@ const Workflow = () => { ...@@ -272,6 +273,7 @@ const Workflow = () => {
</div> </div>
</div> </div>
), ),
flowName: obj.FlowName,
key: obj.FlowID, key: obj.FlowID,
}; };
}; };
...@@ -341,6 +343,7 @@ const Workflow = () => { ...@@ -341,6 +343,7 @@ const Workflow = () => {
<div className={styles.flowChartContainer}> <div className={styles.flowChartContainer}>
{currentSelectId ? ( {currentSelectId ? (
<FlowChart <FlowChart
treeVisible={treeVisible}
flowData={flowData} flowData={flowData}
flowID={currentSelectId} flowID={currentSelectId}
chartLoading={chartLoading} chartLoading={chartLoading}
......
...@@ -24,7 +24,7 @@ let myPaletteNode = null; ...@@ -24,7 +24,7 @@ let myPaletteNode = null;
let myPaletteGateway = null; let myPaletteGateway = null;
let myOverview = null; let myOverview = null;
const FlowChart = props => { const FlowChart = props => {
const { flowData, flowID, chartLoading, leaveCallBack } = props; const { flowData, flowID, chartLoading, leaveCallBack, msg, treeVisible } = props;
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [lineVisible, setLineVisible] = useState(false); const [lineVisible, setLineVisible] = useState(false);
const [editMsg, setEditMsg] = useState({}); // 编辑节点的信息 const [editMsg, setEditMsg] = useState({}); // 编辑节点的信息
...@@ -46,6 +46,12 @@ const FlowChart = props => { ...@@ -46,6 +46,12 @@ const FlowChart = props => {
const [newSerialNo, setNewSerialNo] = useState(0); const [newSerialNo, setNewSerialNo] = useState(0);
const [buttonLoading, setButtonLoading] = useState(); // 发布按钮保存loading const [buttonLoading, setButtonLoading] = useState(); // 发布按钮保存loading
const objGo = go.GraphObject.make; const objGo = go.GraphObject.make;
useEffect(() => {
if (treeVisible) {
setVisible(false);
}
}, [treeVisible]);
// 监听删除,给删除数组里添加删除id // 监听删除,给删除数组里添加删除id
useEffect(() => { useEffect(() => {
if (deleteLine) { if (deleteLine) {
...@@ -132,6 +138,7 @@ const FlowChart = props => { ...@@ -132,6 +138,7 @@ const FlowChart = props => {
}, []); }, []);
useEffect(() => { useEffect(() => {
if (flowData) { if (flowData) {
console.log(flowData, 'msgmsgmsg');
// 每次切换时清空删除得id数组跟新增得id数组 // 每次切换时清空删除得id数组跟新增得id数组
setDeleteNodes([]); setDeleteNodes([]);
setDeleteLines([]); setDeleteLines([]);
...@@ -144,13 +151,14 @@ const FlowChart = props => { ...@@ -144,13 +151,14 @@ const FlowChart = props => {
setCurrentFlowData(dataList); setCurrentFlowData(dataList);
setShowLeaveTip(false); setShowLeaveTip(false);
setVisible(false);
} }
}, [flowData]); }, [flowData]);
// 存入在树形流程中选择得流程数据 // 存入在树形流程中选择得流程数据
useEffect(() => { useEffect(() => {
let nodeDataArray = []; let nodeDataArray = [];
let linkDataArray = []; let linkDataArray = [];
console.log(currentFlowData, 'currentFlowData');
// 处理老数据,让老数据可以正常展示 // 处理老数据,让老数据可以正常展示
nodeDataArray = currentFlowData.Nodes.map((item, index) => { nodeDataArray = currentFlowData.Nodes.map((item, index) => {
let obj; let obj;
...@@ -178,7 +186,7 @@ const FlowChart = props => { ...@@ -178,7 +186,7 @@ const FlowChart = props => {
obj.lineDetail = JSON.stringify(obj); obj.lineDetail = JSON.stringify(obj);
return obj; return obj;
}); });
console.log(linkDataArray, 'linkDataArray');
// 保存初始数据 // 保存初始数据
setInitFlowData( setInitFlowData(
JSON.parse( JSON.parse(
...@@ -470,7 +478,7 @@ const FlowChart = props => { ...@@ -470,7 +478,7 @@ const FlowChart = props => {
alignment: go.Spot.Center, alignment: go.Spot.Center,
margin: new go.Margin(0, 10, 0, 10), margin: new go.Margin(0, 10, 0, 10),
overflow: go.TextBlock.OverflowEllipsis, overflow: go.TextBlock.OverflowEllipsis,
font: 'normal 12pt serif', font: 'normal 12pt Microsoft YaHei',
}, },
new go.Binding('visible', 'NodeType', v => { new go.Binding('visible', 'NodeType', v => {
if (v.NodeType === '20' || v.NodeType === '21' || v.NodeType === '22') { if (v.NodeType === '20' || v.NodeType === '21' || v.NodeType === '22') {
...@@ -488,10 +496,10 @@ const FlowChart = props => { ...@@ -488,10 +496,10 @@ const FlowChart = props => {
alignment: go.Spot.Center, alignment: go.Spot.Center,
maxLines: 2, maxLines: 2,
overflow: go.TextBlock.OverflowEllipsis, overflow: go.TextBlock.OverflowEllipsis,
font: 'normal 12pt serif', font: 'normal 12pt Microsoft YaHei',
}, },
new go.Binding('spacingAbove', 'roleList', v => (v?.length > 0 ? 10 : 0)), new go.Binding('spacingAbove', 'roleList', v => (v?.length > 0 ? 5 : 0)),
new go.Binding('height', 'roleList', v => (v?.length > 0 ? 20 : 0)), new go.Binding('height', 'roleList', v => (v?.length > 0 ? 30 : 0)),
new go.Binding('margin', 'roleList', v => new go.Binding('margin', 'roleList', v =>
v?.length > 0 ? new go.Margin(10, 10, 0, 10) : 0, v?.length > 0 ? new go.Margin(10, 10, 0, 10) : 0,
), ),
...@@ -605,7 +613,7 @@ const FlowChart = props => { ...@@ -605,7 +613,7 @@ const FlowChart = props => {
go.TextBlock, go.TextBlock,
{ {
textAlign: 'center', textAlign: 'center',
font: '10pt helvetica, arial, sans-serif', font: '10pt helvetica, arial, Microsoft YaHei',
stroke: '#555555', stroke: '#555555',
margin: 4, margin: 4,
}, },
...@@ -631,10 +639,10 @@ const FlowChart = props => { ...@@ -631,10 +639,10 @@ const FlowChart = props => {
// 线的样式 // 线的样式
const lineStyle = (v, styleName) => { const lineStyle = (v, styleName) => {
const msg = diagram.model.findNodeDataForKey(v); const linemsg = diagram.model.findNodeDataForKey(v);
switch (styleName) { switch (styleName) {
case 'strokeDashArray': case 'strokeDashArray':
if (msg.NodeType === '20') { if (linemsg.NodeType === '20') {
return [6, 3]; return [6, 3];
} }
return null; return null;
...@@ -772,7 +780,6 @@ const FlowChart = props => { ...@@ -772,7 +780,6 @@ const FlowChart = props => {
}; };
// 双击线 // 双击线
const addLineMsg = (e, node) => { const addLineMsg = (e, node) => {
console.log(node.part.data, 'node.part.data');
setLineKey(node.part.data.LineKey); setLineKey(node.part.data.LineKey);
setLineMsg(node.part.data); setLineMsg(node.part.data);
setLineVisible(true); setLineVisible(true);
...@@ -780,7 +787,7 @@ const FlowChart = props => { ...@@ -780,7 +787,7 @@ const FlowChart = props => {
// 新增节点 // 新增节点
const addNode = type => { const addNode = type => {
const list = JSON.parse(diagram.model.toJson()).nodeDataArray; const list = JSON.parse(diagram.model.toJson()).nodeDataArray;
console.log(list, 'list');
let newNum; let newNum;
let newKey; let newKey;
...@@ -816,7 +823,7 @@ const FlowChart = props => { ...@@ -816,7 +823,7 @@ const FlowChart = props => {
default: default:
break; break;
} }
console.log(newNum, newKey);
setNewSerialNo(newNum); setNewSerialNo(newNum);
// 新增节点 // 新增节点
// 新增得key比最大得key值+1 // 新增得key比最大得key值+1
...@@ -839,7 +846,6 @@ const FlowChart = props => { ...@@ -839,7 +846,6 @@ const FlowChart = props => {
}; };
// 节点配置回调 // 节点配置回调
const nodeCallBack = (obj, nextlinkNodes) => { const nodeCallBack = (obj, nextlinkNodes) => {
console.log(obj, nextlinkNodes, 'obj');
let nameIsRepeat; let nameIsRepeat;
let { nodes } = diagram; let { nodes } = diagram;
let keyArr = []; let keyArr = [];
...@@ -885,7 +891,7 @@ const FlowChart = props => { ...@@ -885,7 +891,7 @@ const FlowChart = props => {
nodeData.RuleList = RuleList; nodeData.RuleList = RuleList;
nodeData.CarbonCopyPeopleList = CarbonCopyPeopleList; nodeData.CarbonCopyPeopleList = CarbonCopyPeopleList;
diagram.model.updateTargetBindings(nodeData); diagram.model.updateTargetBindings(nodeData);
console.log(nodeData, 'nodeData');
// 给线上添加文字 // 给线上添加文字
let diagramObj = JSON.parse(diagram.model.toJson()); let diagramObj = JSON.parse(diagram.model.toJson());
...@@ -896,7 +902,7 @@ const FlowChart = props => { ...@@ -896,7 +902,7 @@ const FlowChart = props => {
}); });
// 关闭时进行数据比对看数据是否改变 // 关闭时进行数据比对看数据是否改变
leaveTip(); leaveTip();
setVisible(false); // setVisible(false);
}; };
// 关闭时进行数据比对看数据是否改变 // 关闭时进行数据比对看数据是否改变
const leaveTip = () => { const leaveTip = () => {
...@@ -930,7 +936,7 @@ const FlowChart = props => { ...@@ -930,7 +936,7 @@ const FlowChart = props => {
// 保存后离开不用提醒要修改数据了 // 保存后离开不用提醒要修改数据了
setShowLeaveTip(false); setShowLeaveTip(false);
leaveCallBack(false); leaveCallBack(false);
console.log(JSON.parse(JSON.stringify(res.data)), 'res.data');
setCurrentFlowData(JSON.parse(JSON.stringify(res.data))); setCurrentFlowData(JSON.parse(JSON.stringify(res.data)));
} else { } else {
notification.error({ notification.error({
...@@ -1007,6 +1013,7 @@ const FlowChart = props => { ...@@ -1007,6 +1013,7 @@ const FlowChart = props => {
}); });
}); });
}; };
return ( return (
<> <>
<Prompt message="编辑的内容还未保存,确定要离开该页面吗?" when={showLeaveTip} /> <Prompt message="编辑的内容还未保存,确定要离开该页面吗?" when={showLeaveTip} />
...@@ -1035,6 +1042,7 @@ const FlowChart = props => { ...@@ -1035,6 +1042,7 @@ const FlowChart = props => {
</div> </div>
<div className={styles.chartBox}> <div className={styles.chartBox}>
<div id="myOverviewDiv" className={styles.myOverviewDiv} /> <div id="myOverviewDiv" className={styles.myOverviewDiv} />
<div className={styles.flowName}>{flowData.flowName}</div>
<Spin spinning={chartLoading}> <Spin spinning={chartLoading}>
<div <div
id="myDiagramDiv" id="myDiagramDiv"
......
...@@ -187,7 +187,7 @@ const RoalChoose = props => { ...@@ -187,7 +187,7 @@ const RoalChoose = props => {
maskClosable={false} maskClosable={false}
destroyOnClose destroyOnClose
getContainer={false} getContainer={false}
zIndex={11} zIndex={20}
> >
<div className={styles.pageContent}> <div className={styles.pageContent}>
{/* 可选列表 */} {/* 可选列表 */}
......
...@@ -106,11 +106,23 @@ ...@@ -106,11 +106,23 @@
position: relative; position: relative;
height: calc(100% - 52px); height: calc(100% - 52px);
.flowName {
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
font-size: 24px;
font-weight: 700;
color: #1585FF;
z-index: 9;
}
.myOverviewDiv { .myOverviewDiv {
position: absolute; position: absolute;
height: 150px; height: 150px;
width: 300px; width: 300px;
right: 0; left: 0;
bottom: 0; bottom: 0;
background-color: #ccc; background-color: #ccc;
z-index: 9; z-index: 9;
......
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