sasp-flow-render 1.1.33 → 1.1.35-decoupling

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2397 @@
1
+ // utils/workflow.js
2
+
3
+ import {AjaxUtil} from "sasp-base";
4
+
5
+ /**
6
+ * 工作流引擎类
7
+ * 支持多步骤、异步操作、自定义弹窗内容、错误处理
8
+ */
9
+ class WorkflowEngine {
10
+ initParams(component,flowAttrs = {}){
11
+ this.$this = component; // required
12
+ if(!this.$this){
13
+ console.error("初始化失败,component不能为空");
14
+ return;
15
+ }
16
+ this.flowId = flowAttrs.flowId; // required
17
+ this.tableviewId = flowAttrs.tableviewId; // 外部调用时初始化必须
18
+ this.formGloabalInfo = (this.$this.formGloabalInfo || {});
19
+ this.flowParams = {};
20
+ this.formComponent = this.formGloabalInfo.formComponent;
21
+ this.dataId = "";
22
+ this.formId = "";
23
+ this.currentInst = {};
24
+ this.installListObj = this.$this.EVENT_PLUGIN['installEventObj']||{}; //已经安装的流程事件
25
+ this.loginUser = this.$this.FLOW_CACHE_GLOBAL.getLoginUser();
26
+ if(!this.loginUser.id){ // 判断是否是表单独立登录
27
+ if(this.$this.FORM_USER_GLOBAL){
28
+ this.loginUser = this.$this.FORM_USER_GLOBAL.getLoginUser();
29
+ }
30
+ }
31
+
32
+ this.skipAutoInit = false;
33
+ if(flowAttrs.skipAutoInit){
34
+ this.skipAutoInit = flowAttrs.skipAutoInit;
35
+ }
36
+ this.formInfo = {
37
+ dataId: this.dataId,
38
+ opt: "view",
39
+ }
40
+ this.$flowDialog = this.$this.$flowDialog;
41
+ this.flowDefine = {};
42
+ this.flowRecordObj = {};
43
+ this.flowChartObj = {};
44
+ this.draftNodeId = "";
45
+
46
+ // 初始化插入部分方法
47
+ let methods = flowAttrs["methods"] || {};
48
+ this.initTabNum = methods["initTabNum"];
49
+ this.tabCrudSearch = methods["tabCrudSearch"];
50
+ this.batchTabRemove = methods["batchTabRemove"];
51
+ this.setFlowTabInfo = methods["setFlowTabInfo"];
52
+ this.getFlowBatchDialog = methods["getFlowBatchDialog"];
53
+ this.closeFlowBatchDialog = methods["closeFlowBatchDialog"];
54
+ this.initFormInfo = methods["initFormInfo"];
55
+ this.saveFormInfo = methods["saveFormInfo"];
56
+ this.getFormInfo = methods["getFormInfo"];
57
+ this.flowNextOperation = methods["flowNextOperation"];
58
+ this.forceUpdateComponent = methods["forceUpdateComponent"];
59
+ this.nextStepAfterSave = methods["nextStepAfterSave"]; // 流程下一步保存表单数据后的回调
60
+ this.afterNextStepSuccess = methods["afterNextStepSuccess"]; // 流程下一步成功后,即关闭对话框后的回调
61
+ this.backSubmitEvent = methods["backSubmitEvent"]; // 退回后执行方法
62
+ this.getBackSubmitEvent = methods["getBackSubmitEvent"]; // 取回后执行方法
63
+ this.setParams = methods["setParams"];
64
+
65
+ if(!this.initFormInfo){
66
+ this.initFormInfo = this.$flowDialog.initFormInfo;
67
+ }
68
+
69
+ if(!this.saveFormInfo){
70
+ this.saveFormInfo = this.$flowDialog.saveFormInfo;
71
+ }
72
+
73
+ if(!this.getFormInfo){
74
+ this.getFormInfo = this.$flowDialog.getFormInfo;
75
+ }
76
+
77
+ // 流程的参数
78
+ this.flowInstDataDialog = false;
79
+ this.nextSteptUserDialog = false;
80
+ this.doMainDatasObj = {};
81
+ this.userMap = {};
82
+ this.userArr = [];
83
+ this.tabActive = "draft";
84
+ this.flowDefineByFlowId = {};
85
+ this.startNodeKey = "";
86
+ this.startNodeKeyObj = {};
87
+ this.allNodeInfo = {};
88
+ this.flowNodeIdToInfo = {};
89
+ this.flowNodeNameObj = {};
90
+ this.nodeListButtonObj = {};
91
+ this.listButtonObj = { // 列表按钮
92
+ add: "新增",
93
+ delete: "删除",
94
+ update: "修改",
95
+ view: "查看",
96
+ deal: "处理",
97
+ flowRecord: "流转记录",
98
+ flowChart: "流程图",
99
+ };
100
+ this.diyButtonsObj= {};
101
+ this.optColumnWidth = 336;
102
+ this.nodeFormButtonObj = {};
103
+ this.nodeFormBtnObj = {};
104
+ this.startNodeKeyObjByFlowId = {};
105
+ this.flowVersionNodeObj = {}; //版本号对应的节点对象
106
+ this.flowVersionNodeObjByFlowId = {};
107
+ this.flowEventScriptByFlowId = {};
108
+ this.operateType= {};
109
+
110
+ this.nextNode = {};
111
+ this.description = "";
112
+ this.saveInstId = "";
113
+ this.nowNode = {};
114
+ this.isProceedNext = false;
115
+ this.nextNodeName = "";
116
+ this.choosePosUserIds = "";
117
+ this.choosePosUserIdsObj = {};
118
+ this.chooseNextUserIdObj = {};
119
+ this.chooseNextUserNameObj = {};
120
+ this.chooseNextUserId = "";
121
+ this.chooseNextUserName = "";
122
+ this.nextSteptUserArr = [];
123
+
124
+ this.newEventObj = {};
125
+ this.newScriptObj = {};
126
+ this.scriptObj = {};
127
+ this.resourceTabOpts = ['draft','pending','processed','rescinded','finished','discontinue','flowQuery'];
128
+ //表单按钮
129
+ this.formButtonObj = {
130
+ saveDraft: "存草稿",
131
+ completeSign: "加签",
132
+ turnSign: "转签",
133
+ nextStep: "下一步",
134
+ back: "退回",
135
+ getBack: "取回",
136
+ cancel: "撤销",
137
+ stopped: "中止",
138
+ close: "关闭",
139
+ export: "导出",
140
+ retSpecified: "退回指定节点"
141
+ }
142
+
143
+ this.flowParams = {};
144
+ this.isDisabled = {
145
+ update: true,
146
+ deal: true,
147
+ flowRecord: true,
148
+ flowChart: true,
149
+ view: true,
150
+ saveDraft: true,
151
+ completeSign: true,
152
+ turnSign: true,
153
+ nextStep: true,
154
+ back: true,
155
+ cancel: true,
156
+ stopped: true,
157
+ close: true,
158
+ export: true,
159
+ retSpecified: true,
160
+ getBack: true,
161
+ record: true,
162
+ restore: true,
163
+ };
164
+
165
+ this.formBtnObjDefault = {
166
+ saveDraft: {
167
+ text: "存草稿",
168
+ type: "success",
169
+ icon: "el-icon-check",
170
+ disabled: false,
171
+ show: false,
172
+ method: () => {
173
+ this.saveDraft();
174
+ }
175
+ },
176
+
177
+ nextStep: {
178
+ text: "下一步",
179
+ type: "primary",
180
+ icon: "el-icon-d-arrow-right",
181
+ disabled: false,
182
+ show: false,
183
+ method: () => {
184
+ this.nextStep();
185
+ // this.isDisabled1 = true;
186
+ this.$flowDialog.fillFlowDialogParams({
187
+ isDisabled1: true
188
+ });
189
+ }
190
+ },
191
+
192
+ completeSign: {
193
+ text: "加签",
194
+ type: "primary",
195
+ icon: "saspiconfont pl-icon-jiaqian",
196
+ disabled: false,
197
+ show: false,
198
+ method: () => {
199
+ // this.completeSignDialog = true; // todo加签
200
+ this.$flowDialog.operateDialog('completeSignDialog',true);
201
+ }
202
+ },
203
+
204
+ turnSign: {
205
+ text: "转签",
206
+ type: "primary",
207
+ icon: "saspiconfont pl-icon-zhuanqian-icon",
208
+ disabled: false,
209
+ show: false,
210
+ method: () => {
211
+ // this.turnSignDialog = true; // todo转签
212
+ this.$flowDialog.operateDialog('turnSignDialog',true);
213
+ }
214
+ },
215
+
216
+ back: {
217
+ text: "退回",
218
+ type: "danger",
219
+ icon: "el-icon-d-arrow-left",
220
+ disabled: false,
221
+ show: false,
222
+ method: () => {
223
+ this.backToPrevious(this.currentInst);
224
+ }
225
+ },
226
+
227
+ retSpecified: {
228
+ text: "退回指定节点",
229
+ type: "danger",
230
+ icon: "el-icon-refresh-left",
231
+ disabled: false,
232
+ show: false,
233
+ method: () => {
234
+ this.retSpecified(this.currentInst); //退回指定节点
235
+ }
236
+ },
237
+
238
+ stopped: {
239
+ text: "中止",
240
+ type: "danger",
241
+ icon: "saspiconfont pl-icon-yizhongzhi",
242
+ disabled: false,
243
+ show: false,
244
+ method: () => {
245
+ this.$this.$confirm('确定要中止此流程吗?', '警告', {
246
+ confirmButtonText: '确定',
247
+ cancelButtonText: '取消',
248
+ }).then(() => {
249
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.stopFlow, {
250
+ instId: this.currentInst.flowInstId, type: "0",
251
+ procInstId: this.currentInst.linkProcId,
252
+ taskId: this.currentInst.taskId
253
+ }).then(res => {
254
+ if (res && res.data) {
255
+ if (res.data.operateSuccess) {
256
+ this.$this.$message({type: "success", message: "中止成功!"});
257
+ if (this.getFlowBatchDialog && this.getFlowBatchDialog()) {
258
+ this.batchTabRemove(this.currentInst.dataId);
259
+ } else {
260
+ this.tabCrudSearch && this.tabCrudSearch();
261
+ this.flowInstDataDialog = false;
262
+ this.$flowDialog.operateDialog('flowInstDataDialog',false);
263
+ }
264
+ this.initTabNum && this.initTabNum();
265
+
266
+ let remindParam = {
267
+ instId:this.currentInst.flowInstId,
268
+ flowId:this.flowDefine.id,
269
+ flowName:this.flowDefine.flowName,
270
+ // formId:this.formInfo.formId,
271
+ // listViewId:this.formInfo.listViewId,
272
+ dataId:this.formInfo.dataId,
273
+ instType:"stopped"
274
+ };
275
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.saveRemind,remindParam);
276
+
277
+ //执行事件规则
278
+ let currentNodeObj = this.flowNodeIdToInfo[this.currentInst.currentNode] ||{};
279
+ if(currentNodeObj.openEvent == '1'){
280
+ this.exeNewFlowEvent("suspend",currentNodeObj.nodeLinkId||'');
281
+ }
282
+ } else {
283
+ this.$this.$message({type: "error", message: res.data.operateMessage});
284
+ }
285
+ }
286
+ });
287
+ });
288
+ }
289
+ },
290
+
291
+ cancel: {
292
+ text: "撤销",
293
+ type: "danger",
294
+ icon: "saspiconfont pl-icon-chexiao",
295
+ disabled: false,
296
+ show: false,
297
+ isView: true,
298
+ method: () => {
299
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.revokeFlow, {
300
+ instId: this.currentInst.flowInstId,
301
+ taskId: this.currentInst.taskId
302
+ }).then(res => {
303
+ if (res && res.data) {
304
+ if (res.data.operateSuccess) {
305
+ this.$this.$message({type: "success", message: "撤销成功!"});
306
+ this.tabCrudSearch && this.tabCrudSearch();
307
+ this.flowInstDataDialog = false;
308
+ this.$flowDialog.operateDialog('flowInstDataDialog',false);
309
+ this.initTabNum && this.initTabNum();
310
+
311
+ let remindParam = {
312
+ instId:this.currentInst.flowInstId,
313
+ flowId:this.flowDefine.id,
314
+ flowName:this.flowDefine.flowName,
315
+ // formId:this.formInfo.formId,
316
+ // listViewId:this.formInfo.listViewId,
317
+ dataId:this.formInfo.dataId,
318
+ instType:"cancel"
319
+ };
320
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.saveRemind,remindParam);
321
+
322
+
323
+ } else {
324
+ this.$this.$message({type: "error", message: res.data.operateMessage});
325
+ }
326
+ }
327
+ });
328
+ }
329
+ },
330
+
331
+ getBack: {
332
+ text: "取回",
333
+ type: "danger",
334
+ icon: "el-icon-refresh-left",
335
+ disabled: false,
336
+ show: false,
337
+ isView: true,
338
+ method: () => {
339
+ this.getBackPrevious();
340
+ }
341
+ },
342
+
343
+ restore: {
344
+ text: "恢复",
345
+ type: "success",
346
+ icon: "saspiconfont pl-icon-chexiao",
347
+ disabled: false,
348
+ show: false,
349
+ isView: true,
350
+ method: () => {
351
+ this.restoreFlow();
352
+ }
353
+ },
354
+ record: {
355
+ text: "流转记录",
356
+ type: "warning",
357
+ icon: "saspiconfont pl-icon-liuchengtu",
358
+ disabled: false,
359
+ show: false,
360
+ isView: true,
361
+ method: () => {
362
+ this.openFlowRecord(this.currentInst);
363
+ }
364
+ },
365
+ close: {
366
+ text: "关闭",
367
+ type: "",
368
+ icon: "el-icon-close",
369
+ disabled: false,
370
+ show: false,
371
+ isView: true,
372
+ method: () => {
373
+ this.flowInstDataDialog = false;
374
+ this.$flowDialog.operateDialog('flowInstDataDialog',false);
375
+ this.closeFlowBatchDialog && this.closeFlowBatchDialog();
376
+ }
377
+ },
378
+ }
379
+ this.loadSuccess = false;
380
+ }
381
+
382
+ constructor(component,flowAttrs = {}) {
383
+ // 工作流配置
384
+ this.initParams(component,flowAttrs);
385
+ }
386
+
387
+ init(){
388
+ return new Promise(resolve => {
389
+ if(!this.skipAutoInit && !this.loadSuccess){
390
+ this.initUserData();
391
+ this.$this.saspFlowAxios.all([
392
+ this.initFlowInfo(),
393
+ this.initFlowFormInfo()
394
+ ]).then(this.$this.saspFlowAxios.spread((resFlow, resForm) => {
395
+ this.loadSuccess = true;
396
+ resolve();
397
+ }));
398
+ }else{
399
+ resolve();
400
+ }
401
+ this.initDialogProps();
402
+ })
403
+ }
404
+
405
+ initFlowFormInfo(){
406
+ return new Promise(resolve => {
407
+ if(!this.$this.FORM_GLOBAL){
408
+ this.$this.$message.error("未安装表单组件,请使用自定义表单开发");
409
+ return;
410
+ }
411
+ this.$this.FORM_GLOBAL.getTableViews(this.tableviewId).then(tableviewsData => {
412
+ if(!tableviewsData || !tableviewsData.id){
413
+ this.$message.error("表单资源不存在!");
414
+ return;
415
+ }
416
+ this.formId = tableviewsData.formId;
417
+ this.$flowDialog.fillFlowDialogParams({
418
+ formId: this.formId,
419
+ tableviewId: this.tableviewId,
420
+ dataId: this.dataId
421
+ });
422
+ resolve();
423
+ });
424
+ });
425
+ }
426
+
427
+ initDialogProps() {
428
+ let dialogProps = {
429
+ flowNextOperation: this.flowNextOperation,
430
+ workFlowUtil: this
431
+ }
432
+ this.$flowDialog.initDialogProps(dialogProps);
433
+ }
434
+
435
+ // 初始化流程相关信息
436
+ initFlowInfo() {
437
+ return new Promise(resolve => {
438
+ if (this.flowId.includes(",")) {
439
+ this.getMultiFlowInfo().then(() => {
440
+ resolve();
441
+ })
442
+ } else {
443
+ this.getFlowInfo().then(() => {
444
+ resolve();
445
+ });
446
+ }
447
+ });
448
+ }
449
+
450
+ /**
451
+ * 多流程初始化
452
+ */
453
+ getMultiFlowInfo() {
454
+ return new Promise(resolve => {
455
+ let flowIdArr = this.flowId.split(",").filter(item => item);
456
+ flowIdArr.forEach(flowId => {
457
+ this.$this.FLOW_GLOBAL.getFlowDefineById(flowId).then(flowDefine => {
458
+ this.flowDefineByFlowId[flowId] = flowDefine;
459
+ });
460
+ });
461
+
462
+ const initFlowNodeFunc = flowIdArr.map(flowId => (() => this.$this.FLOW_GLOBAL.getFlowNodesByFlowId(flowId)));
463
+ Promise.all(initFlowNodeFunc.map(func => func())).then(allFlowNodeArr => {
464
+ //工作流节点
465
+ this.startNodeKey = "Activity_draft"; // todo 确定startNodeKey的位置
466
+ for (const allFlowNode of allFlowNodeArr) {
467
+ this.startNodeKeyObj = {};
468
+ this.flowVersionNodeObj = {};
469
+ let flowId = allFlowNode[0].flowId;
470
+ this.flowDefine = this.flowDefineByFlowId[flowId];
471
+ (allFlowNode || []).forEach(item => {
472
+ if (item.nodeLinkId.indexOf("Activity_draft") > -1) {
473
+ this.startNodeKey = item.nodeLinkId;
474
+ this.startNodeKeyObj[item.version] = item.nodeLinkId; //开始节点对应版本号
475
+ }
476
+ if (!this.flowVersionNodeObj[item.version]) {
477
+ this.$this.$set(this.flowVersionNodeObj, item.version, {});
478
+ }
479
+ this.$this.$set(this.flowVersionNodeObj[item.version], item.nodeLinkId, item); //版本节点对象
480
+
481
+ this.allNodeInfo[item.id] = item;
482
+ this.flowNodeIdToInfo[item.id] = item;
483
+ let nodeArr = ['StartEvent', 'ParallelGateway', 'SequenceFlow', 'ExclusiveGateway', 'InclusiveGateway'];
484
+ if (item.nodeType && nodeArr.indexOf(item.nodeType) === -1) {
485
+ if (!this.flowNodeNameObj[item.nodeLinkId]) {
486
+ let nodeName = item.nodeName;
487
+ if (this.flowId.includes(",")) {
488
+ nodeName = this.flowDefine.flowName + "-" + item.nodeName;
489
+ }
490
+ this.$this.$set(this.flowNodeNameObj, item.nodeLinkId, nodeName);
491
+ } else {
492
+ if (this.flowNodeNameObj[item.nodeLinkId] !== item.nodeName) {
493
+ this.flowNodeNameObj[item.nodeLinkId] = this.flowNodeNameObj[item.nodeLinkId] + "," + item.nodeName;
494
+ }
495
+ }
496
+ }
497
+ if (item.nodeType === "UserTask" && (item.nodeLinkId || "").indexOf("Activity_draft") > -1) {
498
+ this.draftNodeId = item.id; // 草稿节点id
499
+ this.$flowDialog.fillFlowDialogParams({
500
+ draftNodeId: this.draftNodeId
501
+ });
502
+ }
503
+ // 行按钮
504
+ let listButton = JSON.parse(item.listButton || "[]") || [];
505
+ listButton.forEach(button => {
506
+ button.showName = button.showName ? button.showName : this.listButtonObj[button.type];
507
+ });
508
+ this.nodeListButtonObj[item.id] = listButton;
509
+
510
+ // 表单按钮
511
+ let formButton = JSON.parse(item.formButton || "[]") || [];
512
+ formButton.forEach(button => {
513
+ button.showName = button.showName ? button.showName : this.formButtonObj[button.type];
514
+ });
515
+
516
+ this.nodeFormButtonObj[item.id] = this.sortButtonArr(formButton);
517
+ this.nodeFormBtnObj[item.id] = this.formatterFormButton(formButton);
518
+ });
519
+ this.$this.$set(this.startNodeKeyObjByFlowId, flowId, this.startNodeKeyObj);
520
+ this.$this.$set(this.flowVersionNodeObjByFlowId, flowId, this.flowVersionNodeObj);
521
+ // this.initFlowScript().then(() => {
522
+ // resolve(true);
523
+ // });
524
+ }
525
+ const initFlowScriptFunc = flowIdArr.map(flowId => () => this.initFlowScript(flowId));
526
+ Promise.all(initFlowScriptFunc.map(func => func())).then(scriptArr => {
527
+ (scriptArr || []).forEach(scriptEventObj => {
528
+ Object.keys(scriptEventObj).forEach(key => {
529
+ if (key) {
530
+ this.flowEventScriptByFlowId[key] = scriptEventObj[key];
531
+ }
532
+ });
533
+ });
534
+ }).catch(reason => {
535
+ console.log('流程脚本加载出错了', reason);
536
+ });
537
+ let result = {
538
+ flowDefineByFlowId : this.flowDefineByFlowId,
539
+ startNodeKeyObj : this.startNodeKeyObj,
540
+ flowDefine : this.flowDefineByFlowId[this.flowId],
541
+ startNodeKey : this.startNodeKey,
542
+ allNodeInfo : this.allNodeInfo,
543
+ flowNodeIdToInfo : this.flowNodeIdToInfo,
544
+ flowNodeNameObj : this.flowNodeNameObj,
545
+ draftNodeId : this.draftNodeId,
546
+ nodeListButtonObj : this.nodeListButtonObj,
547
+ nodeFormButtonObj : this.nodeFormButtonObj,
548
+ nodeFormBtnObj : this.nodeFormBtnObj,
549
+ startNodeKeyObjByFlowId : this.startNodeKeyObjByFlowId,
550
+ flowVersionNodeObjByFlowId : this.flowVersionNodeObjByFlowId,
551
+ flowEventScriptByFlowId : this.flowEventScriptByFlowId
552
+ };
553
+ this.$flowDialog.fillFlowDialogParams(result);
554
+ resolve(result);
555
+ });
556
+ });
557
+ }
558
+
559
+ /**
560
+ * 初始化流程信息
561
+ */
562
+ getFlowInfo(){
563
+ this.flowDefine.id = this.flowId;
564
+ return new Promise(resolve => {
565
+ this.$this.FLOW_GLOBAL.getFlowDefineById(this.flowId).then(flowobj => {
566
+ this.flowDefine = flowobj;
567
+ this.$flowDialog.fillFlowDialogParams({
568
+ flowDefine: this.flowDefine
569
+ });
570
+ let tabSetting = JSON.parse(this.flowDefine.tabSetting,"[]");
571
+ (tabSetting || []).forEach(item => {
572
+ if(item.isUse == '1'){
573
+ this.operateType[item.type] = true;
574
+ }
575
+ })
576
+ let activeArr = [];
577
+ Object.keys(this.operateType).forEach(key => {
578
+ if(this.operateType[key] && this.resourceTabOpts.indexOf(key) > -1){
579
+ activeArr.push(key);
580
+ }
581
+ })
582
+ if(activeArr.length > 0 && activeArr.indexOf("pending") == -1){
583
+ this.tabActive = activeArr[0]; // todo 返回tabActive
584
+ }
585
+ // this.showModel = flowobj.showModel;
586
+ // this.showInfo = flowobj.showInfo;
587
+ // let formType = flowobj.formType;
588
+ //工作流节点
589
+ this.startNodeKey = "Activity_draft";
590
+ this.startNodeKeyObj = {};
591
+ // let flowVersion = this.flowDefine.flowVersion || '1.0';
592
+ this.$this.FLOW_GLOBAL.getFlowNodesByFlowId(this.flowId).then(nodeDatas => {
593
+ if (nodeDatas) {
594
+ nodeDatas.forEach(item => {
595
+ if (item.nodeLinkId.indexOf("Activity_draft") > -1) {
596
+ this.startNodeKey = item.nodeLinkId;
597
+ this.startNodeKeyObj[item.version] = item.nodeLinkId; //开始节点对应版本号
598
+ }
599
+ if(!this.flowVersionNodeObj[item.version]){
600
+ this.$this.$set(this.flowVersionNodeObj,item.version,{});
601
+ }
602
+ this.$this.$set(this.flowVersionNodeObj[item.version],item.nodeLinkId,item); //版本节点对象
603
+ // if(item.version == this.flowDefine.releaseVersion){ //节点信息只取最新版本
604
+ this.flowNodeIdToInfo[item.id] = item;
605
+ if(item.nodeType&&['StartEvent','ParallelGateway','SequenceFlow','ExclusiveGateway','InclusiveGateway'].indexOf(item.nodeType) == -1){
606
+ if(!this.flowNodeNameObj[item.nodeLinkId]){
607
+ this.$this.$set(this.flowNodeNameObj,item.nodeLinkId,item.nodeName);
608
+ }else {
609
+ if(this.flowNodeNameObj[item.nodeLinkId] != item.nodeName){
610
+ this.flowNodeNameObj[item.nodeLinkId] = this.flowNodeNameObj[item.nodeLinkId] + "," + item.nodeName;
611
+ }
612
+ }
613
+ }
614
+ if(item.nodeType == "UserTask" && (item.nodeLinkId || "").indexOf("Activity_draft") > -1){
615
+ this.draftNodeId = item.id; // 草稿节点id
616
+ this.$flowDialog.fillFlowDialogParams({
617
+ draftNodeId: this.draftNodeId
618
+ });
619
+ }
620
+ // }
621
+ this.allNodeInfo[item.id] = item;
622
+ // 行按钮
623
+ let listButton = JSON.parse(item.listButton || "[]") || [];
624
+ listButton = listButton.filter(item => !item.buttonId);
625
+ listButton.forEach(button => {
626
+ button.showName = button.showName ? button.showName : this.listButtonObj[button.type];
627
+ });
628
+ this.nodeListButtonObj[item.id] = listButton;
629
+
630
+ // 表单按钮
631
+ let formButton = JSON.parse(item.formButton || "[]") || [];
632
+ formButton = formButton.filter(item => !item.buttonId);
633
+ formButton.forEach(button => {
634
+ button.showName = button.showName ? button.showName : this.formButtonObj[button.type];
635
+ });
636
+
637
+ this.nodeFormButtonObj[item.id] = this.sortButtonArr(formButton);
638
+ this.nodeFormBtnObj[item.id] = this.formatterFormButton(formButton);
639
+
640
+ // 自定义按钮
641
+ if(item.plFlowButtons) {
642
+ (item.plFlowButtons || []).forEach(button => {
643
+ this.diyButtonsObj[button.id] = button;
644
+ })
645
+ }
646
+
647
+ let width = 0;
648
+ (this.nodeListButtonObj[item.id] || []).forEach(item => {
649
+ let nameLength = item.showName.length;
650
+ if (nameLength > 2) {
651
+ width += 100 + (nameLength - 2) * 12;
652
+ } else {
653
+ width += 100;
654
+ }
655
+ });
656
+ if (this.optColumnWidth < width) {
657
+ this.optColumnWidth = width;
658
+ }
659
+ });
660
+
661
+ // 显示
662
+ // this.isShowAgentSet = true;
663
+ // this.$forceUpdate();
664
+ }
665
+ // 加载工作流脚本与工作流事件规则
666
+ this.initFlowScript().then(() => {
667
+ let result = {
668
+ operateType : this.operateType,
669
+ tabActive : this.tabActive,
670
+ flowDefine : this.flowDefine,
671
+ startNodeKey : this.startNodeKey,
672
+ startNodeKeyObj : this.startNodeKeyObj,
673
+ flowVersionNodeObj : this.flowVersionNodeObj,
674
+ allNodeInfo : this.allNodeInfo,
675
+ flowNodeNameObj : this.flowNodeNameObj,
676
+ flowNodeIdToInfo : this.flowNodeIdToInfo,
677
+ nodeListButtonObj : this.nodeListButtonObj,
678
+ nodeFormButtonObj : this.nodeFormButtonObj,
679
+ nodeFormBtnObj : this.nodeFormBtnObj,
680
+ optColumnWidth : this.optColumnWidth,
681
+ diyButtonsObj : this.diyButtonsObj,
682
+ };
683
+ this.initFlowObj();
684
+ this.$flowDialog.fillFlowDialogParams(result);
685
+ resolve(result);
686
+ })
687
+ });
688
+ });
689
+ });
690
+ }
691
+
692
+ initFlowObj() {//处理流程定义对象
693
+ this.isRefreshGetNextUsers = [];
694
+ let gatewayFields = this.flowDefine.gatewayFields || "";
695
+ this.isRefreshGetNextUsers = gatewayFields.split(",");
696
+ Object.keys(this.allNodeInfo).forEach(key => {
697
+ let obj = this.allNodeInfo[key];
698
+ if (obj.nodeType === "UserTask" && (!obj.nodeLinkId || obj.nodeLinkId.indexOf('Activity_draft') === -1)) {
699
+ if (obj.dealerType === "form" && obj.formField) {
700
+ this.isRefreshGetNextUsers.push(obj.formField);
701
+ }
702
+ if (obj.dealerType === "variable" && obj.variable) {
703
+ this.isRefreshGetNextUsers.push(obj.variable);
704
+ }
705
+ if (obj.dealerType === "interface" && obj.dealerUrlParam) {
706
+ let dealerUrlParam = JSON.parse(obj.dealerUrlParam || "[]");
707
+ dealerUrlParam.forEach(param => {
708
+ if (param.paramType === "variable") {
709
+ this.isRefreshGetNextUsers.push(param.paramVal);
710
+ }
711
+ })
712
+ }
713
+ }
714
+ });
715
+ let tabTypeObj= {};
716
+ if (!this.flowId.includes(",")) {
717
+ let tabSetting = JSON.parse(this.flowDefine.tabSetting);
718
+ tabSetting.forEach(data => {
719
+ this.$this.$set(tabTypeObj, data.type, data);
720
+ });
721
+ Object.keys(tabTypeObj).forEach(key => {
722
+ let objTemp = tabTypeObj[key];
723
+ objTemp.tabName = objTemp["showName"] || objTemp["name"];
724
+ });
725
+ let tabTitleType = this.flowDefine.tabTitleType;
726
+ if (tabTitleType === "1") {
727
+ tabTypeObj["showtTabText"] = true;
728
+ tabTypeObj["showTabIcon"] = true;
729
+ } else if (tabTitleType === "2") {
730
+ tabTypeObj["showtTabText"] = true;
731
+ } else if (tabTitleType === "3") {
732
+ tabTypeObj["showTabIcon"] = true;
733
+ }
734
+ }
735
+
736
+ let result = {
737
+ isRefreshGetNextUsers : this.isRefreshGetNextUsers,
738
+ tabTypeObj: tabTypeObj
739
+ }
740
+ this.setFlowTabInfo && this.setFlowTabInfo(result);
741
+ }
742
+
743
+ // 初始化流程信息end
744
+
745
+ /**
746
+ * 下一步,保存数据以及获取处理人
747
+ */
748
+ nextStep() {
749
+ let afterClickResult;
750
+ let result;
751
+ let currentNodeObj = this.flowNodeIdToInfo[this.currentInst.currentNode || this.draftNodeId] ||{};
752
+ afterClickResult=this.exeFlowEvent("nextStep","afterClick", this.currentInst.currentNode || this.draftNodeId);
753
+
754
+ if(typeof afterClickResult == "boolean" && afterClickResult === false){
755
+ return;
756
+ }
757
+
758
+ if(currentNodeObj.openEvent === '1'){
759
+ afterClickResult = this.exeNewFlowEvent("nextClick",currentNodeObj.nodeLinkId);
760
+ }
761
+
762
+ if(typeof afterClickResult == "boolean" && afterClickResult === false){
763
+ return;
764
+ }
765
+
766
+ // let afterValidateResult;
767
+ // let currentNodeObj = this.flowNodeIdToInfo[this.currentInst.currentNode || this.draftNodeId] ||{};
768
+ result = this.exeFlowEvent("nextStep","afterValidate", this.currentInst.currentNode || this.draftNodeId);
769
+ if(typeof result == "boolean" && result === false){
770
+ return;
771
+ }
772
+ if(currentNodeObj.openEvent === '1'){
773
+ result = this.exeNewFlowEvent("nextCheck",currentNodeObj.nodeLinkId);
774
+ if(typeof result == "boolean" && result === false){
775
+ return;
776
+ }
777
+ }
778
+
779
+ this.isDisabled['nextStep'] = false;
780
+ this.$flowDialog.fillFlowDialogParams({
781
+ flowParams: this.flowParams,
782
+ isDisabled: this.isDisabled
783
+ });
784
+ this.saveDataFunc('nextStep').then(flowParams => {
785
+ this.flowParams = JSON.parse(JSON.stringify(flowParams));
786
+ this.setParams && this.setParams({
787
+ flowParams:this.flowParams
788
+ });
789
+ let instId = flowParams.flowInstId;
790
+ this.$this.$set(this.formInfo,"opt","update");
791
+ this.currentInst.id = instId;
792
+ this.description = "";
793
+ this.saveInstId = instId;
794
+ this.nowNode = this.allNodeInfo[currentNodeObj.id] || {};
795
+ this.nextStepAfterSaveFunc().then(resultEvt => {
796
+ if(!resultEvt){
797
+ this.isDisabled['nextStep'] = true;
798
+ this.$flowDialog.fillFlowDialogParams({
799
+ isDisabled: this.isDisabled
800
+ });
801
+ return;
802
+ }
803
+ this.isProceedNext = true;
804
+ //获取处理人
805
+ let obj = {instId: instId, taskId: this.currentInst.taskId,};
806
+ if(this.nowNode && this.nowNode.dealType && this.nowNode.dealType == 'multi'){
807
+ this.$this.$set(obj,'passCondition',this.nowNode.passCondition)
808
+ }
809
+ let params = {"SASP_FLOW_USE_VARIABLES":"yes"};
810
+ // Object.assign(params,flowParams || {},obj);
811
+ Object.assign(params,obj);
812
+ let allParamKeys = Object.keys(flowParams || {});
813
+ allParamKeys.forEach(templateKey => {
814
+ if(this.isRefreshGetNextUsers.indexOf(templateKey) > -1){
815
+ params[templateKey] = flowParams[templateKey];
816
+ if(allParamKeys.indexOf(templateKey + "_SASP_SYS_DATA") > -1){
817
+ params[templateKey + "_SASP_SYS_DATA"] = flowParams[templateKey + "_SASP_SYS_DATA"];
818
+ }
819
+ if(allParamKeys.indexOf(templateKey + "_SASP_SYS_DATA_ID") > -1){
820
+ params[templateKey + "_SASP_SYS_DATA_ID"] = flowParams[templateKey + "_SASP_SYS_DATA_ID"];
821
+ }
822
+ }
823
+ });
824
+ this.$flowDialog.fillFlowDialogParams({
825
+ flowParams: this.flowParams,
826
+ formInfo: this.formInfo,
827
+ currentInst: this.currentInst,
828
+ description: this.description,
829
+ saveInstId: this.saveInstId,
830
+ nowNode: this.nowNode,
831
+ isProceedNext: this.isProceedNext,
832
+ });
833
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.getNextUsers, params).then(res => {
834
+ if(!res.data.operateSuccess){
835
+ this.isDisabled['nextStep'] = true;
836
+ if(res.data.resultObject === 'requestException'){
837
+ this.$this.$message.error(res.data.errorInfo);
838
+ }else{
839
+ this.$this.$message.error("未获取到处理人");
840
+ }
841
+ return;
842
+ }
843
+ let obj = {};
844
+ if (res && res.data) {
845
+ obj = res.data.operateObj || {};
846
+ if(res.data.operateMap && res.data.operateMap.isPassCondition == 0){
847
+ this.isProceedNext = false;
848
+ this.$flowDialog.fillFlowDialogParams({
849
+ isProceedNext: this.isProceedNext,
850
+ });
851
+ }
852
+ }
853
+ this.nextNodeName = "";
854
+ this.choosePosUserIds = "";
855
+ this.choosePosUserIdsObj = {};
856
+ this.nextNode = obj;
857
+ this.chooseNextUserIdObj = {};
858
+ this.chooseNextUserNameObj = {};
859
+ this.chooseNextUserId = "";
860
+ this.chooseNextUserName = "";
861
+ let paramKeyArr = ["nextNodeName","choosePosUserIds","choosePosUserIdsObj","nextNode",
862
+ "chooseNextUserIdObj","chooseNextUserNameObj","chooseNextUserId","chooseNextUserName",
863
+ "nextSteptUserArr","nextSteptUserType"];
864
+ let params = {};
865
+ paramKeyArr.forEach(key => {
866
+ params[key] = this[key];
867
+ })
868
+ this.$flowDialog.fillFlowDialogParams(params);
869
+ if (obj.nextType == "inclusiveGateway") {
870
+ let autoChooseUser = false;
871
+ (obj.result || []).forEach(item => {
872
+ //获取下一个节点信息
873
+ let nextNodeTmp = this.flowNodeIdToInfo[item.nextNodeId] || {};
874
+ if (nextNodeTmp.nodeType == "UserTask") {
875
+ item.mulitiChooseUser = nextNodeTmp.dealType != "single";
876
+ autoChooseUser = nextNodeTmp.autoChooseUser == "1";
877
+ if (item.mulitiChooseUser) {
878
+ this.$this.$set(this.chooseNextUserIdObj, item.nodeKey, []);
879
+ } else {
880
+ this.$this.$set(this.chooseNextUserIdObj, item.nodeKey, "");
881
+ }
882
+ } else if (this.nextNode.nodeType == "EndEvent") {
883
+ return;
884
+ }
885
+ let userArr = item.userArr || [];
886
+ //自动执行时的自动执行人
887
+ if (autoChooseUser) {
888
+ if (item.type == "user" && userArr.length == 0) {
889
+ // this.$this.$message({type:"error",message:"没有处理人!"});
890
+ return;
891
+ } else {
892
+ let userIds = "";
893
+ let userNames = "";
894
+ userArr.forEach(userInfo => {
895
+ userIds += "," + userInfo.id;
896
+ userNames += "," + userInfo.userName;
897
+ });
898
+ this.chooseNextUserIdObj[item.nodeKey] = userIds.substring(1);
899
+ this.chooseNextUserId = userIds.substring(1);
900
+ this.chooseNextUserName = userNames.substring(1);
901
+ this.$flowDialog.fillFlowDialogParams({
902
+ chooseNextUserId: this.chooseNextUserId,
903
+ chooseNextUserName: this.chooseNextUserName,
904
+ chooseNextUserIdObj: this.chooseNextUserIdObj
905
+ });
906
+ this.$flowDialog.saveNextStept();
907
+ }
908
+ }
909
+ item.nextSteptUserType = obj.type;
910
+ if (item.type == "user" || item.type== 'all') {
911
+ item.nextSteptUserArr = userArr;
912
+ }
913
+ });
914
+ if(!autoChooseUser){
915
+ this.nextSteptUserDialog = true;
916
+ this.$flowDialog.operateDialog('nextSteptUserDialog',true);
917
+ }
918
+ } else {
919
+ //获取下一个节点信息
920
+ this.nextNode = this.allNodeInfo[obj.nextNodeId] || {};
921
+ this.nextNodeName = obj.nextNodeName || "";
922
+ let autoChooseUser = false;
923
+ this.$flowDialog.fillFlowDialogParams({
924
+ nextNode: this.nextNode,
925
+ nextNodeName: this.nextNodeName
926
+ });
927
+ if (this.nextNode.nodeType == "UserTask") {
928
+ this.mulitiChooseUser = this.nextNode.dealType != "single";
929
+ autoChooseUser = this.nextNode.autoChooseUser == "1";
930
+ this.chooseNextUserId = "";
931
+ this.chooseNextUserName = "";
932
+ this.$flowDialog.fillFlowDialogParams({
933
+ mulitiChooseUser: this.mulitiChooseUser,
934
+ chooseNextUserId: this.chooseNextUserId,
935
+ chooseNextUserName: this.chooseNextUserName
936
+ });
937
+ } else if (this.nextNode.nodeType == "EndEvent") {
938
+ if(window.skipFlowEnd && window.skipFlowEnd.includes(this.flowId)){
939
+ this.$flowDialog.saveNextStept();
940
+ return;
941
+ }
942
+ this.nextSteptUserDialog = true;
943
+ this.$flowDialog.operateDialog('nextSteptUserDialog',true);
944
+ return;
945
+ }
946
+ let userArr = obj.userArr || [];
947
+ //自动执行时的自动执行人
948
+ if (autoChooseUser) {
949
+ if (obj.type == "user" && userArr.length == 0) {
950
+ this.$this.$message({type: "error", message: "没有处理人!"});
951
+ return;
952
+ } else {
953
+ let userIds = "";
954
+ let userNames = "";
955
+ userArr.forEach(userInfo => {
956
+ userIds += "," + userInfo.id;
957
+ userNames += "," + userInfo.userName;
958
+ });
959
+ if (userIds) {
960
+ this.chooseNextUserId = userIds.substring(1);
961
+ this.chooseNextUserName = userNames.substring(1);
962
+ }
963
+ this.$flowDialog.fillFlowDialogParams({
964
+ chooseNextUserId: this.chooseNextUserId,
965
+ chooseNextUserName: this.chooseNextUserName
966
+ });
967
+ this.$flowDialog.saveNextStept();
968
+ }
969
+ }
970
+ this.nextSteptUserType = obj.type;
971
+ if (obj.type == "user" || obj.type == 'all') {
972
+ this.nextSteptUserArr = userArr;
973
+ }
974
+ this.$flowDialog.fillFlowDialogParams({
975
+ nextSteptUserType: this.nextSteptUserType,
976
+ nextSteptUserArr: this.nextSteptUserArr
977
+ });
978
+ if(!autoChooseUser){
979
+ this.nextSteptUserDialog = true;
980
+ this.$flowDialog.operateDialog('nextSteptUserDialog',true);
981
+ }
982
+ }
983
+ if(this.nextNode.nextType == 'inclusiveGateway'){
984
+ (this.nextNode.result || []).forEach(item => {
985
+ this.chooseNextUserIdObj[item.nodeKey] = (item.userArr || {}).id;
986
+ });
987
+ this.$flowDialog.fillFlowDialogParams({
988
+ chooseNextUserIdObj: this.chooseNextUserIdObj,
989
+ });
990
+ }else{
991
+ let userInfo = this.nextSteptUserArr[0] || {};
992
+ if(this.nextNode.dealType=="single"){
993
+ this.chooseNextUserId = userInfo.id;
994
+ this.chooseNextUserName = userInfo.userName;
995
+ this.$flowDialog.fillFlowDialogParams({
996
+ chooseNextUserId: this.chooseNextUserId,
997
+ chooseNextUserName: this.chooseNextUserName
998
+ });
999
+ }
1000
+ if(this.nextNode.dealType === "multi" && this.nextSteptUserArr.length === 1){
1001
+ this.chooseNextUserId = [userInfo.id];
1002
+ this.$flowDialog.fillFlowDialogParams({
1003
+ chooseNextUserId: this.chooseNextUserId
1004
+ });
1005
+ }
1006
+ }
1007
+ });
1008
+ })
1009
+ });
1010
+ }
1011
+
1012
+ nextStepAfterSaveFunc(){
1013
+ return new Promise(resolve => {
1014
+ if(this.nextStepAfterSave){
1015
+ let result = this.nextStepAfterSave(this.$this,this);
1016
+ if(result && (result instanceof Promise)){
1017
+ result.then(res => {
1018
+ resolve(res);
1019
+ })
1020
+ }else{
1021
+ resolve(result);
1022
+ }
1023
+ }else{
1024
+ resolve(true);
1025
+ }
1026
+ })
1027
+ }
1028
+
1029
+ saveDataFunc(type){ // 保存完成后返回流程的相关变量,通过变量传递到后台驱动流程运转
1030
+ // 保存草稿、下一步保存
1031
+ return new Promise(resolve => {
1032
+ if(this.saveFormInfo){
1033
+ let result = this.saveFormInfo(type);
1034
+ if(result && (result instanceof Promise)){
1035
+ result.then(res => {
1036
+ if(!res){
1037
+ this.isDisabled['nextStep'] = true;
1038
+ return;
1039
+ }
1040
+ if(typeof res !== 'object'){
1041
+ res = {};
1042
+ }
1043
+ this.saveFlowData(res).then(flowInstData => {
1044
+ res['flowInstId'] = flowInstData.id;
1045
+ resolve(res);
1046
+ })
1047
+ })
1048
+ }else{
1049
+ if(!result){
1050
+ return;
1051
+ }
1052
+ if(typeof result !== 'object'){
1053
+ result = {};
1054
+ }
1055
+ this.saveFlowData(result).then(flowInstData => {
1056
+ result['flowInstId'] = flowInstData.id;
1057
+ resolve(result);
1058
+ })
1059
+ }
1060
+ }else{
1061
+ this.saveFlowData().then(flowInstData => {
1062
+ let obj = {};
1063
+ obj['flowInstId'] = flowInstData.id;
1064
+ resolve(obj);
1065
+ })
1066
+ }
1067
+ })
1068
+ }
1069
+
1070
+ saveFlowData(flowParams){
1071
+ return new Promise(resolve => {
1072
+ flowParams = flowParams || {};
1073
+ let flowSummary = this.getFlowSummary(flowParams);
1074
+ let flowInst = {};
1075
+ let dataId = (flowParams || {}).flowDataId || "";
1076
+ this.dataId = dataId;
1077
+ if(this.currentInst && this.currentInst.id){
1078
+ this.$this.$set(this.formInfo,"opt","update");
1079
+ flowInst = {
1080
+ "id": this.currentInst.id,
1081
+ "flowSummary": flowSummary,
1082
+ "updated": this.loginUser.id,
1083
+ };
1084
+ if(this.formInfo.opt == 'add' || !this.currentInst.linkProcId){ //版本号也要随之更新
1085
+ flowInst = Object.assign(flowInst,{"version":this.flowDefine.releaseVersion,"isRelease":this.flowDefine.isRelease})
1086
+ }
1087
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.url + "/" + this.formInfo.opt, flowInst).then(instRes => {
1088
+ this.runFlowEvt();
1089
+ resolve(instRes.data.operateObj);
1090
+ });
1091
+ }else{
1092
+ let startNodeKey = this.startNodeKeyObj[this.flowDefine.releaseVersion];
1093
+ if (this.formInfo.opt == "add") {
1094
+ flowInst = {
1095
+ flowId: this.flowDefine.id,
1096
+ flowSummary: flowSummary,
1097
+ dataId: dataId,
1098
+ version:this.flowDefine.releaseVersion, //版本号
1099
+ startTime: this.$this.DATE_UTIL.getCurrentDateTime(), flowStatus: "0",
1100
+ created: this.loginUser.id,
1101
+ currentNode: this.flowVersionNodeObj[this.flowDefine.releaseVersion][startNodeKey].id,
1102
+ isRelease:this.flowDefine.isRelease
1103
+ };
1104
+ } else {
1105
+ flowInst = {
1106
+ id: this.currentInst.id,
1107
+ flowSummary: flowSummary,
1108
+ version:this.flowDefine.releaseVersion, //版本号也要随之更新
1109
+ updated: this.loginUser.id,
1110
+ };
1111
+ }
1112
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.url + "/" + this.formInfo.opt, flowInst).then(instRes => {
1113
+ this.runFlowEvt();
1114
+ resolve(instRes.data.operateObj);
1115
+ this.currentInst=instRes.data.operateObj;
1116
+ });
1117
+ }
1118
+ })
1119
+ }
1120
+
1121
+ /**
1122
+ * 获取流程概要
1123
+ */
1124
+ getFlowSummary(dataObj, summaryTemplate) {
1125
+ let flowSummary = "";
1126
+ let summarySet = summaryTemplate || this.flowDefine.flowSummary;
1127
+ if (!this.currentInst.linkProcId) { // 草稿数据
1128
+ flowSummary = this.$this.platStringUtil.replaceAll(summarySet, "${startUserName*}", this.loginUser.userName);
1129
+ flowSummary = this.$this.platStringUtil.replaceAll(flowSummary, "${createTime*}", this.$this.DATE_UTIL.getCurrentDateTime());
1130
+ } else {
1131
+ flowSummary = this.$this.platStringUtil.replaceAll(summarySet, "${startUserName*}", this.currentStartUser);
1132
+ flowSummary = this.$this.platStringUtil.replaceAll(flowSummary, "${createTime*}", this.currentStartTime);
1133
+ }
1134
+ flowSummary = this.$this.platStringUtil.replaceAll(flowSummary, "${flowName*}", this.flowDefine.flowName);
1135
+ if (this.flowDefine.summaryNameId) {
1136
+ // flowSummary = flowSummary.toUpperCase();
1137
+ let summaryNameId = JSON.parse(this.flowDefine.summaryNameId);
1138
+ Object.keys(summaryNameId).forEach(fieldName => {
1139
+ let fieldId = summaryNameId[fieldName];
1140
+ if (fieldName && dataObj.hasOwnProperty(fieldId)) {
1141
+ let replaceVal = dataObj[fieldId];
1142
+ if(dataObj[fieldId + "_SASP_SYS_DATA"]){
1143
+ replaceVal = dataObj[fieldId+ "_SASP_SYS_DATA"];
1144
+ }
1145
+ if(dataObj[fieldId + "_sequence"]){ // 自增序列
1146
+ replaceVal = dataObj[fieldId + "_sequence"];
1147
+ }
1148
+ flowSummary = this.$this.platStringUtil.replaceAll(flowSummary, "${" + fieldName + "}", replaceVal);
1149
+ }else if(fieldName && dataObj.hasOwnProperty(fieldName)){
1150
+ let replaceVal = dataObj[fieldName];
1151
+ if(dataObj[fieldName + "_SASP_SYS_DATA"]){
1152
+ replaceVal = dataObj[fieldName+ "_SASP_SYS_DATA"];
1153
+ }
1154
+ if(dataObj[fieldName + "_sequence"]){ // 自增序列
1155
+ replaceVal = dataObj[fieldName + "_sequence"];
1156
+ }
1157
+ flowSummary = this.$this.platStringUtil.replaceAll(flowSummary, "${" + fieldName + "}", replaceVal);
1158
+ }else{
1159
+ flowSummary = this.$this.platStringUtil.replaceAll(flowSummary, "${" + fieldName + "}", "");
1160
+ }
1161
+ });
1162
+ }
1163
+ return flowSummary;
1164
+ }
1165
+
1166
+
1167
+ /**
1168
+ * 加载工作流脚本与工作流事件规则
1169
+ */
1170
+ initFlowScript(flowId){
1171
+ if (flowId) {
1172
+ this.flowDefine = this.flowDefineByFlowId[flowId] || {};
1173
+ }
1174
+ return new Promise(resolve => {
1175
+ this.$this.saspFlowAxios.all([
1176
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowScript.find,{"flowId": this.flowDefine.id}),
1177
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowEventDetail.findByFlowAndLeadFunc,{"flowId": this.flowDefine.id,"version":this.flowDefine.flowVersion || "1.0"})
1178
+ ]).then(this.$this.saspFlowAxios.spread((resScript, resEvent) => {
1179
+ // 流程脚本
1180
+ if(resScript){
1181
+ let scriptDatas = resScript.data || [];
1182
+ // 脚本order排序
1183
+ scriptDatas = scriptDatas.sort(sortScript);
1184
+ function sortScript(a,b){
1185
+ return Number(a.scriptOrder) - Number(b.scriptOrder);
1186
+ }
1187
+ // 根据节点区分
1188
+ let scriptObj = {};
1189
+ let arr = ['vm','axios','CTX','formData','LOGINUSER','Ajax','nextNode','resolve'];
1190
+ scriptDatas.forEach(item => {
1191
+ // 添加修改是单独区分开,没有节点概念
1192
+ if(item.executePosition == "add" || item.executePosition == "update"){
1193
+ if(!scriptObj[item.executePosition]){
1194
+ scriptObj[item.executePosition] = {};
1195
+ }
1196
+ if(!scriptObj[item.executePosition][item.executeTime]){
1197
+ scriptObj[item.executePosition][item.executeTime] = [];
1198
+ }
1199
+ try{
1200
+ if(item.content){
1201
+ let value = item.content;
1202
+ value = this.replaceUrl(value);
1203
+ item.content = value;
1204
+ }
1205
+ scriptObj[item.executePosition][item.executeTime].push(new Function(...arr,item.content));
1206
+ }catch (e) {
1207
+ console.log(item.content);
1208
+ console.log("脚本编译失败!");
1209
+ }
1210
+ }else{
1211
+ if(!scriptObj[item.nodeId]){
1212
+ scriptObj[item.nodeId] = {};
1213
+ }
1214
+ let nodeObj = scriptObj[item.nodeId]; // 节点的所有内容
1215
+ if(!nodeObj[item.executePosition]){
1216
+ nodeObj[item.executePosition] = {};
1217
+ }
1218
+ let positionObj = nodeObj[item.executePosition]; // 脚本的执行位置,add,update,deal,等
1219
+ if(!positionObj[item.executeTime]){
1220
+ positionObj[item.executeTime] = [];
1221
+ }
1222
+ let executeTimeArr = positionObj[item.executeTime]; // 在该时间对应的脚本内容数组
1223
+ try{
1224
+ if(item.content){
1225
+ let value = item.content;
1226
+ value = this.replaceUrl(value);
1227
+ item.content = value;
1228
+ }
1229
+ executeTimeArr.push(new Function(...arr,item.content));
1230
+ }catch (e) {
1231
+ console.log(item.content);
1232
+ console.log("脚本编译失败!");
1233
+ }
1234
+ }
1235
+ })
1236
+ this.scriptObj = scriptObj;
1237
+ }
1238
+ // 流程事件规则
1239
+ if(resEvent){
1240
+ let eventDataArr = resEvent.data || [];
1241
+ let scriptObj = {};
1242
+ let eventObj = {};
1243
+ let arr = ['vm','axios','CTX','formData','LOGINUSER','Ajax','nextNode','resolve'];
1244
+ eventDataArr.forEach(item =>{
1245
+ let executeTypeArr = (item.executeType || '').split(",");
1246
+ executeTypeArr.forEach(executeType =>{
1247
+ if (item.source == 'diy'){
1248
+ //自定义
1249
+ // 添加是单独区分开,没有节点概念
1250
+ if(executeType == "addAfter"){
1251
+ if(!scriptObj[executeType]){
1252
+ scriptObj[executeType] = [];
1253
+ }
1254
+ try{
1255
+ if(item.funcBody){ //方法体
1256
+ let value = item.funcBody;
1257
+ value = this.replaceUrl(value);
1258
+ item.funcBody = value;
1259
+ }
1260
+ scriptObj[executeType].push(new Function(...arr,item.funcBody));
1261
+ }catch (e) {
1262
+ console.log(item.funcBody);
1263
+ console.log("脚本编译失败!");
1264
+ }
1265
+ }else{
1266
+ if(!scriptObj[item.nodeKey]){
1267
+ scriptObj[item.nodeKey] = {};
1268
+ }
1269
+ let nodeObj = scriptObj[item.nodeKey]; // 节点的所有内容
1270
+ if(!nodeObj[executeType]){
1271
+ nodeObj[executeType] = [];
1272
+ }
1273
+ let positionArr = nodeObj[executeType]; // 脚本的执行位置,add,update,deal,等
1274
+ try{
1275
+ if(item.funcBody){
1276
+ let value = item.funcBody;
1277
+ value = this.replaceUrl(value);
1278
+ item.funcBody = value;
1279
+ }
1280
+ positionArr.push(new Function(...arr,item.funcBody));
1281
+ }catch (e) {
1282
+ console.log(item.funcBody);
1283
+ console.log("脚本编译失败!");
1284
+ }
1285
+ }
1286
+ this.newScriptObj = scriptObj;
1287
+ }else if(item.source == 'event'){ //事件规则
1288
+ //获取响应配置
1289
+ // 添加单独区分开,没有节点概念
1290
+ if(executeType == "addAfter"){
1291
+ if(!eventObj[executeType]){
1292
+ eventObj[executeType] = {};
1293
+ }
1294
+ try{
1295
+ if(item.resConfigurateion){ //响应配置
1296
+ let resConfigurateionObj = JSON.parse(item.resConfigurateion || "{}");
1297
+ let eventKey = resConfigurateionObj.eventKey;
1298
+ if(!eventObj[executeType][eventKey]){
1299
+ eventObj[executeType][eventKey] = [];
1300
+ }
1301
+ eventObj[executeType][eventKey].push(resConfigurateionObj); //复制响应配置
1302
+ }
1303
+ }catch (e) {
1304
+ console.log(item.funcBody);
1305
+ console.log("脚本编译失败!");
1306
+ }
1307
+ }else{
1308
+ if(!eventObj[item.nodeKey]){
1309
+ eventObj[item.nodeKey] = {};
1310
+ }
1311
+ let nodeObj = eventObj[item.nodeKey]; // 节点的所有内容
1312
+ if(!nodeObj[executeType]){
1313
+ nodeObj[executeType] = {};
1314
+ }
1315
+ let positionObj = nodeObj[executeType]; // 脚本的执行位置,add,update,deal,等
1316
+ try{
1317
+ if(item.resConfigurateion){//响应配置
1318
+ let resConfigurateionObj = JSON.parse(item.resConfigurateion || "{}");
1319
+ let eventKey = resConfigurateionObj.eventKey;
1320
+ if(!positionObj[eventKey]){
1321
+ positionObj[eventKey] = [];
1322
+ }
1323
+ positionObj[eventKey].push(resConfigurateionObj); //复制响应配\
1324
+ }
1325
+ }catch (e) {
1326
+ console.log(item.funcBody);
1327
+ console.log("脚本编译失败!");
1328
+ }
1329
+ }
1330
+ this.newEventObj = eventObj;
1331
+ }
1332
+ });
1333
+ });
1334
+ }
1335
+ // 结束
1336
+ let obj = {"scriptObj": this.scriptObj, "newScriptObj": this.newScriptObj, "newEventObj": this.newEventObj};
1337
+ resolve({[flowId]: obj});
1338
+ }));
1339
+ })
1340
+ }
1341
+
1342
+ /**
1343
+ * 执行下一步
1344
+ * @returns {Promise<boolean>} 是否继续流程
1345
+ */
1346
+ async executeNextStep() {
1347
+
1348
+ }
1349
+
1350
+ /**
1351
+ * 取消当前流程
1352
+ */
1353
+ cancel() {
1354
+
1355
+ }
1356
+
1357
+ // 脚本执行区
1358
+
1359
+ setFlowScript(flowId) {
1360
+ if (flowId) {
1361
+ let scriptObj = this.flowEventScriptByFlowId[flowId] || {};
1362
+ this.scriptObj = scriptObj.scriptObj || {};
1363
+ this.newScriptObj = scriptObj.newScriptObj || {};
1364
+ this.newEventObj = scriptObj.newEventObj || {};
1365
+ }
1366
+ }
1367
+
1368
+ runFlowEvt(){
1369
+ // let afterClickResult;
1370
+ let currentNodeObj = this.flowNodeIdToInfo[this.currentInst.currentNode || this.draftNodeId] ||{};
1371
+ if(currentNodeObj.openEvent == '1'){
1372
+ this.exeNewFlowEvent("saveAfter", currentNodeObj.nodeLinkId);
1373
+ }
1374
+ }
1375
+
1376
+ /**
1377
+ * 执行工作流脚本,为兼容1.0版本定制
1378
+ */
1379
+ exeFlowEvent(executePosition,executeTime,nodeId){
1380
+ // executePosition(为方便1.0转换,与1.0保持相同):add/update/handle/nextStep/view/columnFormatter
1381
+ // executePosition:add:['afterClick'],update:['afterClick'],handle:['afterClick'],
1382
+ // nextStep:['afterClick','afterValidate','submitSuccess'],view:['afterClick'],
1383
+ // (columnFormatter:['finished','end']?暂时不用)
1384
+ let formData = {};
1385
+ if(this.getFormInfo){
1386
+ formData = this.getFormInfo();
1387
+ }
1388
+ let CTX = "";
1389
+ let paramValues = [this.$this,this.$this.saspFlowAxios,CTX,formData,this.loginUser,AjaxUtil,this.nextNode,null]; // 入参
1390
+ if(executePosition == "add" || executePosition == "update"){
1391
+ ((this.scriptObj[executePosition] || {})[executeTime] || []).forEach(event => {
1392
+ event && event(...paramValues); // 执行事件
1393
+ });
1394
+ return;
1395
+ }
1396
+ let eventArr = ((this.scriptObj[nodeId] || {})[executePosition] || {})[executeTime] || [];
1397
+ let result=true;
1398
+ try{
1399
+ eventArr.forEach(event => {
1400
+ let eventResult=event && event(...paramValues); // 执行事件
1401
+ if(eventResult ==false){
1402
+ throw new Error("ending");//报错,就跳出循环
1403
+ }
1404
+ })
1405
+ }catch (e) {
1406
+ console.log(e);
1407
+ result=false;
1408
+ }
1409
+ return result;
1410
+ }
1411
+
1412
+ /**
1413
+ * 执行工作流新版本事件规则
1414
+ */
1415
+ exeNewFlowEvent(executeType,nodeKey){
1416
+ let formData = {};
1417
+ if(this.getFormInfo){
1418
+ formData = this.getFormInfo();
1419
+ }
1420
+ //执行自定义脚本
1421
+ // let CTX = window.JAVA_URL;
1422
+ let CTX = "";
1423
+ let paramValues = [this.$this,this.$this.saspFlowAxios,CTX,formData,this.loginUser,AjaxUtil,this.nextNode]; // 入参
1424
+ if(executeType == "addAfter"){ //新增或后
1425
+ (this.newScriptObj[executeType] || []).forEach(event => {
1426
+ event && event(...paramValues); // 执行事件
1427
+ });
1428
+
1429
+ //执行事件规则脚本
1430
+ Object.keys(this.newEventObj[executeType] || {}).forEach(eventKey =>{
1431
+ if(this.installListObj[eventKey]
1432
+ && this.installListObj[eventKey]["config"]
1433
+ && this.installListObj[eventKey]["config"].methods.renderFlowConfig){
1434
+ let affectContentArr = this.newEventObj[executeType][eventKey] || [];
1435
+ affectContentArr.forEach(affectContent =>{
1436
+ this.installListObj[eventKey]["config"].methods.renderFlowConfig(this.$this,this.$this.CTX,this.$this.saspFlowAxios,this.nextNode,formData,affectContent);
1437
+ });
1438
+ }
1439
+ });
1440
+ return;
1441
+ }
1442
+ let eventArr = (this.newScriptObj[nodeKey] || {})[executeType] || [];
1443
+ let result=true;
1444
+ try{
1445
+ eventArr.forEach(event => {
1446
+ let eventResult=event && event(...paramValues); // 执行事件
1447
+ if(eventResult ==false){
1448
+ throw new Error("ending");//报错,就跳出循环
1449
+ }
1450
+ });
1451
+
1452
+ let eventObj = (this.newEventObj[nodeKey] || {})[executeType] || {};
1453
+ Object.keys(eventObj).forEach(eventKey =>{
1454
+ if(this.installListObj[eventKey]
1455
+ && this.installListObj[eventKey]["config"]
1456
+ && this.installListObj[eventKey]["config"].methods.renderFlowConfig){
1457
+ let affectContentArr = eventObj[eventKey] || [];
1458
+ affectContentArr.forEach(affectContent =>{
1459
+ this.installListObj[eventKey]["config"].methods.renderFlowConfig(this.$this,this.$this.CTX,this.$this.saspFlowAxios,this.nextNode,formData,affectContent,executeType);
1460
+ });
1461
+ }
1462
+ });
1463
+ }catch (e) {
1464
+ console.log(e);
1465
+ result=false;
1466
+ }
1467
+
1468
+ return result;
1469
+
1470
+ }
1471
+ // end脚本执行结束
1472
+
1473
+
1474
+ // buttonMethod,按钮方法
1475
+
1476
+ // 打开前方法
1477
+ /**
1478
+ * 打开[添加]窗口
1479
+ */
1480
+ openAddFlowForm() {
1481
+ return new Promise(resolve => {
1482
+ this.init().then(() => {
1483
+ let nowVersion = this.flowDefine.releaseVersion; //只要已发布最小版本为1.0
1484
+ this.currentRowData = {};
1485
+ this.initFieldStatus(this.startNodeKeyObj[nowVersion],nowVersion).then(()=>{
1486
+ this.flowInstDataDialog = true;
1487
+ this.$flowDialog.operateDialog('flowInstDataDialog',true);
1488
+ this.$this.$nextTick(() => {
1489
+ this.initFormInfoFunc('add').then(() => {
1490
+ this.formBtnArr = this.getAddAndUpdateFormBtn({});
1491
+ Object.assign(this.formInfo, {
1492
+ dataId: "",
1493
+ opt: "add"
1494
+ });
1495
+ this.currentInst = {};
1496
+ this.$this.$nextTick(() => {
1497
+ this.exeFlowEvent("add","afterClick");
1498
+ let startNodeKey = this.startNodeKeyObj[nowVersion];
1499
+ let startNodeObj = this.flowVersionNodeObj[nowVersion][startNodeKey] || {};
1500
+ if(startNodeObj.openEvent == '1'){
1501
+ this.exeNewFlowEvent("addAfter");//新事件规则
1502
+ }
1503
+ })
1504
+ let result = {
1505
+ currentRowData: this.currentRowData,
1506
+ formBtnArr: this.formBtnArr,
1507
+ currentInst: this.currentInst,
1508
+ formInfo: this.formInfo
1509
+ };
1510
+ this.$flowDialog.fillFlowDialogParams(result);
1511
+ resolve(result);
1512
+ })
1513
+ });
1514
+ });
1515
+ })
1516
+ });
1517
+ }
1518
+
1519
+ initFormInfoFunc(type,rowData){
1520
+ if(!rowData){
1521
+ rowData = {};
1522
+ }
1523
+ let dataId = rowData.dataId || "";
1524
+ let nodeObjs = this.flowVersionNodeObj[this.flowDefine.releaseVersion];
1525
+ let startNodeKey = this.startNodeKeyObj[rowData.version];
1526
+ let nodeKey = rowData.nodeKey;
1527
+ let currentNode = nodeObjs[nodeKey || startNodeKey];
1528
+ if(type === 'add'){
1529
+ let version = this.flowDefine.releaseVersion;
1530
+ currentNode = this.flowVersionNodeObj[version][this.startNodeKeyObj[version]];
1531
+ }
1532
+ let result = {
1533
+ draftNodeId: this.draftNodeId,
1534
+ // operateType : this.operateType,
1535
+ // tabActive : this.tabActive,
1536
+ flowDefine : this.flowDefine,
1537
+ startNodeKey : this.startNodeKey,
1538
+ startNodeKeyObj : this.startNodeKeyObj,
1539
+ flowVersionNodeObj : this.flowVersionNodeObj,
1540
+ allNodeInfo : this.allNodeInfo,
1541
+ flowNodeNameObj : this.flowNodeNameObj,
1542
+ flowNodeIdToInfo : this.flowNodeIdToInfo,
1543
+ nodeListButtonObj : this.nodeListButtonObj,
1544
+ nodeFormButtonObj : this.nodeFormButtonObj,
1545
+ nodeFormBtnObj : this.nodeFormBtnObj,
1546
+ // optColumnWidth : this.optColumnWidth,
1547
+ diyButtonsObj : this.diyButtonsObj,
1548
+ };
1549
+ this.$flowDialog.fillFlowDialogParams(result);
1550
+ return new Promise(resolve => {
1551
+ if(this.initFormInfo){
1552
+ let promise = this.initFormInfo(type,dataId,JSON.parse(currentNode.fieldOperate || "{}"),rowData);
1553
+ this.forceUpdateComponent && this.forceUpdateComponent();
1554
+ if(promise.then){
1555
+ promise.then(() => {
1556
+ resolve();
1557
+ })
1558
+ }else{
1559
+ resolve();
1560
+ }
1561
+ } else{
1562
+ resolve();
1563
+ }
1564
+ })
1565
+ }
1566
+ /**
1567
+ * 打开[修改和处理]窗口
1568
+ */
1569
+ initUpdateFlowForm(row, type) {
1570
+ this.currentRowData = row;
1571
+ this.currNodeName = 'noEnd';
1572
+ if (this.flowId.includes(',')) {
1573
+ this.flowDefine = this.flowDefineByFlowId[row.flowId];
1574
+ this.startNodeKeyObj = this.startNodeKeyObjByFlowId[row.flowId];
1575
+ this.flowVersionNodeObj = this.flowVersionNodeObjByFlowId[row.flowId];
1576
+ this.initFlowObj();
1577
+ // 加载工作流脚本与工作流事件规则
1578
+ // this.initFlowScript();
1579
+ // Object.assign(this.formInfo, this.formInfoByFlowId[row.flowId]);
1580
+ }
1581
+
1582
+ return new Promise(resolve => {
1583
+ let startNodeKey = this.startNodeKeyObj[row.version];
1584
+ this.initFieldStatus(row.nodeKey || startNodeKey,row.version).then(()=>{
1585
+ this.initFormInfoFunc(type,row).then(() => {
1586
+ this.currentStartUser = this.userMap[row.startUserId] || "";
1587
+ this.currentStartTime = row.startTime;
1588
+ this.currentInst = row;
1589
+
1590
+ Object.assign(this.formInfo, {
1591
+ dataId: row.dataId,
1592
+ opt: "update"
1593
+ });
1594
+ this.formBtnArr = this.getAddAndUpdateFormBtn(row);
1595
+ let result = {
1596
+ currentRowData: this.currentRowData,
1597
+ currNodeName : this.currNodeName,
1598
+ flowDefine: this.flowDefine,
1599
+ startNodeKeyObj: this.startNodeKeyObj,
1600
+ flowVersionNodeObj: this.flowVersionNodeObj,
1601
+ currentStartUser : this.currentStartUser,
1602
+ currentStartTime : this.currentStartTime,
1603
+ currentInst : this.currentInst,
1604
+ formInfo : this.formInfo,
1605
+ formBtnArr : this.formBtnArr,
1606
+ dataId : row.dataId
1607
+ }
1608
+ resolve(result);
1609
+ });
1610
+ })
1611
+ })
1612
+ }
1613
+
1614
+ /**
1615
+ * 打开[修改和处理]窗口
1616
+ */
1617
+ openUpdateFlowForm(row,executePosition) {
1618
+ return new Promise(resolve => {
1619
+ this.init().then(() => {
1620
+ if (this.flowId.includes(",")) {
1621
+ this.setFlowScript(row.flowId);
1622
+ }
1623
+ this.currentRowData = row;
1624
+ this.currNodeName = 'noEnd';
1625
+ let currentNodeObj1 = this.flowNodeIdToInfo[row.currentNode] ||{};
1626
+ let result = this.exeNewFlowEvent("editBefore",currentNodeObj1.nodeLinkId ||'');//新事件规则
1627
+ if(result === false && typeof result == "boolean"){
1628
+ return;
1629
+ }
1630
+ this.flowInstDataDialog = true;
1631
+ this.$flowDialog.fillFlowDialogParams({
1632
+ flowDefine: this.flowDefine,
1633
+ formInfo: this.formInfo
1634
+ });
1635
+ this.$flowDialog.operateDialog('flowInstDataDialog',true);
1636
+ this.initUpdateFlowForm(row, 'update').then(() =>{
1637
+ this.$this.$nextTick(() => {
1638
+ this.exeFlowEvent(executePosition,"afterClick",row.currentNode);
1639
+ let currentNodeObj = this.flowNodeIdToInfo[row.currentNode] ||{};
1640
+ if(currentNodeObj.openEvent === '1'){ //开启事件
1641
+ this.exeNewFlowEvent("editAfter",currentNodeObj.nodeLinkId ||'');//新事件规则
1642
+ }
1643
+ let result = {
1644
+ currentRowData: this.currentRowData,
1645
+ currNodeName : this.currNodeName,
1646
+ flowDefine: this.flowDefine,
1647
+ startNodeKeyObj: this.startNodeKeyObj,
1648
+ flowVersionNodeObj: this.flowVersionNodeObj,
1649
+ currentStartUser : this.currentStartUser,
1650
+ currentStartTime : this.currentStartTime,
1651
+ currentInst : this.currentInst,
1652
+ formInfo : this.formInfo,
1653
+ formBtnArr : this.formBtnArr
1654
+ }
1655
+ this.$flowDialog.fillFlowDialogParams(result);
1656
+ resolve(result);
1657
+ })
1658
+ });
1659
+ });
1660
+ });
1661
+ }
1662
+
1663
+ /**
1664
+ * 打开[查看]窗口
1665
+ */
1666
+ openViewFlowForm(row) {
1667
+ return new Promise(resolve => {
1668
+ this.init().then(() => {
1669
+ this.currentRowData = row;
1670
+ let startNodeKey = this.startNodeKeyObj[row.version];
1671
+ if (row.currentNodeName === "结束"){
1672
+ this.currNodeName = "end";
1673
+ }
1674
+ this.initFieldStatus(row.nodeKey || startNodeKey,row.version,row.flowStatus).then(() =>{
1675
+ this.$flowDialog.fillFlowDialogParams({
1676
+ flowDefine: this.flowDefine,
1677
+ formInfo: this.formInfo
1678
+ });
1679
+ this.flowInstDataDialog = true;
1680
+ this.$flowDialog.operateDialog('flowInstDataDialog',true);
1681
+ this.$this.$nextTick(() => {
1682
+ this.initFormInfoFunc('view',row).then(() => {
1683
+ this.currentStartUser = this.userMap[row.startUserId] || "";
1684
+ this.currentStartTime = row.startTime;
1685
+ this.currentInst = row;
1686
+
1687
+ Object.assign(this.formInfo, {
1688
+ dataId: row.dataId,
1689
+ opt: "view",
1690
+ });
1691
+ this.formBtnArr = this.getViewFormBtn(row);
1692
+ let result = {
1693
+ currentRowData: this.currentRowData,
1694
+ currNodeName : this.currNodeName,
1695
+ currentStartUser : this.currentStartUser,
1696
+ currentStartTime : this.currentStartTime,
1697
+ currentInst : this.currentInst,
1698
+ formInfo : this.formInfo,
1699
+ formBtnArr : this.formBtnArr,
1700
+ }
1701
+ this.$flowDialog.fillFlowDialogParams(result);
1702
+ resolve(result);
1703
+ });
1704
+ });
1705
+ });
1706
+ });
1707
+ })
1708
+ }
1709
+
1710
+ // 打开前方法end
1711
+
1712
+
1713
+
1714
+ /**
1715
+ * 存草稿
1716
+ */
1717
+ saveDraft() {
1718
+ // let loading = this.$this.$loading({
1719
+ // lock: true,
1720
+ // spinner: 'el-icon-loading',
1721
+ // background: 'rgba(0, 0, 0, 0.7)'
1722
+ // })
1723
+
1724
+ this.saveDataFunc('draft').then(resData => {
1725
+ this.tabCrudSearch && this.tabCrudSearch(); // todo 回调刷新方法,初始化置入即可
1726
+
1727
+ this.flowInstDataDialog = false;
1728
+ this.$flowDialog.operateDialog('flowInstDataDialog',false);
1729
+ if (resData.flowInstId) {
1730
+ this.$this.$message({type: "success", message: "保存成功!"});
1731
+ if (this.getFlowBatchDialog && this.getFlowBatchDialog()) {//批量处理 需处理tab页
1732
+ this.batchSaveDraft();
1733
+ }
1734
+ } else {
1735
+ this.$this.$message({type: "error", message: "保存失败!"});
1736
+ }
1737
+ // loading && loading.close();
1738
+ this.currentInst={};
1739
+ });
1740
+ }
1741
+
1742
+ /**
1743
+ * 批量处理存草稿
1744
+ */
1745
+ batchSaveDraft() {
1746
+ this.batchTabRemove(this.currentInst.dataId);
1747
+ }
1748
+
1749
+ /**
1750
+ * 回退到上一步
1751
+ */
1752
+ backToPrevious() {
1753
+ let loading = this.$this.$loading({
1754
+ lock: true,
1755
+ text: '正在退回,请稍后....',
1756
+ spinner: 'el-icon-loading',
1757
+ background: 'rgba(0, 0, 0, 0.7)'
1758
+ })
1759
+ let currentInst = this.currentInst;
1760
+ this.$this.$prompt('退回备注', '确定要退回至上一个节点吗?', {
1761
+ confirmButtonText: '确定',
1762
+ cancelButtonText: '取消',
1763
+ inputType: 'textarea',
1764
+ }).then(({ value }) => {
1765
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.backRewrite,
1766
+ {
1767
+ taskId:currentInst.taskId,
1768
+ remarks: value
1769
+ }).then(res => {
1770
+ if (res && res.data && res.data.operateSuccess) {
1771
+ this.$this.$message({type: "success", message: "退回成功!"});
1772
+ let currentNodeObj = this.flowNodeIdToInfo[currentInst.currentNode] ||{};
1773
+ this.exeNewFlowEvent("backSubmit",currentNodeObj.nodeLinkId);
1774
+ this.backSubmitEvent && this.backSubmitEvent(this.$this,this,currentInst);
1775
+ this.initTabNum && this.initTabNum();
1776
+ if (this.getFlowBatchDialog && this.getFlowBatchDialog()) {
1777
+ this.batchTabRemove(this.currentInst.dataId);
1778
+ } else {
1779
+ this.tabCrudSearch && this.tabCrudSearch();
1780
+ }
1781
+ } else {
1782
+ this.$this.$message({type: "error", message: res.data.operateMessage});
1783
+ }
1784
+ loading && loading.close();
1785
+ this.flowInstDataDialog = false;
1786
+ this.$flowDialog.operateDialog('flowInstDataDialog',false);
1787
+ })
1788
+ }).catch(() => {
1789
+ loading && loading.close();
1790
+ });
1791
+ }
1792
+
1793
+
1794
+ /**
1795
+ * 取回
1796
+ */
1797
+ getBackPrevious() {
1798
+ let loading = this.$this.$loading({
1799
+ lock: true,
1800
+ text: '正在取回,请稍后....',
1801
+ spinner: 'el-icon-loading',
1802
+ background: 'rgba(0, 0, 0, 0.7)'
1803
+ })
1804
+ let currentInst = this.currentInst;
1805
+ this.$this.$confirm('确定要取回吗?', '警告', {
1806
+ confirmButtonText: '确定',
1807
+ cancelButtonText: '取消',
1808
+ }).then(() => {
1809
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.getBackRewrite,
1810
+ {
1811
+ flowInstId: currentInst.flowInstId,
1812
+ }).then(res => {
1813
+ if (res && res.data && res.data.operateSuccess) {
1814
+ this.$this.$message({type: "success", message: "取回成功!"});
1815
+ let currentNodeObj = this.flowNodeIdToInfo[currentInst.currentNode] ||{};
1816
+ this.exeNewFlowEvent("getBackSubmit",currentNodeObj.nodeLinkId);
1817
+ this.getBackSubmitEvent && this.getBackSubmitEvent(this.$this,this,currentInst);
1818
+ this.initTabNum && this.initTabNum();
1819
+ if (this.getFlowBatchDialog && this.getFlowBatchDialog()) {
1820
+ this.batchTabRemove(this.currentInst.dataId);
1821
+ } else {
1822
+ this.tabCrudSearch && this.tabCrudSearch();
1823
+ }
1824
+ } else {
1825
+ this.$this.$message({type: "error", message: res.data.operateMessage});
1826
+ }
1827
+ loading && loading.close();
1828
+ this.flowInstDataDialog = false;
1829
+ this.$flowDialog.operateDialog('flowInstDataDialog',false);
1830
+ })
1831
+ }).catch(() => {
1832
+ loading && loading.close();
1833
+ });
1834
+ }
1835
+
1836
+ /**
1837
+ * 打开退回节点窗口
1838
+ */
1839
+ retSpecified(currentInst){
1840
+ let flowInstId = currentInst.flowInstId;
1841
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.getBackData,{"flowInstId":flowInstId}).then(res => {
1842
+ this.backNodeArr = [];
1843
+ if(res.data.operateSuccess){
1844
+ let result = res.data.resultObject || [];
1845
+ if(result.length == 0){
1846
+ this.$this.$message.warning("没有可以退回的节点!");
1847
+ return;
1848
+ }
1849
+ let arr = [];
1850
+ result.forEach((item,index) =>{
1851
+ // if(index != res.data.resultObject.length -1){
1852
+ // this.backNodeArr.push(item);
1853
+ // }
1854
+ if(item["endTimeNull"]){
1855
+ arr.push(item);
1856
+ }else{
1857
+ this.backNodeArr.push(item);
1858
+ }
1859
+ });
1860
+ this.backNodeArr = this.backNodeArr.concat(arr);
1861
+ this.backNodeArr.splice(this.backNodeArr.length - 1,1);
1862
+ this.isDisabled2 = true;
1863
+ this.backMsg = "";
1864
+ this.backNodeId = "";
1865
+ this.backDialogVisible = true;
1866
+ this.$flowDialog.operateDialog('backDialogVisible',true);
1867
+ }
1868
+ })
1869
+ }
1870
+
1871
+ syncFlowDialogPrams(params){
1872
+ Object.keys(params).forEach(key => {
1873
+ this[key] = params[key];
1874
+ });
1875
+ this.setParams && this.setParams(params);
1876
+ }
1877
+
1878
+ /**
1879
+ * 恢复方法
1880
+ */
1881
+ restoreFlow() {
1882
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.stopFlow, {
1883
+ instId: this.currentInst.flowInstId, type: "1",
1884
+ procInstId: this.currentInst.linkProcId,
1885
+ taskId: this.currentInst.taskId
1886
+ }).then(res => {
1887
+ if (res && res.data) {
1888
+ if (res.data.operateSuccess) {
1889
+ this.$this.$message({type: "success", message: "恢复成功!"});
1890
+ this.flowInstDataDialog = false;
1891
+ this.$flowDialog.operateDialog('flowInstDataDialog',false);
1892
+ if (this.getFlowBatchDialog && this.getFlowBatchDialog()) {
1893
+ this.batchTabRemove(this.currentInst.dataId);
1894
+ } else {
1895
+ this.tabCrudSearch && this.tabCrudSearch();
1896
+ }
1897
+ this.initTabNum && this.initTabNum();
1898
+ } else {
1899
+ this.$this.$message({type: "error", message: res.data.operateMessage});
1900
+ }
1901
+ }
1902
+ })
1903
+ }
1904
+
1905
+ /**
1906
+ * 打开流转记录窗口
1907
+ * @param row 流程行数据
1908
+ */
1909
+ openFlowRecord(row) {
1910
+ let arr = ["2", "3", "4"]; // 旧版本的已办结已撤销以及已中止数据通过旧版接口查询流转记录
1911
+ this.$flowDialog.fillFlowDialogParams({
1912
+ flowRecordObj: this.flowRecordObj
1913
+ });
1914
+ if (arr.indexOf(row.flowStatus) > -1 && row.isOldData === "1") {
1915
+ this.flowRecordObj = {instId: row.flowInstId || "", oldDialogVisible: true};
1916
+ } else {
1917
+ this.flowRecordObj = {instId: row.flowInstId || "", dialogVisible: true};
1918
+ }
1919
+ }
1920
+
1921
+ openFlowChart(row) {
1922
+ let flowId = "";
1923
+ let instId = "";
1924
+ let linkProcId = "";
1925
+ let isRelease = "";
1926
+ if (row) {
1927
+ flowId = row.flowId;
1928
+ instId = row.flowInstId;
1929
+ linkProcId = row.linkProcId;
1930
+ isRelease = row.isRelease;
1931
+ }
1932
+ this.flowChartObj = {flowId: flowId,instId: instId,linkProcId:linkProcId,isRelease:isRelease, dialogVisible: true};
1933
+ this.$flowDialog.fillFlowDialogParams({
1934
+ flowChartObj: this.flowChartObj,
1935
+ })
1936
+ }
1937
+
1938
+ // end of button methods 按钮方法结束
1939
+
1940
+ // 功能区域,用于作为一些方法处理数据
1941
+
1942
+ // 自定义按钮窗口回调函数
1943
+ openDiyButtonEvent(type,row, button) {
1944
+ let formData = {};
1945
+ if(this.getFormInfo){
1946
+ formData = this.getFormInfo();
1947
+ }
1948
+ if(type === 'list') {
1949
+ this.execDiyBtnScripts(type,row,button.funcBody);
1950
+ }else {
1951
+ this.execDiyBtnScripts(type,formData,button.funcBody);
1952
+ }
1953
+ }
1954
+
1955
+ judeDiyButton(tabActive,button) {
1956
+ if(tabActive === 'pending') {
1957
+ return button.position === 'table' && button.nodeId === this.currentInst.currentNode;
1958
+ }
1959
+ return button.position === 'table' && button.buttonSign.indexOf(tabActive) > -1;
1960
+ }
1961
+
1962
+ execDiyBtnScripts(type,data,fnBody) {
1963
+ try {
1964
+ fnBody = this.replaceUrl(fnBody);
1965
+ fnBody = fnBody.replace(/\\'/g, "'").replace(/&quot;/g, "\"");
1966
+ if(type === 'list') {
1967
+ new Function('vm,rowData,Ajax', fnBody)(this.$this,data,AjaxUtil);
1968
+ }else {
1969
+ new Function('vm,formData,Ajax', fnBody)(this.$this,data,AjaxUtil);
1970
+ }
1971
+ } catch (e) {
1972
+ console.log("自定义按钮事件执行错误!", e);
1973
+ }
1974
+ }
1975
+
1976
+ /**
1977
+ * 获取[添加、修改和处理]的操作按钮
1978
+ */
1979
+ getAddAndUpdateFormBtn(row) {
1980
+ //走版本
1981
+ let arrNodeFormBtns = [];
1982
+ if(row.version){
1983
+ arrNodeFormBtns = this.nodeFormBtnObj[(this.flowVersionNodeObj[row.version][row.nodeKey || this.startNodeKeyObj[row.version]] || {}).id];
1984
+ }else {
1985
+ arrNodeFormBtns = this.nodeFormBtnObj[this.flowVersionNodeObj[this.flowDefine.releaseVersion][this.startNodeKeyObj[this.flowDefine.releaseVersion]].id];
1986
+ }
1987
+ let hideBtnTypes = new Set(["getBack"]);
1988
+ if (this.tabActive == "draft") {
1989
+ hideBtnTypes.add("flowRecord");
1990
+ hideBtnTypes.add("record");
1991
+ }else if(this.tabActive == "pending"){//待处理
1992
+ hideBtnTypes.add("cancel");
1993
+ if(row.operateStatus=='1'||row.operateStatus=='3'){//如果是加签转签 不需要部分按钮
1994
+ hideBtnTypes.add("retSpecified");
1995
+ hideBtnTypes.add("back");
1996
+ hideBtnTypes.add("completeSign");
1997
+ hideBtnTypes.add("turnSign");
1998
+ }
1999
+ }
2000
+
2001
+ return this.formatterFormBtnByHideBtnTypes(arrNodeFormBtns, hideBtnTypes);
2002
+ }
2003
+
2004
+ /**
2005
+ * 根据隐藏按钮类型格式化按钮信息
2006
+ */
2007
+ formatterFormBtnByHideBtnTypes(arrFormBtns, hideBtnTypes) {
2008
+ let arrResults = [];
2009
+ arrFormBtns.forEach(data => {
2010
+ let objTmp = Object.assign({}, data);
2011
+ hideBtnTypes.has(data.btnType) && (objTmp.show = false);
2012
+ if(this.tabActive == "discontinue" && data.btnType == "restore" && !hideBtnTypes.has(data.btnType)){
2013
+ objTmp.show = true;
2014
+ }
2015
+ if(this.tabActive == "processed" && data.btnType == "getBack" && !hideBtnTypes.has(data.btnType)){
2016
+ objTmp.show = true;
2017
+ }
2018
+ if(this.tabActive == "processed" && data.btnType == "cancel" && !hideBtnTypes.has(data.btnType)){
2019
+ objTmp.show = true;
2020
+ }
2021
+ arrResults.push(objTmp);
2022
+ });
2023
+ return arrResults;
2024
+ }
2025
+
2026
+ /**
2027
+ * 获取[查看]的操作按钮
2028
+ */
2029
+ getViewFormBtn(row) {
2030
+ //走版本
2031
+ let arrNodeFormBtns = [];
2032
+ if(row.version){
2033
+ arrNodeFormBtns = this.nodeFormBtnObj[(this.flowVersionNodeObj[row.version][row.nodeKey || this.startNodeKeyObj[row.version]] || {}).id];
2034
+ }else {
2035
+ arrNodeFormBtns = this.nodeFormBtnObj[this.flowVersionNodeObj[this.flowDefine.releaseVersion][this.startNodeKeyObj[this.flowDefine.releaseVersion]].id];
2036
+ }
2037
+ let hideBtnTypes = new Set(["getBack", "cancel", "restore"]);
2038
+ if (this.tabActive == "processed") { // 已处理
2039
+
2040
+ // 上个节点的处理可以取回(已开启按钮的情况下)
2041
+ if ((row.beforeDealer || "").split(",").indexOf(this.loginUser.id) > -1) {
2042
+ hideBtnTypes.delete("getBack");
2043
+ }
2044
+
2045
+ // 流程的发起人可以撤销(已开启按钮的情况下)
2046
+ if (row.startUserId == this.loginUser.id) {
2047
+ // hideBtnTypes.delete("cancel");
2048
+ }
2049
+ //被挂起数据只有查看按钮
2050
+ if(row.hangUp == '1'){
2051
+ hideBtnTypes.add("getBack");
2052
+ hideBtnTypes.add("cancel");
2053
+ hideBtnTypes.add("restore");
2054
+ }
2055
+ } else if (this.tabActive == "discontinue" && row.discontinueUserId == this.loginUser.id) { // 已中止
2056
+ // 当前登陆用户是中止人才显示恢复按钮(已开启按钮的情况下)
2057
+ hideBtnTypes.delete("restore");
2058
+ }
2059
+
2060
+ return this.formatterFormBtnByHideBtnTypes(arrNodeFormBtns, hideBtnTypes);
2061
+ }
2062
+
2063
+ initFieldStatus(nodeKey,version,flowStatus) {
2064
+ return new Promise(resolve => {
2065
+ resolve();
2066
+ });
2067
+ }
2068
+
2069
+ replaceUrl(value){
2070
+ if(window.ADMIN_URL && (value.indexOf("/admin/") > -1 || value.indexOf("/oaadmin/") > -1)){
2071
+ if(value.indexOf("/admin/") > -1){
2072
+ value = this.$this.platStringUtil.replaceAll(value,"/admin/", window.ADMIN_URL + "/");
2073
+ }else{
2074
+ value = this.$this.platStringUtil.replaceAll(value,"/oaadmin/",window.ADMIN_URL + "/");
2075
+ }
2076
+ }
2077
+ if(window.FLOW_URL && (value.indexOf("/flow/") > -1 || value.indexOf("/oaflow/") > -1)){
2078
+ if(value.indexOf("/flow/") > -1){
2079
+ value = this.$this.platStringUtil.replaceAll(value,"/flow/", window.FLOW_URL + "/");
2080
+ }else{
2081
+ value = this.$this.platStringUtil.replaceAll(value,"/oaflow/",window.FLOW_URL + "/");
2082
+ }
2083
+ }
2084
+ if(window.FORM_RENDER_URL && (value.indexOf("/form/") > -1|| value.indexOf("/oaform/") > -1)){
2085
+ if(value.indexOf("/form/") > -1){
2086
+ value = this.$this.platStringUtil.replaceAll(value,"/form/", window.FORM_RENDER_URL + "/");
2087
+ }else{
2088
+ value = this.$this.platStringUtil.replaceAll(value,"/oaform/",window.FORM_RENDER_URL + "/");
2089
+ }
2090
+ }
2091
+ if(window.OA_URL && (value.indexOf("/project/") > -1 || value.indexOf("/oaproject/") > -1)){
2092
+ if(value.indexOf("/project/") > -1){
2093
+ value = this.$this.platStringUtil.replaceAll(value,"/project/", window.OA_URL + "/");
2094
+ }else{
2095
+ value = this.$this.platStringUtil.replaceAll(value,"/oaproject/",window.OA_URL + "/");
2096
+ }
2097
+ }
2098
+ value = this.$this.platStringUtil.replaceAll(value,"window.JAVA_URL","''");
2099
+ value = this.$this.platStringUtil.replaceAll(value,"JAVA_URL","''");
2100
+ value = this.$this.platStringUtil.replaceAll(value,"window.baseUrl","''");
2101
+ value = this.$this.platStringUtil.replaceAll(value,"baseUrl","''");
2102
+ return value;
2103
+ }
2104
+
2105
+ /**
2106
+ * 格式化表单操作按钮
2107
+ */
2108
+ formatterFormButton(formButton) {
2109
+
2110
+ let formBtnObj = {};
2111
+ let formBtnArr = [];
2112
+
2113
+ for (let [key, data] of Object.entries(this.formBtnObjDefault)) {
2114
+ formBtnObj[key] = Object.assign({btnType: key}, data);
2115
+ }
2116
+
2117
+ let objTmp;
2118
+ (formButton || []).forEach(data => {
2119
+ if (formBtnObj[data.type]) {
2120
+ objTmp = formBtnObj[data.type];
2121
+ objTmp.show = (data.isUse != '0');
2122
+ objTmp.text = data.showName || objTmp.text;
2123
+ }
2124
+ });
2125
+
2126
+ for (let [key, data] of Object.entries(formBtnObj)) {
2127
+ formBtnArr.push(data);
2128
+ }
2129
+ return formBtnArr;
2130
+ }
2131
+
2132
+ sortButtonArr(formButton) {
2133
+ let objBtnOrder = {
2134
+ "saveDraft": 1,
2135
+ "nextStep": 2,
2136
+ "completeSign": 3,
2137
+ "turnSign": 4,
2138
+ "retSpecified": 5,
2139
+ "back": 6,
2140
+ "stopped": 7,
2141
+ "close": 8
2142
+ };
2143
+ (formButton || []).forEach(data => {
2144
+ data.order = objBtnOrder[data.type] || data.order;
2145
+ });
2146
+ return formButton;
2147
+ }
2148
+
2149
+ // 获取流程用户数据
2150
+ initUserData(){
2151
+ // 先载入系统接口数据
2152
+ let userArr = this.$this.INTER_CACHE.getUserArr();
2153
+ if(userArr && userArr.length > 0){
2154
+ this.userMap = this.$this.INTER_CACHE.getUserMap();
2155
+ this.userArr = userArr;
2156
+ }else{
2157
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInterface.find,{sysInterName:'userData',interType:'sys',interStatus:'1'}).then(res => {
2158
+ if((res.data || []).length === 0){
2159
+ return;
2160
+ }
2161
+ let dataInter = res.data[0];
2162
+ this.loadUserData(dataInter);
2163
+ })
2164
+ }
2165
+ }
2166
+ loadUserData(dataInter){
2167
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowDomain.findRealUrl,{status:'1'}).then(res => {
2168
+ (res.data || []).forEach(item => {
2169
+ this.doMainDatasObj[item.id] = item.domainUrl;
2170
+ })
2171
+ // 解析用户数据
2172
+ this.analyseRequest(dataInter).then(data => {
2173
+ let arr = [];
2174
+ let userIdArr = [];
2175
+ data.forEach(item => {
2176
+ item.dataUserId = item[dataInter["idCode"] || "userId"];
2177
+ item.dataKey = item.dataUserId;
2178
+ item.flowDataType = "user";
2179
+ item.dataLabel = item[dataInter["showCode"] || "userName"];
2180
+ item.dataOrgId = item[dataInter["orgCode"] || "orgId"];
2181
+ item.dataPosId = item[dataInter["posCode"] || "posId"];
2182
+ if(item.dataOrgId){
2183
+ item.dataParentId = item.orgId;
2184
+ }
2185
+ if(item.dataPosId){
2186
+ item.dataParentId = item.posId;
2187
+ }
2188
+ if(userIdArr.indexOf(item.dataKey) === -1){
2189
+ arr.push({
2190
+ id:item.dataKey,
2191
+ userName:item.dataLabel
2192
+ })
2193
+ userIdArr.push(item.dataKey);
2194
+ }
2195
+ })
2196
+ this.userArr = arr;
2197
+ this.$this.INTER_CACHE.setUserArr(arr);
2198
+ this.userMap = this.$this.INTER_CACHE.getUserMap();
2199
+ })
2200
+ })
2201
+ }
2202
+ analyseRequest(dataInter){
2203
+ return new Promise(resolve => {
2204
+ let domainUrl = this.doMainDatasObj[dataInter.domainId] || "";
2205
+ let url = domainUrl + dataInter.requestUrl;
2206
+ let requestParam = JSON.parse(dataInter.requestParam || "[]");
2207
+ let obj = {};
2208
+ requestParam.forEach(item => {
2209
+ if(!item.key){
2210
+ return;
2211
+ }
2212
+ obj[item.key] = item.value || ""; // 注意这里要replace ${userCode}
2213
+ })
2214
+ if(dataInter.requestType === 'post'){
2215
+ this.$this.saspFlowAxios.post(url,obj).then(res => {
2216
+ this.$this.INTER_CACHE.setCacheInfo(dataInter.sysInterName,res.data);
2217
+ resolve(res.data || []);
2218
+ })
2219
+ }else{
2220
+ let params = "";
2221
+ let arr = []
2222
+ Object.keys(obj).forEach(key => {
2223
+ arr.push(key + "=" + obj[key]);
2224
+ })
2225
+ params = arr.join("&");
2226
+ if(params){
2227
+ if(url.indexOf("?") > -1){
2228
+ url += "&" + params;
2229
+ }else{
2230
+ url += "?" + params;
2231
+ }
2232
+ }
2233
+ this.$this.saspFlowAxios(url).then(res => {
2234
+ this.$this.INTER_CACHE.setCacheInfo(dataInter.sysInterName,res.data);
2235
+ resolve(res.data || []);
2236
+ })
2237
+ }
2238
+ })
2239
+ }
2240
+
2241
+ /**
2242
+ *
2243
+ * @param dataId 数据ID
2244
+ * @param type 操作类型,view-查看、update-编辑
2245
+ * @param forceOpen 是否强制打开,默认false,为true时可以将非工作流列表数据自动插入草稿数据并打开
2246
+ * @param callback 回调函数
2247
+ */
2248
+ open(dataId,type,forceOpen,callback){
2249
+ if(!this.tableviewId){
2250
+ this.$this.$message.error("请先设置tableviewId");
2251
+ return;
2252
+ }
2253
+ this.init().then(() => {
2254
+ this.formInfo["dataId"] = dataId;
2255
+ this.$flowDialog.fillFlowDialogParams({
2256
+ formId: this.formId,
2257
+ tableviewId: this.tableviewId,
2258
+ dataId: dataId || "",
2259
+ formInfo: this.formInfo
2260
+ });
2261
+ if(dataId){
2262
+ this.getDataByDataId(dataId,forceOpen).then(rowData => {
2263
+ if(!rowData){
2264
+ this.$this.$message.error("未获取到此流程数据!");
2265
+ return;
2266
+ }
2267
+ if(type !== "view" && rowData.operateAuth === "0"){
2268
+ console.log("当前登录用户无此流程数据操作权限,已自动切换为查看!");
2269
+ type = "view";
2270
+ }
2271
+ if(rowData.linkProcId){
2272
+ this.tabActive = "pending";
2273
+ }else{
2274
+ this.tabActive = "draft";
2275
+ }
2276
+ this.currentInst = rowData;
2277
+ if(type === "view"){
2278
+ this.openViewFlowForm(rowData).then(() => {
2279
+ callback && callback(this,this.$this);
2280
+ })
2281
+ }else{
2282
+ let executePosition = "update";
2283
+ if(rowData.linkProcId){
2284
+ executePosition = "handle";
2285
+ }
2286
+ this.openUpdateFlowForm(rowData,executePosition).then(() => {
2287
+ callback && callback(this,this.$this);
2288
+ })
2289
+ }
2290
+ });
2291
+ }else{
2292
+ this.currentInst = {};
2293
+ this.tabActive = "draft";
2294
+ this.openAddFlowForm().then(() => {
2295
+ callback && callback(this,this.$this);
2296
+ })
2297
+ }
2298
+ })
2299
+ }
2300
+
2301
+ /**
2302
+ * 根据数据ID获取流程数据
2303
+ * @param dataId
2304
+ * @returns {Promise<unknown>}
2305
+ */
2306
+ getDataByDataId(dataId,forceOpen){
2307
+ return new Promise(resolve => {
2308
+ this.getFlowInstByDataId(dataId).then(rowData => {
2309
+ if(!rowData) {
2310
+ if (forceOpen) {
2311
+ this.$this.axios.post(this.$this.api.flowEngine.saveFlowDraft, {
2312
+ flowId: this.flowId,
2313
+ dataId: dataId,
2314
+ userCode: this.loginUser.id
2315
+ }).then(flowDraftRes => {
2316
+ let flowDraftData = flowDraftRes.data || {};
2317
+ if (flowDraftData.requestStatus === "1") {
2318
+ this.getFlowInstByDataId(dataId).then(rowData => {
2319
+ resolve(rowData);
2320
+ });
2321
+ }else{
2322
+ resolve(false);
2323
+ }
2324
+ });
2325
+ }else{
2326
+ resolve(false);
2327
+ }
2328
+ }else{
2329
+ resolve(rowData);
2330
+ }
2331
+ })
2332
+ })
2333
+ }
2334
+
2335
+ getFlowInstByDataId(dataId){
2336
+ return new Promise(resolve => {
2337
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.getFlowInstByFlowDataId,{flowId:this.flowId,dataId:dataId}).then(res => {
2338
+ if(!res.data){
2339
+ resolve(false);
2340
+ return;
2341
+ }
2342
+ let rowData = res.data || {};
2343
+ resolve(rowData);
2344
+ });
2345
+ })
2346
+ }
2347
+
2348
+ openFlowDialog(args){
2349
+ this.$flowDialog.openFlowDialog(args);
2350
+ }
2351
+
2352
+ openRecordEvent(dataId){ // 采用初始化构造类时传递flowId
2353
+ if(!this.flowId){
2354
+ this.$this.$message.error("请先设置flowId");
2355
+ return;
2356
+ }
2357
+ this.openRecord(this.flowId,dataId);
2358
+ }
2359
+
2360
+ openRecord(flowId,dataId){
2361
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.getFlowInstByFlowDataId,{flowId:(flowId || this.flowId),dataId:dataId}).then(res => {
2362
+ if (!res.data) {
2363
+ this.$this.$message.error("未获取到此流程数据!");
2364
+ return;
2365
+ }
2366
+ let currentInst = res.data || {};
2367
+ this.openFlowRecord(currentInst);
2368
+ });
2369
+ }
2370
+
2371
+ openChartEvent(dataId){ // 采用初始化构造类时传递flowId
2372
+ if(!this.flowId){
2373
+ this.$this.$message.error("请先设置flowId");
2374
+ return;
2375
+ }
2376
+ this.openChart(this.flowId,dataId);
2377
+ }
2378
+
2379
+ openChart(flowId,dataId){
2380
+ if(dataId){
2381
+ this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.getFlowInstByFlowDataId,{flowId:flowId || this.flowId,dataId:dataId}).then(res => {
2382
+ if (!res.data) {
2383
+ this.$this.$message.error("未获取到此流程数据");
2384
+ return;
2385
+ }
2386
+ let currentInst = res.data || {};
2387
+ this.openFlowChart(currentInst);
2388
+ });
2389
+ }else{
2390
+ this.openFlowChart({flowId:(flowId || this.flowId)});
2391
+ }
2392
+ }
2393
+ }
2394
+
2395
+ export default {
2396
+ workflow: WorkflowEngine
2397
+ }