feat: 节点独立表单配置校验

saber
ssc 4 years ago
parent b5a577bee6
commit 08a76360bf
  1. 58
      src/views/plugin/workflow/design/index.vue

@ -198,10 +198,6 @@ export default {
label: '表单',
prop: 'formKey',
type: 'select',
dicUrl: '/api/blade-workflow/design/form/list?size=-1&status=1',
dicFormatter: (data) => {
return data.data.records
},
props: {
label: 'name',
value: 'formKey'
@ -302,6 +298,7 @@ export default {
this.getButtonList()
// this.getUserList()
this.getUserListV2()
this.getFormList()
},
methods: {
handleNextStep() {
@ -319,11 +316,9 @@ export default {
exFormKey, column
})
} else if (formType == 3) { //
this.$axios.get('/api/blade-workflow/design/form/list?size=-1&status=1').then(res => {
this.$set(this.step2.option, 'indepForm', {
mode: 'indep',
list: res.data.data.records
})
this.$set(this.step2.option, 'indepForm', {
mode: 'indep',
list: this.formList
})
}
this.step++
@ -332,6 +327,28 @@ export default {
})
break;
case 1:
if (this.step1.form.formType == 3) { //
const registry = this.$refs.bpmn2.getElementRegistry().getAll()
let errorList = []
registry.forEach(ele => {
this.validateIndepFormOption(ele, errorList)
})
if (errorList.length > 0) {
errorList = new Set(errorList)
let message = ''
errorList.forEach(err => {
const { businessObject } = err
const { id, name } = businessObject
message += `<p>${name || id} 节点未正确配置表单</p>`
})
this.$message({
type: 'error',
dangerouslyUseHTMLString: true,
message
})
return
}
}
this.$refs.bpmn2.getData('xml').then(data => {
this.$set(this.step2.option, 'xml', data)
this.$set(this.step3.option, 'xml', data)
@ -396,6 +413,23 @@ export default {
})
}
},
validateIndepFormOption(element, errorList) {
const { type, businessObject, children } = element
const indepFormKey = 'flowable:IndepFormKey'
const indepFormSummary = 'flowable:IndepFormSummary'
if ('bpmn:StartEvent' == type) {
const extensionElements = businessObject.extensionElements
if (extensionElements && extensionElements.values && extensionElements.values.length > 0) {
const summary = extensionElements.values.find(v => v.$type == indepFormSummary)
if (!extensionElements.values.find(v => v.$type == indepFormKey) && (!summary || summary == '0')) errorList.push(element)
} else errorList.push(element)
} else if ('bpmn:UserTask' == type) {
const summary = businessObject['indepFormSummary']
if (!businessObject['indepFormKey'] && (!summary || summary == '0')) errorList.push(element)
} else if ('bpmn:SubProcess' == type) {
children.forEach(ele => this.validateIndepFormOption(ele, errorList))
}
},
getButtonList() {
buttonList(1, 99, { status: 1 }).then(res => {
const list = res.data.data.records.map(l => {
@ -408,6 +442,12 @@ export default {
this.$set(this.step2.option, 'button', list)
})
},
getFormList() {
this.$axios.get('/api/blade-workflow/design/form/list?size=-1&status=1').then(res => {
this.formList = res.data.data.records
this.findObject(this.step1.option.group, 'formKey').dicData = this.formList
})
},
getUserList() {
const userConfig = {
leftColumns: [{

Loading…
Cancel
Save