同一层级只能存在一个审批节点或抄送节点

This commit is contained in:
ChenXinXin committed 2024-05-08 16:09:42 +08:00
1 parent f8159254da
commit 84ac519499
1 file changed
+54 -23
+54 -23
View File
@@ -104,6 +104,21 @@
</div>
<!-- <<<<<<<<<<<<< 复杂右侧 -->
</template>
<template>
<v-snackbar v-model="isSnackerShown" top timeout="5000">
<span>{{disPassValidateText}}</span>
<template v-slot:action="{ attrs }">
<v-btn
color="red"
text
v-bind="attrs"
@click="isSnackerShown = false"
>
关闭
</v-btn>
</template>
</v-snackbar>
</template>
</v-card>
</template>
@@ -211,6 +226,9 @@ Vue.component("process-flow", {
displayMode: 'complex', // 'complex'、'simple'
isAddNodeMenuShown: false,
activeMenuIndex: -1,
isSnackerShown: false,
disPassValidateText:"",
isPassValidate: true
};
},
watch: {
@@ -269,6 +287,9 @@ Vue.component("process-flow", {
case 'dataValidate':
await this.dataValidate();
break;
case 'closeEditNode':
await this.closeEditNode();
break;
default:
console.error("[doUiAction] uiActionId not find", {uiActionId});
break;
@@ -798,15 +819,14 @@ Vue.component("process-flow", {
* 检验数据
*/
async dataValidate(){
var isPassValidate = true,
disPassValidateText = '';
this.disPassValidateText = ""
this.isPassValidate = true
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个开始节点或结束节点!"
this.isPassValidate = false
this.disPassValidateText += "只允许存在1个开始节点或结束节点!\n"
}
// 不允许孤立节点 => 除了开始节点和结束节点外,每个节点都有入线和出线
@@ -818,18 +838,18 @@ Vue.component("process-flow", {
}
});
if(Object.keys(mergeTemp).length < nodeList.length){
isPassValidate = false
disPassValidateText += '存在孤立节点!\n'
this.isPassValidate = false
this.disPassValidateText += '不允许存在孤立节点!\n'
}else{
// 判断开始节点是否只含有出线sourceNodeId
if(_.some(Object.keys(lineByTargetNodeId), (i) => i.startsWith('start-'))){
isPassValidate = false
disPassValidateText += "连线终点不能为开始节点!\n"
this.isPassValidate = false
this.disPassValidateText += "连线终点不能为开始节点!"
}
// 结束节点是否是含有入线targetNodeId
if(_.some(Object.keys(lineBySourceNodeId), (i) => i.startsWith('end-'))){
isPassValidate = false
disPassValidateText += "连线起点不能为结束节点!\n"
this.isPassValidate = false
this.disPassValidateText += "连线起点不能为结束节点!"
}
// 其他的节点必须至少有一个入线和出线
for (const key in mergeTemp) {
@@ -838,8 +858,8 @@ Vue.component("process-flow", {
const element = mergeTemp[key];
if(!_.some(element, i => i.sourceNodeId == key) || !_.some(element, i => i.targetNodeId == key)){
isPassValidate = false
disPassValidateText += "存在除了开始和结束节点以外的节点没有入线或出线!"
this.isPassValidate = false
this.disPassValidateText += "不允许存在除了开始和结束节点以外的节点没有入线或出线!"
break
}
}
@@ -847,16 +867,23 @@ Vue.component("process-flow", {
}
}
// 不允许条件节点和审批/通知节点存在同一层级
// 不允许条件节点和审批/通知节点存在同一层级 以及 不允许无条件层级,多个审批/抄送节点同时存在
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 += "不允许条件节点和审批/通知节点存在同一层级!"
if(_.some(node, i => i.properties.type == "conditionTask")){
if(_.some(node, i => i.properties.type != "conditionTask")){
this.isPassValidate = false
this.disPassValidateText += "不允许条件节点和审批/通知节点存在同一层级!"
}
}else{
if(node.length > 1){
this.isPassValidate = false
this.disPassValidateText += "不允许同一层级多个审批/抄送节点同时存在!"
}
}
}
}
@@ -870,16 +897,20 @@ Vue.component("process-flow", {
var conditionNode = element.map(l => nodeList.find(n => n.id === l.targetNodeId))
if(!_.some(conditionNode, i => i.properties.priority == -1)){
isPassValidate = false
disPassValidateText += "存在某层条件节点没有默认条件优先级!"
this.isPassValidate = false
this.disPassValidateText += "不允许存在某层条件节点没有默认条件优先级!"
}
}
}
if(!isPassValidate){
await window.vtoast.fail(disPassValidateText);
throw new Error(disPassValidateText)
if(!this.isPassValidate){
// await window.vtoast.fail(this.disPassValidateText);
this.isSnackerShown = true
throw new Error(this.disPassValidateText)
}
},
closeEditNode(){
this.editType = null
}
}
})