diff --git a/app/view/component/createTaskDrawer.html b/app/view/component/createTaskDrawer.html
index dcb545e..4a15b25 100644
--- a/app/view/component/createTaskDrawer.html
+++ b/app/view/component/createTaskDrawer.html
@@ -219,7 +219,7 @@ Vue.component("create-task-drawer", {
}
formObj.workflowConfig = formObj.workflowConfig ? formObj.workflowConfig : null;
formObj.workflowForm = formObj.workflowForm ? (typeof formObj.workflowForm == 'string'? JSON.parse(formObj.workflowForm): formObj.workflowForm) : [];
- formObj.workflowForm.forEach(f => f.answer = []) // 兼容多选
+ formObj.workflowForm.forEach(f => f.answer = ['multiple', 'file'].includes(f.type) ? [] : '') // 兼容多选
this.defaultWorkflowConfig = _.cloneDeep(formObj.workflowConfig);
this.defaultWorkflowForm = _.cloneDeep(formObj.workflowForm);
this.defaultWorkflowConfig.nodeList.forEach(node =>{
@@ -525,9 +525,21 @@ Vue.component("create-task-drawer", {
// -- <<<<<<<<<<<<< 操作审批流 --------------------
// -- 新建任务 >>>>>>>>>>> ---------------
+ isValidDateTime(str) {
+ // 正则表达式,考虑日期和时间的范围
+ const regex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/;
+
+ // 使用test方法检查字符串是否符合正则表达式
+ return regex.test(str);
+ },
+
async prepareCreateValidate() {
- // 检查必填是否已填 TODO:注意文件
this.taskData.workflowForm.forEach(f => {
+ if(f.type == 'time' && !this.isValidDateTime(f.answer)){
+ window.vtoast.fail("时间日期格式不正确!")
+ throw new Error("时间日期格式不正确!")
+ }
+ // 检查必填是否已填
if(f.isRequire){
if(!f.answer || f.answer && f.answer.length == 0){
window.vtoast.fail("请完善表单信息")
@@ -535,13 +547,14 @@ Vue.component("create-task-drawer", {
}
}
})
-
},
+
async confirmCreateWorkDialog() {
if (await window.confirmDialog({ title: "新建任务", content: "确定新建任务吗?" }) === false) {
throw new Error("[confirmCreateFormDialog] 否");
}
},
+
prepareDoWorkItem() {
const { workflowInfo, workflowForm, workflowConfig, workflowName, taskTemplateGroup, } = this.taskData
var curNode = this.curWorkflow[0]
diff --git a/app/view/component/flow/editNode.html b/app/view/component/flow/editNode.html
index d9be491..778e3bd 100644
--- a/app/view/component/flow/editNode.html
+++ b/app/view/component/flow/editNode.html
@@ -353,7 +353,8 @@
return window.innerWidth < 600;
},
prioritys(){
- var num = this.workflowConfig.nodeList.filter(n=>n.properties.type == 'conditionTask').length
+ const { nodeList } = this.workflowConfig
+ var num = nodeList.filter(n=>n.properties.type == 'conditionTask').length
return [
{ text: '默认条件', priority: -1 },
..._.times(num - 1, i => {
diff --git a/app/view/component/flow/processFlow.html b/app/view/component/flow/processFlow.html
index f72cae2..5d39e10 100644
--- a/app/view/component/flow/processFlow.html
+++ b/app/view/component/flow/processFlow.html
@@ -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)
+ }
}
}
})
diff --git a/app/view/component/tpl/formComponentList.html b/app/view/component/tpl/formComponentList.html
index eb8f9a0..b67b35c 100644
--- a/app/view/component/tpl/formComponentList.html
+++ b/app/view/component/tpl/formComponentList.html
@@ -63,7 +63,7 @@
v-model="formItem.answer"
>
-
+
diff --git a/app/view/component/tpl/formItemListGenerator.html b/app/view/component/tpl/formItemListGenerator.html
index c433e4b..b7d6127 100644
--- a/app/view/component/tpl/formItemListGenerator.html
+++ b/app/view/component/tpl/formItemListGenerator.html
@@ -260,6 +260,17 @@ Vue.component("form-item-list-generator", {
return this.formItemList;
},
+ dataValidate(){
+ console.log('formItemListGenerator-dataValidate', this.formItemList);
+ // 检查单选多选是否还有选项
+ this.formItemList.forEach(async element => {
+ if(['single', 'multiple'].includes(element.type) && !(element.optionList && element.optionList.length)){
+ await window.vtoast.fail("存在选择题没有选项!");
+ throw new Error("存在选择题没有选项!")
+ }
+ });
+
+ }
},
})
diff --git a/app/view/component/tpl/tplFormDesign.html b/app/view/component/tpl/tplFormDesign.html
index a04d4f0..ced0577 100644
--- a/app/view/component/tpl/tplFormDesign.html
+++ b/app/view/component/tpl/tplFormDesign.html
@@ -38,19 +38,24 @@
}
},
watch: {
- // 每个属性值发生变化就会调用这个函数
- form(newVal, oldVal) {
- this.saveData(newVal)
- },
- // 深度监听 属性的变化
- deep: true
+
},
async created() {
},
mounted() {},
methods: {
- saveData(newVal) {
- // this.$emit('change-structure', this.form);
+ async doUiAction(uiActionId, uiActionData) {
+ switch (uiActionId) {
+ case 'dataValidate':
+ await this.dataValidate();
+ break;
+ default:
+ console.error("[doUiAction] uiActionId not find", {uiActionId});
+ break;
+ }
+ },
+ dataValidate(){
+ this.$refs.formItemListGenerator.dataValidate()
}
}
})
diff --git a/app/view/component/workflowBasicInfo.html b/app/view/component/workflowBasicInfo.html
index 2d96047..0a6ee37 100644
--- a/app/view/component/workflowBasicInfo.html
+++ b/app/view/component/workflowBasicInfo.html
@@ -1,78 +1,80 @@
-
-
- 流程名*必填
-
-
-
-
- 模板图标
-
-
+
+
+
+ 流程名*必填
+
+
+
+ 模板图标
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
- 模板分组(支持输入自定义分组)
-
-
-
-
-
+
+ 模板分组(支持输入自定义分组)
+
+
+
+
+
+
@@ -111,13 +113,20 @@ Vue.component("workflow-basic-info", {
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
+ case 'dataValidate':
+ await this.dataValidate();
+ break;
default:
console.error("[doUiAction] uiActionId not find", {uiActionId});
break;
}
},
- setIcon(icon){
- this.$set(this.workflowInfo, 'taskTemplateIcon', icon)
+ async dataValidate(){
+ if (await this.$refs.basicInfoForm.validate()) {
+ return true;
+ }
+ await window.vtoast.fail("请完善基础信息!");
+ throw new Error("请完善基础信息!")
}
}
})
diff --git a/app/view/component/workflowEditorDrawer.html b/app/view/component/workflowEditorDrawer.html
index 16b4f08..f79dd05 100644
--- a/app/view/component/workflowEditorDrawer.html
+++ b/app/view/component/workflowEditorDrawer.html
@@ -45,7 +45,7 @@
-
+
@@ -55,7 +55,7 @@
-
+
@@ -125,6 +125,11 @@ Vue.component("workflow-editor-drawer", {
step: 1
}
},
+ watch:{
+ step(newVal, oldVal){
+ console.log('step', newVal, oldVal);
+ }
+ },
computed: {
isMobile() {
return window.innerWidth < 600;
@@ -154,6 +159,7 @@ Vue.component("workflow-editor-drawer", {
break;
case 'createItem':
await this.confirmCreateItemDialog();
+ await this.prepareValidate();
await this.prepareFormSubmitData();
await this.doCreateItem();
await this.syncUpdateFormObj();
@@ -161,6 +167,7 @@ Vue.component("workflow-editor-drawer", {
break;
case 'updateItem':
await this.confirmUpdateItemDialog();
+ await this.prepareValidate();
await this.prepareFormSubmitData();
await this.doUpdateItem();
await this.syncUpdateFormObj();
@@ -258,7 +265,6 @@ Vue.component("workflow-editor-drawer", {
},
// -- <<<<<<<<<<<<< 获取数据 --------------------
// -- constantObj 数据构建 >>>>>>>>>>> ---------------
-
buildConstantWorkflowConfig() {
if (!this.formObj.workflowConfig) return;
this.$refs.processFlow.doUiAction('complexModeInit');
@@ -286,19 +292,23 @@ Vue.component("workflow-editor-drawer", {
await this.prepareFormObj();
this.hideLoading();
},
+
hideLoading() {
setTimeout(() => {
this.loading = false;
}, 300)
},
- // TODO: 检验数据
+
prepareValidate(){
+ const { id, workflowId, workflowInfo, workflowForm } = this.formObj;
var submitAble = false
- // 判断info的数据
- // 判断form的数据
+
+ // 判断info的数据 ==>
+ this.$refs.basicInfo.doUiAction('dataValidate')
+ // 判断form的数据 ==> 判断单选多选是否有选项
+ this.$refs.tplFormDesign.doUiAction('dataValidate')
// 判断流程图的数据
- // 只允许在第一个节点设置条件节点
- // 不允许节点孤立
+ this.$refs.processFlow.doUiAction('dataValidate')
},
prepareFormSubmitData() {