From b84d8a871ec7600dba7aa5519e0d9c582570e072 Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Tue, 10 Feb 2026 23:22:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20[bpm]=20=E6=B5=81=E7=A8=8B=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/.env | 3 + src/api/bpm/task/index.ts | 1 + .../processInstance/detail/audit/index.vue | 11 ++ .../detail/components/form-detail.vue | 153 ++++++++++++++-- .../detail/components/operation-button.vue | 29 ++- .../processInstance/detail/index.vue | 10 +- .../processInstance/form-webview/index.vue | 165 ++++++++++++++++++ 7 files changed, 350 insertions(+), 22 deletions(-) create mode 100644 src/pages-bpm/processInstance/form-webview/index.vue diff --git a/env/.env b/env/.env index b7fc154..95d5fba 100644 --- a/env/.env +++ b/env/.env @@ -27,6 +27,9 @@ VITE_UPLOAD_TYPE=server # 静态资源地址 VITE_STATIC_BASEURL = 'http://test.yudao.iocoder.cn' +# BPM 移动端流程嵌入地址(用于 webview 嵌入 vben 项目的流程表单页面) +VITE_BPM_FORM_URL = 'http://localhost:5666/bpm/mobile/form-preview' + # 认证模式,'single' | 'double' ==> 单token | 双token VITE_AUTH_MODE = 'double' diff --git a/src/api/bpm/task/index.ts b/src/api/bpm/task/index.ts index 41174f6..bffd2fa 100644 --- a/src/api/bpm/task/index.ts +++ b/src/api/bpm/task/index.ts @@ -52,6 +52,7 @@ export function approveTask(data: { reason: string signPicUrl?: string // 签名图片 URL nextAssignees?: Record // 下一个节点审批人 + variables?: Record }) { return http.put('/bpm/task/approve', data) } diff --git a/src/pages-bpm/processInstance/detail/audit/index.vue b/src/pages-bpm/processInstance/detail/audit/index.vue index 4d55d0e..d57d339 100644 --- a/src/pages-bpm/processInstance/detail/audit/index.vue +++ b/src/pages-bpm/processInstance/detail/audit/index.vue @@ -110,6 +110,7 @@ const props = defineProps<{ processInstanceId?: string taskId?: string pass?: string + updateFormValues?: string }>() definePage({ @@ -281,6 +282,15 @@ async function handleSubmit() { formLoading.value = true try { if (isApprove.value) { + let variables = {} + // 从 props 中获取更新的表单数据 + if (props.updateFormValues) { + try { + variables = JSON.parse(decodeURIComponent(props.updateFormValues)) + } catch (parseError) { + console.error('[approve] 解析更新表单的数据失败:', parseError) + } + } // 审批通过 await approveTask({ id: taskId.value as string, @@ -289,6 +299,7 @@ async function handleSubmit() { nextAssignees: Object.keys(approveUserSelectAssignees.value).length > 0 ? approveUserSelectAssignees.value : undefined, + variables, }) } else { // 审批拒绝 diff --git a/src/pages-bpm/processInstance/detail/components/form-detail.vue b/src/pages-bpm/processInstance/detail/components/form-detail.vue index 9de8f1f..c1775bf 100644 --- a/src/pages-bpm/processInstance/detail/components/form-detail.vue +++ b/src/pages-bpm/processInstance/detail/components/form-detail.vue @@ -1,4 +1,119 @@ + + - + - + diff --git a/src/pages-bpm/processInstance/detail/components/operation-button.vue b/src/pages-bpm/processInstance/detail/components/operation-button.vue index 939d633..5ac6f2b 100644 --- a/src/pages-bpm/processInstance/detail/components/operation-button.vue +++ b/src/pages-bpm/processInstance/detail/components/operation-button.vue @@ -96,11 +96,17 @@ const moreOperations = ref([]) // 更多操作 const runningTask = ref() const processInstance = ref() const reasonRequire = ref(false) +const formDetailRef = ref<{ getFormData: () => Record | null }>() // 表单详情组件引用 /** 初始化 */ -function init(theProcessInstance: ProcessInstance, task: Task) { +function init( + theProcessInstance: ProcessInstance, + task: Task, + formDetail?: { getFormData: () => Record | null }, +) { processInstance.value = theProcessInstance runningTask.value = task + formDetailRef.value = formDetail if (task) { reasonRequire.value = task.reasonRequire ?? false // TODO @jason:这里的判断,是否可以简化哈?就是默认计算出按钮,然后根据数量,去渲染具体的按钮。 @@ -191,9 +197,13 @@ function init(theProcessInstance: ProcessInstance, task: Task) { /** 跳转到相应的操作页面 */ function handleOperation(operationType: number) { switch (operationType) { - case BpmTaskOperationButtonTypeEnum.APPROVE: - uni.navigateTo({ url: `/pages-bpm/processInstance/detail/audit/index?processInstanceId=${processInstance.value.id}&taskId=${runningTask.value?.id}&pass=true` }) + case BpmTaskOperationButtonTypeEnum.APPROVE: { + // 获取更新的表单数据 + const formValues = getFormData() + const updateFormValues = encodeURIComponent(JSON.stringify(formValues || {})) + uni.navigateTo({ url: `/pages-bpm/processInstance/detail/audit/index?processInstanceId=${processInstance.value.id}&taskId=${runningTask.value?.id}&updateFormValues=${updateFormValues}&pass=true` }) break + } case BpmTaskOperationButtonTypeEnum.REJECT: uni.navigateTo({ url: `/pages-bpm/processInstance/detail/audit/index?processInstanceId=${processInstance.value.id}&taskId=${runningTask.value?.id}&pass=false` }) break @@ -306,6 +316,17 @@ function isShowProcessStartCancel() { return isProcessStartUser() && !isEndProcessStatus(processInstance.value?.status) } +/** + * 获取表单数据(供外部调用或审批操作时使用) + * @returns 表单数据对象 | null + */ +function getFormData(): Record | null { + if (formDetailRef.value?.getFormData) { + return formDetailRef.value.getFormData() + } + return null +} + /** 暴露方法 */ -defineExpose({ init }) +defineExpose({ init, getFormData }) diff --git a/src/pages-bpm/processInstance/detail/index.vue b/src/pages-bpm/processInstance/detail/index.vue index a6f775a..36365bc 100644 --- a/src/pages-bpm/processInstance/detail/index.vue +++ b/src/pages-bpm/processInstance/detail/index.vue @@ -41,7 +41,12 @@ - + @@ -95,6 +100,7 @@ const tasks = ref([]) const activityNodes = ref([]) // 审批节点信息 const operationButtonRef = ref() // 操作按钮组件 ref +const formDetailRef = ref>() // 表单详情组件 ref /** 返回上一页 */ function handleBack() { @@ -128,7 +134,7 @@ async function loadProcessInstance() { // 获取审批节点,显示 Timeline 的数据 activityNodes.value = data.activityNodes - operationButtonRef.value?.init(data.processInstance, data.todoTask) + operationButtonRef.value?.init(data.processInstance, data.todoTask, formDetailRef.value) } /** 加载任务列表 */ diff --git a/src/pages-bpm/processInstance/form-webview/index.vue b/src/pages-bpm/processInstance/form-webview/index.vue new file mode 100644 index 0000000..846213c --- /dev/null +++ b/src/pages-bpm/processInstance/form-webview/index.vue @@ -0,0 +1,165 @@ + + + + + + -- Gitee