Commit bd6a1dcc645ecd9464152eb6acd9c3bf67a1bef1
1 parent
3702fb0c
bpm:流程详情的审批表单
Showing
2 changed files
with
35 additions
and
27 deletions
yudao-ui-admin-vue3/src/views/bpm/processInstance/detail.vue
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | </template> |
| 13 | 13 | <el-col :span="16" :offset="6"> |
| 14 | 14 | <el-form |
| 15 | - :ref="'form' + index" | |
| 15 | + :ref="auditFormRefs" | |
| 16 | 16 | :model="auditForms[index]" |
| 17 | 17 | :rules="auditRule" |
| 18 | 18 | label-width="100px" |
| ... | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | </el-form-item> |
| 23 | 23 | <el-form-item label="流程发起人" v-if="processInstance && processInstance.startUser"> |
| 24 | 24 | {{ processInstance.startUser.nickname }} |
| 25 | - <el-tag type="info" size="mini">{{ processInstance.startUser.deptName }}</el-tag> | |
| 25 | + <el-tag type="info" size="small">{{ processInstance.startUser.deptName }}</el-tag> | |
| 26 | 26 | </el-form-item> |
| 27 | 27 | <el-form-item label="审批建议" prop="reason"> |
| 28 | 28 | <el-input |
| ... | ... | @@ -137,6 +137,33 @@ const auditRule = reactive({ |
| 137 | 137 | reason: [{ required: true, message: '审批建议不能为空', trigger: 'blur' }] |
| 138 | 138 | }) |
| 139 | 139 | |
| 140 | +// 处理审批通过和不通过的操作 | |
| 141 | +const handleAudit = async (task, pass) => { | |
| 142 | + // 1.1 获得对应表单 | |
| 143 | + const index = runningTasks.value.indexOf(task) | |
| 144 | + // const auditFormRef = ref<any>([]).value.get(index) | |
| 145 | + // 1.2 校验表单 | |
| 146 | + // const elForm = unref(auditFormRef) | |
| 147 | + // if (!elForm) return | |
| 148 | + // const valid = await auditFormRef.validate() | |
| 149 | + // if (!valid) return | |
| 150 | + | |
| 151 | + // 2.1 提交审批 | |
| 152 | + const data = { | |
| 153 | + id: task.id, | |
| 154 | + reason: auditForms.value[index].reason | |
| 155 | + } | |
| 156 | + if (pass) { | |
| 157 | + await TaskApi.approveTask(data) | |
| 158 | + message.success('审批通过成功') | |
| 159 | + } else { | |
| 160 | + await TaskApi.rejectTask(data) | |
| 161 | + message.success('审批不通过成功') | |
| 162 | + } | |
| 163 | + // 2.2 加载最新数据 | |
| 164 | + getDetail() | |
| 165 | +} | |
| 166 | + | |
| 140 | 167 | // ========== 申请信息 ========== |
| 141 | 168 | import { setConfAndFields2 } from '@/utils/formCreate' |
| 142 | 169 | import { ApiAttrs } from '@form-create/element-ui/types/config' |
| ... | ... | @@ -187,6 +214,10 @@ const getTimelineItemType = (item) => { |
| 187 | 214 | |
| 188 | 215 | // ========== 初始化 ========== |
| 189 | 216 | onMounted(() => { |
| 217 | + getDetail() | |
| 218 | +}) | |
| 219 | + | |
| 220 | +const getDetail = () => { | |
| 190 | 221 | // 1. 获得流程实例相关 |
| 191 | 222 | processInstanceLoading.value = true |
| 192 | 223 | ProcessInstanceApi.getProcessInstanceApi(id) |
| ... | ... | @@ -269,7 +300,7 @@ onMounted(() => { |
| 269 | 300 | .finally(() => { |
| 270 | 301 | tasksLoad.value = false |
| 271 | 302 | }) |
| 272 | -}) | |
| 303 | +} | |
| 273 | 304 | </script> |
| 274 | 305 | |
| 275 | 306 | <style lang="scss"> | ... | ... |
yudao-ui-admin-vue3/src/views/bpm/processInstance/detail2.vue
| ... | ... | @@ -146,30 +146,7 @@ export default { |
| 146 | 146 | }) |
| 147 | 147 | }, |
| 148 | 148 | |
| 149 | - /** 处理审批通过和不通过的操作 */ | |
| 150 | - handleAudit (task, pass) { | |
| 151 | - const index = this.runningTasks.indexOf(task) | |
| 152 | - this.$refs['form' + index][0].validate(valid => { | |
| 153 | - if (!valid) { | |
| 154 | - return | |
| 155 | - } | |
| 156 | - const data = { | |
| 157 | - id: task.id, | |
| 158 | - reason: this.auditForms[index].reason | |
| 159 | - } | |
| 160 | - if (pass) { | |
| 161 | - approveTask(data).then(response => { | |
| 162 | - this.$modal.msgSuccess("审批通过成功!") | |
| 163 | - this.getDetail() // 获得最新详情 | |
| 164 | - }) | |
| 165 | - } else { | |
| 166 | - rejectTask(data).then(response => { | |
| 167 | - this.$modal.msgSuccess("审批不通过成功!") | |
| 168 | - this.getDetail() // 获得最新详情 | |
| 169 | - }) | |
| 170 | - } | |
| 171 | - }) | |
| 172 | - }, | |
| 149 | + | |
| 173 | 150 | /** 处理转派审批人 */ |
| 174 | 151 | handleUpdateAssignee (task) { |
| 175 | 152 | // 设置表单 | ... | ... |