diff --git a/api/work-order-manage/work-order-manage.js b/api/work-order-manage/work-order-manage.js index 064ea4d..1a4df88 100644 --- a/api/work-order-manage/work-order-manage.js +++ b/api/work-order-manage/work-order-manage.js @@ -112,3 +112,20 @@ export const workorderCreate = (data) => { + + +/** + * 获得当前任务可用的统一节点动作(工作流配置化) + * @returns {Promise} + */ +export const getTaskActions = (taskId) => { + return get(`/app-api/workorder/task/${taskId}/actions`); +}; + +/** + * 执行统一节点动作(工作流配置化) + * @returns {Promise} + */ +export const executeTaskAction = (data) => { + return post('/app-api/workorder/task/action', data); +}; diff --git a/components/unified-task-actions/unified-task-actions.vue b/components/unified-task-actions/unified-task-actions.vue new file mode 100644 index 0000000..c93ab34 --- /dev/null +++ b/components/unified-task-actions/unified-task-actions.vue @@ -0,0 +1,290 @@ + + + + + diff --git a/pages-sub/problem/ai-manage/index.vue b/pages-sub/problem/ai-manage/index.vue index 6173a24..712ebca 100644 --- a/pages-sub/problem/ai-manage/index.vue +++ b/pages-sub/problem/ai-manage/index.vue @@ -98,7 +98,7 @@ - {{ nextStepMap[item.taskKey].btnText }} + {{ nextStepMap[item.taskKey].btnText }} 详情 @@ -244,6 +244,9 @@ + + + @@ -260,6 +263,7 @@ import { dcyUniversalApproval, aiUniversalApproval } from '@/api/regional-order-manage/regional-order-manage' +import { getTaskActions } from '@/api/work-order-manage/work-order-manage' import { useUserStore } from '@/pinia/user'; import { nextStepMap, buzStatusMap } from '@/common/utils/common' import { useUploadImgs } from '@/common/utils/useUploadImgs' @@ -443,6 +447,38 @@ const handleRenew = (item) => { navToOrderPage(pageUrl, { isRenew: 1, tempKey }); }; +// ========== 统一节点动作(工作流配置化) ========== +const unifiedActionsRef = ref(null) + +/** 查询当前任务是否已配置统一动作;未配置或接口异常时返回 null,回退原有逻辑 */ +const queryUnifiedActions = async (item) => { + if (!item || !item.taskId) return null + try { + const data = await getTaskActions(item.taskId) + if (data && data.configured && Array.isArray(data.actions) && data.actions.length > 0) { + return data.actions + } + } catch (e) { + console.warn('查询统一节点动作失败,回退原有逻辑', e) + } + return null +} + +/** 待办-处理工单:已配置统一动作时走新逻辑,否则回退原有处理 */ +const handleUnifiedProcess = async (item) => { + const actions = await queryUnifiedActions(item) + if (actions) { + unifiedActionsRef.value?.open(item, actions) + return + } + handleProcess(item) +} + +/** 统一动作执行成功后刷新列表 */ +const handleUnifiedSuccess = () => { + pagingRef.value && pagingRef.value.reload() +} + // 处理工单核心逻辑 const handleProcess = async (item) => { if (!item) return uni.showToast({title: '工单信息异常', icon: 'none'}); diff --git a/pages-sub/problem/regional-order-manage/index.vue b/pages-sub/problem/regional-order-manage/index.vue index cfbfecc..dcddf7b 100644 --- a/pages-sub/problem/regional-order-manage/index.vue +++ b/pages-sub/problem/regional-order-manage/index.vue @@ -108,9 +108,9 @@ - 回退 + 回退 重新提交 - {{ nextStepMap[item.taskKey].btnText }} + {{ nextStepMap[item.taskKey].btnText }} 详情 @@ -205,6 +205,9 @@ + + + @@ -221,6 +224,7 @@ import { dcyUniversalApproval, aiUniversalApproval } from '@/api/regional-order-manage/regional-order-manage' +import { getTaskActions } from '@/api/work-order-manage/work-order-manage' import { useUserStore } from '@/pinia/user'; import { nextStepMap, buzStatusMap } from '@/common/utils/common' import { useUploadImgs } from '@/common/utils/useUploadImgs' @@ -419,6 +423,55 @@ const handleRenew = (item) => { }; // 处理工单核心逻辑 +// ========== 统一节点动作(工作流配置化) ========== +const unifiedActionsRef = ref(null) + +/** 查询当前任务是否已配置统一动作;未配置或接口异常时返回 null,回退原有逻辑 */ +const queryUnifiedActions = async (item) => { + if (!item || !item.taskId) return null + try { + const data = await getTaskActions(item.taskId) + if (data && data.configured && Array.isArray(data.actions) && data.actions.length > 0) { + return data.actions + } + } catch (e) { + console.warn('查询统一节点动作失败,回退原有逻辑', e) + } + return null +} + +/** 待办-处理工单:已配置统一动作时走新逻辑,否则回退原有处理 */ +const handleUnifiedProcess = async (item) => { + const actions = await queryUnifiedActions(item) + if (actions) { + unifiedActionsRef.value?.open(item, actions) + return + } + handleProcess(item) +} + +/** 待办-回退:已配置统一动作时走新逻辑,否则回退原有弹窗 */ +const handleUnifiedReject = async (item) => { + const actions = await queryUnifiedActions(item) + if (actions) { + const rejectActions = actions.filter((action) => + ['REJECT', 'RETURN', 'RETURN_PREV'].includes(action.code) + ) + if (rejectActions.length > 0) { + unifiedActionsRef.value?.open(item, rejectActions) + } else { + uni.showToast({ title: '当前节点未配置回退动作', icon: 'none' }) + } + return + } + handleReject(item) +} + +/** 统一动作执行成功后刷新列表 */ +const handleUnifiedSuccess = () => { + pagingHandle('reload') +} + const handleProcess = async (item) => { if (!item) return showToast('工单信息异常'); const stepName = nextStepMap[item.taskKey]?.name; diff --git a/pages-sub/problem/work-order-manage/index.vue b/pages-sub/problem/work-order-manage/index.vue index 50afcdd..b3627d8 100644 --- a/pages-sub/problem/work-order-manage/index.vue +++ b/pages-sub/problem/work-order-manage/index.vue @@ -102,7 +102,7 @@ - 回退 @@ -110,7 +110,7 @@ v-show="nextStepMap[item.taskKey].renewShow">重新提交 - {{ + {{ nextStepMap[item.taskKey].btnText }} @@ -272,6 +272,9 @@ + + + @@ -283,7 +286,8 @@ import { myBuzSimplePage, todoBuzSimplePage, doneBuzSimplePage, - universalApproval + universalApproval, + getTaskActions } from '@/api/work-order-manage/work-order-manage' // 从用户store获取角色信息 import { useUserStore } from '@/pinia/user'; @@ -486,6 +490,55 @@ const handleRenew = (item) => { }); }; +// ========== 统一节点动作(工作流配置化) ========== +const unifiedActionsRef = ref(null) + +/** 查询当前任务是否已配置统一动作;未配置或接口异常时返回 null,回退原有逻辑 */ +const queryUnifiedActions = async (item) => { + if (!item || !item.taskId) return null + try { + const data = await getTaskActions(item.taskId) + if (data && data.configured && Array.isArray(data.actions) && data.actions.length > 0) { + return data.actions + } + } catch (e) { + console.warn('查询统一节点动作失败,回退原有逻辑', e) + } + return null +} + +/** 待办-处理工单:已配置统一动作时走新逻辑,否则回退原有处理 */ +const handleUnifiedProcess = async (item) => { + const actions = await queryUnifiedActions(item) + if (actions) { + unifiedActionsRef.value?.open(item, actions) + return + } + handleProcess(item) +} + +/** 待办-回退:已配置统一动作时走新逻辑,否则回退原有弹窗 */ +const handleUnifiedReject = async (item) => { + const actions = await queryUnifiedActions(item) + if (actions) { + const rejectActions = actions.filter((action) => + ['REJECT', 'RETURN', 'RETURN_PREV'].includes(action.code) + ) + if (rejectActions.length > 0) { + unifiedActionsRef.value?.open(item, rejectActions) + } else { + uni.showToast({ title: '当前节点未配置回退动作', icon: 'none' }) + } + return + } + handleReject(item) +} + +/** 统一动作执行成功后刷新列表 */ +const handleUnifiedSuccess = () => { + paging.value?.reload() +} + // 待办-处理工单 const handleProcess = async (item) => { console.log(nextStepMap[item.taskKey].name) diff --git a/pages-sub/problem/work-order-manage/order-detail.vue b/pages-sub/problem/work-order-manage/order-detail.vue index b504ad3..d89a3f1 100644 --- a/pages-sub/problem/work-order-manage/order-detail.vue +++ b/pages-sub/problem/work-order-manage/order-detail.vue @@ -258,7 +258,7 @@ - 回退 @@ -266,7 +266,7 @@ v-show="nextStepMap[orderDetail.taskKey].renewShow">重新提交 - {{ + {{ nextStepMap[orderDetail.taskKey].btnText }} @@ -358,6 +358,9 @@ + + + @@ -370,7 +373,8 @@ import { getDoneTaskDetail, getTodoTaskDetail, getApprovalDetail, - universalApproval + universalApproval, + getTaskActions } from '@/api/work-order-manage/work-order-manage'; import {nextStepMap, buzStatusMap, calculateFormatTimeDiff} from '@/common/utils/common' // 引入图片上传组合式函数 @@ -697,6 +701,58 @@ const confirmReject = async () => { } }; +// ========== 统一节点动作(工作流配置化) ========== +const unifiedActionsRef = ref(null) + +/** 查询当前任务是否已配置统一动作;未配置或接口异常时返回 null,回退原有逻辑 */ +const queryUnifiedActions = async (item: any) => { + if (!item || !item.taskId) return null + try { + const data = await getTaskActions(item.taskId) + if (data && data.configured && Array.isArray(data.actions) && data.actions.length > 0) { + return data.actions + } + } catch (e) { + console.warn('查询统一节点动作失败,回退原有逻辑', e) + } + return null +} + +/** 处理工单:已配置统一动作时走新逻辑,否则回退原有处理 */ +const handleUnifiedProcess = async (item: any) => { + const actions = await queryUnifiedActions(item) + if (actions) { + unifiedActionsRef.value?.open(item, actions) + return + } + handleProcess(item) +} + +/** 回退:已配置统一动作时走新逻辑,否则回退原有弹窗 */ +const handleUnifiedReject = async (item: any) => { + const actions = await queryUnifiedActions(item) + if (actions) { + const rejectActions = actions.filter((action: any) => + ['REJECT', 'RETURN', 'RETURN_PREV'].includes(action.code) + ) + if (rejectActions.length > 0) { + unifiedActionsRef.value?.open(item, rejectActions) + } else { + uni.showToast({ title: '当前节点未配置回退动作', icon: 'none' }) + } + return + } + handleReject(item) +} + +/** 统一动作执行成功后通知列表刷新并返回 */ +const handleUnifiedSuccess = () => { + if (eventChannel.value) { + eventChannel.value.emit('needRefresh') + } + uni.navigateBack({delta: 1}) +} + // ========== handleProcess 处理工单 ========== const handleProcess = async (item: any) => { console.log(nextStepMap[item.taskKey]?.name)