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