handled.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div class="app-container">
  3. <el-card>
  4. <template #header>
  5. <div class="card-header">
  6. <span>我的已办</span>
  7. </div>
  8. </template>
  9. <el-form :inline="true" :model="queryParams" class="search-form">
  10. <el-form-item label="流程名称">
  11. <el-input v-model="queryParams.processName" placeholder="请输入流程名称" clearable />
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="primary" @click="handleQuery">查询</el-button>
  15. <el-button @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-table v-loading="loading" :data="tableData" border>
  19. <el-table-column type="index" label="序号" width="60" />
  20. <el-table-column prop="definitionName" label="流程名称" />
  21. <el-table-column label="处理节点" show-overflow-tooltip>
  22. <template #default="{ row }">
  23. {{ row.subNodeName ? row.nodeName + ' / ' + row.subNodeName : row.nodeName }}
  24. </template>
  25. </el-table-column>
  26. <el-table-column prop="action" label="操作结果" width="100">
  27. <template #default="{ row }">
  28. <el-tag :type="actionTagType(row.action)">
  29. {{ actionText(row.action) }}
  30. </el-tag>
  31. </template>
  32. </el-table-column>
  33. <el-table-column prop="comment" label="审批意见" show-overflow-tooltip />
  34. <el-table-column prop="endTime" label="处理时间" />
  35. </el-table>
  36. <el-pagination
  37. v-model:current-page="queryParams.pageNum"
  38. v-model:page-size="queryParams.pageSize"
  39. :total="total"
  40. :page-sizes="[10, 20, 50]"
  41. layout="total, sizes, prev, pager, next, jumper"
  42. class="pagination"
  43. @current-change="loadData"
  44. @size-change="loadData"
  45. />
  46. </el-card>
  47. </div>
  48. </template>
  49. <script setup lang="ts">
  50. import { ref, reactive, onMounted } from 'vue'
  51. import { listHandled } from '@/api/flow/task'
  52. import type { FlowTask } from '@/types/flow'
  53. import { ElMessage } from 'element-plus'
  54. const loading = ref(false)
  55. const tableData = ref<FlowTask[]>([])
  56. const total = ref(0)
  57. const queryParams = reactive({
  58. pageNum: 1,
  59. pageSize: 10,
  60. processName: undefined as string | undefined
  61. })
  62. function actionText(action?: string) {
  63. const key = (action || '').toUpperCase()
  64. const map: Record<string, string> = {
  65. PASS: '通过',
  66. REJECT: '拒绝',
  67. RETURN: '回退',
  68. ROLLBACK: '回退',
  69. TRANSFER: '转办',
  70. ADD_SIGN: '加签'
  71. }
  72. return map[key] || action || '-'
  73. }
  74. function actionTagType(action?: string) {
  75. const key = (action || '').toUpperCase()
  76. const map: Record<string, any> = {
  77. PASS: 'success',
  78. REJECT: 'danger',
  79. RETURN: 'warning',
  80. ROLLBACK: 'warning',
  81. TRANSFER: 'info',
  82. ADD_SIGN: 'info'
  83. }
  84. return map[key] || 'info'
  85. }
  86. async function loadData() {
  87. loading.value = true
  88. try {
  89. const res = await listHandled(queryParams)
  90. tableData.value = res.list
  91. total.value = res.total
  92. } catch {
  93. ElMessage.error('加载已办任务失败')
  94. } finally {
  95. loading.value = false
  96. }
  97. }
  98. function handleQuery() {
  99. queryParams.pageNum = 1
  100. loadData()
  101. }
  102. function resetQuery() {
  103. queryParams.processName = undefined
  104. queryParams.pageNum = 1
  105. loadData()
  106. }
  107. onMounted(loadData)
  108. </script>
  109. <style scoped>
  110. .card-header {
  111. display: flex;
  112. justify-content: space-between;
  113. align-items: center;
  114. }
  115. .pagination {
  116. margin-top: 20px;
  117. justify-content: flex-end;
  118. }
  119. .search-form {
  120. margin-bottom: 20px;
  121. }
  122. </style>