ProcessInstanceTaskList.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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="3" :span="17">
  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.status" />
  18. <el-button
  19. class="ml-10px"
  20. v-if="!isEmpty(item.children)"
  21. @click="openChildrenTask(item)"
  22. size="small"
  23. >
  24. <Icon icon="ep:memo" /> 子任务
  25. </el-button>
  26. <el-button
  27. class="ml-10px"
  28. size="small"
  29. v-if="item.formId > 0"
  30. @click="handleFormDetail(item)"
  31. >
  32. <Icon icon="ep:document" /> 查看表单
  33. </el-button>
  34. </p>
  35. <el-card :body-style="{ padding: '10px' }">
  36. <label v-if="item.assigneeUser" style="margin-right: 30px; font-weight: normal">
  37. 审批人:{{ item.assigneeUser.nickname }}
  38. <el-tag size="small" type="info">{{ item.assigneeUser.deptName }}</el-tag>
  39. </label>
  40. <label v-if="item.createTime" style="font-weight: normal">创建时间:</label>
  41. <label style="font-weight: normal; color: #8a909c">
  42. {{ formatDate(item?.createTime) }}
  43. </label>
  44. <label v-if="item.endTime" style="margin-left: 30px; font-weight: normal">
  45. 审批时间:
  46. </label>
  47. <label v-if="item.endTime" style="font-weight: normal; color: #8a909c">
  48. {{ formatDate(item?.endTime) }}
  49. </label>
  50. <label v-if="item.durationInMillis" style="margin-left: 30px; font-weight: normal">
  51. 耗时:
  52. </label>
  53. <label v-if="item.durationInMillis" style="font-weight: normal; color: #8a909c">
  54. {{ formatPast2(item?.durationInMillis) }}
  55. </label>
  56. <p v-if="item.reason"> 审批建议:{{ item.reason }} </p>
  57. </el-card>
  58. </el-timeline-item>
  59. </el-timeline>
  60. </div>
  61. </el-col>
  62. </el-card>
  63. <!-- 弹窗:子任务 -->
  64. <TaskSignList ref="taskSignListRef" @success="refresh" />
  65. <!-- 弹窗:表单 -->
  66. <Dialog title="表单详情" v-model="taskFormVisible" width="600">
  67. <form-create
  68. ref="fApi"
  69. v-model="taskForm.value"
  70. :option="taskForm.option"
  71. :rule="taskForm.rule"
  72. />
  73. </Dialog>
  74. </template>
  75. <script lang="ts" setup>
  76. import { formatDate, formatPast2 } from '@/utils/formatTime'
  77. import { propTypes } from '@/utils/propTypes'
  78. import { DICT_TYPE } from '@/utils/dict'
  79. import { isEmpty } from '@/utils/is'
  80. import TaskSignList from './dialog/TaskSignList.vue'
  81. import type { ApiAttrs } from '@form-create/element-ui/types/config'
  82. import { setConfAndFields2 } from '@/utils/formCreate'
  83. defineOptions({ name: 'BpmProcessInstanceTaskList' })
  84. defineProps({
  85. loading: propTypes.bool, // 是否加载中
  86. tasks: propTypes.arrayOf(propTypes.object) // 流程任务的数组
  87. })
  88. /** 获得任务对应的 icon */
  89. // TODO @芋艿:对应的 icon 需要调整
  90. const getTimelineItemIcon = (item) => {
  91. if (item.status === 1) {
  92. return 'el-icon-time'
  93. }
  94. if (item.status === 2) {
  95. return 'el-icon-check'
  96. }
  97. if (item.status === 3) {
  98. return 'el-icon-close'
  99. }
  100. if (item.status === 4) {
  101. return 'el-icon-remove-outline'
  102. }
  103. if (item.status === 5) {
  104. return 'el-icon-back'
  105. }
  106. return ''
  107. }
  108. /** 获得任务对应的颜色 */
  109. const getTimelineItemType = (item: any) => {
  110. if (item.status === 1) {
  111. return 'primary'
  112. }
  113. if (item.status === 2) {
  114. return 'success'
  115. }
  116. if (item.status === 3) {
  117. return 'danger'
  118. }
  119. if (item.status === 4) {
  120. return 'info'
  121. }
  122. if (item.status === 5) {
  123. return 'warning'
  124. }
  125. if (item.status === 6) {
  126. return 'default'
  127. }
  128. if (item.status === 7 || item.status === 8) {
  129. return 'warning'
  130. }
  131. return ''
  132. }
  133. /** 子任务 */
  134. const taskSignListRef = ref()
  135. const openChildrenTask = (item: any) => {
  136. taskSignListRef.value.open(item)
  137. }
  138. /** 查看表单 */
  139. const fApi = ref<ApiAttrs>() // form-create 的 API 操作类
  140. const taskForm = ref({
  141. rule: [],
  142. option: {},
  143. value: {}
  144. }) // 流程任务的表单详情
  145. const taskFormVisible = ref(false)
  146. const handleFormDetail = async (row) => {
  147. // 设置表单
  148. setConfAndFields2(taskForm, row.formConf, row.formFields, row.formVariables)
  149. // 弹窗打开
  150. taskFormVisible.value = true
  151. // 隐藏提交、重置按钮,设置禁用只读
  152. await nextTick()
  153. fApi.value.fapi.btn.show(false)
  154. fApi.value?.fapi?.resetBtn.show(false)
  155. fApi.value?.fapi?.disabled(true)
  156. }
  157. /** 刷新数据 */
  158. const emit = defineEmits(['refresh']) // 定义 success 事件,用于操作成功后的回调
  159. const refresh = () => {
  160. emit('refresh')
  161. }
  162. </script>