审批流保存数据检验
This commit is contained in:
1 parent
7e094cd83e
commit
9bec3c6de0
8 files changed
+233
-94
No files matched your search
@@ -266,6 +266,9 @@ Vue.component("process-flow", {
|
||||
case 'deleteNodeBySimple':
|
||||
await this.deleteNodeBySimple(uiActionData);
|
||||
break;
|
||||
case 'dataValidate':
|
||||
await this.dataValidate();
|
||||
break;
|
||||
default:
|
||||
console.error("[doUiAction] uiActionId not find", {uiActionId});
|
||||
break;
|
||||
@@ -390,10 +393,9 @@ Vue.component("process-flow", {
|
||||
},
|
||||
// 切换展示模式
|
||||
changeDisplayMode(displayMode){
|
||||
var changeAble = true
|
||||
var changeText = ""
|
||||
var lineList = this.workflowConfig.lineList
|
||||
var nodeList = this.workflowConfig.nodeList
|
||||
var changeAble = true,
|
||||
changeText = "";
|
||||
const {lineList, nodeList} = this.workflowConfig;
|
||||
|
||||
if(displayMode == 'simple'){
|
||||
// 检查是否有多个开始节点或结束节点
|
||||
@@ -787,9 +789,97 @@ Vue.component("process-flow", {
|
||||
*/
|
||||
parseBusinessDataTologicFlowData() {
|
||||
return {
|
||||
nodes: this.workflowConfig.nodeList.map(node => node).filter(node => node != null),
|
||||
edges: this.workflowConfig.lineList.map(line => line).filter(line => line != null)
|
||||
nodes: this.workflowConfig.nodeList.filter(node => node != null),
|
||||
edges: this.workflowConfig.lineList.filter(line => line != null)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 检验数据
|
||||
*/
|
||||
async dataValidate(){
|
||||
var isPassValidate = true,
|
||||
disPassValidateText = '';
|
||||
const { lineList, nodeList } = this.workflowConfig;
|
||||
|
||||
|
||||
// 不允许多个开始节点或结束节点
|
||||
if(nodeList.filter(n=>n.properties.type == 'start').length != 1 || nodeList.filter(n=>n.properties.type == 'end').length != 1){
|
||||
isPassValidate = false
|
||||
disPassValidateText += "只允许存在1个开始节点或结束节点!"
|
||||
}
|
||||
|
||||
// 不允许孤立节点 => 除了开始节点和结束节点外,每个节点都有入线和出线
|
||||
var lineBySourceNodeId = _.groupBy(lineList, 'sourceNodeId'),
|
||||
lineByTargetNodeId = _.groupBy(lineList, 'targetNodeId'),
|
||||
mergeTemp = _.mergeWith(_.cloneDeep(lineBySourceNodeId), lineByTargetNodeId, (objValue, srcValue)=>{
|
||||
if (_.isArray(objValue)) {
|
||||
return objValue.concat(srcValue);
|
||||
}
|
||||
});
|
||||
if(Object.keys(mergeTemp).length < nodeList.length){
|
||||
isPassValidate = false
|
||||
disPassValidateText += '存在孤立节点!\n'
|
||||
}else{
|
||||
// 判断开始节点是否只含有出线sourceNodeId
|
||||
if(_.some(Object.keys(lineByTargetNodeId), (i) => i.startsWith('start-'))){
|
||||
isPassValidate = false
|
||||
disPassValidateText += "连线终点不能为开始节点!\n"
|
||||
}
|
||||
// 结束节点是否是含有入线targetNodeId
|
||||
if(_.some(Object.keys(lineBySourceNodeId), (i) => i.startsWith('end-'))){
|
||||
isPassValidate = false
|
||||
disPassValidateText += "连线起点不能为结束节点!\n"
|
||||
}
|
||||
// 其他的节点必须至少有一个入线和出线
|
||||
for (const key in mergeTemp) {
|
||||
if (Object.hasOwnProperty.call(mergeTemp, key)) {
|
||||
if(!(key.startsWith('start-') || key.startsWith('end-'))){
|
||||
const element = mergeTemp[key];
|
||||
|
||||
if(!_.some(element, i => i.sourceNodeId == key) || !_.some(element, i => i.targetNodeId == key)){
|
||||
isPassValidate = false
|
||||
disPassValidateText += "存在除了开始和结束节点以外的节点没有入线或出线!"
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 不允许条件节点和审批/通知节点存在同一层级
|
||||
for (const key in lineBySourceNodeId) {
|
||||
if (Object.hasOwnProperty.call(lineBySourceNodeId, key)) {
|
||||
const element = lineBySourceNodeId[key];
|
||||
// 拿到同一层的节点
|
||||
var node = element.map(l => nodeList.find(n => n.id === l.targetNodeId))
|
||||
|
||||
if(_.some(node, i => i.properties.type == "conditionTask") && _.some(node, i => i.properties.type != "conditionTask")){
|
||||
isPassValidate = false
|
||||
disPassValidateText += "不允许条件节点和审批/通知节点存在同一层级!"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 不允许有条件节点的优先级没有默认优先级节点, 允许存在多个默认节点,读取顺序按放置时间的先后顺序
|
||||
var conditionNodeLineBySourceNodeId = _.groupBy(lineList.filter(i => i.targetNodeId.startsWith('conditionTask-')), 'sourceNodeId');
|
||||
for (const key in conditionNodeLineBySourceNodeId) {
|
||||
if (Object.hasOwnProperty.call(conditionNodeLineBySourceNodeId, key)) {
|
||||
const element = conditionNodeLineBySourceNodeId[key];
|
||||
// 拿到同一层的条件节点
|
||||
var conditionNode = element.map(l => nodeList.find(n => n.id === l.targetNodeId))
|
||||
|
||||
if(!_.some(conditionNode, i => i.properties.priority == -1)){
|
||||
isPassValidate = false
|
||||
disPassValidateText += "存在某层条件节点没有默认条件优先级!"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!isPassValidate){
|
||||
await window.vtoast.fail(disPassValidateText);
|
||||
throw new Error(disPassValidateText)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user