detail.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div class="app-container" style="padding: 15px">
  3. <!-- 审批记录 -->
  4. <el-card class="box-card" v-loading="tasksLoad">
  5. <div slot="header" class="clearfix">
  6. <span class="el-icon-picture-outline">审批记录</span>
  7. </div>
  8. <el-col :span="16" :offset="4">
  9. <div class="block">
  10. <el-timeline>
  11. <el-timeline-item
  12. v-for="(item, index) in tasks"
  13. :key="index"
  14. :icon="getTimelineItemIcon(item)"
  15. :type="getTimelineItemType(item)"
  16. >
  17. <p style="font-weight: 700">任务:{{ item.name }}</p>
  18. <el-card :body-style="{ padding: '10px' }">
  19. <label
  20. v-if="item.assigneeUser"
  21. style="font-weight: normal; margin-right: 30px"
  22. >
  23. {{index==0?' 审批人':'发起人' }}:{{ item.assigneeUser.nickname }}
  24. <el-tag type="info" size="mini">{{
  25. item.assigneeUser.deptName
  26. }}</el-tag>
  27. </label>
  28. <label style="font-weight: normal" v-if="item.createTime"
  29. >创建时间:</label
  30. >
  31. <label style="color: #8a909c; font-weight: normal">{{
  32. item.createTime
  33. }}</label>
  34. <label
  35. v-if="item.endTime"
  36. style="margin-left: 30px; font-weight: normal"
  37. >审批时间:</label
  38. >
  39. <label
  40. v-if="item.endTime"
  41. style="color: #8a909c; font-weight: normal"
  42. >
  43. {{ item.endTime }}</label
  44. >
  45. <label
  46. v-if="item.durationInMillis"
  47. style="margin-left: 30px; font-weight: normal"
  48. >耗时:</label
  49. >
  50. <label
  51. v-if="item.durationInMillis"
  52. style="color: #8a909c; font-weight: normal"
  53. >
  54. {{ getDateStar(item.durationInMillis) }}
  55. </label>
  56. <label v-if="item.result!=1" style="margin-left: 30px;color: #8a909c; font-weight: normal">
  57. 签名:
  58. </label>
  59. <label v-if="item.result!=1">
  60. <el-image
  61. style="width: 50px; height: 50px;position: absolute;transform: translate(0px, 0px);"
  62. :src="item?.assigneeUser?.signature[0]?.url">
  63. <div slot="error" class="image-slot">
  64. <!-- <i class="el-icon-picture-outline"></i>-->
  65. <span></span>
  66. </div>
  67. </el-image>
  68. </label>
  69. <p v-if="item.reason&&item.result!=4">
  70. <el-tag :type="getTimelineItemType(item)">{{
  71. item.reason
  72. }}</el-tag>
  73. </p>
  74. </el-card>
  75. </el-timeline-item>
  76. </el-timeline>
  77. </div>
  78. </el-col>
  79. </el-card>
  80. <!-- 高亮流程图 -->
  81. <el-card class="box-card" v-loading="processInstanceLoading">
  82. <div slot="header" class="clearfix">
  83. <span class="el-icon-picture-outline">流程图</span>
  84. </div>
  85. <my-process-viewer
  86. key="designer"
  87. v-model="bpmnXML"
  88. v-bind="bpmnControlForm"
  89. :activityData="activityList"
  90. :processInstanceData="processInstance"
  91. :taskData="tasks"
  92. />
  93. </el-card>
  94. </div>
  95. </template>
  96. <script>
  97. import {
  98. getProcessDefinitionBpmnXML,
  99. getProcessInstance,
  100. getTaskListByProcessInstanceId,
  101. getActivityList
  102. } from '@/api/bpm/index';
  103. import store from '@/store';
  104. import { getDate } from '@/utils/dateUtils';
  105. import dictMixins from '@/mixins/dictMixins';
  106. // import Vue from 'vue';
  107. // 流程实例的详情页,可用于审批
  108. export default {
  109. name: 'ProcessInstanceDetail',
  110. mixins: [dictMixins],
  111. props: {
  112. id: {
  113. default: ''
  114. }
  115. },
  116. components: {},
  117. data() {
  118. return {
  119. // 遮罩层
  120. processInstanceLoading: true,
  121. dialogVisible: false,
  122. // 流程实例
  123. // id: undefined, // 流程实例的编号
  124. processInstance: {},
  125. // BPMN 数据
  126. bpmnXML: null,
  127. bpmnControlForm: {
  128. prefix: 'flowable'
  129. },
  130. activityList: [],
  131. // 审批记录
  132. tasksLoad: true,
  133. tasks: []
  134. };
  135. },
  136. created() {
  137. this.getDetail();
  138. },
  139. methods: {
  140. /** 获得流程实例 */
  141. getDetail() {
  142. // 获得流程实例相关
  143. this.processInstanceLoading = true;
  144. getProcessInstance(this.id).then((response) => {
  145. if (!response) {
  146. this.$message.error('查询不到流程信息!');
  147. return;
  148. }
  149. // 设置流程信息
  150. this.processInstance = response;
  151. // //将业务表单,注册为动态组件
  152. // const path = this.processInstance.processDefinition.formCustomViewPath;
  153. // Vue.component("async-biz-form-component", function (resolve) {
  154. // require([`@/views${path}`], resolve);
  155. // });
  156. // 加载流程图
  157. getProcessDefinitionBpmnXML(
  158. this.processInstance.processDefinition.id
  159. ).then((response) => {
  160. this.bpmnXML = response;
  161. });
  162. // 加载活动列表
  163. getActivityList({
  164. processInstanceId: this.processInstance.id
  165. }).then((response) => {
  166. this.activityList = response;
  167. });
  168. // 取消加载中
  169. this.processInstanceLoading = false;
  170. });
  171. // 获得流程任务列表(审批记录)
  172. this.tasksLoad = true;
  173. getTaskListByProcessInstanceId(this.id).then((response) => {
  174. // 审批记录
  175. this.tasks = [];
  176. // 移除已取消的审批
  177. response.forEach((task) => {
  178. // if (task.result !== 4) {
  179. this.tasks.push(task);
  180. // }
  181. });
  182. // 排序,将未完成的排在前面,已完成的排在后面;
  183. this.tasks.sort((a, b) => {
  184. // 有已完成的情况,按照完成时间倒序
  185. if (a.endTime && b.endTime) {
  186. return b.endTime - a.endTime;
  187. } else if (a.endTime) {
  188. return 1;
  189. } else if (b.endTime) {
  190. return -1;
  191. // 都是未完成,按照创建时间倒序
  192. } else {
  193. return b.createTime - a.createTime;
  194. }
  195. });
  196. // 需要审核的记录
  197. const userId = store.getters.userId;
  198. this.tasks.forEach((task) => {
  199. if (task.result !== 1 && task.result !== 6) {
  200. // 只有待处理才需要
  201. return;
  202. }
  203. if (!task.assigneeUser || task.assigneeUser.id !== userId) {
  204. // 自己不是处理人
  205. return;
  206. }
  207. });
  208. // 取消加载中
  209. this.tasksLoad = false;
  210. });
  211. },
  212. getDateStar(ms) {
  213. return getDate(ms);
  214. },
  215. getTimelineItemIcon(item) {
  216. if (item.result === 1) {
  217. return 'el-icon-time';
  218. }
  219. if (item.result === 2) {
  220. return 'el-icon-check';
  221. }
  222. if (item.result === 3) {
  223. return 'el-icon-close';
  224. }
  225. if (item.result === 4) {
  226. return 'el-icon-remove-outline';
  227. }
  228. if (item.result === 5) {
  229. return 'el-icon-back';
  230. }
  231. return '';
  232. },
  233. getTimelineItemType(item) {
  234. if (item.result === 1) {
  235. return 'primary';
  236. }
  237. if (item.result === 2) {
  238. return 'success';
  239. }
  240. if (item.result === 3) {
  241. return 'danger';
  242. }
  243. if (item.result === 4) {
  244. return 'info';
  245. }
  246. if (item.result === 5) {
  247. return 'warning';
  248. }
  249. if (item.result === 6) {
  250. return 'default';
  251. }
  252. return '';
  253. },
  254. handleClose() {
  255. this.dialogVisible = false;
  256. }
  257. }
  258. };
  259. </script>
  260. <style lang="scss">
  261. .my-process-designer {
  262. height: calc(100vh - 200px);
  263. }
  264. .box-card {
  265. width: 100%;
  266. margin-bottom: 20px;
  267. }
  268. </style>