processMange.vue 21 KB

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