综合办公系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <!--
  2. * @Author: ysh
  3. * @Date: 2024-01-03 09:23:11
  4. * @LastEditors: Please set LastEditors
  5. * @LastEditTime: 2024-06-19 16:29:56
  6. -->
  7. <template>
  8. <div class="app-container">
  9. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  10. <el-form-item label="名称" prop="name">
  11. <el-input v-model="queryParams.name" placeholder="请输入名称" clearable size="small"
  12. @keyup.enter.native="handleQuery" />
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  16. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  17. </el-form-item>
  18. </el-form>
  19. <el-row :gutter="10" class="mb8">
  20. <el-col :span="1.5">
  21. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  22. v-hasPermi="['system:deployment:add']">发起流程</el-button>
  23. </el-col>
  24. <!-- <el-col :span="1.5">
  25. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  26. v-hasPermi="['system:deployment:remove']">删除</el-button>
  27. </el-col> -->
  28. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  29. </el-row>
  30. <el-table v-loading="loading" :data="myProcessList" border @selection-change="handleSelectionChange">
  31. <!-- <el-table-column type="selection" width="55" align="center" /> -->
  32. <el-table-column type="index" label="序号" width="55" align="center" />
  33. <el-table-column label="流程状态" align="center" width="100">
  34. <template slot-scope="scope">
  35. <el-tag v-if="scope.row.finishTime == null" size="mini">进行中</el-tag>
  36. <el-tag type="success" v-if="scope.row.finishTime != null" size="mini">已完成</el-tag>
  37. </template>
  38. </el-table-column>
  39. <!-- <el-table-column label="流程编号" align="center" prop="procInsId" :show-overflow-tooltip="true" /> -->
  40. <el-table-column label="流程名称" align="center" prop="procDefName" :show-overflow-tooltip="true" />
  41. <!-- <el-table-column label="流程类别" align="center" prop="category" width="100px" /> -->
  42. <!-- <el-table-column label="流程版本" align="center" width="80px">
  43. <template slot-scope="scope">
  44. <el-tag size="medium">v{{ scope.row.procDefVersion }}</el-tag>
  45. </template>
  46. </el-table-column> -->
  47. <el-table-column label="提交时间" align="center" prop="createTime" width="180" />
  48. <el-table-column label="耗时" align="center" prop="duration" width="180" />
  49. <el-table-column label="当前节点" align="center" prop="taskName" />
  50. <el-table-column label="待办人" align="center">
  51. <template slot-scope="scope">
  52. <label v-if="scope.row.assigneeName">
  53. {{ scope.row.assigneeName }}
  54. <el-tag type="info" size="mini">{{ scope.row.assigneeDeptName }}</el-tag></label>
  55. <!-- <label v-if="scope.row.candidate">{{scope.row.candidate}}</label>-->
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="操作" width="200" fixed="right" class-name="small-padding fixed-width">
  59. <template slot-scope="scope">
  60. <el-button @click="handleFlowRecord(scope.row)" type="text" size="small">办理进度</el-button>
  61. <el-button @click="handleFlowNote(scope.row)" type="text" size="small">表单信息</el-button>
  62. <!-- <el-button @click="handleStop(scope.row)" type="text" size="small">取消申请</el-button> -->
  63. <el-button @click="handleDelete(scope.row)" style="color:#F56C6C" type="text" size="small"
  64. :disabled="beDeleted(scope.row)" v-hasPermi="['system:deployment:remove']">取消流程</el-button>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  69. @pagination="getList" />
  70. <!-- 发起流程 -->
  71. <el-dialog :title="title" :visible.sync="open" width="400px" append-to-body>
  72. <progress-tree :definitionList="definitionList" @confirm="handleStartProcess"
  73. @close="open = false"></progress-tree>
  74. <!-- <el-form :model="queryProcessParams" ref="queryProcessForm" :inline="true" v-show="showSearch" label-width="68px">
  75. <el-form-item label="名称" prop="name">
  76. <el-input v-model="queryProcessParams.name" placeholder="请输入名称" clearable size="small"
  77. @keyup.enter.native="handleQuery" />
  78. </el-form-item>
  79. <el-form-item>
  80. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleProcessQuery">搜索</el-button>
  81. <el-button icon="el-icon-refresh" size="mini" @click="resetProcessQuery">重置</el-button>
  82. </el-form-item>
  83. </el-form> -->
  84. <!-- <el-table v-loading="processLoading" fit :data="definitionList" border>
  85. <el-table-column label="流程名称" align="center" prop="name" />
  86. <el-table-column label="流程版本" align="center">
  87. <template slot-scope="scope">
  88. <el-tag size="medium">v{{ scope.row.version }}</el-tag>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="流程分类" align="center" prop="category" />
  92. <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width">
  93. <template slot-scope="scope">
  94. <el-button size="mini" type="text" icon="el-icon-edit-outline"
  95. @click="handleStartProcess(scope.row)">发起流程</el-button>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <pagination v-show="processTotal > 0" :total="processTotal" :page.sync="queryProcessParams.pageNum"
  100. :limit.sync="queryProcessParams.pageSize" @pagination="listDefinition" /> -->
  101. </el-dialog>
  102. <el-dialog title="流程进度" :visible.sync="detailsOpen" append-to-body width="600px">
  103. <el-scrollbar style="height: 600px;">
  104. <RowDetail :rows="clickRow"></RowDetail>
  105. </el-scrollbar>
  106. </el-dialog>
  107. <el-dialog title="表单信息" :visible.sync="formOpen" append-to-body width="80%">
  108. <conditionDisplay :passingParam="passingParam"></conditionDisplay>
  109. </el-dialog>
  110. </div>
  111. </template>
  112. <script>
  113. import {
  114. getDeployment,
  115. delDeployment,
  116. addDeployment,
  117. updateDeployment,
  118. exportDeployment,
  119. flowRecord
  120. } from "@/api/flowable/finished";
  121. import { todoList } from "@/api/flowable/todo";
  122. import { myProcessList, stopProcess } from "@/api/flowable/process";
  123. import { listDefinition } from "@/api/flowable/definition";
  124. import { getNextFlowNodeByStart } from "@/api/flowable/todo";
  125. import { definitionStart, flowXmlAndNode } from "@/api/flowable/definition";
  126. import { Snowflake } from '@/utils/snowFlake.js'
  127. import RowDetail from './send/rowDetail.vue'
  128. import ProgressTree from './progressTree.vue';
  129. import { getProcessVariables } from "@/api/flowable/definition";
  130. import conditionDisplay from '@/views/flowable/form/components/conditionDisplay.vue'
  131. import { deleteResources } from "@/utils/deleteResource"
  132. export default {
  133. name: "Deploy",
  134. components: {
  135. RowDetail,
  136. ProgressTree,
  137. conditionDisplay
  138. },
  139. data() {
  140. return {
  141. // 遮罩层
  142. loading: true,
  143. processLoading: true,
  144. // 选中数组
  145. ids: [],
  146. // 非单个禁用
  147. single: true,
  148. // 非多个禁用
  149. multiple: true,
  150. // 显示搜索条件
  151. showSearch: true,
  152. // 总条数
  153. total: 0,
  154. processTotal: 0,
  155. // 我发起的流程列表数据
  156. myProcessList: [],
  157. // 弹出层标题
  158. title: "",
  159. // 是否显示弹出层
  160. open: false,
  161. // 详情弹出框
  162. detailsOpen: false,
  163. formOpen: false,
  164. src: "",
  165. definitionList: [],
  166. // 查询参数
  167. queryParams: {
  168. pageNum: 1,
  169. pageSize: 10,
  170. name: null,
  171. category: null,
  172. key: null,
  173. tenantId: null,
  174. deployTime: null,
  175. derivedFrom: null,
  176. derivedFromRoot: null,
  177. parentDeploymentId: null,
  178. engineVersion: null
  179. },
  180. // 查询参数
  181. queryProcessParams: {
  182. pageNum: 1,
  183. pageSize: 9999,
  184. name: null,
  185. category: null,
  186. key: null,
  187. tenantId: null,
  188. deployTime: null,
  189. derivedFrom: null,
  190. derivedFromRoot: null,
  191. parentDeploymentId: null,
  192. engineVersion: null
  193. },
  194. // 表单参数
  195. form: {},
  196. // 表单校验
  197. rules: {
  198. },
  199. // 当前点击的行数据
  200. clickRow: {},
  201. passingParam: {},
  202. pathRoute: [
  203. {
  204. name: '借款审批',
  205. path: '/applyForm/borrow'
  206. },
  207. {
  208. name: '用车审批',
  209. path: '/applyForm/carApply'
  210. },
  211. {
  212. name: '设备审批',
  213. path: '/applyForm/deviceApply'
  214. },
  215. {
  216. name: '项目结算',
  217. path: '/applyForm/settleApply'
  218. }
  219. ]
  220. };
  221. },
  222. created() {
  223. this.getList();
  224. },
  225. methods: {
  226. /** 查询流程定义列表 */
  227. getList() {
  228. this.loading = true;
  229. myProcessList(this.queryParams).then(response => {
  230. this.myProcessList = response.data.records;
  231. this.total = response.data.total;
  232. this.loading = false;
  233. });
  234. },
  235. // 取消按钮
  236. cancel() {
  237. this.open = false;
  238. this.reset();
  239. },
  240. // 表单重置
  241. reset() {
  242. this.form = {
  243. id: null,
  244. name: null,
  245. category: null,
  246. key: null,
  247. tenantId: null,
  248. deployTime: null,
  249. derivedFrom: null,
  250. derivedFromRoot: null,
  251. parentDeploymentId: null,
  252. engineVersion: null
  253. };
  254. this.resetForm("form");
  255. },
  256. /** 搜索按钮操作 */
  257. handleQuery() {
  258. this.queryParams.pageNum = 1;
  259. this.getList();
  260. },
  261. /** 重置按钮操作 */
  262. resetQuery() {
  263. this.resetForm("queryForm");
  264. this.handleQuery();
  265. },
  266. /** 搜索按钮操作 */
  267. handleProcessQuery() {
  268. this.queryProcessParams.pageNum = 1;
  269. this.listDefinition();
  270. },
  271. /** 重置按钮操作 */
  272. resetProcessQuery() {
  273. this.resetForm("queryProcessForm");
  274. this.handleProcessQuery();
  275. },
  276. // 多选框选中数据
  277. handleSelectionChange(selection) {
  278. this.ids = selection.map(item => item.procInsId)
  279. this.single = selection.length !== 1
  280. this.multiple = !selection.length
  281. },
  282. /** 新增按钮操作 */
  283. handleAdd() {
  284. this.open = true;
  285. this.title = "发起流程";
  286. this.listDefinition();
  287. },
  288. listDefinition() {
  289. listDefinition(this.queryProcessParams).then(response => {
  290. this.definitionList = response.data.records;
  291. this.processTotal = response.data.total;
  292. this.processLoading = false;
  293. });
  294. },
  295. /** 发起流程申请 */
  296. handleStartProcess(row) {
  297. // if (row.category == "assess" || row.category == "car" || ) {
  298. let formId = new Snowflake(1n, 1n, 0n).nextId().toString();
  299. getNextFlowNodeByStart({ deploymentId: row.deploymentId, variables: { formId: formId } }).then(res => {
  300. let data = res.data;
  301. if (data.dataType === 'dynamic') {
  302. if (data.type === 'assignee') { // 指定人员
  303. this.checkSendUser = true;
  304. this.checkType = "single";
  305. } else if (data.type === 'candidateUsers') { // 候选人员(多个)
  306. this.checkSendUser = true;
  307. this.checkType = "multiple";
  308. } else if (data.type === 'candidateGroups') { // 指定组(所属角色接收任务)
  309. this.checkSendRole = true;
  310. } else { // 会签
  311. // 流程设计指定的 elementVariable 作为会签人员列表
  312. this.multiInstanceVars = data.vars;
  313. this.checkSendUser = true;
  314. this.checkType = "multiple";
  315. }
  316. this.taskOpen = true;
  317. this.taskTitle = "选择任务接收";
  318. } else {
  319. const variables = {};
  320. const formData = {};
  321. formData.disabled = true;
  322. formData.formBtns = false;
  323. formData.formId = formId
  324. if (row.id) {
  325. variables.variables = formData;
  326. let routePath = this.getRoutePath(row);
  327. // 启动流程并将表单数据加入流程变量
  328. definitionStart(row.id, JSON.stringify(variables)).then(res => {
  329. this.$modal.msgSuccess(res.msg);
  330. let procInstanceId = res.data;
  331. todoList({
  332. pageNum: 1,
  333. pageSize: 99999999, processInsId: procInstanceId
  334. }).then(toDoRes => {
  335. let records = toDoRes.data.records;
  336. if (records.length == 1) {
  337. records = records[0]
  338. }
  339. this.$router.push({
  340. path: routePath,
  341. query: {
  342. procInsId: records.procInsId,
  343. executionId: records.executionId,
  344. deployId: records.deployId,
  345. taskId: records.taskId,
  346. taskName: records.taskName,
  347. startUser: records.startUserName + '-' + records.startDeptName,
  348. formId: formData.formId,
  349. procDefName: records.procDefName
  350. }
  351. })
  352. })
  353. // this.goBack();
  354. // this.$router.push({
  355. // path: '/flowable/task/myProcess/send/index',
  356. // query: {
  357. // deployId: row.deploymentId,
  358. // procDefId: row.id,
  359. // name: row.name
  360. // }
  361. // })
  362. })
  363. }
  364. }
  365. })
  366. // } else {
  367. // }
  368. },
  369. getRoutePath(row) {
  370. let path;
  371. for (let p of this.publicData.pathRoute) {
  372. if (p.name == row.name) {
  373. path = p.path
  374. break
  375. } else {
  376. path = '/flowable/task/todo/detail/index'
  377. }
  378. }
  379. return path
  380. },
  381. /** 取消流程申请 */
  382. handleStop(row) {
  383. const params = {
  384. instanceId: row.procInsId
  385. }
  386. stopProcess(params).then(res => {
  387. this.$modal.msgSuccess(res.msg);
  388. this.getList();
  389. });
  390. },
  391. /** 流程流转记录 */
  392. handleFlowRecord(row) {
  393. // this.$router.push({
  394. // path: '/flowable/task/myProcess/detail/index',
  395. // query: {
  396. // procInsId: row.procInsId,
  397. // deployId: row.deployId,
  398. // taskId: row.taskId
  399. // }
  400. // })
  401. this.clickRow = row;
  402. this.detailsOpen = true;
  403. },
  404. // 表单信息
  405. handleFlowNote(row) {
  406. getProcessVariables(row.taskId).then(res => {
  407. if (res.data) {
  408. this.passingParam = row
  409. this.passingParam.formId = res.data.formId
  410. this.formOpen = true
  411. }
  412. })
  413. },
  414. /** 修改按钮操作 */
  415. handleUpdate(row) {
  416. this.reset();
  417. const id = row.id || this.ids
  418. getDeployment(id).then(response => {
  419. this.form = response.data;
  420. this.open = true;
  421. this.title = "修改流程定义";
  422. });
  423. },
  424. /** 提交按钮 */
  425. submitForm() {
  426. this.$refs["form"].validate(valid => {
  427. if (valid) {
  428. if (this.form.id != null) {
  429. updateDeployment(this.form).then(response => {
  430. this.$modal.msgSuccess("修改成功");
  431. this.open = false;
  432. this.getList();
  433. });
  434. } else {
  435. addDeployment(this.form).then(response => {
  436. this.$modal.msgSuccess("新增成功");
  437. this.open = false;
  438. this.getList();
  439. });
  440. }
  441. }
  442. });
  443. },
  444. /** 删除按钮操作 */
  445. handleDelete(row) {
  446. const ids = row.procInsId || this.ids;// 暂不支持删除多个流程
  447. this.$confirm('是否确定取消流程?', "警告", {
  448. confirmButtonText: "确定",
  449. cancelButtonText: "取消",
  450. type: "warning"
  451. }).then(() => {
  452. getProcessVariables(row.taskId).then(res => {
  453. if (res.data) {
  454. let delId = res.data.formId;
  455. this.deleteDataByUrl(row.procDefName, delId)
  456. }
  457. return delDeployment(ids);
  458. }).then(() => {
  459. this.getList();
  460. this.$modal.msgSuccess("流程取消成功");
  461. })
  462. })
  463. },
  464. deleteDataByUrl(procDefName, id) {
  465. return deleteResources(procDefName, id)
  466. },
  467. // 子流程不可以删除
  468. beDeleted(row) {
  469. if (row.procDefName == '项目预算' || row.procDefName == '技术方案' || row.procDefName == '安全交底' || row.finishTime != null) {
  470. return true
  471. } else if (row.procDefName == '项目流转' && row.taskName != '项目登记') {
  472. return true
  473. } else {
  474. return false
  475. }
  476. },
  477. /** 导出按钮操作 */
  478. handleExport() {
  479. const queryParams = this.queryParams;
  480. this.$confirm('是否确认导出所有流程定义数据项?', "警告", {
  481. confirmButtonText: "确定",
  482. cancelButtonText: "取消",
  483. type: "warning"
  484. }).then(() => {
  485. return exportDeployment(queryParams);
  486. }).then(response => {
  487. this.download(response.msg);
  488. })
  489. }
  490. }
  491. };
  492. </script>