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

fix: 修改线名称问题

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