allTaskWaiting.vue 11 KB

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