Commit 361898fc authored by 邓超's avatar 邓超

fix: 节点改为点击添加

parent 88f55687
Pipeline #62898 passed with stages
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Button, Modal, notification, Spin } from 'antd'; import { Button, Modal, notification, Spin, Tooltip } from 'antd';
import { SaveNodeChange, GetFlowNode } from '@/services/workflow/workflow'; import { SaveNodeChange, GetFlowNode } from '@/services/workflow/workflow';
import { ExclamationCircleOutlined } from '@ant-design/icons'; import { ExclamationCircleOutlined } from '@ant-design/icons';
...@@ -18,7 +18,14 @@ import gatewayConfluence from '@/assets/images/workFlow/gatewayConfluence.png'; ...@@ -18,7 +18,14 @@ import gatewayConfluence from '@/assets/images/workFlow/gatewayConfluence.png';
import gatewayInclude from '@/assets/images/workFlow/gatewayInclude.png'; import gatewayInclude from '@/assets/images/workFlow/gatewayInclude.png';
const { confirm } = Modal; const { confirm } = Modal;
let diagram = null; let diagram = null;
const nodeTypeList = [{ name: '开始节点', nodeType: '0', src: imgStart }]; const nodeTypeList = [
{ nodeTypeName: '开始节点', NodeType: '1', src: imgStart },
{ nodeTypeName: '普通节点', NodeType: '0', src: imgGeneral },
{ nodeTypeName: '结束节点', NodeType: '2', src: imgEnd },
{ nodeTypeName: '条件网关', NodeType: '20', src: gatewayExclusive },
{ nodeTypeName: '汇合网关', NodeType: '21', src: gatewayInclude },
{ nodeTypeName: '并行网关', NodeType: '22', src: gatewayConfluence },
];
const FlowChart = props => { const FlowChart = props => {
const { flowData, flowID, chartLoading, leaveCallBack } = props; const { flowData, flowID, chartLoading, leaveCallBack } = props;
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
...@@ -205,19 +212,19 @@ const FlowChart = props => { ...@@ -205,19 +212,19 @@ const FlowChart = props => {
new go.Binding('width', 'NodeType', v => { new go.Binding('width', 'NodeType', v => {
switch (v) { switch (v) {
case '1': case '1':
return 126; return 125;
case '2': case '2':
return 126; return 125;
case '0': case '0':
return 210; return 210;
case '4': case '4':
return 210; return 210;
case '20': case '20':
return 52; return 55;
case '21': case '21':
return 52; return 55;
case '22': case '22':
return 52; return 55;
default: default:
return null; return null;
} }
...@@ -226,19 +233,19 @@ const FlowChart = props => { ...@@ -226,19 +233,19 @@ const FlowChart = props => {
new go.Binding('height', 'NodeType', v => { new go.Binding('height', 'NodeType', v => {
switch (v) { switch (v) {
case '1': case '1':
return 126; return 125;
case '2': case '2':
return 126; return 125;
case '0': case '0':
return 110; return 110;
case '4': case '4':
return 110; return 110;
case '20': case '20':
return 52; return 55;
case '21': case '21':
return 52; return 55;
case '22': case '22':
return 52; return 55;
default: default:
return null; return null;
} }
...@@ -348,7 +355,7 @@ const FlowChart = props => { ...@@ -348,7 +355,7 @@ const FlowChart = props => {
}); });
}; };
// 出口线条颜色 // 线的样式
const lineStyle = (v, styleName) => { const lineStyle = (v, styleName) => {
const msg = diagram.model.findNodeDataForKey(v); const msg = diagram.model.findNodeDataForKey(v);
switch (styleName) { switch (styleName) {
...@@ -406,22 +413,41 @@ const FlowChart = props => { ...@@ -406,22 +413,41 @@ const FlowChart = props => {
setLineVisible(true); setLineVisible(true);
}; };
// 新增节点 // 新增节点
const addNode = () => { const addNode = type => {
const list = JSON.parse(diagram.model.toJson()).nodeDataArray; const list = JSON.parse(diagram.model.toJson()).nodeDataArray;
console.log(list, 'list'); console.log(list, 'list');
let newNum; let newNum;
let newKey;
if (list.length > 0) { if (list.length > 0) {
// eslint-disable-next-line prefer-spread // eslint-disable-next-line prefer-spread
newNum = Math.max.apply(Math, list.map(item => item.SerialNo)) + 1; newNum = Math.max.apply(Math, list.map(item => item.SerialNo)) + 1;
// eslint-disable-next-line prefer-spread
newKey = Math.max.apply(Math, list.map(item => item.key)) + 1;
} else { } else {
newKey = 1;
newNum = 1; newNum = 1;
} }
setNodeLength(list.length); setNodeLength(list.length);
console.log(newNum); console.log(newNum, newKey);
setNewSerialNo(newNum); setNewSerialNo(newNum);
setModalType('add'); // 新增节点
setVisible(true); // 新增得key比最大得key值+1
let obj = {
key: newKey,
NodeId: newKey,
NodeType: type,
SerialNo: newNum,
aheadHandle: 1,
NodeHandling: 1,
RuleList: [],
roleList: [],
};
diagram.model.addNodeData({ ...obj, nodeDetail: JSON.stringify(obj) });
setAddNodes([...AddNodes, newKey]);
// 关闭时进行数据比对看数据是否改变
leaveTip();
}; };
// 节点配置回调 // 节点配置回调
const nodeCallBack = obj => { const nodeCallBack = obj => {
...@@ -487,6 +513,11 @@ const FlowChart = props => { ...@@ -487,6 +513,11 @@ const FlowChart = props => {
nodeData.RuleList = RuleList; nodeData.RuleList = RuleList;
diagram.model.updateTargetBindings(nodeData); diagram.model.updateTargetBindings(nodeData);
} }
// 关闭时进行数据比对看数据是否改变
leaveTip();
setVisible(false);
};
const leaveTip = () => {
// 关闭时进行数据比对看数据是否改变 // 关闭时进行数据比对看数据是否改变
let diagramObj = JSON.parse(diagram.model.toJson()); let diagramObj = JSON.parse(diagram.model.toJson());
let stageJson = { let stageJson = {
...@@ -500,7 +531,6 @@ const FlowChart = props => { ...@@ -500,7 +531,6 @@ const FlowChart = props => {
leaveCallBack(true); leaveCallBack(true);
setShowLeaveTip(true); setShowLeaveTip(true);
} }
setVisible(false);
}; };
// 线配置回调函数 // 线配置回调函数
const lineCallBack = obj => { const lineCallBack = obj => {
...@@ -608,46 +638,19 @@ const FlowChart = props => { ...@@ -608,46 +638,19 @@ const FlowChart = props => {
<> <>
<Prompt message="编辑的内容还未保存,确定要离开该页面吗?" when={showLeaveTip} /> <Prompt message="编辑的内容还未保存,确定要离开该页面吗?" when={showLeaveTip} />
<div className={styles.control}> <div className={styles.control}>
{/* <div className={styles.nodeList}> <div className={styles.nodeList}>
<div className={styles.nodeBox}> {nodeTypeList.map(item => (
<div className={styles.nodeImg}> <Tooltip placement="topLeft" title="点击插入节点" key={item.NodeType}>
<img src={imgStart} alt="" /> <div className={styles.nodeBox} onClick={() => addNode(item.NodeType)}>
</div> <div className={styles.nodeImg}>
<div className={styles.nodeTypeName}>开始节点</div> <img src={item.src} alt="" />
</div> </div>
<div className={styles.nodeBox}> <div className={styles.nodeTypeName}>{item.nodeTypeName}</div>
<div className={styles.nodeImg}> </div>
<img src={imgGeneral} alt="" /> </Tooltip>
</div> ))}
<div className={styles.nodeTypeName}>经办节点</div> </div>
</div>
<div className={styles.nodeBox}>
<div className={styles.nodeImg}>
<img src={imgEnd} alt="" />
</div>
<div className={styles.nodeTypeName}>结束节点</div>
</div>
<div className={styles.nodeBox}>
<div className={styles.nodeImg}>
<img src={gatewayExclusive} alt="" />
</div>
<div className={styles.nodeTypeName}>条件网关</div>
</div>
<div className={styles.nodeBox}>
<div className={styles.nodeImg}>
<img src={gatewayConfluence} alt="" />
</div>
<div className={styles.nodeTypeName}>并行网关</div>
</div>
<div className={styles.nodeBox}>
<div className={styles.nodeImg}>
<img src={gatewayInclude} alt="" />
</div>
<div className={styles.nodeTypeName}>汇合网关</div>
</div>
</div> */}
<div className={styles.buttonList}> <div className={styles.buttonList}>
<Button onClick={() => addNode()}>添加节点</Button>
<Button type="primary" onClick={() => saveFlow()}> <Button type="primary" onClick={() => saveFlow()}>
发布 发布
</Button> </Button>
......
...@@ -24,6 +24,7 @@ import Undertaker from './nodeModalComponents/Undertaker'; ...@@ -24,6 +24,7 @@ import Undertaker from './nodeModalComponents/Undertaker';
import RuleConfig from './nodeModalComponents/RuleConfig'; import RuleConfig from './nodeModalComponents/RuleConfig';
import styles from './NodeModal.less'; import styles from './NodeModal.less';
import { GetFormDataSource } from '@/services/workflow/workflow'; import { GetFormDataSource } from '@/services/workflow/workflow';
import { node } from 'prop-types';
const { Option } = Select; const { Option } = Select;
let chnNumChar = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']; let chnNumChar = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
...@@ -70,59 +71,34 @@ const NodeModal = props => { ...@@ -70,59 +71,34 @@ const NodeModal = props => {
form.resetFields(); form.resetFields();
if (visible) { if (visible) {
console.log(editMsg, 'editMsg'); console.log(editMsg, 'editMsg');
if (modalType === 'edit') { // 获取网关连接的节点
// 获取网关连接的节点 if (editMsg.NodeType === '21' || editMsg.NodeType === '20') {
if (editMsg.NodeType === '21' || editMsg.NodeType === '20') { getNextLinkNodes(editMsg.key);
getNextLinkNodes(editMsg.key); // getPreviousLinkNodes(editMsg.key);
// getPreviousLinkNodes(editMsg.key); setRuleList(editMsg.RuleList);
setRuleList(editMsg.RuleList); // 获取表数据
// 获取表数据 GetFormDataSource({ flowID }).then(res => {
GetFormDataSource({ flowID }).then(res => { let list = new Set(talbeList.current);
let list = new Set(talbeList.current); allFieldList.current = [];
allFieldList.current = []; res.data.forEach(item => {
res.data.forEach(item => { if (!allFieldList.current.some(ele => ele.TableName === item.TableName)) {
if (!allFieldList.current.some(ele => ele.TableName === item.TableName)) { allFieldList.current.push({
allFieldList.current.push({ TableFieldNames: item.TableFieldNames,
TableFieldNames: item.TableFieldNames, TableName: item.TableName,
TableName: item.TableName, });
}); }
} list.add(item.TableName);
list.add(item.TableName); // if (previousLinkNodes.current.some(ele => ele.NodeName === item.NodeName)) {
// if (previousLinkNodes.current.some(ele => ele.NodeName === item.NodeName)) { // list.add(item.TableName);
// list.add(item.TableName); // }
// }
});
talbeList.current = [...list];
setFlag(flag + 1);
console.log(talbeList.current, 'talbeList');
}); });
} talbeList.current = [...list];
setFlag(flag + 1);
console.log(nextlinkNodes.current, previousLinkNodes.current, 'linkNodes.current');
getFormData();
console.log(form.getFieldValue(), 'getFieldValue');
} else {
let type;
if (nodeNum > 0) {
type = '0';
} else {
type = '1';
}
let nodeDetail = JSON.stringify({
...nodeMsg,
newSerialNo,
NodeType: type,
roleList: [],
RuleList,
});
setNodeMsg({ ...nodeMsg, newSerialNo, NodeType: type, roleList: [], nodeDetail, RuleList });
form.setFieldsValue({
SerialNo: newSerialNo,
NodeType: type,
aheadHandle: 1,
NodeHandling: 1,
}); });
} }
getFormData();
console.log(form.getFieldValue(), 'getFieldValue');
} else { } else {
nextlinkNodes.current = []; nextlinkNodes.current = [];
previousLinkNodes.current = []; previousLinkNodes.current = [];
...@@ -219,7 +195,13 @@ const NodeModal = props => { ...@@ -219,7 +195,13 @@ const NodeModal = props => {
// 获取表单回显 // 获取表单回显
const getFormData = () => { const getFormData = () => {
const { NodeName, NodeType, SerialNo, aheadHandle, NodeHandling } = editMsg; const { NodeName, NodeType, SerialNo, aheadHandle, NodeHandling } = editMsg;
form.setFieldsValue({ NodeName, NodeType, SerialNo, aheadHandle, NodeHandling }); form.setFieldsValue({
NodeName,
NodeType,
SerialNo,
aheadHandle: aheadHandle || 1,
NodeHandling: NodeHandling || 1,
});
setNodeMsg(editMsg); setNodeMsg(editMsg);
setFlag(flag + 1); setFlag(flag + 1);
}; };
...@@ -228,8 +210,18 @@ const NodeModal = props => { ...@@ -228,8 +210,18 @@ const NodeModal = props => {
form.validateFields().then(validate => { form.validateFields().then(validate => {
if (validate) { if (validate) {
validate.SerialNo = Number(validate.SerialNo); validate.SerialNo = Number(validate.SerialNo);
let nodeDetail = JSON.stringify({ ...validate, roleList: nodeMsg.roleList }); let nodeDetail = JSON.stringify({
let obj = { ...validate, roleList: nodeMsg.roleList, nodeDetail, RuleList }; ...validate,
NodeType: nodeMsg.NodeType,
roleList: nodeMsg.roleList,
});
let obj = {
...validate,
NodeType: nodeMsg.NodeType,
roleList: nodeMsg.roleList,
nodeDetail,
RuleList,
};
onSubumit(obj); onSubumit(obj);
} }
}); });
...@@ -267,6 +259,7 @@ const NodeModal = props => { ...@@ -267,6 +259,7 @@ const NodeModal = props => {
}; };
// 添加规则 // 添加规则
const addRule = () => { const addRule = () => {
console.log(fieldList, 'fieldList');
let list = JSON.parse(JSON.stringify(RuleList)); let list = JSON.parse(JSON.stringify(RuleList));
list.push({ RuleContent: '', NextNodeName: '', TableNames: '' }); list.push({ RuleContent: '', NextNodeName: '', TableNames: '' });
setRuleList(list); setRuleList(list);
...@@ -318,10 +311,12 @@ const NodeModal = props => { ...@@ -318,10 +311,12 @@ const NodeModal = props => {
console.log(listfleld, allFieldList.current, 'listfleld1111'); console.log(listfleld, allFieldList.current, 'listfleld1111');
allFieldList.current.forEach(item => { allFieldList.current.forEach(item => {
if (listfleld.some(ele => ele === item.TableName)) { if (listfleld.some(ele => ele === item.TableName)) {
list.push({ if (item.TableName && item.TableFieldNames?.length > 0) {
TableFieldNames: item.TableFieldNames, list.push({
TableName: item.TableName, TableFieldNames: item.TableFieldNames,
}); TableName: item.TableName,
});
}
} }
}); });
console.log(list, 'listfleld'); console.log(list, 'listfleld');
...@@ -335,7 +330,7 @@ const NodeModal = props => { ...@@ -335,7 +330,7 @@ const NodeModal = props => {
setNodeMsg({ ...nodeMsg, roleList: [], RuleList: [] }); setNodeMsg({ ...nodeMsg, roleList: [], RuleList: [] });
setFlag(flag + 1); setFlag(flag + 1);
} }
console.log(changedFields, allFields, 'allFields'); // console.log(changedFields, allFields, 'allFields');
}; };
// 定义表格 // 定义表格
const columns = [ const columns = [
...@@ -415,7 +410,7 @@ const NodeModal = props => { ...@@ -415,7 +410,7 @@ const NodeModal = props => {
), ),
}, },
]; ];
console.log(form?.getFieldValue('NodeType'), 'afdsfasdg');
return ( return (
<> <>
<Drawer <Drawer
...@@ -443,13 +438,16 @@ const NodeModal = props => { ...@@ -443,13 +438,16 @@ const NodeModal = props => {
marginBottom: '30px', marginBottom: '30px',
}} }}
> >
节点信息 {nodeMsg.NodeType === '20' || nodeMsg.NodeType === '21' || nodeMsg.NodeType === '22'
? '网关'
: '节点'}
信息
</Divider> </Divider>
<Form <Form
form={form} form={form}
labelCol={{ span: 5 }} labelCol={{ span: 4 }}
wrapperCol={{ span: 19 }} wrapperCol={{ span: 20 }}
onFieldsChange={changeValue} // onFieldsChange={changeValue}
> >
<Form.Item <Form.Item
label="排序" label="排序"
...@@ -459,7 +457,11 @@ const NodeModal = props => { ...@@ -459,7 +457,11 @@ const NodeModal = props => {
<Input placeholder="请输入序号" /> <Input placeholder="请输入序号" />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="节点名称" label={`${
nodeMsg.NodeType === '20' || nodeMsg.NodeType === '21' || nodeMsg.NodeType === '22'
? '网关'
: '节点'
}名称`}
name="NodeName" name="NodeName"
rules={[ rules={[
{ required: true, message: '请输入节点名称' }, { required: true, message: '请输入节点名称' },
...@@ -471,9 +473,15 @@ const NodeModal = props => { ...@@ -471,9 +473,15 @@ const NodeModal = props => {
// }, // },
]} ]}
> >
<Input placeholder="请输入节点名称(最多6个字)" /> <Input
placeholder={`请输入${
nodeMsg.NodeType === '20' || nodeMsg.NodeType === '21' || nodeMsg.NodeType === '22'
? '网关'
: '节点'
}名称`}
/>
</Form.Item> </Form.Item>
<Form.Item {/* <Form.Item
label="节点类型" label="节点类型"
name="NodeType" name="NodeType"
rules={[{ required: true, message: '请选择节点类型' }]} rules={[{ required: true, message: '请选择节点类型' }]}
...@@ -481,14 +489,14 @@ const NodeModal = props => { ...@@ -481,14 +489,14 @@ const NodeModal = props => {
<Select placeholder="请选择节点类型" disabled={modalType === 'edit'}> <Select placeholder="请选择节点类型" disabled={modalType === 'edit'}>
<Option value="1">开始节点</Option> <Option value="1">开始节点</Option>
<Option value="0">普通节点</Option> <Option value="0">普通节点</Option>
{/* <Option value="3">审批节点</Option> */} <Option value="3">审批节点</Option>
<Option value="2">结束节点</Option> <Option value="2">结束节点</Option>
{/* <Option value="4">抄送节点</Option> */} <Option value="4">抄送节点</Option>
<Option value="20">条件网关</Option> <Option value="20">条件网关</Option>
<Option value="21">汇合网关</Option> <Option value="21">汇合网关</Option>
<Option value="22">并行网关</Option> <Option value="22">并行网关</Option>
</Select> </Select>
</Form.Item> </Form.Item> */}
<div style={{ display: 'none' }}> <div style={{ display: 'none' }}>
<Form.Item label="检查前面在办" name="aheadHandle"> <Form.Item label="检查前面在办" name="aheadHandle">
<Select> <Select>
...@@ -509,7 +517,7 @@ const NodeModal = props => { ...@@ -509,7 +517,7 @@ const NodeModal = props => {
: 'block', : 'block',
}} }}
> >
<Form.Item label="节点办理方式" name="NodeHandling"> <Form.Item label="办理方式" name="NodeHandling">
<Select> <Select>
<Option value={1}>多人接收,一人办理(抢占模式)</Option> <Option value={1}>多人接收,一人办理(抢占模式)</Option>
<Option value={0}>多人接收,多人办理(会签模式)</Option> <Option value={0}>多人接收,多人办理(会签模式)</Option>
...@@ -618,7 +626,7 @@ const NodeModal = props => { ...@@ -618,7 +626,7 @@ const NodeModal = props => {
</Select> </Select>
</div> </div>
</div> </div>
<div className={styles.formBox}> {/* <div className={styles.formBox}>
<div className={styles.label}>选择业务表单:</div> <div className={styles.label}>选择业务表单:</div>
<div className={styles.item}> <div className={styles.item}>
<Select <Select
...@@ -636,7 +644,7 @@ const NodeModal = props => { ...@@ -636,7 +644,7 @@ const NodeModal = props => {
))} ))}
</Select> </Select>
</div> </div>
</div> </div> */}
<div className={styles.buttonBox} onClick={() => editRule(item, index)}> <div className={styles.buttonBox} onClick={() => editRule(item, index)}>
<div className={styles.setButton}> <div className={styles.setButton}>
<Tooltip title={item.RuleContent}> <Tooltip title={item.RuleContent}>
......
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