index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item label="任务名称" prop="name">
  12. <el-input
  13. v-model="queryParams.name"
  14. placeholder="请输入任务名称"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. />
  18. </el-form-item>
  19. <el-form-item label="状态" prop="status">
  20. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
  21. <el-option
  22. v-for="dict in getIntDictOptions(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT)"
  23. :key="dict.value"
  24. :label="dict.label"
  25. :value="dict.value"
  26. />
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item>
  30. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  31. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  32. <el-button
  33. type="success"
  34. plain
  35. @click="handleExport"
  36. :loading="exportLoading"
  37. v-hasPermi="['bpm:task:done:export']"
  38. >
  39. <Icon icon="ep:download" class="mr-5px" /> 导出
  40. </el-button>
  41. </el-form-item>
  42. </el-form>
  43. </ContentWrap>
  44. <!-- 列表 -->
  45. <ContentWrap>
  46. <el-table v-loading="loading" :data="list" align="center">
  47. <el-table-column label="任务编号" align="center" prop="id" width="300px" />
  48. <el-table-column label="任务名称" align="center" prop="name" />
  49. <el-table-column label="所属流程" align="center" prop="processInstance.name" />
  50. <el-table-column label="流程发起人" align="center" prop="processInstance.startUserNickname" />
  51. <el-table-column label="状态" align="center" prop="result">
  52. <template #default="scope">
  53. <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT" :value="scope.row.result" />
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="原因" align="center" prop="reason" />
  57. <el-table-column
  58. label="创建时间"
  59. align="center"
  60. prop="createTime"
  61. width="180"
  62. :formatter="dateFormatter"
  63. />
  64. <el-table-column label="操作" align="center">
  65. <template #default="scope">
  66. <el-button link type="primary" @click="openModal(scope.row)"> 流程信息 </el-button>
  67. <el-button link type="primary" @click="handleAudit(scope.row)"> 流程详情 </el-button>
  68. </template>
  69. </el-table-column>
  70. </el-table>
  71. <!-- 分页 -->
  72. <Pagination
  73. :total="total"
  74. v-model:page="queryParams.pageNo"
  75. v-model:limit="queryParams.pageSize"
  76. @pagination="getList"
  77. />
  78. </ContentWrap>
  79. <!-- 表单弹窗:详情 -->
  80. <TaskDoneDetail ref="modalRef" @success="getList" />
  81. </template>
  82. <script setup lang="tsx">
  83. import { dateFormatter } from '@/utils/formatTime'
  84. import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  85. import * as TaskApi from '@/api/bpm/task'
  86. import download from '@/utils/download'
  87. import TaskDoneDetail from './Taskdetail.vue'
  88. const loading = ref(true) // 列表的加载中
  89. const total = ref(0) // 列表的总页数
  90. const list = ref([]) // 列表的数据
  91. const message = useMessage() // 消息弹窗
  92. const exportLoading = ref(false) // 导出的加载中
  93. const queryFormRef = ref() // 搜索的表单
  94. const queryParams = reactive({
  95. pageNo: 1,
  96. pageSize: 10,
  97. name: '',
  98. status: undefined,
  99. createTime: []
  100. })
  101. /** 搜索按钮操作 */
  102. const handleQuery = () => {
  103. queryParams.pageNo = 1
  104. getList()
  105. }
  106. /** 详情操作 */
  107. const modalRef = ref()
  108. const openModal = (data: TaskApi.TaskVO) => {
  109. modalRef.value.openModal(data)
  110. }
  111. /** 重置按钮操作 */
  112. const resetQuery = () => {
  113. queryFormRef.value.resetFields()
  114. handleQuery()
  115. }
  116. /** 查询任务列表 */
  117. const getList = async () => {
  118. loading.value = true
  119. try {
  120. const data = await TaskApi.getDoneTaskPage(queryParams)
  121. list.value = data.list
  122. total.value = data.total
  123. } finally {
  124. loading.value = false
  125. }
  126. }
  127. /** 导出按钮操作 */
  128. const handleExport = async () => {
  129. try {
  130. // 导出的二次确认
  131. await message.exportConfirm()
  132. // 发起导出
  133. exportLoading.value = true
  134. const data = await TaskApi.exportTask(queryParams)
  135. download.excel(data, '任务列表.xls')
  136. } catch {
  137. } finally {
  138. exportLoading.value = false
  139. }
  140. }
  141. const { push } = useRouter() // 路由
  142. // 处理审批按钮
  143. const handleAudit = (row) => {
  144. push({
  145. name: 'BpmProcessInstanceDetail',
  146. query: {
  147. id: row.processInstance.id
  148. }
  149. })
  150. }
  151. /** 初始化 **/
  152. onMounted(() => {
  153. getList()
  154. })
  155. </script>