taskWaiting.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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
  63. v-if="scope.row.participantVo && (scope.row.participantVo.claim === null || scope.row.participantVo.claim === true)"
  64. type="primary"
  65. size="small"
  66. icon="Edit"
  67. @click="handleOpen(scope.row)"
  68. >办理</el-button
  69. >
  70. <el-button
  71. v-if="scope.row.participantVo && scope.row.participantVo.claim === true"
  72. type="primary"
  73. size="small"
  74. icon="Document"
  75. @click="handleReturnTask(scope.row.id)"
  76. >归还</el-button
  77. >
  78. <el-button
  79. v-if="scope.row.participantVo && scope.row.participantVo.claim === false"
  80. type="primary"
  81. size="small"
  82. icon="Document"
  83. @click="handleClaimTask(scope.row.id)"
  84. >认领</el-button
  85. >
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. <pagination
  90. v-show="total > 0"
  91. v-model:page="queryParams.pageNum"
  92. v-model:limit="queryParams.pageSize"
  93. :total="total"
  94. @pagination="handleQuery"
  95. />
  96. </el-card>
  97. </div>
  98. </template>
  99. <script lang="ts" setup>
  100. import { getPageByTaskWait, claim, returnTask } from '@/api/workflow/task';
  101. import { TaskQuery, TaskVO } from '@/api/workflow/task/types';
  102. import workflowCommon from '@/api/workflow/workflowCommon';
  103. import { RouterJumpVo } from '@/api/workflow/workflowCommon/types';
  104. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  105. const { wf_business_status } = toRefs<any>(proxy?.useDict('wf_business_status'));
  106. //提交组件
  107. const queryFormRef = ref<ElFormInstance>();
  108. // 遮罩层
  109. const loading = ref(true);
  110. // 选中数组
  111. const ids = ref<Array<any>>([]);
  112. // 非单个禁用
  113. const single = ref(true);
  114. // 非多个禁用
  115. const multiple = ref(true);
  116. // 显示搜索条件
  117. const showSearch = ref(true);
  118. // 总条数
  119. const total = ref(0);
  120. // 模型定义表格数据
  121. const taskList = ref([]);
  122. // 查询参数
  123. const queryParams = ref<TaskQuery>({
  124. pageNum: 1,
  125. pageSize: 10,
  126. name: undefined,
  127. processDefinitionName: undefined,
  128. processDefinitionKey: undefined
  129. });
  130. onMounted(() => {
  131. getWaitingList();
  132. });
  133. /** 搜索按钮操作 */
  134. const handleQuery = () => {
  135. getWaitingList();
  136. };
  137. /** 重置按钮操作 */
  138. const resetQuery = () => {
  139. queryFormRef.value?.resetFields();
  140. queryParams.value.pageNum = 1;
  141. queryParams.value.pageSize = 10;
  142. handleQuery();
  143. };
  144. // 多选框选中数据
  145. const handleSelectionChange = (selection: any) => {
  146. ids.value = selection.map((item: any) => item.id);
  147. single.value = selection.length !== 1;
  148. multiple.value = !selection.length;
  149. };
  150. //分页
  151. const getWaitingList = () => {
  152. loading.value = true;
  153. getPageByTaskWait(queryParams.value).then((resp) => {
  154. taskList.value = resp.rows;
  155. total.value = resp.total;
  156. loading.value = false;
  157. });
  158. };
  159. //办理
  160. const handleOpen = async (row: TaskVO) => {
  161. const routerJumpVo = reactive<RouterJumpVo>({
  162. wfDefinitionConfigVo: row.wfDefinitionConfigVo,
  163. wfNodeConfigVo: row.wfNodeConfigVo,
  164. businessKey: row.businessKey,
  165. taskId: row.id,
  166. type: 'approval'
  167. });
  168. workflowCommon.routerJump(routerJumpVo, proxy);
  169. };
  170. /** 认领任务 */
  171. const handleClaimTask = async (taskId: string) => {
  172. loading.value = true;
  173. await claim(taskId).finally(() => (loading.value = false));
  174. getWaitingList();
  175. proxy?.$modal.msgSuccess('操作成功');
  176. };
  177. /** 归还任务 */
  178. const handleReturnTask = async (taskId: string) => {
  179. loading.value = true;
  180. await returnTask(taskId).finally(() => (loading.value = false));
  181. getWaitingList();
  182. proxy?.$modal.msgSuccess('操作成功');
  183. };
  184. </script>