Commit 83d3afec authored by 邓超's avatar 邓超

fix: 优化规则弹窗样式,添加规则验证

parent b80b33b7
Pipeline #63301 passed with stages
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
* @Author: dengchao 754083046@qq.com * @Author: dengchao 754083046@qq.com
* @Date: 2022-11-02 14:37:53 * @Date: 2022-11-02 14:37:53
* @LastEditors: dengchao 754083046@qq.com * @LastEditors: dengchao 754083046@qq.com
* @LastEditTime: 2022-11-07 11:48:08 * @LastEditTime: 2022-11-07 17:32:35
* @FilePath: \maintenance\src\components\RuleConfig\index.jsx * @FilePath: \maintenance\src\components\RuleConfig\index.jsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
import React, { useEffect, useState, useRef } from 'react'; import React, { useEffect, useState, useRef } from 'react';
import { Modal, Input, Form } from 'antd'; import { RuleValidation } from '@/services/workflow/workflow';
import { Modal, Input, Form, message } from 'antd';
import styles from './index.less'; import styles from './index.less';
import Tree from '@/components/ExpendableTree'; import Tree from '@/components/ExpendableTree';
const { TextArea } = Input; const { TextArea } = Input;
...@@ -31,7 +32,13 @@ const RuleConfig = props => { ...@@ -31,7 +32,13 @@ const RuleConfig = props => {
}, [visible]); }, [visible]);
// 保存线配置 // 保存线配置
const onSave = () => { const onSave = () => {
onSubumit(rule); RuleValidation({ ruleContent: rule }).then(res => {
if (res.data) {
onSubumit(rule);
} else {
message.error('请检查规则是否正确');
}
});
}; };
// 处理树数据 // 处理树数据
const mapTree = (val, index) => ({ const mapTree = (val, index) => ({
...@@ -84,20 +91,26 @@ const RuleConfig = props => { ...@@ -84,20 +91,26 @@ const RuleConfig = props => {
onChange={e => setRule(e.target.value)} onChange={e => setRule(e.target.value)}
/> />
</div> </div>
<div className={styles.tipBox}> <ul className={styles.tipBox}>
<p>请从左侧面板选择字段或选项</p> <li>
<p>{'支持英文模式下运算符(+、-、*、/、>、<、==、!=、<=、>=)及函数'}</p> <p>请从左侧面板选择字段或选项</p>
{flag == 1 ? ( <p>
{'支持'} <i>英文</i> {'模式下运算符(+、-、*、/、>、<、==、!=、<=、>=)及函数'}
</p>
</li>
{flag === 1 ? (
<> <>
{' '} <li>
<p>参考场景:</p> <p>参考场景:</p>
<p>当报销金额大于10000时,才能进入所选节点,则可将流转条件设置为:</p> <p>当报销金额大于10000时,才能进入所选节点,则可将流转条件设置为:</p>
<p>{'报销金额>10000'}</p> <p>{'报销金额>10000'}</p>
</li>
</> </>
) : ( ) : (
<p>{`示例:{表名.是否缴费} = ‘是’ and {表名.缴费金额} > 1000`}</p> <li>{`示例:{表名.是否缴费} = ‘是’ and {表名.缴费金额} > 1000`}</li>
)} )}
</div> </ul>
</div> </div>
</div> </div>
</Modal> </Modal>
......
...@@ -10,6 +10,14 @@ ...@@ -10,6 +10,14 @@
} }
.rightContent { .rightContent {
.title {
width: 100%;
background-color: #80C3FF;
font-size: 18px;
font-weight: 700;
padding: 5px 10px;
}
.textAreaBox { .textAreaBox {
// height: 400px; // height: 400px;
// overflow-y: scroll; // overflow-y: scroll;
...@@ -19,5 +27,22 @@ ...@@ -19,5 +27,22 @@
border: 1px solid #ccc; border: 1px solid #ccc;
} }
} }
.tipBox {
li {
list-style: disc;
color: #AEAEAE;
}
i {
font-style: normal;
color: red;
}
p {
margin-bottom: 0;
color: #AEAEAE;
}
}
} }
} }
\ No newline at end of file
...@@ -79,7 +79,7 @@ const FlowChart = props => { ...@@ -79,7 +79,7 @@ const FlowChart = props => {
} }
if (n.data.LineKey) { if (n.data.LineKey) {
setTimeout(() => { setTimeout(() => {
setDeleteLine(n.data.LineKey); setDeleteLine(n.data.LineId);
}, 0); }, 0);
} }
}); });
...@@ -113,13 +113,10 @@ const FlowChart = props => { ...@@ -113,13 +113,10 @@ const FlowChart = props => {
setAddNodes([]); setAddNodes([]);
setDeleteNode(''); setDeleteNode('');
setDeleteLine(''); setDeleteLine('');
console.log(flowData, 'flowData');
let dataList = JSON.parse(JSON.stringify(flowData));
dataList.Lines.forEach(item => { let dataList = lodash.cloneDeep(flowData);
item.text = ''; console.log(dataList, 'dataList');
item.lineDetail = JSON.stringify(item);
});
setCurrentFlowData(dataList); setCurrentFlowData(dataList);
setShowLeaveTip(false); setShowLeaveTip(false);
} }
...@@ -128,7 +125,7 @@ const FlowChart = props => { ...@@ -128,7 +125,7 @@ const FlowChart = props => {
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;
...@@ -148,7 +145,6 @@ const FlowChart = props => { ...@@ -148,7 +145,6 @@ const FlowChart = props => {
linkDataArray = currentFlowData.Lines.map(item => { linkDataArray = currentFlowData.Lines.map(item => {
let obj; let obj;
obj = item; obj = item;
obj.LineKey = item.LineId; obj.LineKey = item.LineId;
obj.lineDetail = JSON.stringify(obj); obj.lineDetail = JSON.stringify(obj);
return obj; return obj;
...@@ -171,7 +167,7 @@ const FlowChart = props => { ...@@ -171,7 +167,7 @@ const FlowChart = props => {
}); });
// 修改复制后节点内容 // 修改复制后节点内容
diagram.model.copyNodeDataFunction = (obj, model) => { diagram.model.copyNodeDataFunction = (obj, model) => {
let copyObj = JSON.parse(JSON.stringify(obj)); let copyObj = lodash.cloneDeep(obj);
delete copyObj.ActivityId; delete copyObj.ActivityId;
return copyObj; return copyObj;
}; };
...@@ -478,13 +474,10 @@ const FlowChart = props => { ...@@ -478,13 +474,10 @@ const FlowChart = props => {
}; };
// 线上的文案 // 线上的文案
const lineText = v => { const lineText = v => {
console.log('rfioehjgiouewrhgio');
let obj = JSON.parse(v); let obj = JSON.parse(v);
let nodeData = diagram.model.findNodeDataForKey(obj.from); let nodeData = diagram.model.findNodeDataForKey(obj.from);
if (nodeData.NodeType === '20' || nodeData.NodeType === '21') { if (nodeData.NodeType === '20' || nodeData.NodeType === '21') {
// if(nodeData.)
if (nodeData.RuleList.some(ele => ele.NextNodeId === obj.to)) { if (nodeData.RuleList.some(ele => ele.NextNodeId === obj.to)) {
console.log(nodeData.RuleList.find(ele => ele.NextNodeId === obj.to), 'aaaaaaaaa');
return nodeData.RuleList.find(ele => ele.NextNodeId === obj.to).RuleName; return nodeData.RuleList.find(ele => ele.NextNodeId === obj.to).RuleName;
} }
return ''; return '';
...@@ -659,8 +652,8 @@ const FlowChart = props => { ...@@ -659,8 +652,8 @@ const FlowChart = props => {
leaveTip(); leaveTip();
}; };
// 节点配置回调 // 节点配置回调
const nodeCallBack = obj => { const nodeCallBack = (obj, nextlinkNodes) => {
console.log(obj, 'obj'); console.log(obj, nextlinkNodes, 'obj');
let nameIsRepeat; let nameIsRepeat;
let { nodes } = diagram; let { nodes } = diagram;
let keyArr = []; let keyArr = [];
...@@ -726,14 +719,18 @@ const FlowChart = props => { ...@@ -726,14 +719,18 @@ const FlowChart = props => {
let diagramObj = JSON.parse(diagram.model.toJson()); let diagramObj = JSON.parse(diagram.model.toJson());
diagramObj.linkDataArray.forEach(item => { diagramObj.linkDataArray.forEach(item => {
if ( let node = diagram.model.findLinkDataForKey(item.LineKey);
item.from === nodeData.NodeId && node.text = item.RuleName;
nodeData.RuleList.some(ele => ele.NextNodeId === item.to) diagram.model.updateTargetBindings(node);
) { // if (
let node = diagram.model.findLinkDataForKey(item.LineKey); // item.from === nodeData.NodeId &&
node.text = item.RuleName; // nodeData.RuleList.some(ele => ele.NextNodeId === item.to)
diagram.model.updateTargetBindings(node); // ) {
} // let node = diagram.model.findLinkDataForKey(item.LineKey);
// node.text = item.RuleName;
// diagram.model.updateTargetBindings(node);
// } else {
// }
}); });
// } // }
// 关闭时进行数据比对看数据是否改变 // 关闭时进行数据比对看数据是否改变
...@@ -776,7 +773,8 @@ const FlowChart = props => { ...@@ -776,7 +773,8 @@ const FlowChart = props => {
// 保存后离开不用提醒要修改数据了 // 保存后离开不用提醒要修改数据了
setShowLeaveTip(false); setShowLeaveTip(false);
leaveCallBack(false); leaveCallBack(false);
setCurrentFlowData(res.data); console.log(JSON.parse(JSON.stringify(res.data)), 'res.data');
setCurrentFlowData(JSON.parse(JSON.stringify(res.data)));
} else { } else {
notification.error({ notification.error({
title: '提示', title: '提示',
...@@ -910,7 +908,7 @@ const FlowChart = props => { ...@@ -910,7 +908,7 @@ const FlowChart = props => {
nodeNum={nodeLength} nodeNum={nodeLength}
modalType={modalType} modalType={modalType}
handleCancel={() => setVisible(false)} handleCancel={() => setVisible(false)}
onSubumit={obj => nodeCallBack(obj)} onSubumit={(obj, nextlinkNodes) => nodeCallBack(obj, nextlinkNodes)}
flowData={diagram ? JSON.parse(diagram.model.toJson()) : {}} flowData={diagram ? JSON.parse(diagram.model.toJson()) : {}}
/> />
<LineModal <LineModal
......
...@@ -247,7 +247,8 @@ const NodeModal = props => { ...@@ -247,7 +247,8 @@ const NodeModal = props => {
nodeDetail, nodeDetail,
RuleList, RuleList,
}; };
onSubumit(obj); console.log(nextlinkNodes.current);
onSubumit(obj, nextlinkNodes.current);
} }
}); });
}; };
......
...@@ -21,3 +21,5 @@ export const DeleteFlow = param => get(`${PUBLISH_SERVICE}/WorkFlow/DeleteFlow`, ...@@ -21,3 +21,5 @@ export const DeleteFlow = param => get(`${PUBLISH_SERVICE}/WorkFlow/DeleteFlow`,
// 获取流程节点级字段 // 获取流程节点级字段
export const GetFormDataSource = param => export const GetFormDataSource = param =>
get(`${PUBLISH_SERVICE}/WorkFlow/GetFormDataSource`, param); get(`${PUBLISH_SERVICE}/WorkFlow/GetFormDataSource`, param);
// 规则效验
export const RuleValidation = param => get(`${PUBLISH_SERVICE}/WorkFlow/RuleValidation`, param);
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