Commit f45d17ab authored by 邓超's avatar 邓超

fix: 修改规则节点后的线显示规则名称

parent 9270de0d
Pipeline #63265 passed with stages
......@@ -2,7 +2,7 @@
* @Author: dengchao 754083046@qq.com
* @Date: 2022-11-02 14:37:53
* @LastEditors: dengchao 754083046@qq.com
* @LastEditTime: 2022-11-02 14:40:57
* @LastEditTime: 2022-11-07 11:48:08
* @FilePath: \maintenance\src\components\RuleConfig\index.jsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -53,7 +53,7 @@ const RuleConfig = props => {
return (
<div>
<Modal
title="节点转规则配置"
title="节点转规则配置"
visible={visible}
onOk={onSave}
width="860px"
......
......@@ -12,6 +12,7 @@ import {
Popconfirm,
message,
} from 'antd';
import lodash from 'lodash';
import {
DeleteOutlined,
EditTwoTone,
......@@ -164,7 +165,7 @@ const NodeModal = props => {
let linkNode = flowData.nodeDataArray.find(ele => ele.key === item.to);
if (linkNode.NodeType === '20') {
getNextLinkNodes(linkNode.key);
} else {
} else if (!nextlinkNodes.current.some(ele => ele.key === linkNode.key)) {
nextlinkNodes.current.push(linkNode);
}
}
......@@ -209,6 +210,27 @@ const NodeModal = props => {
};
// 提交表单
const onFinish = () => {
// 规则填写校验
for (let i = 0; i < RuleList.length; i++) {
if (!RuleList[i].RuleName) {
message.error('请填写规则名称');
return;
}
if (!RuleList[i].NextNodeId && RuleList[i].NextNodeId !== 0) {
message.error('请选择需要流转的节点');
return;
}
if (!RuleList[i].RuleContent) {
message.error('请填写规则');
return;
}
}
const newListLength = new Set(RuleList.map(item => item.NextNodeId)).size;
if (RuleList.length > newListLength) {
message.error('规则流转到的节点不能重复');
return;
}
form.validateFields().then(validate => {
console.log(validate, 'validate');
if (validate) {
......@@ -263,8 +285,16 @@ const NodeModal = props => {
// 添加规则
const addRule = () => {
console.log(fieldList, 'fieldList');
if (nextlinkNodes.current.length === 0) {
message.error('请连接需要添加规则的节点');
return;
}
if (RuleList.length === nextlinkNodes.current.length) {
message.error('请连接需要添加规则的节点');
return;
}
let list = JSON.parse(JSON.stringify(RuleList));
list.push({ RuleContent: '', NextNodeName: '', TableNames: '' });
list.push({ RuleContent: '', NextNodeId: '', TableNames: '', RuleName: '' });
setRuleList(list);
};
// 删除规则
......@@ -284,10 +314,13 @@ const NodeModal = props => {
};
// 网关表单配置监听
const formChage = (e, index, field) => {
console.log(e, 'fasdfga');
let list = JSON.parse(JSON.stringify(RuleList));
let list = lodash.cloneDeep(RuleList);
if (field === 'TableNames') {
list[index][field] = e.join(',');
}
if (field === 'RuleName') {
e.persist();
list[index][field] = e.target.value;
} else {
list[index][field] = e;
}
......@@ -628,18 +661,31 @@ const NodeModal = props => {
<div className={styles.textContet}>规则{NumberToChinese(index + 1)}</div>
<DeleteOutlined style={{ cursor: 'pointer' }} onClick={() => deleRule(index)} />
</div>
<div className={styles.formBox}>
<div className={styles.label}>规则名称:</div>
<div className={styles.item}>
<Input
style={{ width: '100%' }}
value={item.RuleName}
placeholder="请输入规则名称"
onChange={e => {
formChage(e, index, 'RuleName');
}}
/>
</div>
</div>
<div className={styles.formBox}>
<div className={styles.label}>设置规则条件,需要流转到节点:</div>
<div className={styles.item}>
<Select
style={{ width: '100%' }}
value={item.NextNodeName}
value={item.NextNodeId}
onChange={e => {
formChage(e, index, 'NextNodeName');
formChage(e, index, 'NextNodeId');
}}
>
{nextlinkNodes.current.map(ele => (
<Option value={ele.NodeName} key={ele.NodeName}>
<Option value={ele.NodeId} key={ele.NodeName}>
{ele.NodeName}
</Option>
))}
......
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