myDocument.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div class="p-2">
  3. <el-row :gutter="20">
  4. <!-- 流程分类树 -->
  5. <el-col :lg="4" :xs="24" style="">
  6. <el-card shadow="hover">
  7. <el-input v-model="categoryName" placeholder="请输入流程分类名" prefix-icon="Search" clearable />
  8. <el-tree
  9. ref="categoryTreeRef"
  10. class="mt-2"
  11. node-key="id"
  12. :data="categoryOptions"
  13. :props="{ label: 'categoryName', children: 'children' }"
  14. :expand-on-click-node="false"
  15. :filter-node-method="filterNode"
  16. highlight-current
  17. default-expand-all
  18. @node-click="handleNodeClick"
  19. ></el-tree>
  20. </el-card>
  21. </el-col>
  22. <el-col :lg="20" :xs="24">
  23. <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
  24. <div v-show="showSearch" class="mb-[10px]">
  25. <el-card shadow="hover">
  26. <el-form v-show="showSearch" ref="queryFormRef" :model="queryParams" :inline="true" label-width="120px">
  27. <el-form-item label="流程定义名称" prop="name">
  28. <el-input v-model="queryParams.name" placeholder="请输入流程定义名称" @keyup.enter="handleQuery" />
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  32. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  33. </el-form-item>
  34. </el-form>
  35. </el-card>
  36. </div>
  37. </transition>
  38. <el-card shadow="hover">
  39. <template #header>
  40. <el-row :gutter="10" class="mb8">
  41. <right-toolbar v-model:showSearch="showSearch" @query-table="handleQuery"></right-toolbar>
  42. </el-row>
  43. </template>
  44. <el-table v-loading="loading" border :data="processInstanceList" @selection-change="handleSelectionChange">
  45. <el-table-column type="selection" width="55" align="center" />
  46. <el-table-column align="center" type="index" label="序号" width="60"></el-table-column>
  47. <el-table-column v-if="false" align="center" prop="id" label="id"></el-table-column>
  48. <el-table-column :show-overflow-tooltip="true" align="center" label="流程定义名称">
  49. <template #default="scope">
  50. <span>{{ scope.row.processDefinitionName }}v{{ scope.row.processDefinitionVersion }}.0</span>
  51. </template>
  52. </el-table-column>
  53. <el-table-column align="center" prop="processDefinitionKey" label="流程定义KEY"></el-table-column>
  54. <el-table-column align="center" prop="processDefinitionVersion" label="版本号" width="90">
  55. <template #default="scope"> v{{ scope.row.processDefinitionVersion }}.0</template>
  56. </el-table-column>
  57. <el-table-column v-if="tab === 'running'" align="center" prop="isSuspended" label="状态" min-width="70">
  58. <template #default="scope">
  59. <el-tag v-if="!scope.row.isSuspended" type="success">激活</el-tag>
  60. <el-tag v-else type="danger">挂起</el-tag>
  61. </template>
  62. </el-table-column>
  63. <el-table-column align="center" label="流程状态" min-width="70">
  64. <template #default="scope">
  65. <dict-tag :options="wf_business_status" :value="scope.row.businessStatus"></dict-tag>
  66. </template>
  67. </el-table-column>
  68. <el-table-column align="center" prop="startTime" label="启动时间" width="160"></el-table-column>
  69. <el-table-column v-if="tab === 'finish'" align="center" prop="endTime" label="结束时间" width="160"></el-table-column>
  70. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  71. <template #default="scope">
  72. <el-tooltip
  73. v-if="
  74. scope.row.businessStatus === 'draft' ||
  75. scope.row.businessStatus === 'cancel' ||
  76. scope.row.businessStatus === 'back'
  77. "
  78. content="修改"
  79. placement="top"
  80. >
  81. <el-button v-hasPermi="['demo:leave:edit']" link type="primary" icon="Edit" @click="handleOpen(scope.row,'update')"></el-button>
  82. </el-tooltip>
  83. <el-tooltip
  84. v-if="
  85. scope.row.businessStatus === 'draft' ||
  86. scope.row.businessStatus === 'cancel' ||
  87. scope.row.businessStatus === 'back'
  88. "
  89. content="删除"
  90. placement="top"
  91. >
  92. <el-button v-hasPermi="['demo:leave:remove']" link type="primary" icon="Delete" @click="handleDelete(scope.row)"></el-button>
  93. </el-tooltip>
  94. <el-tooltip placement="top" content="查看" >
  95. <el-button link type="primary" icon="View" @click="handleOpen(scope.row,'view')"></el-button>
  96. </el-tooltip>
  97. <el-tooltip v-if="scope.row.businessStatus === 'waiting'" content="撤销" placement="top">
  98. <el-button link type="primary" icon="Notification" @click="handleCancelProcessApply(scope.row.id)"></el-button>
  99. </el-tooltip>
  100. </template>
  101. </el-table-column>
  102. </el-table>
  103. <pagination
  104. v-show="total > 0"
  105. v-model:page="queryParams.pageNum"
  106. v-model:limit="queryParams.pageSize"
  107. :total="total"
  108. @pagination="getList"
  109. />
  110. </el-card>
  111. </el-col>
  112. </el-row>
  113. <!-- 提交组件 -->
  114. <submitVerify ref="submitVerifyRef" @submit-callback="getList" />
  115. </div>
  116. </template>
  117. <script lang="ts" setup>
  118. import { getPageByCurrent, deleteRunAndHisInstance, cancelProcessApply } from '@/api/workflow/processInstance';
  119. import { listCategory } from '@/api/workflow/category';
  120. import { CategoryVO } from '@/api/workflow/category/types';
  121. import { ProcessInstanceQuery, ProcessInstanceVO } from '@/api/workflow/processInstance/types';
  122. import workflowCommon from '@/api/workflow/workflowCommon';
  123. import { RouterJumpVo } from '@/api/workflow/workflowCommon/types';
  124. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  125. const { wf_business_status } = toRefs<any>(proxy?.useDict('wf_business_status'));
  126. const queryFormRef = ref<ElFormInstance>();
  127. const categoryTreeRef = ref<ElTreeInstance>();
  128. // 遮罩层
  129. const loading = ref(true);
  130. // 选中数组
  131. const ids = ref<Array<any>>([]);
  132. // 非单个禁用
  133. const single = ref(true);
  134. // 非多个禁用
  135. const multiple = ref(true);
  136. // 显示搜索条件
  137. const showSearch = ref(true);
  138. // 总条数
  139. const total = ref(0);
  140. // 模型定义表格数据
  141. const processInstanceList = ref<ProcessInstanceVO[]>([]);
  142. const categoryOptions = ref<CategoryOption[]>([]);
  143. const categoryName = ref('');
  144. interface CategoryOption {
  145. categoryCode: string;
  146. categoryName: string;
  147. children?: CategoryOption[];
  148. }
  149. const tab = ref('running');
  150. // 查询参数
  151. const queryParams = ref<ProcessInstanceQuery>({
  152. pageNum: 1,
  153. pageSize: 10,
  154. name: undefined,
  155. categoryCode: undefined
  156. });
  157. onMounted(() => {
  158. getList();
  159. getTreeselect();
  160. });
  161. /** 节点单击事件 */
  162. const handleNodeClick = (data: CategoryVO) => {
  163. queryParams.value.categoryCode = data.categoryCode;
  164. if (data.categoryCode === 'ALL') {
  165. queryParams.value.categoryCode = '';
  166. }
  167. handleQuery();
  168. };
  169. /** 通过条件过滤节点 */
  170. const filterNode = (value: string, data: any) => {
  171. if (!value) return true;
  172. return data.categoryName.indexOf(value) !== -1;
  173. };
  174. /** 根据名称筛选部门树 */
  175. watchEffect(
  176. () => {
  177. categoryTreeRef.value.filter(categoryName.value);
  178. },
  179. {
  180. flush: 'post' // watchEffect会在DOM挂载或者更新之前就会触发,此属性控制在DOM元素更新后运行
  181. }
  182. );
  183. /** 查询流程分类下拉树结构 */
  184. const getTreeselect = async () => {
  185. const res = await listCategory();
  186. categoryOptions.value = [];
  187. const data: CategoryOption = { categoryCode: 'ALL', categoryName: '顶级节点', children: [] };
  188. data.children = proxy?.handleTree<CategoryOption>(res.data, 'id', 'parentId');
  189. categoryOptions.value.push(data);
  190. };
  191. //审批记录
  192. const handleApprovalRecord = (processInstanceId: string) => {
  193. if (approvalRecordRef.value) {
  194. approvalRecordRef.value.init(processInstanceId);
  195. }
  196. };
  197. /** 搜索按钮操作 */
  198. const handleQuery = () => {
  199. getList();
  200. };
  201. /** 重置按钮操作 */
  202. const resetQuery = () => {
  203. queryFormRef.value?.resetFields();
  204. queryParams.value.categoryCode = '';
  205. queryParams.value.pageNum = 1;
  206. queryParams.value.pageSize = 10;
  207. handleQuery();
  208. };
  209. // 多选框选中数据
  210. const handleSelectionChange = (selection: ProcessInstanceVO[]) => {
  211. ids.value = selection.map((item: any) => item.id);
  212. single.value = selection.length !== 1;
  213. multiple.value = !selection.length;
  214. };
  215. //分页
  216. const getList = () => {
  217. loading.value = true;
  218. getPageByCurrent(queryParams.value).then((resp) => {
  219. processInstanceList.value = resp.rows;
  220. total.value = resp.total;
  221. loading.value = false;
  222. });
  223. };
  224. /** 删除按钮操作 */
  225. const handleDelete = async (row: ProcessInstanceVO) => {
  226. const id = row.id || ids.value;
  227. await proxy?.$modal.confirm('是否确认删除id为【' + id + '】的数据项?');
  228. loading.value = true;
  229. if ('running' === tab.value) {
  230. await deleteRunAndHisInstance(id).finally(() => (loading.value = false));
  231. getList();
  232. }
  233. proxy?.$modal.msgSuccess('删除成功');
  234. };
  235. /** 撤销按钮操作 */
  236. const handleCancelProcessApply = async (processInstanceId: string) => {
  237. await proxy?.$modal.confirm('是否确认撤销当前单据?');
  238. loading.value = true;
  239. if ('running' === tab.value) {
  240. await cancelProcessApply(processInstanceId).finally(() => (loading.value = false));
  241. getList();
  242. }
  243. proxy?.$modal.msgSuccess('撤销成功');
  244. };
  245. //办理
  246. const handleOpen = async (row,type) => {
  247. const routerJumpVo = reactive<RouterJumpVo>({
  248. wfDefinitionConfigVo: row.wfDefinitionConfigVo,
  249. wfNodeConfigVo: row.wfNodeConfigVo,
  250. businessKey: row.businessKey,
  251. taskId: row.id,
  252. type: type
  253. });
  254. workflowCommon.routerJump(routerJumpVo,proxy)
  255. };
  256. </script>