taskWaiting.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div class="p-2">
  3. <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
  4. <div v-show="showSearch" class="mb-[10px]">
  5. <el-card shadow="hover">
  6. <el-form v-show="showSearch" ref="queryFormRef" :model="queryParams" :inline="true" label-width="68px">
  7. <el-form-item label="任务名称" prop="name">
  8. <el-input v-model="queryParams.name" placeholder="请输入任务名称" @keyup.enter="handleQuery" />
  9. </el-form-item>
  10. <el-form-item label="流程定义名称" label-width="100" prop="processDefinitionName">
  11. <el-input v-model="queryParams.processDefinitionName" placeholder="请输入流程定义名称" @keyup.enter="handleQuery" />
  12. </el-form-item>
  13. <el-form-item label="流程定义KEY" label-width="100" prop="processDefinitionKey">
  14. <el-input v-model="queryParams.processDefinitionKey" placeholder="请输入流程定义KEY" @keyup.enter="handleQuery" />
  15. </el-form-item>
  16. <el-form-item>
  17. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  18. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  19. </el-form-item>
  20. </el-form>
  21. </el-card>
  22. </div>
  23. </transition>
  24. <el-card shadow="hover">
  25. <template #header>
  26. <el-row :gutter="10" class="mb8">
  27. <right-toolbar v-model:showSearch="showSearch" @query-table="handleQuery"></right-toolbar>
  28. </el-row>
  29. </template>
  30. <el-table v-loading="loading" border :data="taskList" @selection-change="handleSelectionChange">
  31. <el-table-column type="selection" width="55" align="center" />
  32. <el-table-column align="center" type="index" label="序号" width="60"></el-table-column>
  33. <el-table-column :show-overflow-tooltip="true" align="center" label="流程定义名称">
  34. <template #default="scope">
  35. <span>{{ scope.row.processDefinitionName }}v{{ scope.row.processDefinitionVersion }}.0</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column align="center" prop="processDefinitionKey" label="流程定义KEY"></el-table-column>
  39. <el-table-column align="center" prop="name" label="任务名称"></el-table-column>
  40. <el-table-column align="center" prop="assigneeName" label="办理人">
  41. <template #default="scope">
  42. <template v-if="scope.row.participantVo && scope.row.assignee === null">
  43. <el-tag v-for="(item, index) in scope.row.participantVo.candidateName" :key="index" type="success">
  44. {{ item }}
  45. </el-tag>
  46. </template>
  47. <template v-else>
  48. <el-tag type="success">
  49. {{ scope.row.assigneeName || '无' }}
  50. </el-tag>
  51. </template>
  52. </template>
  53. </el-table-column>
  54. <el-table-column align="center" label="流程状态" min-width="70">
  55. <template #default="scope">
  56. <dict-tag :options="wf_business_status" :value="scope.row.businessStatus"></dict-tag>
  57. </template>
  58. </el-table-column>
  59. <el-table-column align="center" prop="createTime" label="创建时间" width="160"></el-table-column>
  60. <el-table-column label="操作" align="center" width="200">
  61. <template #default="scope">
  62. <el-button v-if="scope.row.participantVo && (scope.row.participantVo.claim === null || scope.row.participantVo.claim === true)"
  63. type="primary" size="small" icon="Edit" @click="handleOpen(scope.row)">办理</el-button>
  64. <el-button v-if="scope.row.participantVo && scope.row.participantVo.claim === true"
  65. type="primary" size="small" icon="Document" @click="handleReturnTask(scope.row.id)">归还</el-button>
  66. <el-button v-if="scope.row.participantVo && scope.row.participantVo.claim === false"
  67. type="primary" size="small" icon="Document" @click="handleClaimTask(scope.row.id)">认领</el-button>
  68. </template>
  69. </el-table-column>
  70. </el-table>
  71. <pagination
  72. v-show="total > 0"
  73. v-model:page="queryParams.pageNum"
  74. v-model:limit="queryParams.pageSize"
  75. :total="total"
  76. @pagination="handleQuery"
  77. />
  78. </el-card>
  79. </div>
  80. </template>
  81. <script lang="ts" setup>
  82. import { getPageByTaskWait, claim, returnTask } from '@/api/workflow/task';
  83. import { TaskQuery, TaskVO } from '@/api/workflow/task/types';
  84. import workflowCommon from '@/api/workflow/workflowCommon';
  85. import { RouterJumpVo } from '@/api/workflow/workflowCommon/types';
  86. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  87. const { wf_business_status } = toRefs<any>(proxy?.useDict('wf_business_status'));
  88. //提交组件
  89. const queryFormRef = ref<ElFormInstance>();
  90. // 遮罩层
  91. const loading = ref(true);
  92. // 选中数组
  93. const ids = ref<Array<any>>([]);
  94. // 非单个禁用
  95. const single = ref(true);
  96. // 非多个禁用
  97. const multiple = ref(true);
  98. // 显示搜索条件
  99. const showSearch = ref(true);
  100. // 总条数
  101. const total = ref(0);
  102. // 模型定义表格数据
  103. const taskList = ref([]);
  104. // 查询参数
  105. const queryParams = ref<TaskQuery>({
  106. pageNum: 1,
  107. pageSize: 10,
  108. name: undefined,
  109. processDefinitionName: undefined,
  110. processDefinitionKey: undefined
  111. });
  112. onMounted(() => {
  113. getWaitingList();
  114. });
  115. /** 搜索按钮操作 */
  116. const handleQuery = () => {
  117. getWaitingList();
  118. };
  119. /** 重置按钮操作 */
  120. const resetQuery = () => {
  121. queryFormRef.value?.resetFields();
  122. queryParams.value.pageNum = 1;
  123. queryParams.value.pageSize = 10;
  124. handleQuery();
  125. };
  126. // 多选框选中数据
  127. const handleSelectionChange = (selection: any) => {
  128. ids.value = selection.map((item: any) => item.id);
  129. single.value = selection.length !== 1;
  130. multiple.value = !selection.length;
  131. };
  132. //分页
  133. const getWaitingList = () => {
  134. loading.value = true;
  135. getPageByTaskWait(queryParams.value).then((resp) => {
  136. taskList.value = resp.rows;
  137. total.value = resp.total;
  138. loading.value = false;
  139. });
  140. };
  141. //办理
  142. const handleOpen = async (row: TaskVO) => {
  143. const routerJumpVo = reactive<RouterJumpVo>({
  144. wfDefinitionConfigVo: row.wfDefinitionConfigVo,
  145. wfNodeConfigVo: row.wfNodeConfigVo,
  146. businessKey: row.businessKey,
  147. taskId: row.id,
  148. type: 'approval'
  149. });
  150. workflowCommon.routerJump(routerJumpVo,proxy)
  151. };
  152. /** 认领任务 */
  153. const handleClaimTask = async (taskId: string) => {
  154. loading.value = true;
  155. await claim(taskId).finally(() => (loading.value = false));
  156. getWaitingList();
  157. proxy?.$modal.msgSuccess('操作成功');
  158. };
  159. /** 归还任务 */
  160. const handleReturnTask = async (taskId: string) => {
  161. loading.value = true;
  162. await returnTask(taskId).finally(() => (loading.value = false));
  163. getWaitingList();
  164. proxy?.$modal.msgSuccess('操作成功');
  165. };
  166. </script>