diff --git a/src/api/bpm/model/index.ts b/src/api/bpm/model/index.ts index 63b6af6ad..6d2b4d224 100644 --- a/src/api/bpm/model/index.ts +++ b/src/api/bpm/model/index.ts @@ -6,6 +6,7 @@ export type ProcessDefinitionVO = { deploymentTIme: string suspensionState: number formType?: number + formCustomCreatePath?: string } export type ModelVO = { diff --git a/src/views/bpm/oa/leave/create.vue b/src/views/bpm/oa/leave/create.vue index cf4a13e2a..06aedb09f 100644 --- a/src/views/bpm/oa/leave/create.vue +++ b/src/views/bpm/oa/leave/create.vue @@ -79,6 +79,7 @@ defineOptions({ name: 'BpmOALeaveCreate' }) const message = useMessage() // 消息弹窗 const { delView } = useTagsViewStore() // 视图操作 const { push, currentRoute } = useRouter() // 路由 +const { query } = useRoute() // 查询参数 const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 const formData = ref({ @@ -190,6 +191,23 @@ const daysDifference = () => { return Math.floor(diffTime / oneDay) } +/** 获取请假数据,用于重新发起时自动填充 */ +const getLeaveData = async (oldId: number) => { + formLoading.value = true + const data = await LeaveApi.getLeave(oldId) + if (!data) { + message.error('重新发起请假失败,原因:请假数据不存在') + return + } + formData.value = { + type: data.type, + reason: data.reason, + startTime: data.startTime, + endTime: data.endTime + } + formLoading.value = false +} + /** 初始化 */ onMounted(async () => { // TODO @小北:这里可以简化,统一通过 getApprovalDetail 处理么? @@ -205,6 +223,11 @@ onMounted(async () => { processDefinitionId.value = processDefinitionDetail.id startUserSelectTasks.value = processDefinitionDetail.startUserSelectTasks + // 如果有业务编号,说明是重新发起,需要加载原有数据 + if (query.oldId) { + await getLeaveData(Number(query.oldId)) + } + // 审批相关:加载最新的审批详情,主要用于节点预测 await getApprovalDetail() }) diff --git a/src/views/bpm/oa/leave/index.vue b/src/views/bpm/oa/leave/index.vue index 1d1d42740..c1b24098b 100644 --- a/src/views/bpm/oa/leave/index.vue +++ b/src/views/bpm/oa/leave/index.vue @@ -140,6 +140,15 @@ > 取消 + + 重新发起 + @@ -206,6 +215,16 @@ const handleCreate = () => { router.push({ name: 'OALeaveCreate' }) } +/** 重新发起操作 */ +const handleReCreate = (row: LeaveApi.LeaveVO) => { + router.push({ + name: 'OALeaveCreate', + query: { + oldId: row.id + } + }) +} + /** 详情操作 */ const handleDetail = (row: LeaveApi.LeaveVO) => { router.push({ diff --git a/src/views/bpm/processInstance/index.vue b/src/views/bpm/processInstance/index.vue index d6fc83d38..7dd73a222 100644 --- a/src/views/bpm/processInstance/index.vue +++ b/src/views/bpm/processInstance/index.vue @@ -275,21 +275,26 @@ const resetQuery = () => { /** 发起流程操作 **/ const handleCreate = async (row?: ProcessInstanceVO) => { - // 如果是【业务表单】,不支持重新发起 if (row?.id) { const processDefinitionDetail = await DefinitionApi.getProcessDefinition( row.processDefinitionId ) + //如果是【业务表单】,跳转到对应的发起界面 if (processDefinitionDetail.formType === 20) { - message.error('重新发起流程失败,原因:该流程使用业务表单,不支持重新发起') - return + await router.push({ + path: processDefinitionDetail.formCustomCreatePath, + query: { + oldId: row.businessKey + } + }) + } else if (processDefinitionDetail.formType === 10) { + //如果是【流程表单】,跳转到流程发起界面 + await router.push({ + name: 'BpmProcessInstanceCreate', + query: { processInstanceId: row.id } + }) } } - // 跳转发起流程界面 - await router.push({ - name: 'BpmProcessInstanceCreate', - query: { processInstanceId: row?.id } - }) } /** 查看详情 */