Commit 54340b89 by YuleiLan

添加流程创建验证。

parent e72ae80f
<template>
<div>
<div class="panelRow">
<div>{{ i18n['label'] }}</div>
<div><span style="color: red">*</span> {{ i18n['label'] }}</div>
<el-input
style="width:90%; font-size:12px"
:disabled="readOnly"
......@@ -10,7 +10,7 @@
/>
</div>
<div class="panelRow">
<div>顺序:</div>
<div><span style="color: red">*</span> 顺序:</div>
<el-input
style="width:90%; font-size:12px"
:disabled="readOnly"
......
......@@ -4,7 +4,7 @@
<div class="panelBody">
<DefaultDetail :model="model" :on-change="onChange" :read-only="readOnly" />
<div class="panelRow">
<div>属性:</div>
<div><span style="color: red">*</span> 属性:</div>
<el-select
style="width:90%; font-size:12px"
placeholder="选择流转属性"
......
......@@ -19,7 +19,7 @@
</el-select>
</div>
<div class="panelRow">
<div>{{ i18n['handleNode.assignType'] }}</div>
<div><span style="color: red">*</span> {{ i18n['handleNode.assignType'] }}</div>
<el-select
style="width:90%; font-size: 12px"
:placeholder="i18n['handleNode.assignType.placeholder']"
......@@ -34,7 +34,7 @@
</el-select>
</div>
<div v-if="model.assignType === 'person'" class="panelRow">
<div>{{ i18n['handleNode.assignType.person.title'] }}</div>
<div><span style="color: red">*</span> {{ i18n['handleNode.assignType.person.title'] }}</div>
<el-select
style="width:90%; font-size:12px"
:placeholder="i18n['handleNode.assignType.person.placeholder']"
......@@ -64,7 +64,7 @@
</el-select>
</div> -->
<div v-else-if="model.assignType === 'department'" class="panelRow">
<div>{{ i18n['handleNode.assignType.department.title'] }}</div>
<div><span style="color: red">*</span> {{ i18n['handleNode.assignType.department.title'] }}</div>
<el-select
style="width:90%; font-size:12px"
:placeholder="i18n['handleNode.assignType.department.placeholder']"
......@@ -84,7 +84,7 @@
</el-select>
</div>
<div v-else-if="model.assignType === 'variable'" class="panelRow">
<div>{{ i18n['handleNode.assignType.variable.title'] }}</div>
<div><span style="color: red">*</span> {{ i18n['handleNode.assignType.variable.title'] }}</div>
<el-select
v-model.number="model.assignValue"
style="width:90%; font-size:12px"
......
......@@ -19,7 +19,7 @@
</el-select>
</div>
<div class="panelRow">
<div>{{ i18n['userTask.assignType'] }}</div>
<div><span style="color: red">*</span> {{ i18n['userTask.assignType'] }}</div>
<el-select
style="width:90%; font-size: 12px"
:placeholder="i18n['userTask.assignType.placeholder']"
......@@ -34,7 +34,7 @@
</el-select>
</div>
<div v-if="model.assignType === 'person'" class="panelRow">
<div>{{ i18n['userTask.assignType.person.title'] }}</div>
<div><span style="color: red">*</span> {{ i18n['userTask.assignType.person.title'] }}</div>
<el-select
style="width:90%; font-size:12px"
:placeholder="i18n['userTask.assignType.person.placeholder']"
......@@ -64,7 +64,7 @@
</el-select>
</div> -->
<div v-else-if="model.assignType === 'department'" class="panelRow">
<div>{{ i18n['userTask.assignType.department.title'] }}</div>
<div><span style="color: red">*</span> {{ i18n['userTask.assignType.department.title'] }}</div>
<el-select
style="width:90%; font-size:12px"
:placeholder="i18n['userTask.assignType.department.placeholder']"
......@@ -79,7 +79,7 @@
</el-select>
</div>
<div v-else-if="model.assignType === 'variable'" class="panelRow">
<div>{{ i18n['userTask.assignType.variable.title'] }}</div>
<div><span style="color: red">*</span> {{ i18n['userTask.assignType.variable.title'] }}</div>
<el-select
v-model.number="model.assignValue"
style="width:90%; font-size:12px"
......
......@@ -95,6 +95,7 @@ export default {
return {
resizeFunc: () => {},
selectedModel: {},
previous: '',
processModel: {
id: '',
name: '',
......@@ -179,13 +180,48 @@ export default {
}
return data
},
verifyProcess(pv) {
if (pv.label === undefined || pv.label === null || pv.label === '') {
return '标题不能为空'
} else if (pv.sort === undefined || pv.sort === null || pv.sort === '') {
return '顺序不能为空'
}
if (pv.clazz === 'userTask' || pv.clazz === 'receiveTask') {
if (pv.assignType === undefined || pv.assignType === null || pv.assignType === '') {
return '审批节点或处理节点的处理人类型不能为空'
} else if (pv.assignValue === undefined || pv.assignValue === null || pv.assignValue === '' || pv.assignValue.length === 0) {
return '审批节点或处理节点的处理人不能为空'
}
}
if (pv.clazz === 'flow') {
if (pv.flowProperties === undefined || pv.flowProperties === null || pv.flowProperties === '') {
return '流转属性不能为空'
}
}
return ''
},
initEvents() {
this.graph.on('afteritemselected', (items) => {
if (items && items.length > 0) {
if (this.previous !== '') {
// 1. 获取之前的数据
var previousValue = ''
const item = this.graph.findById(this.previous[0])
previousValue = { ...item.getModel() }
var err = this.verifyProcess(previousValue)
if (err !== '') {
this.selectedModel = previousValue
this.$message.error(err)
return
}
}
const item = this.graph.findById(items[0])
this.selectedModel = { ...item.getModel() }
this.previous = items
} else {
this.selectedModel = this.processModel
if (this.previous !== '') {
this.selectedModel = this.processModel
}
}
})
const page = this.$refs['canvas']
......@@ -197,7 +233,12 @@ export default {
window.addEventListener('resize', this.resizeFunc)
},
onItemCfgChange(key, value) {
const items = this.graph.get('selectedItems')
var items = ''
if (this.previous.length !== 0) {
items = [this.previous[0]]
} else {
items = this.graph.get('selectedItems')
}
if (items && items.length > 0) {
const item = this.graph.findById(items[0])
if (this.graph.executeCommand) {
......
......@@ -327,8 +327,40 @@ export default {
})
})
},
submitForm(formName) {
verifyProcess() {
this.ruleForm.structure = this.$refs.wfd.graph.save()
console.log(this.ruleForm.structure)
for (var r of this.ruleForm.structure.nodes) {
if (r.sort === undefined || r.sort === null || r.sort === '') {
return '流程节点顺序不能为空'
} else if (r.label === undefined || r.label === null || r.label === '') {
return '流程节点标题不能为空'
}
if (r.clazz === 'userTask' || r.clazz === 'receiveTask') {
if (r.assignType === undefined || r.assignType === null || r.assignType === '') {
return '审批节点或处理节点的处理人类型不能为空'
} else if (r.assignValue === undefined || r.assignValue === null || r.assignValue === '' || r.assignValue.length === 0) {
return '审批节点或处理节点的处理人不能为空'
}
}
}
for (var e of this.ruleForm.structure.edges) {
if (e.sort === undefined || e.sort === null || e.sort === '') {
return '流转顺序不能为空'
} else if (e.label === undefined || e.label === null || e.label === '') {
return '流转标题不能为空'
} else if (e.flowProperties === undefined || e.flowProperties === null || e.flowProperties === '') {
return '流转属性不能为空'
}
}
return ''
},
submitForm(formName) {
var r = this.verifyProcess()
if (r !== '') {
this.$message.error(r)
return
}
this.$refs[formName].validate((valid) => {
if (valid) {
if (this.ruleForm.structure.nodes.length > 0 && this.ruleForm.structure.edges.length > 0) {
......@@ -343,6 +375,12 @@ export default {
})
},
editForm(formName) {
var r = this.verifyProcess()
console.log(r)
if (r !== '') {
this.$message.error(r)
return
}
this.$refs[formName].validate((valid) => {
if (valid) {
var structureValue = this.$refs.wfd.graph.save()
......
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 sign in to comment