From 697918321c1aa876f5357149355b5edf675ac0b1 Mon Sep 17 00:00:00 2001 From: cxx Date: Wed, 15 May 2024 10:14:00 +0800 Subject: [PATCH] =?UTF-8?q?fix=20bug=EF=BC=9A=E8=87=AA=E5=8A=A8=E5=AE=A1?= =?UTF-8?q?=E6=89=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/task.js | 36 ++++++++++++++++--------------- app/view/page/myTask.html | 7 +++--- app/view/page/taskManagement.html | 28 +++++++++++++----------- 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/app/service/task.js b/app/service/task.js index 7454e0e..3c42c47 100644 --- a/app/service/task.js +++ b/app/service/task.js @@ -57,7 +57,7 @@ class TaskService extends Service { taskFormInput: JSON.parse(taskFormInput), } // 往下走 - await this.submitNode(data, '同意', 1) + await this.submitNode(data, '同意', 1, 'createTask') } } @@ -65,12 +65,12 @@ class TaskService extends Service { const { actionData } = this.ctx.request.body.appData; const { updateItem, type } = actionData; - await this.submitNode(updateItem, type, 0) + await this.submitNode(updateItem, type, 0, 'updateTask') } - async submitNode(taskData, type, times) { + async submitNode(taskData, type, times, action) { const { jianghuKnex } = this.app; - const { updateTaskData, historyInsertData, noticeInsertData } = await this.buildNext1({ taskData: taskData, type: type, times: times }) + const { updateTaskData, historyInsertData, noticeInsertData } = await this.buildNext1({ taskData: taskData, type: type, times: times, action: action }) console.log('updateTaskData------', updateTaskData); console.log('historyInsertData------', historyInsertData); @@ -82,7 +82,7 @@ class TaskService extends Service { }) } - async buildNext1({ taskData, type, times }) { + async buildNext1({ taskData, type, times, action }) { const { jianghuKnex } = this.app; const { userId, username } = this.ctx.userInfo; const { taskId, taskInfo, taskWorkflow, taskConfigId, taskEditUserList, taskEditedUserList } = taskData; @@ -95,8 +95,9 @@ class TaskService extends Service { curNode = taskWorkflow.nodeList.find(node => node.id == taskConfigId), curNodeType = curNode?.properties.type, taskStatus = "running", - taskHistoryUser = [userId, ...taskHistory.map(h => h.createHistoryBy)]; + taskHistoryUser = [...taskHistory.map(h => h.createHistoryBy)]; + if (action == 'update') taskHistoryUser.push(userId) // 插入上一次节点历史 if (!taskData?.createHistoryBy) taskData.createHistoryBy = [userId] taskStatus = curNodeType == 'end' ? 'end' : 'running' @@ -120,6 +121,7 @@ class TaskService extends Service { taskHandleDesc: '结束', createHistoryBy: [userId] } + // 插入任务的结束记录 historyInsertData.push(...await this.createTaskHistory({ taskData, taskStatus, type })) } @@ -180,7 +182,7 @@ class TaskService extends Service { operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss") } - const result = await this.buildNext1({ taskData, type: '同意', times: 1 }) + const result = await this.buildNext1({ taskData, type: '同意', times: 1, action }) updateTaskData = result.updateTaskData historyInsertData.push(...result.historyInsertData) noticeInsertData.push(...result.noticeInsertData) @@ -212,7 +214,7 @@ class TaskService extends Service { operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss") } - const result = await this.buildNext1({ taskData, type: '同意', times: 1 }) + const result = await this.buildNext1({ taskData, type: '同意', times: 1, action }) updateTaskData = result.updateTaskData historyInsertData.push(...result.historyInsertData) noticeInsertData.push(...result.noticeInsertData) @@ -252,7 +254,7 @@ class TaskService extends Service { operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss") } - const result = await this.buildNext1({ taskData, type: '同意', times: 1 }) + const result = await this.buildNext1({ taskData, type: '同意', times: 1, action }) updateTaskData = result.updateTaskData historyInsertData.push(...result.historyInsertData) noticeInsertData.push(...result.noticeInsertData) @@ -293,7 +295,7 @@ class TaskService extends Service { operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss") } - const result = await this.buildNext1({ taskData, type: '同意', times: 1 }) + const result = await this.buildNext1({ taskData, type: '同意', times: 1, action }) updateTaskData = result.updateTaskData historyInsertData.push(...result.historyInsertData) noticeInsertData.push(...result.noticeInsertData) @@ -337,7 +339,7 @@ class TaskService extends Service { operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss") } - const result = await this.buildNext1({ taskData, type: '同意', times: 1 }) + const result = await this.buildNext1({ taskData, type: '同意', times: 1, action }) updateTaskData = result.updateTaskData historyInsertData.push(...result.historyInsertData) noticeInsertData.push(...result.noticeInsertData) @@ -386,16 +388,15 @@ class TaskService extends Service { operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss") } - const result = await this.buildNext1({ taskData, type: '同意', times: 1 }) + const result = await this.buildNext1({ taskData, type: '同意', times: 1, action }) updateTaskData = result.updateTaskData historyInsertData.push(...result.historyInsertData) noticeInsertData.push(...result.noticeInsertData) break; case 'end': - taskStatus = "end" updateTaskData = { - taskStatus: taskStatus, + taskStatus: "success", taskConfigId: null, taskLineType: null, taskEditUserList: null, @@ -408,17 +409,18 @@ class TaskService extends Service { } } else { + // 插入该条审批记录 + historyInsertData.push(...await this.createTaskHistory({ taskData, taskStatus: 'end', type })) // 直接结束任务 - taskStatus = "end" updateTaskData = { - taskStatus: taskStatus, + taskStatus: 'reject', taskConfigId: null, taskLineType: null, taskEditUserList: null, taskEditedUserList: null, taskFinishAt: dayjs().format("YYYY-MM-DD HH:mm:ss") } - // historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type: '拒绝' })) + // historyInsertData.push(...await this.createTaskHistory({ taskData, taskStatus, type: '拒绝' })) } diff --git a/app/view/page/myTask.html b/app/view/page/myTask.html index 5e178be..16be21a 100644 --- a/app/view/page/myTask.html +++ b/app/view/page/myTask.html @@ -208,7 +208,6 @@ // 表格相关数据 isTableZebraLineShown: true, - // 生日日期选择 validationRules: { requireRules: [ v => !!v || 'This is required', @@ -219,8 +218,8 @@ tableData: [], historyData: [], headers: [ - { text: "审批ID", value: "taskId", width: 120 }, - { text: "分组", value: "taskTemplateGroup", width: 120 }, + { text: "审批ID", value: "taskId", width: 90 }, + { text: "分组", value: "taskTemplateGroup", width: 100 }, { text: "审批项", value: "taskTitle", width: 200 }, { text: "创建者", value: "taskInitUser", width: 120 }, { text: "创建时间", value: "taskCreateAt", width: 150 }, @@ -363,7 +362,7 @@ } }) await window.vtoast.success("提交审核成功"); - this.isSubmitNodeLoading = true + this.isSubmitNodeLoading = false }, async closeSubmitDrawer() { this.isSubmitDrawerShown = false; diff --git a/app/view/page/taskManagement.html b/app/view/page/taskManagement.html index c4ba60c..d6515db 100644 --- a/app/view/page/taskManagement.html +++ b/app/view/page/taskManagement.html @@ -52,10 +52,7 @@ @@ -66,7 +63,7 @@ mdi-text-box-outline 查看 - + mdi-arrow-u-left-top 撤回 @@ -184,16 +181,22 @@ tableData: [], headers: [ { text: "申请ID", value: "taskId", width: 100 }, + { text: "申请分组", value: "taskTemplateGroup", width: 120 }, { text: "申请名称", value: "taskTitle", width: 350 }, - { text: "申请状态", value: "taskStatus" }, - { text: "申请时间", value: "taskCreateAt", width: 300 }, - { text: "结束时间", value: "taskFinishAt", width: 300 }, - { text: '操作', value: 'action', align: 'center', sortable: false, width: 150, class: 'fixed', cellClass: 'fixed' }, + { text: "申请状态", value: "taskStatus", width: 150 }, + { text: "申请时间", value: "taskCreateAt", width: 250 }, + { text: "结束时间", value: "taskFinishAt", width: 250 }, + { text: '操作', value: 'action', align: 'center', sortable: false, width: 200, class: 'fixed', cellClass: 'fixed' }, ], isViewDrawerShown: false, viewItem: {}, - userId: '<$ ctx.userInfo.userId $>' + userId: '<$ ctx.userInfo.userId $>', + taskStatusColor:{ + '已通过': 'primary', + '已拒绝': 'red', + '审核中': 'blue' + } }, // 计算 computed: { @@ -243,8 +246,9 @@ const rows = result.data.appData.resultData.rows; const statusMap = { - 'running': '审核中', - 'end': '已结束', + 'success': '已通过', + 'reject': '已拒绝', + 'running': '审核中' }; rows.forEach(row => { row.taskFormInput = JSON.parse(row.taskFormInput);