BPM:新增流程的重新发起

This commit is contained in:
YunaiV 2024-03-21 00:34:10 +08:00
parent 0d4b6f6344
commit 05b408d107
3 changed files with 49 additions and 19 deletions

View File

@ -243,7 +243,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
}, },
children: [ children: [
{ {
path: '/manager/form/edit', path: 'manager/form/edit',
component: () => import('@/views/bpm/form/editor/index.vue'), component: () => import('@/views/bpm/form/editor/index.vue'),
name: 'BpmFormEditor', name: 'BpmFormEditor',
meta: { meta: {
@ -255,7 +255,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
} }
}, },
{ {
path: '/manager/model/edit', path: 'manager/model/edit',
component: () => import('@/views/bpm/model/editor/index.vue'), component: () => import('@/views/bpm/model/editor/index.vue'),
name: 'BpmModelEditor', name: 'BpmModelEditor',
meta: { meta: {
@ -267,7 +267,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
} }
}, },
{ {
path: '/manager/simple/workflow/model/edit', path: 'manager/simple/workflow/model/edit',
component: () => import('@/views/bpm/simpleWorkflow/index.vue'), component: () => import('@/views/bpm/simpleWorkflow/index.vue'),
name: 'SimpleWorkflowDesignEditor', name: 'SimpleWorkflowDesignEditor',
meta: { meta: {
@ -279,7 +279,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
} }
}, },
{ {
path: '/manager/definition', path: 'manager/definition',
component: () => import('@/views/bpm/definition/index.vue'), component: () => import('@/views/bpm/definition/index.vue'),
name: 'BpmProcessDefinition', name: 'BpmProcessDefinition',
meta: { meta: {
@ -291,7 +291,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
} }
}, },
{ {
path: '/process-instance/detail', path: 'process-instance/detail',
component: () => import('@/views/bpm/processInstance/detail/index.vue'), component: () => import('@/views/bpm/processInstance/detail/index.vue'),
name: 'BpmProcessInstanceDetail', name: 'BpmProcessInstanceDetail',
meta: { meta: {
@ -299,11 +299,11 @@ const remainingRouter: AppRouteRecordRaw[] = [
hidden: true, hidden: true,
canTo: true, canTo: true,
title: '流程详情', title: '流程详情',
activeMenu: 'bpm/processInstance/detail' activeMenu: '/bpm/task/my'
} }
}, },
{ {
path: '/bpm/oa/leave/create', path: 'oa/leave/create',
component: () => import('@/views/bpm/oa/leave/create.vue'), component: () => import('@/views/bpm/oa/leave/create.vue'),
name: 'OALeaveCreate', name: 'OALeaveCreate',
meta: { meta: {
@ -315,7 +315,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
} }
}, },
{ {
path: '/bpm/oa/leave/detail', path: 'oa/leave/detail',
component: () => import('@/views/bpm/oa/leave/detail.vue'), component: () => import('@/views/bpm/oa/leave/detail.vue'),
name: 'OALeaveDetail', name: 'OALeaveDetail',
meta: { meta: {

View File

@ -51,6 +51,7 @@
<form-create <form-create
:rule="detailForm.rule" :rule="detailForm.rule"
v-model:api="fApi" v-model:api="fApi"
v-model="detailForm.value"
:option="detailForm.option" :option="detailForm.option"
@submit="submitForm" @submit="submitForm"
/> />
@ -67,12 +68,16 @@ import { setConfAndFields2 } from '@/utils/formCreate'
import type { ApiAttrs } from '@form-create/element-ui/types/config' import type { ApiAttrs } from '@form-create/element-ui/types/config'
import ProcessInstanceBpmnViewer from '../detail/ProcessInstanceBpmnViewer.vue' import ProcessInstanceBpmnViewer from '../detail/ProcessInstanceBpmnViewer.vue'
import { CategoryApi } from '@/api/bpm/category' import { CategoryApi } from '@/api/bpm/category'
import { useTagsViewStore } from '@/store/modules/tagsView'
defineOptions({ name: 'BpmProcessInstanceCreate' }) defineOptions({ name: 'BpmProcessInstanceCreate' })
const router = useRouter() // const route = useRoute() //
const { push, currentRoute } = useRouter() //
const message = useMessage() // const message = useMessage() //
const { delView } = useTagsViewStore() //
const processInstanceId = route.query.processInstanceId
const loading = ref(true) // const loading = ref(true) //
const categoryList = ref([]) // const categoryList = ref([]) //
const categoryActive = ref('') // const categoryActive = ref('') //
@ -91,6 +96,23 @@ const getList = async () => {
processDefinitionList.value = await DefinitionApi.getProcessDefinitionList({ processDefinitionList.value = await DefinitionApi.getProcessDefinitionList({
suspensionState: 1 suspensionState: 1
}) })
// processInstanceId
if (processInstanceId?.length > 0) {
const processInstance = await ProcessInstanceApi.getProcessInstance(processInstanceId)
if (!processInstance) {
message.error('重新发起流程失败,原因:流程实例不存在')
return
}
const processDefinition = processDefinitionList.value.find(
(item) => item.key == processInstance.processDefinition?.key
)
if (!processDefinition) {
message.error('重新发起流程失败,原因:流程定义不存在')
return
}
await handleSelect(processDefinition, processInstance.formVariables)
}
} finally { } finally {
loading.value = false loading.value = false
} }
@ -105,26 +127,26 @@ const categoryProcessDefinitionList = computed(() => {
const bpmnXML = ref(null) // BPMN const bpmnXML = ref(null) // BPMN
const fApi = ref<ApiAttrs>() const fApi = ref<ApiAttrs>()
const detailForm = ref({ const detailForm = ref({
//
rule: [], rule: [],
option: {} option: {},
}) value: {}
}) //
const selectProcessDefinition = ref() // const selectProcessDefinition = ref() //
/** 处理选择流程的按钮操作 **/ /** 处理选择流程的按钮操作 **/
const handleSelect = async (row) => { const handleSelect = async (row, formVariables) => {
// //
selectProcessDefinition.value = row selectProcessDefinition.value = row
// //
if (row.formType == 10) { if (row.formType == 10) {
// //
setConfAndFields2(detailForm, row.formConf, row.formFields) setConfAndFields2(detailForm, row.formConf, row.formFields, formVariables)
// //
bpmnXML.value = await DefinitionApi.getProcessDefinitionBpmnXML(row.id) bpmnXML.value = await DefinitionApi.getProcessDefinitionBpmnXML(row.id)
// //
} else if (row.formCustomCreatePath) { } else if (row.formCustomCreatePath) {
await router.push({ await push({
path: row.formCustomCreatePath path: row.formCustomCreatePath
}) })
// Tab // Tab
@ -145,7 +167,11 @@ const submitForm = async (formData) => {
}) })
// //
message.success('发起流程成功') message.success('发起流程成功')
router.go(-1) //
delView(unref(currentRoute))
await push({
name: 'BpmProcessInstance'
})
} finally { } finally {
fApi.value.btn.loading(false) fApi.value.btn.loading(false)
} }

View File

@ -76,7 +76,7 @@
type="primary" type="primary"
plain plain
v-hasPermi="['bpm:process-instance:query']" v-hasPermi="['bpm:process-instance:query']"
@click="handleCreate" @click="handleCreate()"
> >
<Icon icon="ep:plus" class="mr-5px" /> 发起流程 <Icon icon="ep:plus" class="mr-5px" /> 发起流程
</el-button> </el-button>
@ -135,6 +135,9 @@
> >
取消 取消
</el-button> </el-button>
<el-button link type="primary" v-else @click="handleCreate(scope.row.id)">
重新发起
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -200,9 +203,10 @@ const resetQuery = () => {
} }
/** 发起流程操作 **/ /** 发起流程操作 **/
const handleCreate = () => { const handleCreate = (id) => {
router.push({ router.push({
name: 'BpmProcessInstanceCreate' name: 'BpmProcessInstanceCreate',
query: { processInstanceId: id }
}) })
} }