myDocument.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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: 'label', children: 'children' } as any"
  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="flowCode">
  28. <el-input v-model="queryParams.flowCode" 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:show-search="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" prop="flowName" align="center" label="流程定义名称"> </el-table-column>
  49. <el-table-column align="center" prop="flowCode" label="流程定义编码"></el-table-column>
  50. <el-table-column align="center" prop="categoryName" label="流程分类"></el-table-column>
  51. <el-table-column align="center" prop="version" label="版本号" width="90">
  52. <template #default="scope"> v{{ scope.row.version }}.0</template>
  53. </el-table-column>
  54. <el-table-column v-if="tab === 'running'" align="center" prop="isSuspended" label="状态" min-width="70">
  55. <template #default="scope">
  56. <el-tag v-if="!scope.row.isSuspended" type="success">激活</el-tag>
  57. <el-tag v-else type="danger">挂起</el-tag>
  58. </template>
  59. </el-table-column>
  60. <el-table-column align="center" label="流程状态" min-width="70">
  61. <template #default="scope">
  62. <dict-tag :options="wf_business_status" :value="scope.row.flowStatus"></dict-tag>
  63. </template>
  64. </el-table-column>
  65. <el-table-column align="center" prop="createTime" label="启动时间" width="160"></el-table-column>
  66. <el-table-column label="操作" align="center" width="162">
  67. <template #default="scope">
  68. <el-row :gutter="10" class="mb8">
  69. <el-col :span="1.5" v-if="scope.row.flowStatus === 'draft' || scope.row.flowStatus === 'cancel' || scope.row.flowStatus === 'back'">
  70. <el-button type="primary" size="small" icon="Edit" @click="handleOpen(scope.row, 'update')">编辑</el-button>
  71. </el-col>
  72. <el-col :span="1.5" v-if="scope.row.flowStatus === 'draft' || scope.row.flowStatus === 'cancel' || scope.row.flowStatus === 'back'">
  73. <el-button type="primary" size="small" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
  74. </el-col>
  75. </el-row>
  76. <el-row :gutter="10" class="mb8">
  77. <el-col :span="1.5">
  78. <el-button type="primary" size="small" icon="View" @click="handleOpen(scope.row, 'view')">查看</el-button>
  79. </el-col>
  80. <el-col :span="1.5" v-if="scope.row.flowStatus === 'waiting'">
  81. <el-button type="primary" size="small" icon="Notification" @click="handleCancelProcessApply(scope.row.businessId)"
  82. >撤销</el-button
  83. >
  84. </el-col>
  85. </el-row>
  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="getList"
  95. />
  96. </el-card>
  97. </el-col>
  98. </el-row>
  99. <!-- 提交组件 -->
  100. <submitVerify ref="submitVerifyRef" @submit-callback="getList" />
  101. </div>
  102. </template>
  103. <script setup lang="ts">
  104. import { pageByCurrent, deleteByInstanceIds, cancelProcessApply } from '@/api/workflow/instance';
  105. import { categoryTree } from '@/api/workflow/category';
  106. import { CategoryTreeVO } from '@/api/workflow/category/types';
  107. import { FlowInstanceQuery, FlowInstanceVO } from '@/api/workflow/instance/types';
  108. import workflowCommon from '@/api/workflow/workflowCommon';
  109. import { RouterJumpVo } from '@/api/workflow/workflowCommon/types';
  110. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  111. const { wf_business_status } = toRefs<any>(proxy?.useDict('wf_business_status'));
  112. const queryFormRef = ref<ElFormInstance>();
  113. const categoryTreeRef = ref<ElTreeInstance>();
  114. // 遮罩层
  115. const loading = ref(true);
  116. // 选中数组
  117. const businessIds = ref<Array<number | string>>([]);
  118. const instanceIds = ref<Array<number | string>>([]);
  119. // 非单个禁用
  120. const single = ref(true);
  121. // 非多个禁用
  122. const multiple = ref(true);
  123. // 显示搜索条件
  124. const showSearch = ref(true);
  125. // 总条数
  126. const total = ref(0);
  127. // 模型定义表格数据
  128. const processInstanceList = ref<FlowInstanceVO[]>([]);
  129. const categoryOptions = ref<CategoryTreeVO[]>([]);
  130. const categoryName = ref('');
  131. const tab = ref('running');
  132. // 查询参数
  133. const queryParams = ref<FlowInstanceQuery>({
  134. pageNum: 1,
  135. pageSize: 10,
  136. flowCode: undefined,
  137. category: undefined
  138. });
  139. onMounted(() => {
  140. getList();
  141. getTreeselect();
  142. });
  143. /** 节点单击事件 */
  144. const handleNodeClick = (data: CategoryTreeVO) => {
  145. queryParams.value.category = data.id;
  146. if (data.id === '0') {
  147. queryParams.value.category = '';
  148. }
  149. handleQuery();
  150. };
  151. /** 通过条件过滤节点 */
  152. const filterNode = (value: string, data: any) => {
  153. if (!value) return true;
  154. return data.categoryName.indexOf(value) !== -1;
  155. };
  156. /** 根据名称筛选部门树 */
  157. watchEffect(
  158. () => {
  159. categoryTreeRef.value.filter(categoryName.value);
  160. },
  161. {
  162. flush: 'post' // watchEffect会在DOM挂载或者更新之前就会触发,此属性控制在DOM元素更新后运行
  163. }
  164. );
  165. /** 查询流程分类下拉树结构 */
  166. const getTreeselect = async () => {
  167. const res = await categoryTree();
  168. categoryOptions.value = res.data;
  169. };
  170. /** 搜索按钮操作 */
  171. const handleQuery = () => {
  172. getList();
  173. };
  174. /** 重置按钮操作 */
  175. const resetQuery = () => {
  176. queryFormRef.value?.resetFields();
  177. queryParams.value.category = '';
  178. queryParams.value.pageNum = 1;
  179. queryParams.value.pageSize = 10;
  180. handleQuery();
  181. };
  182. // 多选框选中数据
  183. const handleSelectionChange = (selection: FlowInstanceVO[]) => {
  184. businessIds.value = selection.map((item: any) => item.businessId);
  185. instanceIds.value = selection.map((item: FlowInstanceVO) => item.id);
  186. single.value = selection.length !== 1;
  187. multiple.value = !selection.length;
  188. };
  189. //分页
  190. const getList = () => {
  191. loading.value = true;
  192. pageByCurrent(queryParams.value).then((resp) => {
  193. processInstanceList.value = resp.rows;
  194. total.value = resp.total;
  195. loading.value = false;
  196. });
  197. };
  198. /** 删除按钮操作 */
  199. const handleDelete = async (row: FlowInstanceVO) => {
  200. const instanceIdList = row.id || instanceIds.value;
  201. await proxy?.$modal.confirm('是否确认删除?');
  202. loading.value = true;
  203. if ('running' === tab.value) {
  204. await deleteByInstanceIds(instanceIdList).finally(() => (loading.value = false));
  205. getList();
  206. }
  207. proxy?.$modal.msgSuccess('删除成功');
  208. };
  209. /** 撤销按钮操作 */
  210. const handleCancelProcessApply = async (businessId: string) => {
  211. await proxy?.$modal.confirm('是否确认撤销当前单据?');
  212. loading.value = true;
  213. if ('running' === tab.value) {
  214. const data = {
  215. businessId: businessId,
  216. message: '申请人撤销流程!'
  217. };
  218. await cancelProcessApply(data).finally(() => (loading.value = false));
  219. getList();
  220. }
  221. proxy?.$modal.msgSuccess('撤销成功');
  222. };
  223. //办理
  224. const handleOpen = async (row, type) => {
  225. const routerJumpVo = reactive<RouterJumpVo>({
  226. businessId: row.businessId,
  227. taskId: row.id,
  228. type: type,
  229. formCustom: row.formCustom,
  230. formPath: row.formPath
  231. });
  232. workflowCommon.routerJump(routerJumpVo, proxy);
  233. };
  234. </script>