fix: 表单配置group时,发起流程报错的问题

saber
ssc 5 years ago
parent a7d32ce6ed
commit aba7017566
  1. 59
      src/views/plugin/workflow/process/components/detail.vue
  2. 51
      src/views/plugin/workflow/process/components/form.vue

@ -11,7 +11,7 @@
name="first"> name="first">
<el-card shadow="never"> <el-card shadow="never">
<div ref="printBody"> <div ref="printBody">
<avue-form v-if="option && option.column && option.column.length > 0" <avue-form v-if="option && ((option.column && option.column.length > 0) || (option.group && option.group.length > 0))"
v-model="form" v-model="form"
ref="form" ref="form"
:option="option"> :option="option">
@ -79,7 +79,7 @@
v-loading="submitLoading" v-loading="submitLoading"
@click="handleCompleteTask(false)">驳回</el-button> @click="handleCompleteTask(false)">驳回</el-button>
<el-button v-if="buttonList.find(b => b.key == 'wf_transfer')" <el-button v-if="buttonList.find(b => b.key == 'wf_transfer')"
type="warning" type="primary"
size="medium" size="medium"
v-loading="submitLoading" v-loading="submitLoading"
@click="handleUserSelect('transfer')">转办</el-button> @click="handleUserSelect('transfer')">转办</el-button>
@ -89,7 +89,7 @@
v-loading="submitLoading" v-loading="submitLoading"
@click="handleUserSelect('delegate')">委托</el-button> @click="handleUserSelect('delegate')">委托</el-button>
<el-button v-if="buttonList.find(b => b.key == 'wf_print')" <el-button v-if="buttonList.find(b => b.key == 'wf_print')"
type="warning" type="info"
size="medium" size="medium"
v-loading="submitLoading" v-loading="submitLoading"
@click="handlePrint()">打印</el-button> @click="handlePrint()">打印</el-button>
@ -202,19 +202,46 @@ export default {
option.menuBtn = false option.menuBtn = false
if (status != 'todo') option.detail = true if (status != 'todo') option.detail = true
else { else {
const arr = [] const columnArr = []
const groupArr = []
const vars = [] const vars = []
taskForm.forEach(task => { const { column, group } = option
const column = option.column.find(c => c.prop == task.id) if (column && column.length > 0) { // column
if (task.readable && column) { column.forEach(col => {
if (!task.writable) { const c = taskForm.find(s => s.id == col.prop)
column.readonly = true if (c && c.readable) {
column.disabled = true if (!c.writable) {
} else vars.push(column.prop) col.readonly = true
} col.disabled = true
arr.push(column) delete col.rules
}) } else vars.push(col.prop)
option.column = arr columnArr.push(col)
}
})
}
if (group && group.length > 0) { // group
group.forEach(gro => {
if (gro.column && gro.column.length > 0) {
const groupColumnArr = []
gro.column.forEach(col => {
const c = taskForm.find(s => s.id == col.prop)
if (c && c.readable) {
if (!c.writable) {
col.readonly = true
col.disabled = true
delete col.rules
} else vars.push(col.prop)
groupColumnArr.push(col)
}
})
gro.column = groupColumnArr
}
if (gro.column.length > 0) groupArr.push(gro)
})
}
option.column = columnArr
option.group = groupArr
this.vars = vars this.vars = vars
} }
@ -271,6 +298,8 @@ export default {
}).catch(() => { }).catch(() => {
this.submitLoading = false this.submitLoading = false
}) })
} else {
this.submitLoading = false
} }
}) })
}, },

@ -3,7 +3,7 @@
<avue-title style="margin-bottom: 20px; " <avue-title style="margin-bottom: 20px; "
:styles="{fontSize: '20px'}" :styles="{fontSize: '20px'}"
:value="process.name"></avue-title> :value="process.name"></avue-title>
<avue-form v-if="option && option.column && option.column.length > 0" <avue-form v-if="option && ((option.column && option.column.length > 0) || (option.group && option.group.length > 0))"
v-model="form" v-model="form"
:option="option" :option="option"
@submit="handleSubmit"> @submit="handleSubmit">
@ -48,18 +48,45 @@ export default {
const option = eval('(' + form + ')') const option = eval('(' + form + ')')
// option.menuBtn = false // option.menuBtn = false
const arr = [] const columnArr = []
startForm.forEach(s => { const groupArr = []
const column = option.column.find(c => c.prop == s.id) const { column, group } = option
if (s.readable && column) { if (column && column.length > 0) { // column
if (!s.writable) { column.forEach(col => {
column.readonly = true const c = startForm.find(s => s.id == col.prop)
column.disabled = true if (c && c.readable) {
if (!c.writable) {
col.readonly = true
col.disabled = true
delete col.rules
}
columnArr.push(col)
} }
} })
arr.push(column) }
}) if (group && group.length > 0) { // group
option.column = arr group.forEach(gro => {
if (gro.column && gro.column.length > 0) {
const groupColumnArr = []
gro.column.forEach(col => {
const c = startForm.find(s => s.id == col.prop)
if (c && c.readable) {
if (!c.writable) {
col.readonly = true
col.disabled = true
delete col.rules
}
groupColumnArr.push(col)
}
})
gro.column = groupColumnArr
}
if (gro.column.length > 0) groupArr.push(gro)
})
}
option.column = columnArr
option.group = groupArr
this.option = option this.option = option
} }

Loading…
Cancel
Save