代码优化
This commit is contained in:
1 parent
12bbc3dade
commit
991cae5f15
1 file changed
+16
-10
+16
-10
@@ -361,7 +361,7 @@ class TaskService extends Service {
|
||||
editUserList.splice(i + 1, 0, abnormalUser);
|
||||
}
|
||||
}
|
||||
var abnormalUserName = userList.find(u => u.userId == abnormalUser)?.username || abnormalUser
|
||||
var abnormalUserName = userList.find(u => u.userId == abnormalUser)?.username || abnormalUser + "(账号被禁用)"
|
||||
// 插入禁用账号的历史记录
|
||||
_.assign(taskData, {
|
||||
taskComment: "账号禁用,系统自动转交" + abnormalUserName,
|
||||
@@ -390,7 +390,11 @@ class TaskService extends Service {
|
||||
foundNode.properties.userIdList = newUserIdList;
|
||||
}
|
||||
updateTaskData.taskWorkflow = JSON.stringify(_.cloneDeep(taskWorkflow))
|
||||
updateTaskData.taskViewUserList = taskViewUserList.push(abnormalUser)
|
||||
if (taskViewUserList) {
|
||||
updateTaskData.taskViewUserList = taskViewUserList.split(',').concat(abnormalUser).join(',')
|
||||
} else {
|
||||
updateTaskData.taskViewUserList = abnormalUser
|
||||
}
|
||||
} else {
|
||||
// 自动同意
|
||||
editUserList = editUserList.filter(editUser => !bannedUser.includes(editUser))
|
||||
@@ -489,17 +493,19 @@ class TaskService extends Service {
|
||||
|
||||
async getTaskWorkflow() {
|
||||
const { jianghuKnex } = this.app;
|
||||
const { userId } = this.ctx.userInfo;
|
||||
const { taskId } = this.ctx.request.body.appData.actionData;
|
||||
|
||||
// 获取当前审批
|
||||
const task = await jianghuKnex('task').where({ taskId }).first();
|
||||
const { taskWorkflow, taskConfigId } = task
|
||||
const task = await jianghuKnex('task').where({ taskId }).select('taskWorkflow', 'taskConfigId', 'taskViewUserList').first();
|
||||
const { taskWorkflow, taskViewUserList } = task
|
||||
|
||||
// 获取审批流历史
|
||||
const taskHistory = await jianghuKnex('task_history').where({ taskId }).select();
|
||||
const taskHistory = await jianghuKnex('task_history').where({ taskId })
|
||||
.select('taskConfigId', 'createHistoryBy', 'taskComment', 'taskHandleDesc', 'createHistoryAt', 'taskStatus');
|
||||
|
||||
// 获取人员
|
||||
const userList = await jianghuKnex('enterprise_user').select()
|
||||
const userList = await jianghuKnex('enterprise_user').whereIn('userId', taskViewUserList.split(',')).select('userId', 'username')
|
||||
if (!task) throw new Error('Task not found');
|
||||
|
||||
var workflowHistory = JSON.parse(taskWorkflow).nodeList.filter(n => !['start', 'end', 'conditionTask'].includes(n.properties.type))
|
||||
.map(node => {
|
||||
@@ -509,12 +515,13 @@ class TaskService extends Service {
|
||||
var username = userList.find(u => u.userId == appUserId)?.username,
|
||||
historyRecord = taskHistory.find(h => h.taskConfigId == node.id && h.createHistoryBy == appUserId);
|
||||
|
||||
username = username ? username : appUserId + '(账号被禁用)'
|
||||
if (historyRecord) {
|
||||
const { taskComment, taskHandleDesc, createHistoryAt, taskStatus } = historyRecord
|
||||
|
||||
return {
|
||||
userId: appUserId,
|
||||
username: username || appUserId + '(账号被禁用)',
|
||||
username: username,
|
||||
comment: taskComment,
|
||||
handleDesc: taskHandleDesc,
|
||||
createHistoryAt: dayjs(createHistoryAt || '').format('YYYY-MM-DD HH:mm:ss'),
|
||||
@@ -523,7 +530,7 @@ class TaskService extends Service {
|
||||
} else {
|
||||
return {
|
||||
userId: appUserId,
|
||||
username: username || appUserId + '(账号被禁用)',
|
||||
username: username,
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -550,7 +557,6 @@ class TaskService extends Service {
|
||||
})
|
||||
|
||||
return workflowHistory
|
||||
|
||||
}
|
||||
|
||||
async getTaskList() {
|
||||
|
||||
Reference in new issue
Block a user