Commit 5022ed2533d3f4e2b8334eb9018908bea8cc07b5

Authored by YunaiV
1 parent f0963c39

流程详情页 60% - 审批记录

yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java
... ... @@ -95,7 +95,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
95 95 // 获得任务列表
96 96 List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery()
97 97 .processInstanceId(processInstanceId)
98   - .orderByTaskCreateTime().desc().list();
  98 + .orderByHistoricTaskInstanceStartTime().desc() // 创建时间倒序
  99 + .list();
99 100 if (CollUtil.isEmpty(tasks)) {
100 101 return Collections.emptyList();
101 102 }
... ... @@ -401,7 +402,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
401 402 @Override
402 403 public void updateTaskExtComplete(org.activiti.api.task.model.Task task) {
403 404 BpmTaskExtDO taskExtDO = BpmTaskConvert.INSTANCE.convert(task)
404   - .setEndTime(task.getCompletedDate())
  405 + .setEndTime(new Date()) // 此时不能使用 task 的 completeData,因为还是空的。
405 406 .setResult(BpmProcessInstanceResultEnum.APPROVE.getResult());
406 407 taskExtMapper.updateByTaskId(taskExtDO);
407 408 }
... ...
yudao-admin-ui/src/views/bpm/processInstance/detail.vue
... ... @@ -12,7 +12,37 @@
12 12 </div>
13 13 </el-col>
14 14 </el-card>
15   - <!-- TODO 审批记录 -->
  15 + <el-card class="box-card" v-loading="historicTasksLoad">
  16 + <div slot="header" class="clearfix">
  17 + <span class="el-icon-picture-outline">审批记录</span>
  18 + </div>
  19 + <el-col :span="16" :offset="4" >
  20 + <div class="block">
  21 + <el-timeline>
  22 + <el-timeline-item v-for="(item, index) in historicTasks" :key="index"
  23 + :icon="getTimelineItemIcon(item)"
  24 + :type="getTimelineItemType(item)">
  25 + <p style="font-weight: 700">任务:{{ item.name }}</p>
  26 + <el-card :body-style="{ padding: '10px' }">
  27 + <label v-if="item.assigneeUser" style="font-weight: normal; margin-right: 30px;">
  28 + 审批人:{{ item.assigneeUser.nickname }}
  29 + <el-tag type="info" size="mini">{{ item.assigneeUser.deptName }}</el-tag>
  30 + </label>
  31 + <label style="font-weight: normal">创建时间:</label>
  32 + <label style="color:#8a909c; font-weight: normal">{{ parseTime(item.createTime) }}</label>
  33 + <label v-if="item.endTime" style="margin-left: 30px;font-weight: normal">审批时间:</label>
  34 + <label v-if="item.endTime" style="color:#8a909c;font-weight: normal"> {{ parseTime(item.endTime) }}</label>
  35 + <label v-if="item.durationInMillis" style="margin-left: 30px;font-weight: normal">耗时:</label>
  36 + <label v-if="item.durationInMillis" style="color:#8a909c;font-weight: normal"> {{ getDateStar(item.durationInMillis) }} </label>
  37 + <p v-if="item.comment">
  38 + <el-tag :type="getTimelineItemType(item)">{{ item.comment }}</el-tag>
  39 + </p>
  40 + </el-card>
  41 + </el-timeline-item>
  42 + </el-timeline>
  43 + </div>
  44 + </el-col>
  45 + </el-card>
16 46 <!-- TODO 流程图 -->
17 47 <el-card class="box-card" v-loading="processInstanceLoading">
18 48 <div slot="header" class="clearfix">
... ... @@ -31,6 +61,7 @@ import {decodeFields} from &quot;@/utils/formGenerator&quot;;
31 61 import Parser from '@/components/parser/Parser'
32 62 import {createProcessInstance, getMyProcessInstancePage, getProcessInstance} from "@/api/bpm/processInstance";
33 63 import {getHistoricTaskListByProcessInstanceId} from "@/api/bpm/task";
  64 +import {getDate} from "@/utils/dateUtils";
34 65  
35 66 // 流程实例的详情页,可用于审批
36 67 export default {
... ... @@ -114,7 +145,21 @@ export default {
114 145 this.historicTasksLoad = true;
115 146 getHistoricTaskListByProcessInstanceId(this.id).then(response => {
116 147 this.historicTasks = response.data;
117   - this.historicTasksLoad = true;
  148 + // 排序,将未完成的排在前面,已完成的排在后面;
  149 + this.historicTasks.sort((a, b) => {
  150 + // 有已完成的情况,按照完成时间倒序
  151 + if (a.endTime && b.endTime) {
  152 + return b.endTime - a.endTime;
  153 + } else if (a.endTime) {
  154 + return 1;
  155 + } else if (b.endTime) {
  156 + return -1;
  157 + // 都是未完成,按照创建时间倒序
  158 + } else {
  159 + return b.createTime - a.createTime;
  160 + }
  161 + });
  162 + this.historicTasksLoad = false;
118 163 });
119 164 },
120 165 /** 处理选择流程的按钮操作 **/
... ... @@ -161,6 +206,39 @@ export default {
161 206 conf.formBtns = true; // 按钮展示
162 207 })
163 208 },
  209 + getDateStar(ms) {
  210 + return getDate(ms);
  211 + },
  212 + getTimelineItemIcon(item) {
  213 + if (item.result === 1) {
  214 + return 'el-icon-time';
  215 + }
  216 + if (item.result === 2) {
  217 + return 'el-icon-check';
  218 + }
  219 + if (item.result === 3) {
  220 + return 'el-icon-close';
  221 + }
  222 + if (item.result === 4) {
  223 + return 'el-icon-remove-outline';
  224 + }
  225 + return '';
  226 + },
  227 + getTimelineItemType(item) {
  228 + if (item.result === 1) {
  229 + return 'primary';
  230 + }
  231 + if (item.result === 2) {
  232 + return 'success';
  233 + }
  234 + if (item.result === 3) {
  235 + return 'danger';
  236 + }
  237 + if (item.result === 4) {
  238 + return 'info';
  239 + }
  240 + return '';
  241 + },
164 242 }
165 243 };
166 244 </script>
... ...