detailNew.vue 9.0 KB

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