fix审批流转逻辑

This commit is contained in:
ChenXinXin committed 2024-05-09 16:04:07 +08:00
1 parent e31835cc13
commit fb714c0ea8
2 files changed
+47 -19

No files matched your search

+43 -16
View File
@@ -56,6 +56,7 @@ class TaskService extends Service {
}) })
} }
// TODO:逻辑待优化
async buildNext({ taskData, type }) { async buildNext({ taskData, type }) {
const { userId, username } = this.ctx.userInfo; const { userId, username } = this.ctx.userInfo;
const { taskId, taskWorkflow, taskConfigId, taskEditUserList, taskEditedUserList } = taskData; const { taskId, taskWorkflow, taskConfigId, taskEditUserList, taskEditedUserList } = taskData;
@@ -66,6 +67,8 @@ class TaskService extends Service {
var curNode = taskWorkflow.nodeList.find(node => node.id == taskConfigId) var curNode = taskWorkflow.nodeList.find(node => node.id == taskConfigId)
var taskStatus = "running" var taskStatus = "running"
taskData.createHistoryBy = userId
// 1、更新task状态 // 1、更新task状态
if (type == '同意') { if (type == '同意') {
var approvalType = curNode.properties.approvalType var approvalType = curNode.properties.approvalType
@@ -73,14 +76,13 @@ class TaskService extends Service {
var editedUserList = taskEditedUserList && taskEditedUserList.split(',') || [] var editedUserList = taskEditedUserList && taskEditedUserList.split(',') || []
// 判断该节点是否已完成 // 判断该节点是否已完成
if ((approvalType == "会签" || approvalType == "依次审批") && editUserList.length > 1) { if (curNode.id.startsWith('approvalTask') && (approvalType == "会签" || approvalType == "依次审批") && editUserList.length > 1) {
// 未完成 // 未完成
editedUserList.push(userId) editedUserList.push(userId)
updateTaskData = { updateTaskData = {
taskEditUserList: editUserList.filter(u => u != userId).join(','), taskEditUserList: editUserList.filter(u => u != userId).join(','),
taskEditedUserList: editedUserList.join(','), taskEditedUserList: editedUserList.join(','),
} }
historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type })) historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type }))
} else {// 流转搭配下一节点 } else {// 流转搭配下一节点
@@ -102,6 +104,19 @@ class TaskService extends Service {
} }
// 下一个节点是抄送节点 // 下一个节点是抄送节点
if (nextNode.properties.type === "noticeTask") { if (nextNode.properties.type === "noticeTask") {
historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type }))
taskData = {
...taskData,
taskConfigId: nextNode.id,
taskEditUserList: nextNode.properties.userIdList.join(','),
taskEditedUserList: null,
taskComment: null,
taskExplain: '抄送节点',
taskHandleDesc: '抄送',
taskLineTypeList: '抄送',
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
}
noticeInsertData.push({ noticeInsertData.push({
noticeId: await idGenerateUtil.uuid(), noticeId: await idGenerateUtil.uuid(),
@@ -112,19 +127,25 @@ class TaskService extends Service {
pushAt: dayjs().format("YYYY-MM-DD HH:mm:ss") pushAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
}) })
historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type })) var noticeUser = nextNode.properties.userIdList
nextNode = await this.getNextNode(taskWorkflow, curNode) for (let index = 0; index < noticeUser.length; index++) {
const element = noticeUser[index];
taskData.createHistoryBy = element
historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type }))
}
taskData = { taskData = {
...taskData, ...taskData,
taskConfigId: nextNode.id, taskEditUserList: null,
taskEditUserList: nextNode.properties.userIdList.join(','),
taskEditedUserList: null, taskEditedUserList: null,
taskComment: null, taskComment: null,
taskExplain: null,
taskHandleDesc: null,
taskLineTypeList: null,
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss") operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
} }
const result = await this.buildNext({ taskData, type }) const result = await this.buildNext({ taskData, type: 'end' })
updateTaskData = result.updateTaskData updateTaskData = result.updateTaskData
historyInsertData.push(...result.historyInsertData) historyInsertData.push(...result.historyInsertData)
noticeInsertData.push(...result.noticeInsertData) noticeInsertData.push(...result.noticeInsertData)
@@ -184,7 +205,8 @@ class TaskService extends Service {
// 解构 taskData 对象以简化访问 // 解构 taskData 对象以简化访问
const { taskId, taskFormInput, taskConfigId, taskNextConfigList, const { taskId, taskFormInput, taskConfigId, taskNextConfigList,
taskLineType, taskEditUserList, taskViewUserList, taskLineType, taskEditUserList, taskViewUserList,
taskComment, taskWorkflow, operationAt } = taskData; taskComment, taskWorkflow, operationAt, createHistoryBy,
taskHandleDesc, taskExplain, taskLineTypeList } = taskData;
// 计算任务持续时间 // 计算任务持续时间
const taskCostDuration = Math.round(dayjs().diff(dayjs(operationAt)) / 1000); const taskCostDuration = Math.round(dayjs().diff(dayjs(operationAt)) / 1000);
@@ -195,15 +217,15 @@ class TaskService extends Service {
taskFormInput: JSON.stringify(taskFormInput), taskFormInput: JSON.stringify(taskFormInput),
taskConfigId, taskConfigId,
taskNextConfigList, taskNextConfigList,
taskLineTypeList: taskLineType, taskLineTypeList: taskLineTypeList || type,
taskEditUserList, taskEditUserList,
taskViewUserList, taskViewUserList,
taskComment, taskComment,
taskWorkflow: JSON.stringify(taskWorkflow), taskWorkflow: JSON.stringify(taskWorkflow),
taskExplain: type, taskExplain: taskExplain || type,
taskHandleDesc: type, taskHandleDesc: taskHandleDesc || type,
taskCostDuration, taskCostDuration,
createHistoryBy: taskEditUserList, createHistoryBy: createHistoryBy,
createHistoryAt: dayjs().format('YYYY-MM-DD HH:mm:ss') createHistoryAt: dayjs().format('YYYY-MM-DD HH:mm:ss')
} }
} }
@@ -251,12 +273,17 @@ class TaskService extends Service {
}) })
var nodeStatus = '审批中' var nodeStatus = '审批中'
if (approvalType == "或签") { if (id.startsWith('approvalTask')) {
nodeStatus = _.some(userConfig, ['handleDesc', '拒绝']) ? '已拒绝' : _.some(userConfig, ['handleDesc', '同意']) ? '已同意' : '审批中' if (approvalType == "或签") {
} else { nodeStatus = _.some(userConfig, ['handleDesc', '拒绝']) ? '已拒绝' : _.some(userConfig, ['handleDesc', '同意']) ? '已同意' : '审批中'
var nodeStatus = _.some(userConfig, ['handleDesc', '拒绝']) ? '已拒绝' : _.every(userConfig, ['handleDesc', '同意']) ? '已同意' : '审批中' } else {
var nodeStatus = _.some(userConfig, ['handleDesc', '拒绝']) ? '已拒绝' : _.every(userConfig, ['handleDesc', '同意']) ? '已同意' : '审批中'
}
} else if (id.startsWith('noticeTask')) {
nodeStatus = _.every(userConfig, u => u.createHistoryAt) ? '已抄送' : '抄送中'
} }
return { return {
id, id,
label, label,
+4 -3
View File
@@ -5,7 +5,7 @@
<div class="history-box"> <div class="history-box">
<div class="node-box d-flex mb-2" v-for="(nodeItem, nodeIndex) in workflowHistory" :key="nodeIndex"> <div class="node-box d-flex mb-2" v-for="(nodeItem, nodeIndex) in workflowHistory" :key="nodeIndex">
<div class="node-box-stepper"> <div class="node-box-stepper">
<template v-if="nodeItem.nodeStatus == '已同意'"> <template v-if="nodeItem.nodeStatus == '已同意' || nodeItem.nodeStatus == '已抄送'">
<v-icon v-if="nodeItem.id.startsWith('approvalTask')" color="#4caf50">mdi-account-circle</v-icon> <v-icon v-if="nodeItem.id.startsWith('approvalTask')" color="#4caf50">mdi-account-circle</v-icon>
<v-icon v-if="nodeItem.id.startsWith('noticeTask')" color="#4caf50">mdi-send-circle</v-icon> <v-icon v-if="nodeItem.id.startsWith('noticeTask')" color="#4caf50">mdi-send-circle</v-icon>
</template> </template>
@@ -13,11 +13,11 @@
<v-icon v-if="nodeItem.id.startsWith('approvalTask')" color="#f4807b">mdi-account-circle</v-icon> <v-icon v-if="nodeItem.id.startsWith('approvalTask')" color="#f4807b">mdi-account-circle</v-icon>
<v-icon v-if="nodeItem.id.startsWith('noticeTask')" color="#f4807b">mdi-send-circle</v-icon> <v-icon v-if="nodeItem.id.startsWith('noticeTask')" color="#f4807b">mdi-send-circle</v-icon>
</template> </template>
<template v-if="nodeItem.nodeStatus == '审批中'"> <template v-if="nodeItem.nodeStatus == '审批中' || nodeItem.nodeStatus == '抄送中'">
<v-icon v-if="nodeItem.id.startsWith('approvalTask')" color="#cdcfd1">mdi-account-circle</v-icon> <v-icon v-if="nodeItem.id.startsWith('approvalTask')" color="#cdcfd1">mdi-account-circle</v-icon>
<v-icon v-if="nodeItem.id.startsWith('noticeTask')" color="#cdcfd1">mdi-send-circle</v-icon> <v-icon v-if="nodeItem.id.startsWith('noticeTask')" color="#cdcfd1">mdi-send-circle</v-icon>
</template> </template>
<div v-if="nodeIndex < workflowHistory.length - 1" class="vertical-line" :style="{ borderColor: nodeItem['nodeStatus'] === '已同意' ? '#4caf50' : '#cdcfd1' }"></div> <div v-if="nodeIndex < workflowHistory.length - 1" class="vertical-line" :style="{ borderColor: ['已同意','已抄送'].includes(nodeItem['nodeStatus']) ? '#4caf50' : '#cdcfd1' }"></div>
</div> </div>
<div class="node-box-item"> <div class="node-box-item">
<div class="node-label font-weight-bold"> <div class="node-label font-weight-bold">
@@ -103,6 +103,7 @@
} }
})).data.appData.resultData })).data.appData.resultData
this.workflowHistory = resultData this.workflowHistory = resultData
console.log(resultData);
this.isTableLoading = false; this.isTableLoading = false;
}, },
// ---------- <<<<<<<<<< 获取列表 -------- // ---------- <<<<<<<<<< 获取列表 --------