ProcessInstanceTaskList.vue 5.7 KB

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