diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts index 309a8e49..bc62a3c4 100644 --- a/src/router/modules/remaining.ts +++ b/src/router/modules/remaining.ts @@ -243,7 +243,7 @@ const remainingRouter: AppRouteRecordRaw[] = [ }, children: [ { - path: '/manager/form/edit', + path: 'manager/form/edit', component: () => import('@/views/bpm/form/editor/index.vue'), name: 'BpmFormEditor', meta: { @@ -255,7 +255,7 @@ const remainingRouter: AppRouteRecordRaw[] = [ } }, { - path: '/manager/model/edit', + path: 'manager/model/edit', component: () => import('@/views/bpm/model/editor/index.vue'), name: 'BpmModelEditor', 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'), name: 'SimpleWorkflowDesignEditor', meta: { @@ -279,7 +279,7 @@ const remainingRouter: AppRouteRecordRaw[] = [ } }, { - path: '/manager/definition', + path: 'manager/definition', component: () => import('@/views/bpm/definition/index.vue'), name: 'BpmProcessDefinition', meta: { @@ -291,7 +291,7 @@ const remainingRouter: AppRouteRecordRaw[] = [ } }, { - path: '/process-instance/detail', + path: 'process-instance/detail', component: () => import('@/views/bpm/processInstance/detail/index.vue'), name: 'BpmProcessInstanceDetail', meta: { @@ -299,11 +299,11 @@ const remainingRouter: AppRouteRecordRaw[] = [ hidden: true, canTo: true, 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'), name: 'OALeaveCreate', 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'), name: 'OALeaveDetail', meta: { diff --git a/src/views/bpm/processInstance/create/index.vue b/src/views/bpm/processInstance/create/index.vue index 2cbfe9c4..bd782fef 100644 --- a/src/views/bpm/processInstance/create/index.vue +++ b/src/views/bpm/processInstance/create/index.vue @@ -51,6 +51,7 @@ @@ -67,12 +68,16 @@ import { setConfAndFields2 } from '@/utils/formCreate' import type { ApiAttrs } from '@form-create/element-ui/types/config' import ProcessInstanceBpmnViewer from '../detail/ProcessInstanceBpmnViewer.vue' import { CategoryApi } from '@/api/bpm/category' +import { useTagsViewStore } from '@/store/modules/tagsView' defineOptions({ name: 'BpmProcessInstanceCreate' }) -const router = useRouter() // 路由 +const route = useRoute() // 路由 +const { push, currentRoute } = useRouter() // 路由 const message = useMessage() // 消息 +const { delView } = useTagsViewStore() // 视图操作 +const processInstanceId = route.query.processInstanceId const loading = ref(true) // 加载中 const categoryList = ref([]) // 分类的列表 const categoryActive = ref('') // 选中的分类 @@ -91,6 +96,23 @@ const getList = async () => { processDefinitionList.value = await DefinitionApi.getProcessDefinitionList({ 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 { loading.value = false } @@ -105,26 +127,26 @@ const categoryProcessDefinitionList = computed(() => { const bpmnXML = ref(null) // BPMN 数据 const fApi = ref() const detailForm = ref({ - // 流程表单详情 rule: [], - option: {} -}) + option: {}, + value: {} +}) // 流程表单详情 const selectProcessDefinition = ref() // 选择的流程定义 /** 处理选择流程的按钮操作 **/ -const handleSelect = async (row) => { +const handleSelect = async (row, formVariables) => { // 设置选择的流程 selectProcessDefinition.value = row // 情况一:流程表单 if (row.formType == 10) { // 设置表单 - setConfAndFields2(detailForm, row.formConf, row.formFields) + setConfAndFields2(detailForm, row.formConf, row.formFields, formVariables) // 加载流程图 bpmnXML.value = await DefinitionApi.getProcessDefinitionBpmnXML(row.id) // 情况二:业务表单 } else if (row.formCustomCreatePath) { - await router.push({ + await push({ path: row.formCustomCreatePath }) // 这里暂时无需加载流程图,因为跳出到另外个 Tab; @@ -145,7 +167,11 @@ const submitForm = async (formData) => { }) // 提示 message.success('发起流程成功') - router.go(-1) + // 跳转回去 + delView(unref(currentRoute)) + await push({ + name: 'BpmProcessInstance' + }) } finally { fApi.value.btn.loading(false) } diff --git a/src/views/bpm/processInstance/index.vue b/src/views/bpm/processInstance/index.vue index 1b3e8484..504a4801 100644 --- a/src/views/bpm/processInstance/index.vue +++ b/src/views/bpm/processInstance/index.vue @@ -76,7 +76,7 @@ type="primary" plain v-hasPermi="['bpm:process-instance:query']" - @click="handleCreate" + @click="handleCreate()" > 发起流程 @@ -135,6 +135,9 @@ > 取消 + + 重新发起 + @@ -200,9 +203,10 @@ const resetQuery = () => { } /** 发起流程操作 **/ -const handleCreate = () => { +const handleCreate = (id) => { router.push({ - name: 'BpmProcessInstanceCreate' + name: 'BpmProcessInstanceCreate', + query: { processInstanceId: id } }) }