审批流保存数据检验
This commit is contained in:
1 parent
7e094cd83e
commit
9bec3c6de0
8 files changed
+169
-30
No files matched your search
@@ -219,7 +219,7 @@ Vue.component("create-task-drawer", {
|
|||||||
}
|
}
|
||||||
formObj.workflowConfig = formObj.workflowConfig ? formObj.workflowConfig : null;
|
formObj.workflowConfig = formObj.workflowConfig ? formObj.workflowConfig : null;
|
||||||
formObj.workflowForm = formObj.workflowForm ? (typeof formObj.workflowForm == 'string'? JSON.parse(formObj.workflowForm): formObj.workflowForm) : [];
|
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.defaultWorkflowConfig = _.cloneDeep(formObj.workflowConfig);
|
||||||
this.defaultWorkflowForm = _.cloneDeep(formObj.workflowForm);
|
this.defaultWorkflowForm = _.cloneDeep(formObj.workflowForm);
|
||||||
this.defaultWorkflowConfig.nodeList.forEach(node =>{
|
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() {
|
async prepareCreateValidate() {
|
||||||
// 检查必填是否已填 TODO:注意文件
|
|
||||||
this.taskData.workflowForm.forEach(f => {
|
this.taskData.workflowForm.forEach(f => {
|
||||||
|
if(f.type == 'time' && !this.isValidDateTime(f.answer)){
|
||||||
|
window.vtoast.fail("时间日期格式不正确!")
|
||||||
|
throw new Error("时间日期格式不正确!")
|
||||||
|
}
|
||||||
|
// 检查必填是否已填
|
||||||
if(f.isRequire){
|
if(f.isRequire){
|
||||||
if(!f.answer || f.answer && f.answer.length == 0){
|
if(!f.answer || f.answer && f.answer.length == 0){
|
||||||
window.vtoast.fail("请完善表单信息")
|
window.vtoast.fail("请完善表单信息")
|
||||||
@@ -535,13 +547,14 @@ Vue.component("create-task-drawer", {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async confirmCreateWorkDialog() {
|
async confirmCreateWorkDialog() {
|
||||||
if (await window.confirmDialog({ title: "新建任务", content: "确定新建任务吗?" }) === false) {
|
if (await window.confirmDialog({ title: "新建任务", content: "确定新建任务吗?" }) === false) {
|
||||||
throw new Error("[confirmCreateFormDialog] 否");
|
throw new Error("[confirmCreateFormDialog] 否");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
prepareDoWorkItem() {
|
prepareDoWorkItem() {
|
||||||
const { workflowInfo, workflowForm, workflowConfig, workflowName, taskTemplateGroup, } = this.taskData
|
const { workflowInfo, workflowForm, workflowConfig, workflowName, taskTemplateGroup, } = this.taskData
|
||||||
var curNode = this.curWorkflow[0]
|
var curNode = this.curWorkflow[0]
|
||||||
|
|||||||
@@ -353,7 +353,8 @@
|
|||||||
return window.innerWidth < 600;
|
return window.innerWidth < 600;
|
||||||
},
|
},
|
||||||
prioritys(){
|
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 [
|
return [
|
||||||
{ text: '默认条件', priority: -1 },
|
{ text: '默认条件', priority: -1 },
|
||||||
..._.times(num - 1, i => {
|
..._.times(num - 1, i => {
|
||||||
|
|||||||
@@ -266,6 +266,9 @@ Vue.component("process-flow", {
|
|||||||
case 'deleteNodeBySimple':
|
case 'deleteNodeBySimple':
|
||||||
await this.deleteNodeBySimple(uiActionData);
|
await this.deleteNodeBySimple(uiActionData);
|
||||||
break;
|
break;
|
||||||
|
case 'dataValidate':
|
||||||
|
await this.dataValidate();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.error("[doUiAction] uiActionId not find", {uiActionId});
|
console.error("[doUiAction] uiActionId not find", {uiActionId});
|
||||||
break;
|
break;
|
||||||
@@ -390,10 +393,9 @@ Vue.component("process-flow", {
|
|||||||
},
|
},
|
||||||
// 切换展示模式
|
// 切换展示模式
|
||||||
changeDisplayMode(displayMode){
|
changeDisplayMode(displayMode){
|
||||||
var changeAble = true
|
var changeAble = true,
|
||||||
var changeText = ""
|
changeText = "";
|
||||||
var lineList = this.workflowConfig.lineList
|
const {lineList, nodeList} = this.workflowConfig;
|
||||||
var nodeList = this.workflowConfig.nodeList
|
|
||||||
|
|
||||||
if(displayMode == 'simple'){
|
if(displayMode == 'simple'){
|
||||||
// 检查是否有多个开始节点或结束节点
|
// 检查是否有多个开始节点或结束节点
|
||||||
@@ -787,8 +789,96 @@ Vue.component("process-flow", {
|
|||||||
*/
|
*/
|
||||||
parseBusinessDataTologicFlowData() {
|
parseBusinessDataTologicFlowData() {
|
||||||
return {
|
return {
|
||||||
nodes: this.workflowConfig.nodeList.map(node => node).filter(node => node != null),
|
nodes: this.workflowConfig.nodeList.filter(node => node != null),
|
||||||
edges: this.workflowConfig.lineList.map(line => line).filter(line => line != 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
v-model="formItem.answer"
|
v-model="formItem.answer"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</template>
|
</template>
|
||||||
<v-date-picker no-title scrollable></v-date-picker>
|
<v-date-picker no-title scrollable v-model="formItem.answer"></v-date-picker>
|
||||||
</v-menu>
|
</v-menu>
|
||||||
</v-list-item-content>
|
</v-list-item-content>
|
||||||
|
|
||||||
|
|||||||
@@ -260,6 +260,17 @@ Vue.component("form-item-list-generator", {
|
|||||||
return this.formItemList;
|
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("存在选择题没有选项!")
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -38,19 +38,24 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
// 每个属性值发生变化就会调用这个函数
|
|
||||||
form(newVal, oldVal) {
|
|
||||||
this.saveData(newVal)
|
|
||||||
},
|
|
||||||
// 深度监听 属性的变化
|
|
||||||
deep: true
|
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
},
|
},
|
||||||
mounted() {},
|
mounted() {},
|
||||||
methods: {
|
methods: {
|
||||||
saveData(newVal) {
|
async doUiAction(uiActionId, uiActionData) {
|
||||||
// this.$emit('change-structure', this.form);
|
switch (uiActionId) {
|
||||||
|
case 'dataValidate':
|
||||||
|
await this.dataValidate();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.error("[doUiAction] uiActionId not find", {uiActionId});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dataValidate(){
|
||||||
|
this.$refs.formItemListGenerator.dataValidate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<template id="workflow-basic-info">
|
<template id="workflow-basic-info">
|
||||||
<div class="workflow-basic-info-container">
|
<div class="workflow-basic-info-container">
|
||||||
|
<v-form ref="basicInfoForm" lazy-validation>
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col cols="12" sm="12" md="12" xl="12">
|
<v-col cols="12" sm="12" md="12" xl="12">
|
||||||
<span class="jh-input-label">流程名<span class="red--text text--accent-2 ml-1">*必填</span></span>
|
<span class="jh-input-label">流程名<span class="red--text text--accent-2 ml-1">*必填</span></span>
|
||||||
@@ -45,7 +46,7 @@
|
|||||||
<div class="d-flex flex-wrap">
|
<div class="d-flex flex-wrap">
|
||||||
<div
|
<div
|
||||||
v-for="icon in materialDesignIcons"
|
v-for="icon in materialDesignIcons"
|
||||||
:class="`item-icon pa-1 ${workflowInfo.taskTemplateIcon == icon && 'green'}`"
|
:class="`item-icon pa-1 ${workflowInfo.taskTemplateIcon == icon && 'grey lighten-2'}`"
|
||||||
@click="workflowInfo.taskTemplateIcon = icon"
|
@click="workflowInfo.taskTemplateIcon = icon"
|
||||||
>
|
>
|
||||||
<v-img
|
<v-img
|
||||||
@@ -73,6 +74,7 @@
|
|||||||
</v-text-field>
|
</v-text-field>
|
||||||
</v-col> -->
|
</v-col> -->
|
||||||
</v-row>
|
</v-row>
|
||||||
|
</v-form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -111,13 +113,20 @@ Vue.component("workflow-basic-info", {
|
|||||||
methods: {
|
methods: {
|
||||||
async doUiAction(uiActionId, uiActionData) {
|
async doUiAction(uiActionId, uiActionData) {
|
||||||
switch (uiActionId) {
|
switch (uiActionId) {
|
||||||
|
case 'dataValidate':
|
||||||
|
await this.dataValidate();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.error("[doUiAction] uiActionId not find", {uiActionId});
|
console.error("[doUiAction] uiActionId not find", {uiActionId});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setIcon(icon){
|
async dataValidate(){
|
||||||
this.$set(this.workflowInfo, 'taskTemplateIcon', icon)
|
if (await this.$refs.basicInfoForm.validate()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
await window.vtoast.fail("请完善基础信息!");
|
||||||
|
throw new Error("请完善基础信息!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
<v-card-text class="pa-0">
|
<v-card-text class="pa-0">
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
<!-- <div class="text-subtitle-2 mb-2">基础信息</div> -->
|
<!-- <div class="text-subtitle-2 mb-2">基础信息</div> -->
|
||||||
<workflow-basic-info :workflow-info="formObj.workflowInfo"></workflow-basic-info>
|
<workflow-basic-info ref="basicInfo" :workflow-info="formObj.workflowInfo"></workflow-basic-info>
|
||||||
</div>
|
</div>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
<v-card-text class="pa-0">
|
<v-card-text class="pa-0">
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
<!-- <div class="text-subtitle-2 mb-2">表单设置</div> -->
|
<!-- <div class="text-subtitle-2 mb-2">表单设置</div> -->
|
||||||
<tpl-form-design :form="formObj.workflowForm" v-if="!loading"></tpl-form-design>
|
<tpl-form-design ref="tplFormDesign" :form="formObj.workflowForm" v-if="!loading"></tpl-form-design>
|
||||||
</div>
|
</div>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -125,6 +125,11 @@ Vue.component("workflow-editor-drawer", {
|
|||||||
step: 1
|
step: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch:{
|
||||||
|
step(newVal, oldVal){
|
||||||
|
console.log('step', newVal, oldVal);
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isMobile() {
|
isMobile() {
|
||||||
return window.innerWidth < 600;
|
return window.innerWidth < 600;
|
||||||
@@ -154,6 +159,7 @@ Vue.component("workflow-editor-drawer", {
|
|||||||
break;
|
break;
|
||||||
case 'createItem':
|
case 'createItem':
|
||||||
await this.confirmCreateItemDialog();
|
await this.confirmCreateItemDialog();
|
||||||
|
await this.prepareValidate();
|
||||||
await this.prepareFormSubmitData();
|
await this.prepareFormSubmitData();
|
||||||
await this.doCreateItem();
|
await this.doCreateItem();
|
||||||
await this.syncUpdateFormObj();
|
await this.syncUpdateFormObj();
|
||||||
@@ -161,6 +167,7 @@ Vue.component("workflow-editor-drawer", {
|
|||||||
break;
|
break;
|
||||||
case 'updateItem':
|
case 'updateItem':
|
||||||
await this.confirmUpdateItemDialog();
|
await this.confirmUpdateItemDialog();
|
||||||
|
await this.prepareValidate();
|
||||||
await this.prepareFormSubmitData();
|
await this.prepareFormSubmitData();
|
||||||
await this.doUpdateItem();
|
await this.doUpdateItem();
|
||||||
await this.syncUpdateFormObj();
|
await this.syncUpdateFormObj();
|
||||||
@@ -258,7 +265,6 @@ Vue.component("workflow-editor-drawer", {
|
|||||||
},
|
},
|
||||||
// -- <<<<<<<<<<<<< 获取数据 --------------------
|
// -- <<<<<<<<<<<<< 获取数据 --------------------
|
||||||
// -- constantObj 数据构建 >>>>>>>>>>> ---------------
|
// -- constantObj 数据构建 >>>>>>>>>>> ---------------
|
||||||
|
|
||||||
buildConstantWorkflowConfig() {
|
buildConstantWorkflowConfig() {
|
||||||
if (!this.formObj.workflowConfig) return;
|
if (!this.formObj.workflowConfig) return;
|
||||||
this.$refs.processFlow.doUiAction('complexModeInit');
|
this.$refs.processFlow.doUiAction('complexModeInit');
|
||||||
@@ -286,19 +292,23 @@ Vue.component("workflow-editor-drawer", {
|
|||||||
await this.prepareFormObj();
|
await this.prepareFormObj();
|
||||||
this.hideLoading();
|
this.hideLoading();
|
||||||
},
|
},
|
||||||
|
|
||||||
hideLoading() {
|
hideLoading() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}, 300)
|
}, 300)
|
||||||
},
|
},
|
||||||
// TODO: 检验数据
|
|
||||||
prepareValidate(){
|
prepareValidate(){
|
||||||
|
const { id, workflowId, workflowInfo, workflowForm } = this.formObj;
|
||||||
var submitAble = false
|
var submitAble = false
|
||||||
// 判断info的数据
|
|
||||||
// 判断form的数据
|
// 判断info的数据 ==>
|
||||||
|
this.$refs.basicInfo.doUiAction('dataValidate')
|
||||||
|
// 判断form的数据 ==> 判断单选多选是否有选项
|
||||||
|
this.$refs.tplFormDesign.doUiAction('dataValidate')
|
||||||
// 判断流程图的数据
|
// 判断流程图的数据
|
||||||
// 只允许在第一个节点设置条件节点
|
this.$refs.processFlow.doUiAction('dataValidate')
|
||||||
// 不允许节点孤立
|
|
||||||
|
|
||||||
},
|
},
|
||||||
prepareFormSubmitData() {
|
prepareFormSubmitData() {
|
||||||
|
|||||||
Reference in new issue
Block a user