allTaskWaiting.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <div class="p-2">
  3. <div class="mb-[10px]">
  4. <el-card shadow="hover" class="text-center">
  5. <el-radio-group v-model="tab" @change="changeTab(tab)">
  6. <el-radio-button label="waiting">待办任务</el-radio-button>
  7. <el-radio-button label="finish">已办任务</el-radio-button>
  8. </el-radio-group>
  9. </el-card>
  10. </div>
  11. <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
  12. <div v-show="showSearch" class="mb-[10px]">
  13. <el-card shadow="hover">
  14. <el-form v-show="showSearch" ref="queryFormRef" :model="queryParams" :inline="true" label-width="68px">
  15. <el-form-item label="任务名称" prop="name">
  16. <el-input v-model="queryParams.name" placeholder="请输入任务名称" @keyup.enter="handleQuery" />
  17. </el-form-item>
  18. <el-form-item label="流程定义名称" label-width="100" prop="processDefinitionName">
  19. <el-input v-model="queryParams.processDefinitionName" placeholder="请输入流程定义名称" @keyup.enter="handleQuery" />
  20. </el-form-item>
  21. <el-form-item label="流程定义KEY" label-width="100" prop="processDefinitionKey">
  22. <el-input v-model="queryParams.processDefinitionKey" placeholder="请输入流程定义KEY" @keyup.enter="handleQuery" />
  23. </el-form-item>
  24. <el-form-item>
  25. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  26. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  27. </el-form-item>
  28. </el-form>
  29. </el-card>
  30. </div>
  31. </transition>
  32. <el-card shadow="hover">
  33. <template #header>
  34. <el-row :gutter="10" class="mb8">
  35. <el-col :span="1.5">
  36. <el-button type="primary" plain icon="Edit" :disabled="multiple" @click="handleUpdate">修改办理人</el-button>
  37. </el-col>
  38. <right-toolbar v-model:showSearch="showSearch" @query-table="handleQuery"></right-toolbar>
  39. </el-row>
  40. </template>
  41. <el-table v-loading="loading" border :data="taskList" @selection-change="handleSelectionChange">
  42. <el-table-column type="selection" width="55" align="center" />
  43. <el-table-column align="center" type="index" label="序号" width="60"></el-table-column>
  44. <el-table-column :show-overflow-tooltip="true" align="center" label="流程定义名称">
  45. <template #default="scope">
  46. <span>{{ scope.row.processDefinitionName }}v{{ scope.row.processDefinitionVersion }}.0</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column align="center" prop="processDefinitionKey" label="流程定义KEY"></el-table-column>
  50. <el-table-column align="center" prop="name" label="任务名称"></el-table-column>
  51. <el-table-column align="center" prop="assigneeName" label="办理人">
  52. <template v-if="tab === 'waiting'" #default="scope">
  53. <template v-if="scope.row.participantVo && scope.row.assignee === null">
  54. <el-tag v-for="(item, index) in scope.row.participantVo.candidateName" :key="index" type="success">
  55. {{ item }}
  56. </el-tag>
  57. </template>
  58. <template v-else>
  59. <el-tag type="success">
  60. {{ scope.row.assigneeName || '无'}}
  61. </el-tag>
  62. </template>
  63. </template>
  64. <template v-else-if="tab === 'finish'" #default="scope">
  65. <el-tag type="success">
  66. {{ scope.row.assigneeName || '无'}}
  67. </el-tag>
  68. </template>
  69. </el-table-column>
  70. <el-table-column align="center" label="流程状态" min-width="70">
  71. <template #default="scope">
  72. <dict-tag v-if="tab === 'waiting'" :options="wf_business_status" :value="scope.row.businessStatus"></dict-tag>
  73. <el-tag v-else type="success">已完成</el-tag>
  74. </template>
  75. </el-table-column>
  76. <el-table-column align="center" v-if="tab === 'waiting'" prop="createTime" label="创建时间" width="160"></el-table-column>
  77. <el-table-column align="center" v-if="tab === 'finish'" prop="startTime" label="创建时间" width="160"></el-table-column>
  78. <el-table-column label="操作" align="center" :width="tab === 'finish' ? '80' : '151'">
  79. <template #default="scope">
  80. <el-row :gutter="10" class="mb8">
  81. <el-col :span="1.5">
  82. <el-button link type="primary" size="small" icon="View" @click="handleView(scope.row)">查看</el-button>
  83. </el-col>
  84. <el-col v-if="tab === 'waiting'" :span="1.5">
  85. <el-button link type="primary" size="small" icon="Document" @click="handleInstanceVariable(scope.row)">流程变量</el-button>
  86. </el-col>
  87. </el-row>
  88. <el-row :gutter="10" class="mb8" v-if="scope.row.multiInstance" >
  89. <el-col :span="1.5">
  90. <el-button link type="primary" size="small" icon="Remove" @click="deleteMultiInstanceUser(scope.row)">减签</el-button>
  91. </el-col>
  92. <el-col :span="1.5">
  93. <el-button link type="primary" size="small" icon="CirclePlus" @click="addMultiInstanceUser(scope.row)">加签</el-button>
  94. </el-col>
  95. </el-row>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <pagination
  100. v-show="total > 0"
  101. v-model:page="queryParams.pageNum"
  102. v-model:limit="queryParams.pageSize"
  103. :total="total"
  104. @pagination="handleQuery"
  105. />
  106. </el-card>
  107. <!-- 加签组件 -->
  108. <multiInstanceUser ref="multiInstanceUserRef" :title="title" @submit-callback="handleQuery" />
  109. <!-- 选人组件 -->
  110. <UserSelect ref="userSelectRef" :multiple="false" @confirm-call-back="submitCallback"></UserSelect>
  111. <!-- 流程变量开始 -->
  112. <el-dialog v-model="variableVisible" draggable title="流程变量" width="60%" :close-on-click-modal="false">
  113. <el-card class="box-card" v-loading="variableLoading">
  114. <div slot="header" class="clearfix">
  115. <span>流程定义名称:<el-tag>{{processDefinitionName}}</el-tag></span>
  116. </div>
  117. <div v-for="(v,index) in variableList" :key="index" >
  118. <el-form :label-position="'right'" v-if="v.key!=='_FLOWABLE_SKIP_EXPRESSION_ENABLED'" label-width="150px">
  119. <el-form-item :label="v.key+':'">
  120. {{v.value}}
  121. </el-form-item>
  122. </el-form>
  123. </div>
  124. </el-card>
  125. </el-dialog>
  126. <!-- 流程变量结束 -->
  127. </div>
  128. </template>
  129. <script lang="ts" setup>
  130. import { getPageByAllTaskWait, getPageByAllTaskFinish, updateAssignee, getInstanceVariable } from '@/api/workflow/task';
  131. import MultiInstanceUser from '@/components/Process/multiInstanceUser.vue';
  132. import UserSelect from '@/components/UserSelect';
  133. import { TaskQuery, TaskVO, VariableVo } from '@/api/workflow/task/types';
  134. import workflowCommon from '@/api/workflow/workflowCommon';
  135. import { RouterJumpVo } from '@/api/workflow/workflowCommon/types';
  136. //审批记录组件
  137. //加签组件
  138. const multiInstanceUserRef = ref<InstanceType<typeof MultiInstanceUser>>();
  139. //选人组件
  140. const userSelectRef = ref<InstanceType<typeof UserSelect>>();
  141. const queryFormRef = ref<ElFormInstance>();
  142. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  143. const { wf_business_status } = toRefs<any>(proxy?.useDict('wf_business_status'));
  144. // 遮罩层
  145. const loading = ref(true);
  146. // 选中数组
  147. const ids = ref<Array<any>>([]);
  148. // 非单个禁用
  149. const single = ref(true);
  150. // 非多个禁用
  151. const multiple = ref(true);
  152. // 显示搜索条件
  153. const showSearch = ref(true);
  154. // 总条数
  155. const total = ref(0);
  156. // 模型定义表格数据
  157. const taskList = ref([]);
  158. const title = ref('');
  159. // 流程变量是否显示
  160. const variableVisible = ref(false);
  161. const variableLoading = ref(true);
  162. // 流程变量
  163. const variableList = ref<VariableVo>({
  164. key: '',
  165. value: '',
  166. })
  167. //流程定义名称
  168. const processDefinitionName = ref(undefined);
  169. // 查询参数
  170. const queryParams = ref<TaskQuery>({
  171. pageNum: 1,
  172. pageSize: 10,
  173. name: undefined,
  174. processDefinitionName: undefined,
  175. processDefinitionKey: undefined
  176. });
  177. const tab = ref('waiting');
  178. //加签
  179. const addMultiInstanceUser = (row: TaskVO) => {
  180. if (multiInstanceUserRef.value) {
  181. title.value = '加签人员';
  182. multiInstanceUserRef.value.getAddMultiInstanceList(row.id, []);
  183. }
  184. };
  185. //减签
  186. const deleteMultiInstanceUser = (row: TaskVO) => {
  187. if (multiInstanceUserRef.value) {
  188. title.value = '减签人员';
  189. multiInstanceUserRef.value.getDeleteMultiInstanceList(row.id);
  190. }
  191. };
  192. /** 搜索按钮操作 */
  193. const handleQuery = () => {
  194. if ('waiting' === tab.value) {
  195. getWaitingList();
  196. } else {
  197. getFinishList();
  198. }
  199. };
  200. /** 重置按钮操作 */
  201. const resetQuery = () => {
  202. queryFormRef.value?.resetFields();
  203. queryParams.value.pageNum = 1;
  204. queryParams.value.pageSize = 10;
  205. handleQuery();
  206. };
  207. // 多选框选中数据
  208. const handleSelectionChange = (selection: any) => {
  209. ids.value = selection.map((item: any) => item.id);
  210. single.value = selection.length !== 1;
  211. multiple.value = !selection.length;
  212. };
  213. const changeTab = async (data: string) => {
  214. taskList.value = []
  215. queryParams.value.pageNum = 1;
  216. if ('waiting' === data) {
  217. getWaitingList();
  218. } else {
  219. getFinishList();
  220. }
  221. };
  222. //分页
  223. const getWaitingList = () => {
  224. loading.value = true;
  225. getPageByAllTaskWait(queryParams.value).then((resp) => {
  226. taskList.value = resp.rows;
  227. total.value = resp.total;
  228. loading.value = false;
  229. });
  230. };
  231. const getFinishList = () => {
  232. loading.value = true;
  233. getPageByAllTaskFinish(queryParams.value).then((resp) => {
  234. taskList.value = resp.rows;
  235. total.value = resp.total;
  236. loading.value = false;
  237. });
  238. };
  239. //打开修改选人
  240. const handleUpdate = () => {
  241. userSelectRef.value.open();
  242. };
  243. //修改办理人
  244. const submitCallback = async (data) => {
  245. if(data && data.length > 0){
  246. await proxy?.$modal.confirm('是否确认提交?');
  247. loading.value = true;
  248. await updateAssignee(ids.value, data[0].userId)
  249. handleQuery()
  250. proxy?.$modal.msgSuccess('操作成功');
  251. }else{
  252. proxy?.$modal.msgWarning('请选择用户!');
  253. }
  254. };
  255. //查询流程变量
  256. const handleInstanceVariable = async (row: TaskVO) => {
  257. variableLoading.value = true
  258. variableVisible.value = true
  259. processDefinitionName.value = row.processDefinitionName
  260. let data = await getInstanceVariable(row.id)
  261. variableList.value = data.data
  262. variableLoading.value = false
  263. };
  264. /** 查看按钮操作 */
  265. const handleView = (row) => {
  266. const routerJumpVo = reactive<RouterJumpVo>({
  267. wfDefinitionConfigVo: row.wfDefinitionConfigVo,
  268. wfNodeConfigVo: row.wfNodeConfigVo,
  269. businessKey: row.businessKey,
  270. taskId: row.id,
  271. type: 'view'
  272. });
  273. workflowCommon.routerJump(routerJumpVo,proxy)
  274. };
  275. onMounted(() => {
  276. getWaitingList();
  277. });
  278. </script>