Commit 7664f7eb authored by 邓超's avatar 邓超

fix: 修改线名称问题

parent f45d17ab
Pipeline #63279 passed with stages
...@@ -36,7 +36,7 @@ const FlowChart = props => { ...@@ -36,7 +36,7 @@ const FlowChart = props => {
const [editMsg, setEditMsg] = useState({}); // 编辑节点的信息 const [editMsg, setEditMsg] = useState({}); // 编辑节点的信息
const [lineMsg, setLineMsg] = useState({}); const [lineMsg, setLineMsg] = useState({});
const [modalType, setModalType] = useState(''); // 存入弹窗是编辑还是新增 const [modalType, setModalType] = useState(''); // 存入弹窗是编辑还是新增
const [LineId, setLineId] = useState(''); // 存入编辑线id const [LineKey, setLineKey] = useState(''); // 存入编辑线id
const [nodeKey, setNodeKey] = useState(''); // 存入编辑节点的key const [nodeKey, setNodeKey] = useState(''); // 存入编辑节点的key
const [DeleteNodes, setDeleteNodes] = useState([]); // 删除节点数组 const [DeleteNodes, setDeleteNodes] = useState([]); // 删除节点数组
const [DeleteLines, setDeleteLines] = useState([]); // 删除线数组 const [DeleteLines, setDeleteLines] = useState([]); // 删除线数组
...@@ -77,9 +77,9 @@ const FlowChart = props => { ...@@ -77,9 +77,9 @@ const FlowChart = props => {
setDeleteNode(n.data.NodeId); setDeleteNode(n.data.NodeId);
}, 0); }, 0);
} }
if (n.data.LineId) { if (n.data.LineKey) {
setTimeout(() => { setTimeout(() => {
setDeleteLine(n.data.LineId); setDeleteLine(n.data.LineKey);
}, 0); }, 0);
} }
}); });
...@@ -126,15 +126,16 @@ const FlowChart = props => { ...@@ -126,15 +126,16 @@ const FlowChart = props => {
}, [flowData]); }, [flowData]);
// 存入在树形流程中选择得流程数据 // 存入在树形流程中选择得流程数据
useEffect(() => { useEffect(() => {
let nodeDataArray; let nodeDataArray = [];
if (currentFlowData.Nodes.length === 0) { let linkDataArray = [];
nodeDataArray = [];
} else {
// 处理老数据,让老数据可以正常展示 // 处理老数据,让老数据可以正常展示
nodeDataArray = currentFlowData.Nodes.map((item, index) => { nodeDataArray = currentFlowData.Nodes.map((item, index) => {
let obj; let obj;
obj = item; obj = item;
obj.key = item.NodeId; obj.key = item.NodeId;
obj.nodeDetail = JSON.stringify(obj);
if (obj.points === '') { if (obj.points === '') {
if (obj.NodeType === '1') { if (obj.NodeType === '1') {
obj.points = `${(index * 200).toString()}" 100"`; obj.points = `${(index * 200).toString()}" 100"`;
...@@ -144,13 +145,21 @@ const FlowChart = props => { ...@@ -144,13 +145,21 @@ const FlowChart = props => {
} }
return obj; return obj;
}); });
} linkDataArray = currentFlowData.Lines.map(item => {
let obj;
obj = item;
obj.LineKey = item.LineId;
obj.lineDetail = JSON.stringify(obj);
return obj;
});
console.log(linkDataArray, 'linkDataArray');
// 保存初始数据 // 保存初始数据
setInitFlowData( setInitFlowData(
JSON.parse( JSON.parse(
JSON.stringify({ JSON.stringify({
Nodes: nodeDataArray, Nodes: nodeDataArray,
Lines: currentFlowData.Lines, Lines: linkDataArray,
}), }),
), ),
); );
...@@ -158,7 +167,7 @@ const FlowChart = props => { ...@@ -158,7 +167,7 @@ const FlowChart = props => {
linkFromPortIdProperty: 'fromPort', // 所需信息: linkFromPortIdProperty: 'fromPort', // 所需信息:
linkToPortIdProperty: 'toPort', // 标识数据属性名称 linkToPortIdProperty: 'toPort', // 标识数据属性名称
nodeDataArray, nodeDataArray,
linkDataArray: currentFlowData.Lines, linkDataArray,
}); });
// 修改复制后节点内容 // 修改复制后节点内容
diagram.model.copyNodeDataFunction = (obj, model) => { diagram.model.copyNodeDataFunction = (obj, model) => {
...@@ -173,7 +182,7 @@ const FlowChart = props => { ...@@ -173,7 +182,7 @@ const FlowChart = props => {
return copyObj; return copyObj;
}; };
diagram.model.linkKeyProperty = 'LineId'; diagram.model.linkKeyProperty = 'LineKey';
diagram.model.makeUniqueLinkKeyFunction = (model, data) => { diagram.model.makeUniqueLinkKeyFunction = (model, data) => {
let i = model.linkDataArray.length * 2 + 2; let i = model.linkDataArray.length * 2 + 2;
...@@ -295,8 +304,8 @@ const FlowChart = props => { ...@@ -295,8 +304,8 @@ const FlowChart = props => {
v?.length > 0 ? new go.Margin(10, 10, 0, 10) : 0, v?.length > 0 ? new go.Margin(10, 10, 0, 10) : 0,
), ),
new go.Binding('text', 'nodeDetail', v => { new go.Binding('text', 'nodeDetail', v => {
console.log(v, 'nodenodenodne');
const obj = JSON.parse(v); const obj = JSON.parse(v);
if (obj.NodeType === '20' || obj.NodeType === '21' || obj.NodeType === '22') { if (obj.NodeType === '20' || obj.NodeType === '21' || obj.NodeType === '22') {
return ''; return '';
} }
...@@ -453,6 +462,7 @@ const FlowChart = props => { ...@@ -453,6 +462,7 @@ const FlowChart = props => {
return null; return null;
} }
}; };
// 线上文案样式
const lineTextStyle = v => { const lineTextStyle = v => {
let obj = JSON.parse(v); let obj = JSON.parse(v);
...@@ -466,6 +476,7 @@ const FlowChart = props => { ...@@ -466,6 +476,7 @@ const FlowChart = props => {
} }
return 'transparent'; return 'transparent';
}; };
// 线上的文案
const lineText = v => { const lineText = v => {
console.log('rfioehjgiouewrhgio'); console.log('rfioehjgiouewrhgio');
let obj = JSON.parse(v); let obj = JSON.parse(v);
...@@ -509,6 +520,7 @@ const FlowChart = props => { ...@@ -509,6 +520,7 @@ const FlowChart = props => {
new go.Binding('fromLinkable', 'NodeType', v => v !== '2'), // 是否允许用户绘制的链接到这里 new go.Binding('fromLinkable', 'NodeType', v => v !== '2'), // 是否允许用户绘制的链接到这里
new go.Binding('toLinkable', 'NodeType', v => v !== '1'), // 声明用户是否可以从这里绘制链接 new go.Binding('toLinkable', 'NodeType', v => v !== '1'), // 声明用户是否可以从这里绘制链接
); );
// 节点盒子样式
const nodeBoxStyle = (atr, classname) => { const nodeBoxStyle = (atr, classname) => {
switch (atr) { switch (atr) {
case 'width': case 'width':
...@@ -582,7 +594,7 @@ const FlowChart = props => { ...@@ -582,7 +594,7 @@ const FlowChart = props => {
// 双击线 // 双击线
const addLineMsg = (e, node) => { const addLineMsg = (e, node) => {
console.log(node.part.data, 'node.part.data'); console.log(node.part.data, 'node.part.data');
setLineId(node.part.data.LineId); setLineKey(node.part.data.LineKey);
setLineMsg(node.part.data); setLineMsg(node.part.data);
setLineVisible(true); setLineVisible(true);
}; };
...@@ -718,7 +730,7 @@ const FlowChart = props => { ...@@ -718,7 +730,7 @@ const FlowChart = props => {
item.from === nodeData.NodeId && item.from === nodeData.NodeId &&
nodeData.RuleList.some(ele => ele.NextNodeId === item.to) nodeData.RuleList.some(ele => ele.NextNodeId === item.to)
) { ) {
let node = diagram.model.findLinkDataForKey(item.LineId); let node = diagram.model.findLinkDataForKey(item.LineKey);
node.text = item.RuleName; node.text = item.RuleName;
diagram.model.updateTargetBindings(node); diagram.model.updateTargetBindings(node);
} }
...@@ -746,9 +758,9 @@ const FlowChart = props => { ...@@ -746,9 +758,9 @@ const FlowChart = props => {
// 线配置回调函数 // 线配置回调函数
const lineCallBack = obj => { const lineCallBack = obj => {
console.log(obj, 'obj'); console.log(obj, 'obj');
console.log(LineId, 'LineId'); console.log(LineKey, 'LineKey');
console.log(diagram, 'diagram'); console.log(diagram, 'diagram');
let node = diagram.model.findLinkDataForKey(LineId); let node = diagram.model.findLinkDataForKey(LineKey);
console.log(node, 'nodeData'); console.log(node, 'nodeData');
node.text = obj.text; node.text = obj.text;
diagram.model.updateTargetBindings(node); diagram.model.updateTargetBindings(node);
...@@ -764,9 +776,6 @@ const FlowChart = props => { ...@@ -764,9 +776,6 @@ const FlowChart = props => {
// 保存后离开不用提醒要修改数据了 // 保存后离开不用提醒要修改数据了
setShowLeaveTip(false); setShowLeaveTip(false);
leaveCallBack(false); leaveCallBack(false);
res.data.Nodes.forEach(item => {
item.nodeDetail = JSON.stringify(item);
});
setCurrentFlowData(res.data); setCurrentFlowData(res.data);
} else { } else {
notification.error({ notification.error({
......
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