feat: 根据processDefKey发起流程

master
ssc 3 years ago
parent d5a9e9e7f3
commit d42de6f1c5
  1. 11
      src/api/plugin/workflow/process.js
  2. 100
      src/views/plugin/workflow/mixins/ex-form.js

@ -173,6 +173,17 @@ export const startProcess = (data) => {
}) })
} }
/**
* 发起流程 - 根据流程定义key
*/
export const startProcessByKey = (data) => {
return request({
url: `${prefix}/startProcessByKey`,
method: 'post',
data
})
}
/** /**
* 任务审批 * 任务审批
*/ */

@ -1,4 +1,4 @@
import { getFormByProcessId, getFormByProcessDefKey, startProcess, detail, completeTask, transferTask, delegateTask, rollbackTask, terminateProcess, addMultiInstance, withdrawTask } from '@/api/plugin/workflow/process' import { getFormByProcessId, getFormByProcessDefKey, startProcess, startProcessByKey, detail, completeTask, transferTask, delegateTask, rollbackTask, terminateProcess, addMultiInstance, withdrawTask } from '@/api/plugin/workflow/process'
import Layout from '@/page/index/' import Layout from '@/page/index/'
import defaultValues from './default-values' import defaultValues from './default-values'
@ -37,31 +37,31 @@ export default {
processDefKey processDefKey
})).toString('base64') })).toString('base64')
if (formKey && formKey.startsWith('wf_ex_')) { return new Promise((resolve) => {
if (formUrl) { // 配置了自定义路由 if (formKey && formKey.startsWith('wf_ex_')) {
this.$router.push(formUrl + `?p=${param}`) if (formUrl) { // 配置了自定义路由
} else { // 动态添加路由 this.$router.push(formUrl + `?p=${param}`)
this.$router.addRoutes([{ } else { // 动态添加路由
path: `/workflow/process/external`, this.$router.addRoutes([{
component: Layout, path: `/workflow/process/external`,
children: [{ component: Layout,
path: `${formKey.substring(6)}/${type}`, children: [{
name: type == 'start' ? '发起流程' : '流程详情', path: `${formKey.substring(6)}/${type}`,
component: () => name: type == 'start' ? '发起流程' : '流程详情',
import( /* webpackChunkName: "views" */ `@/views/plugin/workflow/process/external/${formKey.substring(6)}/${type}.vue`), component: () =>
}] import( /* webpackChunkName: "views" */ `@/views/plugin/workflow/process/external/${formKey.substring(6)}/${type}.vue`),
}]) }]
this.$router.push(`/workflow/process/external/${formKey.substring(6)}/${type}?p=${param}`) }])
} this.$router.push(`/workflow/process/external/${formKey.substring(6)}/${type}?p=${param}`)
} else { }
if (async) {
return new Promise((resolve) => {
resolve({ row, type, param })
})
} else { } else {
this.$router.push(`/workflow/process/${type}/${param}`) if (async) {
resolve({ row, type, param })
} else {
this.$router.push(`/workflow/process/${type}/${param}`)
}
} }
} })
}, },
// 根据可读可写,过滤avue column // 根据可读可写,过滤avue column
filterAvueColumn(column, taskForm, isExForm = false, props = { label: 'label', prop: 'prop' }) { filterAvueColumn(column, taskForm, isExForm = false, props = { label: 'label', prop: 'prop' }) {
@ -74,15 +74,8 @@ export default {
column.forEach(col => { column.forEach(col => {
let c = taskForm.find(s => s.id == col[props.prop]) let c = taskForm.find(s => s.id == col[props.prop])
if (c && c.readable) { if (c && c.readable) {
// /**
// * @deprecated 与节点配置可读可写冲突
// */
// if (!c) { // 未重新点击节点设计表单字段可读可写。
// if ((this.process.isOwner && this.process.status == 'todo') || !this.process.hasOwnProperty('isOwner')) c = { readable: true, writable: true }
// else c = { readable: true, writable: false }
// }
if (!isExForm) { // 非外置表单 处理事件 if (!isExForm) { // 非外置表单 处理事件
let event = ['change', 'blur', 'click', 'focus'] let event = ['change', 'blur', 'click', 'focus', 'lazyLoad']
event.forEach(e => { event.forEach(e => {
if (col[e]) col[e] = eval((col[e] + '').replace(/this/g, '_this')) if (col[e]) col[e] = eval((col[e] + '').replace(/this/g, '_this'))
}) })
@ -168,9 +161,48 @@ export default {
form = { ...form, copyUser, assignee } form = { ...form, copyUser, assignee }
} }
if (valid) { if (valid) {
startProcess(form).then(() => { startProcess(form).then(res => {
if (isExForm === true) {
resolve(res, done)
} else {
this.$message.success("发起成功")
this.handleCloseTag('/plugin/workflow/process/send')
done()
this.loading = false
}
}).catch(() => {
done()
this.loading = false
})
} else {
done()
this.loading = false
if (msg) {
const key = Object.keys(msg)[0]
const rules = msg[key]
this.$message.error(rules.map(r => r.message).join(' | '))
}
}
})
})
},
/**
* 发起流程
* @param form {"processDefKey": "流程定义key", ...表单自定义字段变量}
*/
handleStartProcessByKey(isExForm = false) {
return new Promise((resolve) => {
this.loading = true
this.$refs.form.validate((valid, done, msg) => {
let form = this.deepClone(this.form)
if (this.$refs.examineForm && this.$refs.examineForm.examineForm) {
const { copyUser, assignee } = this.$refs.examineForm.examineForm
form = { ...form, copyUser, assignee }
}
if (valid) {
startProcessByKey(form).then(res => {
if (isExForm === true) { if (isExForm === true) {
resolve(done) resolve(res, done)
} else { } else {
this.$message.success("发起成功") this.$message.success("发起成功")
this.handleCloseTag('/plugin/workflow/process/send') this.handleCloseTag('/plugin/workflow/process/send')

Loading…
Cancel
Save