myOA.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. <template>
  2. <div class="process-mange-wrap">
  3. <el-card shadow="always" :body-style="{ padding: '20px' }">
  4. <div slot="header" class="clearfix">
  5. <span>我的申请</span>
  6. </div>
  7. <div class="search-area">
  8. <el-form
  9. :model="queryParams"
  10. ref="queryParamsRef"
  11. label-width="80px"
  12. :inline="true"
  13. size="medium"
  14. >
  15. <el-form-item label="名称" size="normal">
  16. <el-input v-model="queryParams.taskName"></el-input>
  17. </el-form-item>
  18. <!-- <el-form-item label="开始时间" size="normal">
  19. <el-date-picker
  20. v-model="queryParams.startDate"
  21. type="date"
  22. size="normal"
  23. placeholder="选择日期时间"
  24. >
  25. </el-date-picker>
  26. </el-form-item> -->
  27. <el-form-item>
  28. <el-button
  29. type="primary"
  30. size="medium"
  31. @click="getList"
  32. icon="el-icon-search"
  33. >搜索</el-button
  34. >
  35. <el-button size="medium" @click="resetQuery" icon="el-icon-refresh"
  36. >重置</el-button
  37. >
  38. <!-- <el-button type="info" size="medium" @click="toDetail"
  39. >详情</el-button
  40. > -->
  41. </el-form-item>
  42. <el-form-item>
  43. <el-radio-group
  44. v-model="queryParams.taskProcessState"
  45. @change="getList"
  46. >
  47. <el-radio-button label="3">已完成</el-radio-button>
  48. <el-radio-button label="0">进行中</el-radio-button>
  49. </el-radio-group>
  50. </el-form-item>
  51. </el-form>
  52. </div>
  53. <!-- <el-button type="primary" size="default" @click="printTest">
  54. 打印测试
  55. </el-button> -->
  56. <div class="show-body">
  57. <!-- 流程任务列表 -->
  58. <el-table
  59. v-loading="loading"
  60. :data="tableData"
  61. border
  62. @selection-change="() => {}"
  63. >
  64. <el-table-column type="selection" width="55" align="center" />
  65. <el-table-column type="index" width="50" align="center" />
  66. <el-table-column
  67. v-for="col in newColumn"
  68. :prop="col.prop"
  69. :key="col.prop"
  70. :label="col.label"
  71. align="center"
  72. >
  73. <template slot-scope="scope">
  74. <span v-if="col.prop == 'benCreateTime'">{{
  75. scope.row.benCreateTime.replace("T", " ")
  76. }}</span>
  77. <span v-else-if="col.prop == 'bepTaskProcessType'">{{
  78. getDictLabel(scope.row.bepTaskProcessType, dict.type.bpm_type)
  79. }}</span>
  80. <span v-else-if="col.prop == 'benTaskNodeState'">{{
  81. scope.row.benTaskNodeState == "0" ? "未执行" : "已执行"
  82. }}</span>
  83. <span v-else-if="col.prop == 'bepTaskProcessState'">{{
  84. getDictLabel(
  85. scope.row.bepTaskProcessState,
  86. dict.type.task_process_state
  87. )
  88. }}</span>
  89. <span v-else>{{ scope.row[col.prop] }}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column
  93. label="操作"
  94. width="150"
  95. fixed="right"
  96. align="center"
  97. class-name="small-padding fixed-width"
  98. >
  99. <template slot-scope="scope">
  100. <!-- <el-button
  101. v-show="scope.row.bepTaskProcessState != 3"
  102. class="mr5 mb5"
  103. @click="approveHandler(scope.row)"
  104. type="primary"
  105. size="small"
  106. >审批</el-button
  107. > -->
  108. <el-button
  109. @click="toDetail(scope.row)"
  110. type="primary"
  111. size="small"
  112. >详情</el-button
  113. >
  114. <!-- <el-dropdown>
  115. <el-button type="warning" plain size="small">
  116. 处理<i class="el-icon-arrow-down el-icon--right"></i>
  117. </el-button>
  118. <el-dropdown-menu slot="dropdown">
  119. <el-dropdown-item>
  120. <el-button
  121. @click="approveHandler(scope.row)"
  122. type="text"
  123. size="small"
  124. >审批</el-button
  125. >
  126. </el-dropdown-item>
  127. <el-dropdown-item>
  128. <el-button
  129. @click="toDetail(scope.row)"
  130. type="text"
  131. size="small"
  132. >详情</el-button
  133. >
  134. </el-dropdown-item>
  135. <el-dropdown-item>
  136. <el-button
  137. v-show="isShowCancel(scope.row)"
  138. @click="cancelHandler(scope.row)"
  139. type="text"
  140. size="small"
  141. >取消申请</el-button
  142. >
  143. </el-dropdown-item>
  144. </el-dropdown-menu>
  145. </el-dropdown> -->
  146. </template>
  147. </el-table-column>
  148. </el-table>
  149. <!-- 分页 -->
  150. <pagination
  151. v-show="total > 0"
  152. :total="total"
  153. :page.sync="queryParams.pageNum"
  154. :limit.sync="queryParams.pageSize"
  155. @pagination="getList"
  156. />
  157. <!-- 审批弹窗 -->
  158. <el-dialog title="审批" :visible.sync="show">
  159. <!-- <FormGroup ref="formGroupRef" :formList="formList"></FormGroup> -->
  160. <Approve
  161. ref="approveRef"
  162. :formList="formList"
  163. :nodeLogList="nodeLogList"
  164. ></Approve>
  165. <template #footer>
  166. <span>
  167. <el-button @click="show = false">取消</el-button>
  168. <el-button type="primary" @click="confirmHandler">确认</el-button>
  169. </span>
  170. </template>
  171. </el-dialog>
  172. </div>
  173. </el-card>
  174. <div id="print"></div>
  175. </div>
  176. </template>
  177. <script>
  178. import {
  179. processList,
  180. runProcessNodeExecution,
  181. getProcessNodeFormTemplate,
  182. getProcessNodeFormInfoData,
  183. processNodeExecutionApproval,
  184. revokeApplication,
  185. listApproveLog,
  186. } from "@/api/bpmprocess/run/executeProcess";
  187. import { triggerExceptionNode } from "@/api/bpmprocess/process";
  188. import getNodeSequence from "@/utils/bpmn/getNodeSequence";
  189. import { getForm } from "@/api/dragform/form";
  190. import FormGroup from "@/components/FormGroup/index.vue";
  191. import Approve from "@/components/FormGroup/Approve.vue";
  192. import receiptDocuments from "@/utils/print/receiptDocuments";
  193. import qrCodeList from "@/utils/print/qrCodeList.js";
  194. import { xmlStr2XmlObj } from "@/utils/bpmn/tool";
  195. export default {
  196. name: "processMange",
  197. props: [],
  198. components: { FormGroup, Approve },
  199. dicts: ["bpm_type", "task_process_state"],
  200. data() {
  201. return {
  202. // 弹窗表单数据
  203. row: {},
  204. formList: [],
  205. show: false,
  206. loading: false,
  207. row: {}, //当前操作行数据
  208. myForm: "", //自定义表单组件名
  209. // 节点弹窗title
  210. nodeTitle: "节点弹窗",
  211. open: false,
  212. // 节点弹窗对应的formData
  213. commonData: {},
  214. taskType: 1,
  215. queryString: "",
  216. taskStatus: "",
  217. tableData: [], //表格数据
  218. // 查询参数
  219. queryParams: {
  220. pageNum: 1,
  221. pageSize: 10,
  222. taskProcessState: "0",
  223. taskProcessType: 1,
  224. },
  225. total: 0,
  226. columns: [
  227. {
  228. prop: "bepTaskKey",
  229. label: "任务编号",
  230. },
  231. {
  232. prop: "bepTaskProcessName",
  233. label: "任务名称",
  234. },
  235. // {
  236. // prop: "bepTaskProcessType",
  237. // label: "任务流程类型",
  238. // },
  239. {
  240. prop: "bepTaskProcessState",
  241. label: "任务流程状态",
  242. },
  243. {
  244. prop: "benTaskNodeName",
  245. label: "节点名称",
  246. },
  247. {
  248. prop: "benTaskNodeType",
  249. label: "节点类型",
  250. },
  251. {
  252. prop: "benTaskNodeState",
  253. label: "节点状态",
  254. },
  255. {
  256. prop: "benCreateBy",
  257. label: "创建人",
  258. },
  259. {
  260. prop: "benCreateTime",
  261. label: "创建时间",
  262. },
  263. ],
  264. formType: "", //表单类型 dragForm:拖拽表单 composeForm:工艺组合表单 designForm:定制表单
  265. // k-form-build 数据
  266. dynamicData: {},
  267. tableName: "",
  268. defaultValue: {},
  269. jsonData: {},
  270. // 拖拽数据
  271. taskInfo: {},
  272. groupKey: "",
  273. subCount: {},
  274. tableCount: {},
  275. subTableName: "",
  276. // 弹窗表单渲染数据
  277. formData: {},
  278. backExceptionTaskList: ["GY06"], //特殊回退表单组件列表
  279. nodeLogList: [], //节点日志列表
  280. };
  281. },
  282. computed: {
  283. newColumn() {
  284. if (this.queryParams.taskProcessState == "3") {
  285. return [
  286. {
  287. prop: "bepTaskKey",
  288. label: "任务编号",
  289. },
  290. {
  291. prop: "bepTaskProcessName",
  292. label: "任务名称",
  293. },
  294. // {
  295. // prop: "bepTaskProcessType",
  296. // label: "任务流程类型",
  297. // },
  298. {
  299. prop: "bepTaskProcessState",
  300. label: "任务流程状态",
  301. },
  302. {
  303. prop: "benCreateBy",
  304. label: "创建人",
  305. },
  306. {
  307. prop: "benCreateTime",
  308. label: "创建时间",
  309. },
  310. ];
  311. } else {
  312. return this.columns;
  313. }
  314. },
  315. },
  316. mounted() {
  317. this.getList();
  318. },
  319. methods: {
  320. // 审批回调
  321. async approveHandler(row) {
  322. console.log(row);
  323. this.row = row;
  324. let {
  325. benTaskNodeFormKey,
  326. benTaskNodeFormType,
  327. bepTaskPlanKey,
  328. bepTaskKey,
  329. benTaskNodeKey,
  330. bepTaskNodeKey,
  331. benTaskProcessKey,
  332. benmTaskAutomaticScriptTriggerType,
  333. bepTaskNodeNextKey,
  334. } = row;
  335. // 新的运行逻辑
  336. let payLoad = {
  337. taskNodeKey: benTaskNodeKey,
  338. taskProcessKey: benTaskProcessKey,
  339. // taskAutomaticScriptTriggerType: benmTaskAutomaticScriptTriggerType,
  340. taskPlanKey: bepTaskPlanKey,
  341. };
  342. let res = await getProcessNodeFormTemplate(payLoad);
  343. if (res.code == 200) {
  344. if (res.data[0]?.template?.mainForm) {
  345. //表单组
  346. this.transformDataFormat(res.data[0].template);
  347. this.tableName =
  348. res.data[0].template.mainForm.showTemplate.dfTableName;
  349. console.log(this.formList);
  350. } else {
  351. this.formList = res.data;
  352. this.tableName = res.data[0].template.dfTableName;
  353. }
  354. this.nodeLogList = row.nodeLog.slice(1);
  355. this.show = true;
  356. } else {
  357. this.$message.error("网络异常,请稍后再试");
  358. }
  359. },
  360. // 将表单组数据转换成符合单个表单的数据格式
  361. transformDataFormat(data) {
  362. let { mainForm, subFormList } = data;
  363. this.formList = [];
  364. let showValue = mainForm.showValue[0];
  365. if (showValue) {
  366. mainForm.showTemplate.resultMap = mainForm.showValue;
  367. }
  368. this.formList.push({
  369. template: mainForm.showTemplate,
  370. tableName: mainForm.mainFormTable,
  371. });
  372. if (subFormList && subFormList.length > 0) {
  373. subFormList.forEach((item) => {
  374. let showValue = item.showValue[0];
  375. if (showValue) {
  376. item.showTemplate.resultMap = mainForm.showValue;
  377. }
  378. this.formList.push({
  379. template: item.showTemplate,
  380. tableName: item.formItem?.split(".")?.[0],
  381. });
  382. });
  383. }
  384. },
  385. toDetail(row) {
  386. console.log(row);
  387. let { bepTaskPlanKey, benTaskNodeKey, benTaskProcessKey } = row;
  388. window.sessionStorage.setItem("oaRow", JSON.stringify(row));
  389. let theLastNode = this.getTheLastNode(row.bepTaskProcessXmlContent);
  390. this.$router.push({
  391. path: "/processMange/detail",
  392. query: {
  393. taskNodeKey:
  394. row.bepTaskProcessState == 3 ? theLastNode : benTaskNodeKey,
  395. taskProcessKey: benTaskProcessKey,
  396. taskPlanKey: bepTaskPlanKey,
  397. },
  398. });
  399. },
  400. // 获取最后一个节点的nodekey 最后一个非结束节点
  401. getTheLastNode(xmlStr) {
  402. let xmlObj = xmlStr2XmlObj(xmlStr);
  403. let nodeSequence = getNodeSequence(xmlObj);
  404. console.log(nodeSequence);
  405. return nodeSequence[nodeSequence.length - 2]?.nodeId;
  406. },
  407. // 获取列表数据
  408. getList() {
  409. listApproveLog({ ...this.queryParams, taskName: this.queryString }).then(
  410. (res) => {
  411. if (res.code == 200) {
  412. this.tableData = res.rows.map((item) => item.resultMap);
  413. this.total = res.total;
  414. console.log(this.tableData);
  415. } else {
  416. this.$message.error("网络异常,请稍后再试");
  417. }
  418. }
  419. );
  420. },
  421. // 获取字典对应label
  422. getDictLabel(value, dictLsit = []) {
  423. return dictLsit.find((item) => {
  424. return item.value == value;
  425. })?.label;
  426. },
  427. // xml字符串转xml对象
  428. xmlStr2XmlObj(xmlStr) {
  429. var xmlObj = {};
  430. if (document.all) {
  431. var xmlDom = new ActiveXObject("Microsoft.XMLDOM");
  432. xmlDom.loadXML(xmlStr);
  433. xmlObj = xmlDom;
  434. } else {
  435. xmlObj = new DOMParser().parseFromString(xmlStr, "text/xml");
  436. }
  437. return xmlObj;
  438. },
  439. // 获取下一个节点的nodekey
  440. getNextNodeKey(nodeKey, xmlStr) {
  441. let xmlObj = this.xmlStr2XmlObj(xmlStr);
  442. let nodeSequence = getNodeSequence(xmlObj);
  443. return nodeSequence.find((item) => item.nodeId == nodeKey) || {};
  444. },
  445. // 确认审批回调
  446. async confirmHandler() {
  447. let { benTaskNodeKey, bepTaskProcessXmlContent, implementationName } =
  448. this.row;
  449. let { nodeId, nextNodeId } = this.getNextNodeKey(
  450. benTaskNodeKey,
  451. bepTaskProcessXmlContent
  452. );
  453. let res = await this.$refs.approveRef.getformInfo();
  454. if (!res.flag) return;
  455. // 准备审批数据
  456. let payLoad = {
  457. taskProcessKey: this.row.bepTaskKey, //当前任务流程编码
  458. taskNodeKey: nodeId, //当前执行节点唯一编码
  459. nextNodeKey: nextNodeId, //下一节点编码
  460. implementationName: this.row.benmTaskAutomaticScriptTriggerType, //当前节点绑定的脚本名
  461. // taskProcessXmlContent: this.row.bepTaskProcessXmlContent, //当前流程xml
  462. tableName: this.tableName,
  463. // formDataMap: JSON.stringify(res.data), //自定义表单组件收集的表单数据
  464. taskNodeType: this.row.benTaskNodeType,
  465. ...res.data,
  466. };
  467. let fileXML = new File(
  468. [this.row.bepTaskProcessXmlContent],
  469. this.row.bepTaskKey + ".bpmn",
  470. {
  471. type: "text/bpmn",
  472. }
  473. );
  474. const subformData = new FormData();
  475. subformData.append("fileXML", fileXML);
  476. for (let key in payLoad) {
  477. subformData.append(key, payLoad[key] == null ? "" : payLoad[key]);
  478. }
  479. let result = await processNodeExecutionApproval(subformData);
  480. console.log(result);
  481. if (result.code == 200) {
  482. this.$message.success("审批成功");
  483. this.show = false;
  484. this.getList();
  485. } else {
  486. this.$message.error("审批失败");
  487. }
  488. },
  489. // 取消审批回调
  490. async cancelHandler(row) {
  491. console.log(row);
  492. // 先获取tableName
  493. let {
  494. benTaskNodeKey,
  495. bepTaskProcessXmlContent,
  496. implementationName,
  497. bepTaskPlanKey,
  498. benTaskProcessKey,
  499. } = row;
  500. let { nodeId, nextNodeId } = this.getNextNodeKey(
  501. benTaskNodeKey,
  502. bepTaskProcessXmlContent
  503. );
  504. // let payLoad = {
  505. // taskNodeKey: benTaskNodeKey,
  506. // taskProcessKey: benTaskProcessKey,
  507. // // taskAutomaticScriptTriggerType: benmTaskAutomaticScriptTriggerType,
  508. // taskPlanKey: bepTaskPlanKey,
  509. // };
  510. // 准备审批数据
  511. let payLoad = {
  512. taskProcessKey: row.bepTaskKey, //当前任务流程编码
  513. taskNodeKey: nodeId, //当前执行节点唯一编码
  514. nextNodeKey: nextNodeId, //下一节点编码
  515. implementationName: row.benmTaskAutomaticScriptTriggerType, //当前节点绑定的脚本名
  516. // taskProcessXmlContent: this.row.bepTaskProcessXmlContent, //当前流程xml
  517. tableName: this.tableName,
  518. // formDataMap: JSON.stringify(res.data), //自定义表单组件收集的表单数据
  519. taskNodeType: row.benTaskNodeType,
  520. };
  521. let fileXML = new File(
  522. [row.bepTaskProcessXmlContent],
  523. row.bepTaskKey + ".bpmn",
  524. {
  525. type: "text/bpmn",
  526. }
  527. );
  528. const subformData = new FormData();
  529. subformData.append("fileXML", fileXML);
  530. for (let key in payLoad) {
  531. subformData.append(key, payLoad[key] == null ? "" : payLoad[key]);
  532. }
  533. this.$confirm("确认取消吗?", "提示", {
  534. confirmButtonText: "确定",
  535. cancelButtonText: "取消",
  536. type: "warning",
  537. }).then(async () => {
  538. let result = await revokeApplication(subformData);
  539. if (result.code == 200) {
  540. this.$message.success("取消成功");
  541. this.getList();
  542. } else {
  543. this.$message.error("取消失败");
  544. }
  545. });
  546. },
  547. // 取消审批按钮 显示与隐藏
  548. isShowCancel(row) {
  549. if (row.bepTaskProcessState == 3) {
  550. return false;
  551. }
  552. this.cancelShow = !this.cancelShow;
  553. },
  554. //重置查询参数
  555. resetQuery() {
  556. this.queryParams = {
  557. pageNum: 1,
  558. pageSize: 10,
  559. taskName: "",
  560. taskProcessState: "0",
  561. taskProcessType: 1,
  562. };
  563. this.getList();
  564. },
  565. // 打印测试
  566. printTest() {
  567. // receiptDocuments({}, "print");
  568. qrCodeList({}, "print");
  569. },
  570. },
  571. };
  572. </script>
  573. <style scoped lang="scss">
  574. .process-mange-wrap {
  575. background-color: #f2f3f8;
  576. padding: 20px;
  577. .col {
  578. background-color: #fff;
  579. border-right: 1px solid #ebedf2;
  580. /* margin-right: 3px; */
  581. .statistic-wrap {
  582. /* // height: 70px; */
  583. box-sizing: border-box;
  584. display: flex;
  585. align-items: center;
  586. padding: 10px 17px;
  587. justify-content: space-between;
  588. .discription {
  589. display: flex;
  590. flex-direction: column;
  591. .title {
  592. line-height: 20px;
  593. font-size: 18px;
  594. font-weight: 700;
  595. margin-bottom: 5px;
  596. }
  597. .sub-title {
  598. font-size: 14px;
  599. }
  600. }
  601. .data {
  602. font-size: 20px;
  603. font-weight: 700;
  604. }
  605. }
  606. }
  607. .main-area {
  608. margin-top: 30px;
  609. box-shadow: 0 1px 15px 1px rgb(69 65 78 / 8%);
  610. background-color: #fff;
  611. .show-header {
  612. border-bottom: 1px solid #ebedf2;
  613. display: flex;
  614. align-items: center;
  615. justify-content: space-between;
  616. padding: 0px 20px 0px 20px;
  617. height: 70px;
  618. /* .header {
  619. } */
  620. .search-list {
  621. display: flex;
  622. .search-tab {
  623. margin-right: 20px;
  624. .btn-list-two {
  625. margin-left: 10px;
  626. }
  627. }
  628. }
  629. }
  630. .show-body {
  631. padding: 25px;
  632. }
  633. }
  634. }
  635. </style>