myDocument.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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 ref="categoryTreeRef" class="mt-2" node-key="id" :data="categoryOptions"
  9. :props="{ label: 'label', children: 'children' } as any" :expand-on-click-node="false"
  10. :filter-node-method="filterNode" highlight-current default-expand-all
  11. @node-click="handleNodeClick"></el-tree>
  12. </el-card>
  13. </el-col>
  14. <el-col :lg="20" :xs="24">
  15. <transition :enter-active-class="proxy?.animate.searchAnimate.enter"
  16. :leave-active-class="proxy?.animate.searchAnimate.leave">
  17. <div v-show="showSearch" class="mb-[10px]">
  18. <el-card shadow="hover">
  19. <el-form v-show="showSearch" ref="queryFormRef" :model="queryParams" :inline="true" label-width="120px">
  20. <el-form-item label="流程定义编码" prop="flowCode">
  21. <el-input v-model="queryParams.flowCode" placeholder="请输入流程定义编码" @keyup.enter="handleQuery" />
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  25. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  26. </el-form-item>
  27. </el-form>
  28. </el-card>
  29. </div>
  30. </transition>
  31. <el-card shadow="hover">
  32. <template #header>
  33. <el-row :gutter="10" class="mb8">
  34. <right-toolbar v-model:show-search="showSearch" @query-table="handleQuery"></right-toolbar>
  35. </el-row>
  36. </template>
  37. <el-table v-loading="loading" border :data="processInstanceList" @selection-change="handleSelectionChange">
  38. <el-table-column type="selection" width="55" align="center" />
  39. <el-table-column align="center" type="index" label="序号" width="60"></el-table-column>
  40. <el-table-column v-if="false" align="center" prop="id" label="id"></el-table-column>
  41. <el-table-column :show-overflow-tooltip="true" prop="flowName" align="center" label="流程定义名称">
  42. </el-table-column>
  43. <el-table-column align="center" prop="flowCode" label="流程定义编码"></el-table-column>
  44. <el-table-column align="center" prop="categoryName" label="流程分类"></el-table-column>
  45. <el-table-column align="center" prop="version" label="版本号" width="90">
  46. <template #default="scope"> v{{ scope.row.version }}.0</template>
  47. </el-table-column>
  48. <el-table-column v-if="tab === 'running'" align="center" prop="isSuspended" label="状态" min-width="70">
  49. <template #default="scope">
  50. <el-tag v-if="!scope.row.isSuspended" type="success">激活</el-tag>
  51. <el-tag v-else type="danger">挂起</el-tag>
  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.flowStatus"></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="280">
  61. <template #default="scope">
  62. <el-button
  63. v-if="scope.row.flowStatus === 'draft' || scope.row.flowStatus === 'cancel' || scope.row.flowStatus === 'back'"
  64. type="primary" size="small" icon="Edit" @click="handleOpen(scope.row, 'update')">编辑</el-button>
  65. <el-button
  66. v-if="scope.row.flowStatus === 'draft' || scope.row.flowStatus === 'cancel' || scope.row.flowStatus === 'back'"
  67. type="danger" size="small" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
  68. <el-button type="warning" size="small" icon="View" @click="handleOpen(scope.row, 'view')">查看</el-button>
  69. <el-button v-if="scope.row.flowStatus === 'waiting'" type="danger" size="small" icon="Notification"
  70. @click="handleCancelProcessApply(scope.row.businessId)">撤销</el-button>
  71. </template>
  72. </el-table-column>
  73. </el-table>
  74. <pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
  75. :total="total" @pagination="getList" />
  76. </el-card>
  77. </el-col>
  78. </el-row>
  79. <!-- 提交组件 -->
  80. <submitVerify ref="submitVerifyRef" @submit-callback="getList" />
  81. </div>
  82. </template>
  83. <script setup lang="ts">
  84. import { pageByCurrent, deleteByInstanceIds, cancelProcessApply } from '@/api/workflow/instance';
  85. import { categoryTree } from '@/api/workflow/category';
  86. import { CategoryTreeVO } from '@/api/workflow/category/types';
  87. import { FlowInstanceQuery, FlowInstanceVO } from '@/api/workflow/instance/types';
  88. import workflowCommon from '@/api/workflow/workflowCommon';
  89. import { RouterJumpVo } from '@/api/workflow/workflowCommon/types';
  90. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  91. const { wf_business_status } = toRefs<any>(proxy?.useDict('wf_business_status'));
  92. const queryFormRef = ref<ElFormInstance>();
  93. const categoryTreeRef = ref<ElTreeInstance>();
  94. // 遮罩层
  95. const loading = ref(true);
  96. // 选中数组
  97. const businessIds = ref<Array<number | string>>([]);
  98. const instanceIds = ref<Array<number | string>>([]);
  99. // 非单个禁用
  100. const single = ref(true);
  101. // 非多个禁用
  102. const multiple = ref(true);
  103. // 显示搜索条件
  104. const showSearch = ref(true);
  105. // 总条数
  106. const total = ref(0);
  107. // 模型定义表格数据
  108. const processInstanceList = ref<FlowInstanceVO[]>([]);
  109. const categoryOptions = ref<CategoryTreeVO[]>([]);
  110. const categoryName = ref('');
  111. const tab = ref('running');
  112. // 查询参数
  113. const queryParams = ref<FlowInstanceQuery>({
  114. pageNum: 1,
  115. pageSize: 10,
  116. flowCode: undefined,
  117. category: undefined
  118. });
  119. onMounted(() => {
  120. getList();
  121. getTreeselect();
  122. });
  123. /** 节点单击事件 */
  124. const handleNodeClick = (data: CategoryTreeVO) => {
  125. queryParams.value.category = data.id;
  126. if (data.id === '0') {
  127. queryParams.value.category = '';
  128. }
  129. handleQuery();
  130. };
  131. /** 通过条件过滤节点 */
  132. const filterNode = (value: string, data: any) => {
  133. if (!value) return true;
  134. return data.categoryName.indexOf(value) !== -1;
  135. };
  136. /** 根据名称筛选部门树 */
  137. watchEffect(
  138. () => {
  139. categoryTreeRef.value.filter(categoryName.value);
  140. },
  141. {
  142. flush: 'post' // watchEffect会在DOM挂载或者更新之前就会触发,此属性控制在DOM元素更新后运行
  143. }
  144. );
  145. /** 查询流程分类下拉树结构 */
  146. const getTreeselect = async () => {
  147. const res = await categoryTree();
  148. categoryOptions.value = res.data;
  149. };
  150. /** 搜索按钮操作 */
  151. const handleQuery = () => {
  152. getList();
  153. };
  154. /** 重置按钮操作 */
  155. const resetQuery = () => {
  156. queryFormRef.value?.resetFields();
  157. queryParams.value.category = '';
  158. queryParams.value.pageNum = 1;
  159. queryParams.value.pageSize = 10;
  160. handleQuery();
  161. };
  162. // 多选框选中数据
  163. const handleSelectionChange = (selection: FlowInstanceVO[]) => {
  164. businessIds.value = selection.map((item: any) => item.businessId);
  165. instanceIds.value = selection.map((item: FlowInstanceVO) => item.id);
  166. single.value = selection.length !== 1;
  167. multiple.value = !selection.length;
  168. };
  169. //分页
  170. const getList = () => {
  171. loading.value = true;
  172. pageByCurrent(queryParams.value).then((resp) => {
  173. processInstanceList.value = resp.rows;
  174. total.value = resp.total;
  175. loading.value = false;
  176. });
  177. };
  178. /** 删除按钮操作 */
  179. const handleDelete = async (row: FlowInstanceVO) => {
  180. const instanceIdList = row.id || instanceIds.value;
  181. await proxy?.$modal.confirm('是否确认删除?');
  182. loading.value = true;
  183. if ('running' === tab.value) {
  184. await deleteByInstanceIds(instanceIdList).finally(() => (loading.value = false));
  185. getList();
  186. }
  187. proxy?.$modal.msgSuccess('删除成功');
  188. };
  189. /** 撤销按钮操作 */
  190. const handleCancelProcessApply = async (businessId: string) => {
  191. await proxy?.$modal.confirm('是否确认撤销当前单据?');
  192. loading.value = true;
  193. if ('running' === tab.value) {
  194. const data = {
  195. businessId: businessId,
  196. message: '申请人撤销流程!'
  197. };
  198. await cancelProcessApply(data).finally(() => (loading.value = false));
  199. getList();
  200. }
  201. proxy?.$modal.msgSuccess('撤销成功');
  202. };
  203. //办理
  204. const handleOpen = async (row, type) => {
  205. const routerJumpVo = reactive<RouterJumpVo>({
  206. businessId: row.businessId,
  207. taskId: row.id,
  208. type: type,
  209. formCustom: row.formCustom,
  210. formPath: row.formPath
  211. });
  212. workflowCommon.routerJump(routerJumpVo, proxy);
  213. };
  214. </script>