From 8fb2f7b7869e19e2066f13ffe1de1a5cf4645b39 Mon Sep 17 00:00:00 2001 From: weicw <594098497@qq.com> Date: Fri, 30 Oct 2026 21:42:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(approval):=20PC=20=E5=BE=85=E5=8A=9E?= =?UTF-8?q?=E6=B4=BE=E5=8D=95=E5=8A=A8=E4=BD=9C=E4=B8=8E=E9=80=89=E4=BA=BA?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=20(#24)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/approval/task/index.ts | 30 ++++- .../todo/components/detail-drawer.vue | 105 +++++++++++++++++- 2 files changed, 133 insertions(+), 2 deletions(-) diff --git a/src/api/approval/task/index.ts b/src/api/approval/task/index.ts index 1bb21a6..7633baf 100644 --- a/src/api/approval/task/index.ts +++ b/src/api/approval/task/index.ts @@ -3,7 +3,8 @@ import type { ApiResult } from '@/api'; import { THINK_API_URL } from '@/config/setting'; import type { ApprovalAssignParam, - ApprovalAssignResult + ApprovalAssignResult, + ApprovalUser } from '../instance/model'; /** @@ -60,6 +61,33 @@ export async function archiveApprovalTask(id: number) { return Promise.reject(new Error(res.data.message)); } +/** + * 派单候选池(仅派单节点、本人待办) + */ +export async function listDispatchCandidates(id: number) { + const res = await request.get>( + THINK_API_URL + '/approval/task/' + id + '/candidates' + ); + if (res.data.code === 0) { + return res.data.data ?? []; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 派单(选定 1 人即完成派单节点) + */ +export async function dispatchApprovalTask(id: number, targetUserId: number) { + const res = await request.post>( + THINK_API_URL + '/approval/task/' + id + '/dispatch', + { targetUserId } + ); + if (res.data.code === 0) { + return res.data.message; + } + return Promise.reject(new Error(res.data.message)); +} + /** * 改派待办 */ diff --git a/src/views/approval/todo/components/detail-drawer.vue b/src/views/approval/todo/components/detail-drawer.vue index 09a882c..bfdeeb1 100644 --- a/src/views/approval/todo/components/detail-drawer.vue +++ b/src/views/approval/todo/components/detail-drawer.vue @@ -21,6 +21,14 @@ > 通过 + + 派单 + + + + + + + +
+ 派单后由报送人与被派单人分别存档,选定后不可更改。 +
+
+
+ (undefined); + const candidateOptions = ref<{ label: string; value: number }[]>([]); + + const candidateLabel = (user: ApprovalUser) => + (user.realName || user.nickname || user.username || '') + + (user.username ? '(' + user.username + ')' : '') + + (user.organizationName ? ' · ' + user.organizationName : ''); + + const filterCandidate = (input: string, option: any) => + String(option?.label ?? '') + .toLowerCase() + .includes(input.toLowerCase()); + + const openDispatch = async () => { + const taskId = detail.value?.myTask?.id; + if (!taskId) { + message.error('待办任务不存在,请刷新'); + return; + } + dispatchTargetUserId.value = undefined; + candidateOptions.value = []; + dispatchVisible.value = true; + candidateLoading.value = true; + try { + const users = await listDispatchCandidates(taskId); + candidateOptions.value = users.map((user) => ({ + value: user.userId as number, + label: candidateLabel(user) + })); + if (!candidateOptions.value.length) { + message.warning('暂无可派单人员,请联系管理员维护部门成员'); + } + } catch (e: any) { + message.error(e.message); + } finally { + candidateLoading.value = false; + } + }; + + const submitDispatch = async () => { + const taskId = detail.value?.myTask?.id; + if (!taskId) { + message.error('待办任务不存在,请刷新'); + return; + } + if (!dispatchTargetUserId.value) { + message.error('请选择派单对象'); + return; + } + submitting.value = true; + try { + await dispatchApprovalTask(taskId, dispatchTargetUserId.value); + message.success('派单成功'); + dispatchVisible.value = false; + await load(); + emit('done'); + } catch (e: any) { + message.error(e.message); + } finally { + submitting.value = false; + } + }; + /* 改派 */ const assignVisible = ref(false); const userLoading = ref(false);