ProcessInstanceTaskList.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <el-card v-loading="loading" class="box-card">
  3. <template #header>
  4. <span class="el-icon-picture-outline">审批记录</span>
  5. </template>
  6. <el-col :offset="4" :span="16">
  7. <div class="block">
  8. <el-timeline>
  9. <el-timeline-item
  10. v-for="(item, index) in tasks"
  11. :key="index"
  12. :icon="getTimelineItemIcon(item)"
  13. :type="getTimelineItemType(item)"
  14. >
  15. <p style="font-weight: 700">
  16. 任务:{{ item.name }}
  17. <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT" :value="item.result" />
  18. <el-button
  19. style="margin-left: 5px"
  20. v-if="!isEmpty(item.children)"
  21. @click="openChildrenTask(item)"
  22. >
  23. <Icon icon="ep:memo" />
  24. 子任务
  25. </el-button>
  26. </p>
  27. <el-card :body-style="{ padding: '10px' }">
  28. <label v-if="item.assigneeUser" style="margin-right: 30px; font-weight: normal">
  29. 审批人:{{ item.assigneeUser.nickname }}
  30. <el-tag size="small" type="info">{{ item.assigneeUser.deptName }}</el-tag>
  31. </label>
  32. <label v-if="item.createTime" style="font-weight: normal">创建时间:</label>
  33. <label style="font-weight: normal; color: #8a909c">
  34. {{ formatDate(item?.createTime) }}
  35. </label>
  36. <label v-if="item.endTime" style="margin-left: 30px; font-weight: normal">
  37. 审批时间:
  38. </label>
  39. <label v-if="item.endTime" style="font-weight: normal; color: #8a909c">
  40. {{ formatDate(item?.endTime) }}
  41. </label>
  42. <label v-if="item.durationInMillis" style="margin-left: 30px; font-weight: normal">
  43. 耗时:
  44. </label>
  45. <label v-if="item.durationInMillis" style="font-weight: normal; color: #8a909c">
  46. {{ formatPast2(item?.durationInMillis) }}
  47. </label>
  48. <p v-if="item.reason">
  49. <el-tag :type="getTimelineItemType(item)">{{ item.reason }}</el-tag>
  50. </p>
  51. </el-card>
  52. </el-timeline-item>
  53. </el-timeline>
  54. </div>
  55. </el-col>
  56. <!-- 子任务 -->
  57. <ProcessInstanceChildrenTaskList ref="processInstanceChildrenTaskList" />
  58. </el-card>
  59. </template>
  60. <script lang="ts" setup>
  61. import { formatDate, formatPast2 } from '@/utils/formatTime'
  62. import { propTypes } from '@/utils/propTypes'
  63. import { DICT_TYPE } from '@/utils/dict'
  64. import { isEmpty } from '@/utils/is'
  65. import ProcessInstanceChildrenTaskList from './ProcessInstanceChildrenTaskList.vue'
  66. defineOptions({ name: 'BpmProcessInstanceTaskList' })
  67. defineProps({
  68. loading: propTypes.bool, // 是否加载中
  69. tasks: propTypes.arrayOf(propTypes.object) // 流程任务的数组
  70. })
  71. /** 获得任务对应的 icon */
  72. const getTimelineItemIcon = (item) => {
  73. if (item.result === 1) {
  74. return 'el-icon-time'
  75. }
  76. if (item.result === 2) {
  77. return 'el-icon-check'
  78. }
  79. if (item.result === 3) {
  80. return 'el-icon-close'
  81. }
  82. if (item.result === 4) {
  83. return 'el-icon-remove-outline'
  84. }
  85. if (item.result === 5) {
  86. return 'el-icon-back'
  87. }
  88. return ''
  89. }
  90. /** 获得任务对应的颜色 */
  91. const getTimelineItemType = (item) => {
  92. if (item.result === 1) {
  93. return 'primary'
  94. }
  95. if (item.result === 2) {
  96. return 'success'
  97. }
  98. if (item.result === 3) {
  99. return 'danger'
  100. }
  101. if (item.result === 4) {
  102. return 'info'
  103. }
  104. if (item.result === 5) {
  105. return 'warning'
  106. }
  107. if (item.result === 6) {
  108. return 'default'
  109. }
  110. if (item.result === 7 || item.result === 8) {
  111. return 'warning'
  112. }
  113. return ''
  114. }
  115. /**
  116. * 子任务
  117. */
  118. const processInstanceChildrenTaskList = ref()
  119. const openChildrenTask = (item) => {
  120. processInstanceChildrenTaskList.value.open(item)
  121. }
  122. </script>