sasp-flow-render 1.1.33 → 1.1.36-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.
- package/index.js +16 -0
- package/package.json +1 -1
- package/src/assets/js/api/apiFlow.js +2 -0
- package/src/components/flowInst/flowInstTab.vue +258 -2468
- package/src/components/flowInst/js/workflow.js +2405 -0
- package/src/components/flowInst/popup/flowDialog.vue +1089 -0
- package/src/components/flowInst/popup/renderForm.vue +19 -0
- package/src/views/popup/event/compoment/system/flowEditContentConfig.vue +2 -1
|
@@ -0,0 +1,2405 @@
|
|
|
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.dealType === "multi"){
|
|
706
|
+
let gatewaySet = JSON.parse(obj.gatewaySet || "[]");
|
|
707
|
+
gatewaySet.forEach(item => {
|
|
708
|
+
item.forEach(data => {
|
|
709
|
+
this.isRefreshGetNextUsers.push(data.field);
|
|
710
|
+
})
|
|
711
|
+
})
|
|
712
|
+
}
|
|
713
|
+
if (obj.dealerType === "interface" && obj.dealerUrlParam) {
|
|
714
|
+
let dealerUrlParam = JSON.parse(obj.dealerUrlParam || "[]");
|
|
715
|
+
dealerUrlParam.forEach(param => {
|
|
716
|
+
if (param.paramType === "variable") {
|
|
717
|
+
this.isRefreshGetNextUsers.push(param.paramVal);
|
|
718
|
+
}
|
|
719
|
+
})
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
let tabTypeObj= {};
|
|
724
|
+
if (!this.flowId.includes(",")) {
|
|
725
|
+
let tabSetting = JSON.parse(this.flowDefine.tabSetting);
|
|
726
|
+
tabSetting.forEach(data => {
|
|
727
|
+
this.$this.$set(tabTypeObj, data.type, data);
|
|
728
|
+
});
|
|
729
|
+
Object.keys(tabTypeObj).forEach(key => {
|
|
730
|
+
let objTemp = tabTypeObj[key];
|
|
731
|
+
objTemp.tabName = objTemp["showName"] || objTemp["name"];
|
|
732
|
+
});
|
|
733
|
+
let tabTitleType = this.flowDefine.tabTitleType;
|
|
734
|
+
if (tabTitleType === "1") {
|
|
735
|
+
tabTypeObj["showtTabText"] = true;
|
|
736
|
+
tabTypeObj["showTabIcon"] = true;
|
|
737
|
+
} else if (tabTitleType === "2") {
|
|
738
|
+
tabTypeObj["showtTabText"] = true;
|
|
739
|
+
} else if (tabTitleType === "3") {
|
|
740
|
+
tabTypeObj["showTabIcon"] = true;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
let result = {
|
|
745
|
+
isRefreshGetNextUsers : this.isRefreshGetNextUsers,
|
|
746
|
+
tabTypeObj: tabTypeObj
|
|
747
|
+
}
|
|
748
|
+
this.setFlowTabInfo && this.setFlowTabInfo(result);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// 初始化流程信息end
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* 下一步,保存数据以及获取处理人
|
|
755
|
+
*/
|
|
756
|
+
nextStep() {
|
|
757
|
+
let afterClickResult;
|
|
758
|
+
let result;
|
|
759
|
+
let currentNodeObj = this.flowNodeIdToInfo[this.currentInst.currentNode || this.draftNodeId] ||{};
|
|
760
|
+
afterClickResult=this.exeFlowEvent("nextStep","afterClick", this.currentInst.currentNode || this.draftNodeId);
|
|
761
|
+
|
|
762
|
+
if(typeof afterClickResult == "boolean" && afterClickResult === false){
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if(currentNodeObj.openEvent === '1'){
|
|
767
|
+
afterClickResult = this.exeNewFlowEvent("nextClick",currentNodeObj.nodeLinkId);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
if(typeof afterClickResult == "boolean" && afterClickResult === false){
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
// let afterValidateResult;
|
|
775
|
+
// let currentNodeObj = this.flowNodeIdToInfo[this.currentInst.currentNode || this.draftNodeId] ||{};
|
|
776
|
+
result = this.exeFlowEvent("nextStep","afterValidate", this.currentInst.currentNode || this.draftNodeId);
|
|
777
|
+
if(typeof result == "boolean" && result === false){
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
if(currentNodeObj.openEvent === '1'){
|
|
781
|
+
result = this.exeNewFlowEvent("nextCheck",currentNodeObj.nodeLinkId);
|
|
782
|
+
if(typeof result == "boolean" && result === false){
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
this.isDisabled['nextStep'] = false;
|
|
788
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
789
|
+
flowParams: this.flowParams,
|
|
790
|
+
isDisabled: this.isDisabled
|
|
791
|
+
});
|
|
792
|
+
this.saveDataFunc('nextStep').then(flowParams => {
|
|
793
|
+
this.flowParams = JSON.parse(JSON.stringify(flowParams));
|
|
794
|
+
this.setParams && this.setParams({
|
|
795
|
+
flowParams:this.flowParams
|
|
796
|
+
});
|
|
797
|
+
let instId = flowParams.flowInstId;
|
|
798
|
+
this.$this.$set(this.formInfo,"opt","update");
|
|
799
|
+
this.currentInst.id = instId;
|
|
800
|
+
this.description = "";
|
|
801
|
+
this.saveInstId = instId;
|
|
802
|
+
this.nowNode = this.allNodeInfo[currentNodeObj.id] || {};
|
|
803
|
+
this.nextStepAfterSaveFunc().then(resultEvt => {
|
|
804
|
+
if(!resultEvt){
|
|
805
|
+
this.isDisabled['nextStep'] = true;
|
|
806
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
807
|
+
isDisabled: this.isDisabled
|
|
808
|
+
});
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
this.isProceedNext = true;
|
|
812
|
+
//获取处理人
|
|
813
|
+
let obj = {instId: instId, taskId: this.currentInst.taskId,};
|
|
814
|
+
if(this.nowNode && this.nowNode.dealType && this.nowNode.dealType == 'multi'){
|
|
815
|
+
this.$this.$set(obj,'passCondition',this.nowNode.passCondition)
|
|
816
|
+
}
|
|
817
|
+
let params = {"SASP_FLOW_USE_VARIABLES":"yes"};
|
|
818
|
+
// Object.assign(params,flowParams || {},obj);
|
|
819
|
+
Object.assign(params,obj);
|
|
820
|
+
let allParamKeys = Object.keys(flowParams || {});
|
|
821
|
+
allParamKeys.forEach(templateKey => {
|
|
822
|
+
if(this.isRefreshGetNextUsers.indexOf(templateKey) > -1){
|
|
823
|
+
params[templateKey] = flowParams[templateKey];
|
|
824
|
+
if(allParamKeys.indexOf(templateKey + "_SASP_SYS_DATA") > -1){
|
|
825
|
+
params[templateKey + "_SASP_SYS_DATA"] = flowParams[templateKey + "_SASP_SYS_DATA"];
|
|
826
|
+
}
|
|
827
|
+
if(allParamKeys.indexOf(templateKey + "_SASP_SYS_DATA_ID") > -1){
|
|
828
|
+
params[templateKey + "_SASP_SYS_DATA_ID"] = flowParams[templateKey + "_SASP_SYS_DATA_ID"];
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
833
|
+
flowParams: this.flowParams,
|
|
834
|
+
formInfo: this.formInfo,
|
|
835
|
+
currentInst: this.currentInst,
|
|
836
|
+
description: this.description,
|
|
837
|
+
saveInstId: this.saveInstId,
|
|
838
|
+
nowNode: this.nowNode,
|
|
839
|
+
isProceedNext: this.isProceedNext,
|
|
840
|
+
});
|
|
841
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.getNextUsers, params).then(res => {
|
|
842
|
+
if(!res.data.operateSuccess){
|
|
843
|
+
this.isDisabled['nextStep'] = true;
|
|
844
|
+
if(res.data.resultObject === 'requestException'){
|
|
845
|
+
this.$this.$message.error(res.data.errorInfo);
|
|
846
|
+
}else{
|
|
847
|
+
this.$this.$message.error("未获取到处理人");
|
|
848
|
+
}
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
let obj = {};
|
|
852
|
+
if (res && res.data) {
|
|
853
|
+
obj = res.data.operateObj || {};
|
|
854
|
+
if(res.data.operateMap && res.data.operateMap.isPassCondition == 0){
|
|
855
|
+
this.isProceedNext = false;
|
|
856
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
857
|
+
isProceedNext: this.isProceedNext,
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
this.nextNodeName = "";
|
|
862
|
+
this.choosePosUserIds = "";
|
|
863
|
+
this.choosePosUserIdsObj = {};
|
|
864
|
+
this.nextNode = obj;
|
|
865
|
+
this.chooseNextUserIdObj = {};
|
|
866
|
+
this.chooseNextUserNameObj = {};
|
|
867
|
+
this.chooseNextUserId = "";
|
|
868
|
+
this.chooseNextUserName = "";
|
|
869
|
+
let paramKeyArr = ["nextNodeName","choosePosUserIds","choosePosUserIdsObj","nextNode",
|
|
870
|
+
"chooseNextUserIdObj","chooseNextUserNameObj","chooseNextUserId","chooseNextUserName",
|
|
871
|
+
"nextSteptUserArr","nextSteptUserType"];
|
|
872
|
+
let params = {};
|
|
873
|
+
paramKeyArr.forEach(key => {
|
|
874
|
+
params[key] = this[key];
|
|
875
|
+
})
|
|
876
|
+
this.$flowDialog.fillFlowDialogParams(params);
|
|
877
|
+
if (obj.nextType == "inclusiveGateway") {
|
|
878
|
+
let autoChooseUser = false;
|
|
879
|
+
(obj.result || []).forEach(item => {
|
|
880
|
+
//获取下一个节点信息
|
|
881
|
+
let nextNodeTmp = this.flowNodeIdToInfo[item.nextNodeId] || {};
|
|
882
|
+
if (nextNodeTmp.nodeType == "UserTask") {
|
|
883
|
+
item.mulitiChooseUser = nextNodeTmp.dealType != "single";
|
|
884
|
+
autoChooseUser = nextNodeTmp.autoChooseUser == "1";
|
|
885
|
+
if (item.mulitiChooseUser) {
|
|
886
|
+
this.$this.$set(this.chooseNextUserIdObj, item.nodeKey, []);
|
|
887
|
+
} else {
|
|
888
|
+
this.$this.$set(this.chooseNextUserIdObj, item.nodeKey, "");
|
|
889
|
+
}
|
|
890
|
+
} else if (this.nextNode.nodeType == "EndEvent") {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
let userArr = item.userArr || [];
|
|
894
|
+
//自动执行时的自动执行人
|
|
895
|
+
if (autoChooseUser) {
|
|
896
|
+
if (item.type == "user" && userArr.length == 0) {
|
|
897
|
+
// this.$this.$message({type:"error",message:"没有处理人!"});
|
|
898
|
+
return;
|
|
899
|
+
} else {
|
|
900
|
+
let userIds = "";
|
|
901
|
+
let userNames = "";
|
|
902
|
+
userArr.forEach(userInfo => {
|
|
903
|
+
userIds += "," + userInfo.id;
|
|
904
|
+
userNames += "," + userInfo.userName;
|
|
905
|
+
});
|
|
906
|
+
this.chooseNextUserIdObj[item.nodeKey] = userIds.substring(1);
|
|
907
|
+
this.chooseNextUserId = userIds.substring(1);
|
|
908
|
+
this.chooseNextUserName = userNames.substring(1);
|
|
909
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
910
|
+
chooseNextUserId: this.chooseNextUserId,
|
|
911
|
+
chooseNextUserName: this.chooseNextUserName,
|
|
912
|
+
chooseNextUserIdObj: this.chooseNextUserIdObj
|
|
913
|
+
});
|
|
914
|
+
this.$flowDialog.saveNextStept();
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
item.nextSteptUserType = obj.type;
|
|
918
|
+
if (item.type == "user" || item.type== 'all') {
|
|
919
|
+
item.nextSteptUserArr = userArr;
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
if(!autoChooseUser){
|
|
923
|
+
this.nextSteptUserDialog = true;
|
|
924
|
+
this.$flowDialog.operateDialog('nextSteptUserDialog',true);
|
|
925
|
+
}
|
|
926
|
+
} else {
|
|
927
|
+
//获取下一个节点信息
|
|
928
|
+
this.nextNode = this.allNodeInfo[obj.nextNodeId] || {};
|
|
929
|
+
this.nextNodeName = obj.nextNodeName || "";
|
|
930
|
+
let autoChooseUser = false;
|
|
931
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
932
|
+
nextNode: this.nextNode,
|
|
933
|
+
nextNodeName: this.nextNodeName
|
|
934
|
+
});
|
|
935
|
+
if (this.nextNode.nodeType == "UserTask") {
|
|
936
|
+
this.mulitiChooseUser = this.nextNode.dealType != "single";
|
|
937
|
+
autoChooseUser = this.nextNode.autoChooseUser == "1";
|
|
938
|
+
this.chooseNextUserId = "";
|
|
939
|
+
this.chooseNextUserName = "";
|
|
940
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
941
|
+
mulitiChooseUser: this.mulitiChooseUser,
|
|
942
|
+
chooseNextUserId: this.chooseNextUserId,
|
|
943
|
+
chooseNextUserName: this.chooseNextUserName
|
|
944
|
+
});
|
|
945
|
+
} else if (this.nextNode.nodeType == "EndEvent") {
|
|
946
|
+
if(window.skipFlowEnd && window.skipFlowEnd.includes(this.flowId)){
|
|
947
|
+
this.$flowDialog.saveNextStept();
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
this.nextSteptUserDialog = true;
|
|
951
|
+
this.$flowDialog.operateDialog('nextSteptUserDialog',true);
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
let userArr = obj.userArr || [];
|
|
955
|
+
//自动执行时的自动执行人
|
|
956
|
+
if (autoChooseUser) {
|
|
957
|
+
if (obj.type == "user" && userArr.length == 0) {
|
|
958
|
+
this.$this.$message({type: "error", message: "没有处理人!"});
|
|
959
|
+
return;
|
|
960
|
+
} else {
|
|
961
|
+
let userIds = "";
|
|
962
|
+
let userNames = "";
|
|
963
|
+
userArr.forEach(userInfo => {
|
|
964
|
+
userIds += "," + userInfo.id;
|
|
965
|
+
userNames += "," + userInfo.userName;
|
|
966
|
+
});
|
|
967
|
+
if (userIds) {
|
|
968
|
+
this.chooseNextUserId = userIds.substring(1);
|
|
969
|
+
this.chooseNextUserName = userNames.substring(1);
|
|
970
|
+
}
|
|
971
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
972
|
+
chooseNextUserId: this.chooseNextUserId,
|
|
973
|
+
chooseNextUserName: this.chooseNextUserName
|
|
974
|
+
});
|
|
975
|
+
this.$flowDialog.saveNextStept();
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
this.nextSteptUserType = obj.type;
|
|
979
|
+
if (obj.type == "user" || obj.type == 'all') {
|
|
980
|
+
this.nextSteptUserArr = userArr;
|
|
981
|
+
}
|
|
982
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
983
|
+
nextSteptUserType: this.nextSteptUserType,
|
|
984
|
+
nextSteptUserArr: this.nextSteptUserArr
|
|
985
|
+
});
|
|
986
|
+
if(!autoChooseUser){
|
|
987
|
+
this.nextSteptUserDialog = true;
|
|
988
|
+
this.$flowDialog.operateDialog('nextSteptUserDialog',true);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
if(this.nextNode.nextType == 'inclusiveGateway'){
|
|
992
|
+
(this.nextNode.result || []).forEach(item => {
|
|
993
|
+
this.chooseNextUserIdObj[item.nodeKey] = (item.userArr || {}).id;
|
|
994
|
+
});
|
|
995
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
996
|
+
chooseNextUserIdObj: this.chooseNextUserIdObj,
|
|
997
|
+
});
|
|
998
|
+
}else{
|
|
999
|
+
let userInfo = this.nextSteptUserArr[0] || {};
|
|
1000
|
+
if(this.nextNode.dealType=="single"){
|
|
1001
|
+
this.chooseNextUserId = userInfo.id || "";
|
|
1002
|
+
this.chooseNextUserName = userInfo.userName || "";
|
|
1003
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
1004
|
+
chooseNextUserId: this.chooseNextUserId,
|
|
1005
|
+
chooseNextUserName: this.chooseNextUserName
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
if(this.nextNode.dealType === "multi" && this.nextSteptUserArr.length === 1){
|
|
1009
|
+
this.chooseNextUserId = [userInfo.id];
|
|
1010
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
1011
|
+
chooseNextUserId: this.chooseNextUserId
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
})
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
nextStepAfterSaveFunc(){
|
|
1021
|
+
return new Promise(resolve => {
|
|
1022
|
+
if(this.nextStepAfterSave){
|
|
1023
|
+
let result = this.nextStepAfterSave(this.$this,this);
|
|
1024
|
+
if(result && (result instanceof Promise)){
|
|
1025
|
+
result.then(res => {
|
|
1026
|
+
resolve(res);
|
|
1027
|
+
})
|
|
1028
|
+
}else{
|
|
1029
|
+
resolve(result);
|
|
1030
|
+
}
|
|
1031
|
+
}else{
|
|
1032
|
+
resolve(true);
|
|
1033
|
+
}
|
|
1034
|
+
})
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
saveDataFunc(type){ // 保存完成后返回流程的相关变量,通过变量传递到后台驱动流程运转
|
|
1038
|
+
// 保存草稿、下一步保存
|
|
1039
|
+
return new Promise(resolve => {
|
|
1040
|
+
if(this.saveFormInfo){
|
|
1041
|
+
let result = this.saveFormInfo(type);
|
|
1042
|
+
if(result && (result instanceof Promise)){
|
|
1043
|
+
result.then(res => {
|
|
1044
|
+
if(!res){
|
|
1045
|
+
this.isDisabled['nextStep'] = true;
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
if(typeof res !== 'object'){
|
|
1049
|
+
res = {};
|
|
1050
|
+
}
|
|
1051
|
+
this.saveFlowData(res).then(flowInstData => {
|
|
1052
|
+
res['flowInstId'] = flowInstData.id;
|
|
1053
|
+
resolve(res);
|
|
1054
|
+
})
|
|
1055
|
+
})
|
|
1056
|
+
}else{
|
|
1057
|
+
if(!result){
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
if(typeof result !== 'object'){
|
|
1061
|
+
result = {};
|
|
1062
|
+
}
|
|
1063
|
+
this.saveFlowData(result).then(flowInstData => {
|
|
1064
|
+
result['flowInstId'] = flowInstData.id;
|
|
1065
|
+
resolve(result);
|
|
1066
|
+
})
|
|
1067
|
+
}
|
|
1068
|
+
}else{
|
|
1069
|
+
this.saveFlowData().then(flowInstData => {
|
|
1070
|
+
let obj = {};
|
|
1071
|
+
obj['flowInstId'] = flowInstData.id;
|
|
1072
|
+
resolve(obj);
|
|
1073
|
+
})
|
|
1074
|
+
}
|
|
1075
|
+
})
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
saveFlowData(flowParams){
|
|
1079
|
+
return new Promise(resolve => {
|
|
1080
|
+
flowParams = flowParams || {};
|
|
1081
|
+
let flowSummary = this.getFlowSummary(flowParams);
|
|
1082
|
+
let flowInst = {};
|
|
1083
|
+
let dataId = (flowParams || {}).flowDataId || "";
|
|
1084
|
+
this.dataId = dataId;
|
|
1085
|
+
if(this.currentInst && this.currentInst.id){
|
|
1086
|
+
this.$this.$set(this.formInfo,"opt","update");
|
|
1087
|
+
flowInst = {
|
|
1088
|
+
"id": this.currentInst.id,
|
|
1089
|
+
"flowSummary": flowSummary,
|
|
1090
|
+
"updated": this.loginUser.id,
|
|
1091
|
+
};
|
|
1092
|
+
if(this.formInfo.opt == 'add' || !this.currentInst.linkProcId){ //版本号也要随之更新
|
|
1093
|
+
flowInst = Object.assign(flowInst,{"version":this.flowDefine.releaseVersion,"isRelease":this.flowDefine.isRelease})
|
|
1094
|
+
}
|
|
1095
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.url + "/" + this.formInfo.opt, flowInst).then(instRes => {
|
|
1096
|
+
this.runFlowEvt();
|
|
1097
|
+
resolve(instRes.data.operateObj);
|
|
1098
|
+
});
|
|
1099
|
+
}else{
|
|
1100
|
+
let startNodeKey = this.startNodeKeyObj[this.flowDefine.releaseVersion];
|
|
1101
|
+
if (this.formInfo.opt == "add") {
|
|
1102
|
+
flowInst = {
|
|
1103
|
+
flowId: this.flowDefine.id,
|
|
1104
|
+
flowSummary: flowSummary,
|
|
1105
|
+
dataId: dataId,
|
|
1106
|
+
version:this.flowDefine.releaseVersion, //版本号
|
|
1107
|
+
startTime: this.$this.DATE_UTIL.getCurrentDateTime(), flowStatus: "0",
|
|
1108
|
+
created: this.loginUser.id,
|
|
1109
|
+
currentNode: this.flowVersionNodeObj[this.flowDefine.releaseVersion][startNodeKey].id,
|
|
1110
|
+
isRelease:this.flowDefine.isRelease
|
|
1111
|
+
};
|
|
1112
|
+
} else {
|
|
1113
|
+
flowInst = {
|
|
1114
|
+
id: this.currentInst.id,
|
|
1115
|
+
flowSummary: flowSummary,
|
|
1116
|
+
version:this.flowDefine.releaseVersion, //版本号也要随之更新
|
|
1117
|
+
updated: this.loginUser.id,
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.url + "/" + this.formInfo.opt, flowInst).then(instRes => {
|
|
1121
|
+
this.runFlowEvt();
|
|
1122
|
+
resolve(instRes.data.operateObj);
|
|
1123
|
+
this.currentInst=instRes.data.operateObj;
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
})
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* 获取流程概要
|
|
1131
|
+
*/
|
|
1132
|
+
getFlowSummary(dataObj, summaryTemplate) {
|
|
1133
|
+
let flowSummary = "";
|
|
1134
|
+
let summarySet = summaryTemplate || this.flowDefine.flowSummary;
|
|
1135
|
+
if (!this.currentInst.linkProcId) { // 草稿数据
|
|
1136
|
+
flowSummary = this.$this.platStringUtil.replaceAll(summarySet, "${startUserName*}", this.loginUser.userName);
|
|
1137
|
+
flowSummary = this.$this.platStringUtil.replaceAll(flowSummary, "${createTime*}", this.$this.DATE_UTIL.getCurrentDateTime());
|
|
1138
|
+
} else {
|
|
1139
|
+
flowSummary = this.$this.platStringUtil.replaceAll(summarySet, "${startUserName*}", this.currentStartUser);
|
|
1140
|
+
flowSummary = this.$this.platStringUtil.replaceAll(flowSummary, "${createTime*}", this.currentStartTime);
|
|
1141
|
+
}
|
|
1142
|
+
flowSummary = this.$this.platStringUtil.replaceAll(flowSummary, "${flowName*}", this.flowDefine.flowName);
|
|
1143
|
+
if (this.flowDefine.summaryNameId) {
|
|
1144
|
+
// flowSummary = flowSummary.toUpperCase();
|
|
1145
|
+
let summaryNameId = JSON.parse(this.flowDefine.summaryNameId);
|
|
1146
|
+
Object.keys(summaryNameId).forEach(fieldName => {
|
|
1147
|
+
let fieldId = summaryNameId[fieldName];
|
|
1148
|
+
if (fieldName && dataObj.hasOwnProperty(fieldId)) {
|
|
1149
|
+
let replaceVal = dataObj[fieldId];
|
|
1150
|
+
if(dataObj[fieldId + "_SASP_SYS_DATA"]){
|
|
1151
|
+
replaceVal = dataObj[fieldId+ "_SASP_SYS_DATA"];
|
|
1152
|
+
}
|
|
1153
|
+
if(dataObj[fieldId + "_sequence"]){ // 自增序列
|
|
1154
|
+
replaceVal = dataObj[fieldId + "_sequence"];
|
|
1155
|
+
}
|
|
1156
|
+
flowSummary = this.$this.platStringUtil.replaceAll(flowSummary, "${" + fieldName + "}", replaceVal);
|
|
1157
|
+
}else if(fieldName && dataObj.hasOwnProperty(fieldName)){
|
|
1158
|
+
let replaceVal = dataObj[fieldName];
|
|
1159
|
+
if(dataObj[fieldName + "_SASP_SYS_DATA"]){
|
|
1160
|
+
replaceVal = dataObj[fieldName+ "_SASP_SYS_DATA"];
|
|
1161
|
+
}
|
|
1162
|
+
if(dataObj[fieldName + "_sequence"]){ // 自增序列
|
|
1163
|
+
replaceVal = dataObj[fieldName + "_sequence"];
|
|
1164
|
+
}
|
|
1165
|
+
flowSummary = this.$this.platStringUtil.replaceAll(flowSummary, "${" + fieldName + "}", replaceVal);
|
|
1166
|
+
}else{
|
|
1167
|
+
flowSummary = this.$this.platStringUtil.replaceAll(flowSummary, "${" + fieldName + "}", "");
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
return flowSummary;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* 加载工作流脚本与工作流事件规则
|
|
1177
|
+
*/
|
|
1178
|
+
initFlowScript(flowId){
|
|
1179
|
+
if (flowId) {
|
|
1180
|
+
this.flowDefine = this.flowDefineByFlowId[flowId] || {};
|
|
1181
|
+
}
|
|
1182
|
+
return new Promise(resolve => {
|
|
1183
|
+
this.$this.saspFlowAxios.all([
|
|
1184
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowScript.find,{"flowId": this.flowDefine.id}),
|
|
1185
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowEventDetail.findByFlowAndLeadFunc,{"flowId": this.flowDefine.id,"version":this.flowDefine.flowVersion || "1.0"})
|
|
1186
|
+
]).then(this.$this.saspFlowAxios.spread((resScript, resEvent) => {
|
|
1187
|
+
// 流程脚本
|
|
1188
|
+
if(resScript){
|
|
1189
|
+
let scriptDatas = resScript.data || [];
|
|
1190
|
+
// 脚本order排序
|
|
1191
|
+
scriptDatas = scriptDatas.sort(sortScript);
|
|
1192
|
+
function sortScript(a,b){
|
|
1193
|
+
return Number(a.scriptOrder) - Number(b.scriptOrder);
|
|
1194
|
+
}
|
|
1195
|
+
// 根据节点区分
|
|
1196
|
+
let scriptObj = {};
|
|
1197
|
+
let arr = ['vm','axios','CTX','formData','LOGINUSER','Ajax','nextNode','resolve'];
|
|
1198
|
+
scriptDatas.forEach(item => {
|
|
1199
|
+
// 添加修改是单独区分开,没有节点概念
|
|
1200
|
+
if(item.executePosition == "add" || item.executePosition == "update"){
|
|
1201
|
+
if(!scriptObj[item.executePosition]){
|
|
1202
|
+
scriptObj[item.executePosition] = {};
|
|
1203
|
+
}
|
|
1204
|
+
if(!scriptObj[item.executePosition][item.executeTime]){
|
|
1205
|
+
scriptObj[item.executePosition][item.executeTime] = [];
|
|
1206
|
+
}
|
|
1207
|
+
try{
|
|
1208
|
+
if(item.content){
|
|
1209
|
+
let value = item.content;
|
|
1210
|
+
value = this.replaceUrl(value);
|
|
1211
|
+
item.content = value;
|
|
1212
|
+
}
|
|
1213
|
+
scriptObj[item.executePosition][item.executeTime].push(new Function(...arr,item.content));
|
|
1214
|
+
}catch (e) {
|
|
1215
|
+
console.log(item.content);
|
|
1216
|
+
console.log("脚本编译失败!");
|
|
1217
|
+
}
|
|
1218
|
+
}else{
|
|
1219
|
+
if(!scriptObj[item.nodeId]){
|
|
1220
|
+
scriptObj[item.nodeId] = {};
|
|
1221
|
+
}
|
|
1222
|
+
let nodeObj = scriptObj[item.nodeId]; // 节点的所有内容
|
|
1223
|
+
if(!nodeObj[item.executePosition]){
|
|
1224
|
+
nodeObj[item.executePosition] = {};
|
|
1225
|
+
}
|
|
1226
|
+
let positionObj = nodeObj[item.executePosition]; // 脚本的执行位置,add,update,deal,等
|
|
1227
|
+
if(!positionObj[item.executeTime]){
|
|
1228
|
+
positionObj[item.executeTime] = [];
|
|
1229
|
+
}
|
|
1230
|
+
let executeTimeArr = positionObj[item.executeTime]; // 在该时间对应的脚本内容数组
|
|
1231
|
+
try{
|
|
1232
|
+
if(item.content){
|
|
1233
|
+
let value = item.content;
|
|
1234
|
+
value = this.replaceUrl(value);
|
|
1235
|
+
item.content = value;
|
|
1236
|
+
}
|
|
1237
|
+
executeTimeArr.push(new Function(...arr,item.content));
|
|
1238
|
+
}catch (e) {
|
|
1239
|
+
console.log(item.content);
|
|
1240
|
+
console.log("脚本编译失败!");
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
})
|
|
1244
|
+
this.scriptObj = scriptObj;
|
|
1245
|
+
}
|
|
1246
|
+
// 流程事件规则
|
|
1247
|
+
if(resEvent){
|
|
1248
|
+
let eventDataArr = resEvent.data || [];
|
|
1249
|
+
let scriptObj = {};
|
|
1250
|
+
let eventObj = {};
|
|
1251
|
+
let arr = ['vm','axios','CTX','formData','LOGINUSER','Ajax','nextNode','resolve'];
|
|
1252
|
+
eventDataArr.forEach(item =>{
|
|
1253
|
+
let executeTypeArr = (item.executeType || '').split(",");
|
|
1254
|
+
executeTypeArr.forEach(executeType =>{
|
|
1255
|
+
if (item.source == 'diy'){
|
|
1256
|
+
//自定义
|
|
1257
|
+
// 添加是单独区分开,没有节点概念
|
|
1258
|
+
if(executeType == "addAfter"){
|
|
1259
|
+
if(!scriptObj[executeType]){
|
|
1260
|
+
scriptObj[executeType] = [];
|
|
1261
|
+
}
|
|
1262
|
+
try{
|
|
1263
|
+
if(item.funcBody){ //方法体
|
|
1264
|
+
let value = item.funcBody;
|
|
1265
|
+
value = this.replaceUrl(value);
|
|
1266
|
+
item.funcBody = value;
|
|
1267
|
+
}
|
|
1268
|
+
scriptObj[executeType].push(new Function(...arr,item.funcBody));
|
|
1269
|
+
}catch (e) {
|
|
1270
|
+
console.log(item.funcBody);
|
|
1271
|
+
console.log("脚本编译失败!");
|
|
1272
|
+
}
|
|
1273
|
+
}else{
|
|
1274
|
+
if(!scriptObj[item.nodeKey]){
|
|
1275
|
+
scriptObj[item.nodeKey] = {};
|
|
1276
|
+
}
|
|
1277
|
+
let nodeObj = scriptObj[item.nodeKey]; // 节点的所有内容
|
|
1278
|
+
if(!nodeObj[executeType]){
|
|
1279
|
+
nodeObj[executeType] = [];
|
|
1280
|
+
}
|
|
1281
|
+
let positionArr = nodeObj[executeType]; // 脚本的执行位置,add,update,deal,等
|
|
1282
|
+
try{
|
|
1283
|
+
if(item.funcBody){
|
|
1284
|
+
let value = item.funcBody;
|
|
1285
|
+
value = this.replaceUrl(value);
|
|
1286
|
+
item.funcBody = value;
|
|
1287
|
+
}
|
|
1288
|
+
positionArr.push(new Function(...arr,item.funcBody));
|
|
1289
|
+
}catch (e) {
|
|
1290
|
+
console.log(item.funcBody);
|
|
1291
|
+
console.log("脚本编译失败!");
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
this.newScriptObj = scriptObj;
|
|
1295
|
+
}else if(item.source == 'event'){ //事件规则
|
|
1296
|
+
//获取响应配置
|
|
1297
|
+
// 添加单独区分开,没有节点概念
|
|
1298
|
+
if(executeType == "addAfter"){
|
|
1299
|
+
if(!eventObj[executeType]){
|
|
1300
|
+
eventObj[executeType] = {};
|
|
1301
|
+
}
|
|
1302
|
+
try{
|
|
1303
|
+
if(item.resConfigurateion){ //响应配置
|
|
1304
|
+
let resConfigurateionObj = JSON.parse(item.resConfigurateion || "{}");
|
|
1305
|
+
let eventKey = resConfigurateionObj.eventKey;
|
|
1306
|
+
if(!eventObj[executeType][eventKey]){
|
|
1307
|
+
eventObj[executeType][eventKey] = [];
|
|
1308
|
+
}
|
|
1309
|
+
eventObj[executeType][eventKey].push(resConfigurateionObj); //复制响应配置
|
|
1310
|
+
}
|
|
1311
|
+
}catch (e) {
|
|
1312
|
+
console.log(item.funcBody);
|
|
1313
|
+
console.log("脚本编译失败!");
|
|
1314
|
+
}
|
|
1315
|
+
}else{
|
|
1316
|
+
if(!eventObj[item.nodeKey]){
|
|
1317
|
+
eventObj[item.nodeKey] = {};
|
|
1318
|
+
}
|
|
1319
|
+
let nodeObj = eventObj[item.nodeKey]; // 节点的所有内容
|
|
1320
|
+
if(!nodeObj[executeType]){
|
|
1321
|
+
nodeObj[executeType] = {};
|
|
1322
|
+
}
|
|
1323
|
+
let positionObj = nodeObj[executeType]; // 脚本的执行位置,add,update,deal,等
|
|
1324
|
+
try{
|
|
1325
|
+
if(item.resConfigurateion){//响应配置
|
|
1326
|
+
let resConfigurateionObj = JSON.parse(item.resConfigurateion || "{}");
|
|
1327
|
+
let eventKey = resConfigurateionObj.eventKey;
|
|
1328
|
+
if(!positionObj[eventKey]){
|
|
1329
|
+
positionObj[eventKey] = [];
|
|
1330
|
+
}
|
|
1331
|
+
positionObj[eventKey].push(resConfigurateionObj); //复制响应配\
|
|
1332
|
+
}
|
|
1333
|
+
}catch (e) {
|
|
1334
|
+
console.log(item.funcBody);
|
|
1335
|
+
console.log("脚本编译失败!");
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
this.newEventObj = eventObj;
|
|
1339
|
+
}
|
|
1340
|
+
});
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
// 结束
|
|
1344
|
+
let obj = {"scriptObj": this.scriptObj, "newScriptObj": this.newScriptObj, "newEventObj": this.newEventObj};
|
|
1345
|
+
resolve({[flowId]: obj});
|
|
1346
|
+
}));
|
|
1347
|
+
})
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* 执行下一步
|
|
1352
|
+
* @returns {Promise<boolean>} 是否继续流程
|
|
1353
|
+
*/
|
|
1354
|
+
async executeNextStep() {
|
|
1355
|
+
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
/**
|
|
1359
|
+
* 取消当前流程
|
|
1360
|
+
*/
|
|
1361
|
+
cancel() {
|
|
1362
|
+
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
// 脚本执行区
|
|
1366
|
+
|
|
1367
|
+
setFlowScript(flowId) {
|
|
1368
|
+
if (flowId) {
|
|
1369
|
+
let scriptObj = this.flowEventScriptByFlowId[flowId] || {};
|
|
1370
|
+
this.scriptObj = scriptObj.scriptObj || {};
|
|
1371
|
+
this.newScriptObj = scriptObj.newScriptObj || {};
|
|
1372
|
+
this.newEventObj = scriptObj.newEventObj || {};
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
runFlowEvt(){
|
|
1377
|
+
// let afterClickResult;
|
|
1378
|
+
let currentNodeObj = this.flowNodeIdToInfo[this.currentInst.currentNode || this.draftNodeId] ||{};
|
|
1379
|
+
if(currentNodeObj.openEvent == '1'){
|
|
1380
|
+
this.exeNewFlowEvent("saveAfter", currentNodeObj.nodeLinkId);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* 执行工作流脚本,为兼容1.0版本定制
|
|
1386
|
+
*/
|
|
1387
|
+
exeFlowEvent(executePosition,executeTime,nodeId){
|
|
1388
|
+
// executePosition(为方便1.0转换,与1.0保持相同):add/update/handle/nextStep/view/columnFormatter
|
|
1389
|
+
// executePosition:add:['afterClick'],update:['afterClick'],handle:['afterClick'],
|
|
1390
|
+
// nextStep:['afterClick','afterValidate','submitSuccess'],view:['afterClick'],
|
|
1391
|
+
// (columnFormatter:['finished','end']?暂时不用)
|
|
1392
|
+
let formData = {};
|
|
1393
|
+
if(this.getFormInfo){
|
|
1394
|
+
formData = this.getFormInfo();
|
|
1395
|
+
}
|
|
1396
|
+
let CTX = "";
|
|
1397
|
+
let paramValues = [this.$this,this.$this.saspFlowAxios,CTX,formData,this.loginUser,AjaxUtil,this.nextNode,null]; // 入参
|
|
1398
|
+
if(executePosition == "add" || executePosition == "update"){
|
|
1399
|
+
((this.scriptObj[executePosition] || {})[executeTime] || []).forEach(event => {
|
|
1400
|
+
event && event(...paramValues); // 执行事件
|
|
1401
|
+
});
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
let eventArr = ((this.scriptObj[nodeId] || {})[executePosition] || {})[executeTime] || [];
|
|
1405
|
+
let result=true;
|
|
1406
|
+
try{
|
|
1407
|
+
eventArr.forEach(event => {
|
|
1408
|
+
let eventResult=event && event(...paramValues); // 执行事件
|
|
1409
|
+
if(eventResult ==false){
|
|
1410
|
+
throw new Error("ending");//报错,就跳出循环
|
|
1411
|
+
}
|
|
1412
|
+
})
|
|
1413
|
+
}catch (e) {
|
|
1414
|
+
console.log(e);
|
|
1415
|
+
result=false;
|
|
1416
|
+
}
|
|
1417
|
+
return result;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* 执行工作流新版本事件规则
|
|
1422
|
+
*/
|
|
1423
|
+
exeNewFlowEvent(executeType,nodeKey){
|
|
1424
|
+
let formData = {};
|
|
1425
|
+
if(this.getFormInfo){
|
|
1426
|
+
formData = this.getFormInfo();
|
|
1427
|
+
}
|
|
1428
|
+
//执行自定义脚本
|
|
1429
|
+
// let CTX = window.JAVA_URL;
|
|
1430
|
+
let CTX = "";
|
|
1431
|
+
let paramValues = [this.$this,this.$this.saspFlowAxios,CTX,formData,this.loginUser,AjaxUtil,this.nextNode]; // 入参
|
|
1432
|
+
if(executeType == "addAfter"){ //新增或后
|
|
1433
|
+
(this.newScriptObj[executeType] || []).forEach(event => {
|
|
1434
|
+
event && event(...paramValues); // 执行事件
|
|
1435
|
+
});
|
|
1436
|
+
|
|
1437
|
+
//执行事件规则脚本
|
|
1438
|
+
Object.keys(this.newEventObj[executeType] || {}).forEach(eventKey =>{
|
|
1439
|
+
if(this.installListObj[eventKey]
|
|
1440
|
+
&& this.installListObj[eventKey]["config"]
|
|
1441
|
+
&& this.installListObj[eventKey]["config"].methods.renderFlowConfig){
|
|
1442
|
+
let affectContentArr = this.newEventObj[executeType][eventKey] || [];
|
|
1443
|
+
affectContentArr.forEach(affectContent =>{
|
|
1444
|
+
this.installListObj[eventKey]["config"].methods.renderFlowConfig(this.$this,this.$this.CTX,this.$this.saspFlowAxios,this.nextNode,formData,affectContent);
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
});
|
|
1448
|
+
return;
|
|
1449
|
+
}
|
|
1450
|
+
let eventArr = (this.newScriptObj[nodeKey] || {})[executeType] || [];
|
|
1451
|
+
let result=true;
|
|
1452
|
+
try{
|
|
1453
|
+
eventArr.forEach(event => {
|
|
1454
|
+
let eventResult=event && event(...paramValues); // 执行事件
|
|
1455
|
+
if(eventResult ==false){
|
|
1456
|
+
throw new Error("ending");//报错,就跳出循环
|
|
1457
|
+
}
|
|
1458
|
+
});
|
|
1459
|
+
|
|
1460
|
+
let eventObj = (this.newEventObj[nodeKey] || {})[executeType] || {};
|
|
1461
|
+
Object.keys(eventObj).forEach(eventKey =>{
|
|
1462
|
+
if(this.installListObj[eventKey]
|
|
1463
|
+
&& this.installListObj[eventKey]["config"]
|
|
1464
|
+
&& this.installListObj[eventKey]["config"].methods.renderFlowConfig){
|
|
1465
|
+
let affectContentArr = eventObj[eventKey] || [];
|
|
1466
|
+
affectContentArr.forEach(affectContent =>{
|
|
1467
|
+
this.installListObj[eventKey]["config"].methods.renderFlowConfig(this.$this,this.$this.CTX,this.$this.saspFlowAxios,this.nextNode,formData,affectContent,executeType);
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1470
|
+
});
|
|
1471
|
+
}catch (e) {
|
|
1472
|
+
console.log(e);
|
|
1473
|
+
result=false;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
return result;
|
|
1477
|
+
|
|
1478
|
+
}
|
|
1479
|
+
// end脚本执行结束
|
|
1480
|
+
|
|
1481
|
+
|
|
1482
|
+
// buttonMethod,按钮方法
|
|
1483
|
+
|
|
1484
|
+
// 打开前方法
|
|
1485
|
+
/**
|
|
1486
|
+
* 打开[添加]窗口
|
|
1487
|
+
*/
|
|
1488
|
+
openAddFlowForm() {
|
|
1489
|
+
return new Promise(resolve => {
|
|
1490
|
+
this.init().then(() => {
|
|
1491
|
+
let nowVersion = this.flowDefine.releaseVersion; //只要已发布最小版本为1.0
|
|
1492
|
+
this.currentRowData = {};
|
|
1493
|
+
this.initFieldStatus(this.startNodeKeyObj[nowVersion],nowVersion).then(()=>{
|
|
1494
|
+
this.flowInstDataDialog = true;
|
|
1495
|
+
this.$flowDialog.operateDialog('flowInstDataDialog',true);
|
|
1496
|
+
this.$this.$nextTick(() => {
|
|
1497
|
+
this.initFormInfoFunc('add').then(() => {
|
|
1498
|
+
this.formBtnArr = this.getAddAndUpdateFormBtn({});
|
|
1499
|
+
Object.assign(this.formInfo, {
|
|
1500
|
+
dataId: "",
|
|
1501
|
+
opt: "add"
|
|
1502
|
+
});
|
|
1503
|
+
this.currentInst = {};
|
|
1504
|
+
this.$this.$nextTick(() => {
|
|
1505
|
+
this.exeFlowEvent("add","afterClick");
|
|
1506
|
+
let startNodeKey = this.startNodeKeyObj[nowVersion];
|
|
1507
|
+
let startNodeObj = this.flowVersionNodeObj[nowVersion][startNodeKey] || {};
|
|
1508
|
+
if(startNodeObj.openEvent == '1'){
|
|
1509
|
+
this.exeNewFlowEvent("addAfter");//新事件规则
|
|
1510
|
+
}
|
|
1511
|
+
})
|
|
1512
|
+
let result = {
|
|
1513
|
+
currentRowData: this.currentRowData,
|
|
1514
|
+
formBtnArr: this.formBtnArr,
|
|
1515
|
+
currentInst: this.currentInst,
|
|
1516
|
+
formInfo: this.formInfo
|
|
1517
|
+
};
|
|
1518
|
+
this.$flowDialog.fillFlowDialogParams(result);
|
|
1519
|
+
resolve(result);
|
|
1520
|
+
})
|
|
1521
|
+
});
|
|
1522
|
+
});
|
|
1523
|
+
})
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
initFormInfoFunc(type,rowData){
|
|
1528
|
+
if(!rowData){
|
|
1529
|
+
rowData = {};
|
|
1530
|
+
}
|
|
1531
|
+
let dataId = rowData.dataId || "";
|
|
1532
|
+
let nodeObjs = this.flowVersionNodeObj[this.flowDefine.releaseVersion];
|
|
1533
|
+
let startNodeKey = this.startNodeKeyObj[rowData.version];
|
|
1534
|
+
let nodeKey = rowData.nodeKey;
|
|
1535
|
+
let currentNode = nodeObjs[nodeKey || startNodeKey];
|
|
1536
|
+
if(type === 'add'){
|
|
1537
|
+
let version = this.flowDefine.releaseVersion;
|
|
1538
|
+
currentNode = this.flowVersionNodeObj[version][this.startNodeKeyObj[version]];
|
|
1539
|
+
}
|
|
1540
|
+
let result = {
|
|
1541
|
+
draftNodeId: this.draftNodeId,
|
|
1542
|
+
// operateType : this.operateType,
|
|
1543
|
+
// tabActive : this.tabActive,
|
|
1544
|
+
flowDefine : this.flowDefine,
|
|
1545
|
+
startNodeKey : this.startNodeKey,
|
|
1546
|
+
startNodeKeyObj : this.startNodeKeyObj,
|
|
1547
|
+
flowVersionNodeObj : this.flowVersionNodeObj,
|
|
1548
|
+
allNodeInfo : this.allNodeInfo,
|
|
1549
|
+
flowNodeNameObj : this.flowNodeNameObj,
|
|
1550
|
+
flowNodeIdToInfo : this.flowNodeIdToInfo,
|
|
1551
|
+
nodeListButtonObj : this.nodeListButtonObj,
|
|
1552
|
+
nodeFormButtonObj : this.nodeFormButtonObj,
|
|
1553
|
+
nodeFormBtnObj : this.nodeFormBtnObj,
|
|
1554
|
+
// optColumnWidth : this.optColumnWidth,
|
|
1555
|
+
diyButtonsObj : this.diyButtonsObj,
|
|
1556
|
+
};
|
|
1557
|
+
this.$flowDialog.fillFlowDialogParams(result);
|
|
1558
|
+
return new Promise(resolve => {
|
|
1559
|
+
if(this.initFormInfo){
|
|
1560
|
+
let promise = this.initFormInfo(type,dataId,JSON.parse(currentNode.fieldOperate || "{}"),rowData);
|
|
1561
|
+
this.forceUpdateComponent && this.forceUpdateComponent();
|
|
1562
|
+
if(promise.then){
|
|
1563
|
+
promise.then(() => {
|
|
1564
|
+
resolve();
|
|
1565
|
+
})
|
|
1566
|
+
}else{
|
|
1567
|
+
resolve();
|
|
1568
|
+
}
|
|
1569
|
+
} else{
|
|
1570
|
+
resolve();
|
|
1571
|
+
}
|
|
1572
|
+
})
|
|
1573
|
+
}
|
|
1574
|
+
/**
|
|
1575
|
+
* 打开[修改和处理]窗口
|
|
1576
|
+
*/
|
|
1577
|
+
initUpdateFlowForm(row, type) {
|
|
1578
|
+
this.currentRowData = row;
|
|
1579
|
+
this.currNodeName = 'noEnd';
|
|
1580
|
+
if (this.flowId.includes(',')) {
|
|
1581
|
+
this.flowDefine = this.flowDefineByFlowId[row.flowId];
|
|
1582
|
+
this.startNodeKeyObj = this.startNodeKeyObjByFlowId[row.flowId];
|
|
1583
|
+
this.flowVersionNodeObj = this.flowVersionNodeObjByFlowId[row.flowId];
|
|
1584
|
+
this.initFlowObj();
|
|
1585
|
+
// 加载工作流脚本与工作流事件规则
|
|
1586
|
+
// this.initFlowScript();
|
|
1587
|
+
// Object.assign(this.formInfo, this.formInfoByFlowId[row.flowId]);
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
return new Promise(resolve => {
|
|
1591
|
+
let startNodeKey = this.startNodeKeyObj[row.version];
|
|
1592
|
+
this.initFieldStatus(row.nodeKey || startNodeKey,row.version).then(()=>{
|
|
1593
|
+
this.initFormInfoFunc(type,row).then(() => {
|
|
1594
|
+
this.currentStartUser = this.userMap[row.startUserId] || "";
|
|
1595
|
+
this.currentStartTime = row.startTime;
|
|
1596
|
+
this.currentInst = row;
|
|
1597
|
+
|
|
1598
|
+
Object.assign(this.formInfo, {
|
|
1599
|
+
dataId: row.dataId,
|
|
1600
|
+
opt: "update"
|
|
1601
|
+
});
|
|
1602
|
+
this.formBtnArr = this.getAddAndUpdateFormBtn(row);
|
|
1603
|
+
let result = {
|
|
1604
|
+
currentRowData: this.currentRowData,
|
|
1605
|
+
currNodeName : this.currNodeName,
|
|
1606
|
+
flowDefine: this.flowDefine,
|
|
1607
|
+
startNodeKeyObj: this.startNodeKeyObj,
|
|
1608
|
+
flowVersionNodeObj: this.flowVersionNodeObj,
|
|
1609
|
+
currentStartUser : this.currentStartUser,
|
|
1610
|
+
currentStartTime : this.currentStartTime,
|
|
1611
|
+
currentInst : this.currentInst,
|
|
1612
|
+
formInfo : this.formInfo,
|
|
1613
|
+
formBtnArr : this.formBtnArr,
|
|
1614
|
+
dataId : row.dataId
|
|
1615
|
+
}
|
|
1616
|
+
resolve(result);
|
|
1617
|
+
});
|
|
1618
|
+
})
|
|
1619
|
+
})
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
/**
|
|
1623
|
+
* 打开[修改和处理]窗口
|
|
1624
|
+
*/
|
|
1625
|
+
openUpdateFlowForm(row,executePosition) {
|
|
1626
|
+
return new Promise(resolve => {
|
|
1627
|
+
this.init().then(() => {
|
|
1628
|
+
if (this.flowId.includes(",")) {
|
|
1629
|
+
this.setFlowScript(row.flowId);
|
|
1630
|
+
}
|
|
1631
|
+
this.currentRowData = row;
|
|
1632
|
+
this.currNodeName = 'noEnd';
|
|
1633
|
+
let currentNodeObj1 = this.flowNodeIdToInfo[row.currentNode] ||{};
|
|
1634
|
+
let result = this.exeNewFlowEvent("editBefore",currentNodeObj1.nodeLinkId ||'');//新事件规则
|
|
1635
|
+
if(result === false && typeof result == "boolean"){
|
|
1636
|
+
return;
|
|
1637
|
+
}
|
|
1638
|
+
this.flowInstDataDialog = true;
|
|
1639
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
1640
|
+
flowDefine: this.flowDefine,
|
|
1641
|
+
formInfo: this.formInfo
|
|
1642
|
+
});
|
|
1643
|
+
this.$flowDialog.operateDialog('flowInstDataDialog',true);
|
|
1644
|
+
this.initUpdateFlowForm(row, 'update').then(() =>{
|
|
1645
|
+
this.$this.$nextTick(() => {
|
|
1646
|
+
this.exeFlowEvent(executePosition,"afterClick",row.currentNode);
|
|
1647
|
+
let currentNodeObj = this.flowNodeIdToInfo[row.currentNode] ||{};
|
|
1648
|
+
if(currentNodeObj.openEvent === '1'){ //开启事件
|
|
1649
|
+
this.exeNewFlowEvent("editAfter",currentNodeObj.nodeLinkId ||'');//新事件规则
|
|
1650
|
+
}
|
|
1651
|
+
let result = {
|
|
1652
|
+
currentRowData: this.currentRowData,
|
|
1653
|
+
currNodeName : this.currNodeName,
|
|
1654
|
+
flowDefine: this.flowDefine,
|
|
1655
|
+
startNodeKeyObj: this.startNodeKeyObj,
|
|
1656
|
+
flowVersionNodeObj: this.flowVersionNodeObj,
|
|
1657
|
+
currentStartUser : this.currentStartUser,
|
|
1658
|
+
currentStartTime : this.currentStartTime,
|
|
1659
|
+
currentInst : this.currentInst,
|
|
1660
|
+
formInfo : this.formInfo,
|
|
1661
|
+
formBtnArr : this.formBtnArr
|
|
1662
|
+
}
|
|
1663
|
+
this.$flowDialog.fillFlowDialogParams(result);
|
|
1664
|
+
resolve(result);
|
|
1665
|
+
})
|
|
1666
|
+
});
|
|
1667
|
+
});
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
/**
|
|
1672
|
+
* 打开[查看]窗口
|
|
1673
|
+
*/
|
|
1674
|
+
openViewFlowForm(row) {
|
|
1675
|
+
return new Promise(resolve => {
|
|
1676
|
+
this.init().then(() => {
|
|
1677
|
+
this.currentRowData = row;
|
|
1678
|
+
let startNodeKey = this.startNodeKeyObj[row.version];
|
|
1679
|
+
if (row.currentNodeName === "结束"){
|
|
1680
|
+
this.currNodeName = "end";
|
|
1681
|
+
}
|
|
1682
|
+
this.initFieldStatus(row.nodeKey || startNodeKey,row.version,row.flowStatus).then(() =>{
|
|
1683
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
1684
|
+
flowDefine: this.flowDefine,
|
|
1685
|
+
formInfo: this.formInfo
|
|
1686
|
+
});
|
|
1687
|
+
this.flowInstDataDialog = true;
|
|
1688
|
+
this.$flowDialog.operateDialog('flowInstDataDialog',true);
|
|
1689
|
+
this.$this.$nextTick(() => {
|
|
1690
|
+
this.initFormInfoFunc('view',row).then(() => {
|
|
1691
|
+
this.currentStartUser = this.userMap[row.startUserId] || "";
|
|
1692
|
+
this.currentStartTime = row.startTime;
|
|
1693
|
+
this.currentInst = row;
|
|
1694
|
+
|
|
1695
|
+
Object.assign(this.formInfo, {
|
|
1696
|
+
dataId: row.dataId,
|
|
1697
|
+
opt: "view",
|
|
1698
|
+
});
|
|
1699
|
+
this.formBtnArr = this.getViewFormBtn(row);
|
|
1700
|
+
let result = {
|
|
1701
|
+
currentRowData: this.currentRowData,
|
|
1702
|
+
currNodeName : this.currNodeName,
|
|
1703
|
+
currentStartUser : this.currentStartUser,
|
|
1704
|
+
currentStartTime : this.currentStartTime,
|
|
1705
|
+
currentInst : this.currentInst,
|
|
1706
|
+
formInfo : this.formInfo,
|
|
1707
|
+
formBtnArr : this.formBtnArr,
|
|
1708
|
+
}
|
|
1709
|
+
this.$flowDialog.fillFlowDialogParams(result);
|
|
1710
|
+
resolve(result);
|
|
1711
|
+
});
|
|
1712
|
+
});
|
|
1713
|
+
});
|
|
1714
|
+
});
|
|
1715
|
+
})
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
// 打开前方法end
|
|
1719
|
+
|
|
1720
|
+
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* 存草稿
|
|
1724
|
+
*/
|
|
1725
|
+
saveDraft() {
|
|
1726
|
+
// let loading = this.$this.$loading({
|
|
1727
|
+
// lock: true,
|
|
1728
|
+
// spinner: 'el-icon-loading',
|
|
1729
|
+
// background: 'rgba(0, 0, 0, 0.7)'
|
|
1730
|
+
// })
|
|
1731
|
+
|
|
1732
|
+
this.saveDataFunc('draft').then(resData => {
|
|
1733
|
+
this.tabCrudSearch && this.tabCrudSearch(); // todo 回调刷新方法,初始化置入即可
|
|
1734
|
+
|
|
1735
|
+
this.flowInstDataDialog = false;
|
|
1736
|
+
this.$flowDialog.operateDialog('flowInstDataDialog',false);
|
|
1737
|
+
if (resData.flowInstId) {
|
|
1738
|
+
this.$this.$message({type: "success", message: "保存成功!"});
|
|
1739
|
+
if (this.getFlowBatchDialog && this.getFlowBatchDialog()) {//批量处理 需处理tab页
|
|
1740
|
+
this.batchSaveDraft();
|
|
1741
|
+
}
|
|
1742
|
+
} else {
|
|
1743
|
+
this.$this.$message({type: "error", message: "保存失败!"});
|
|
1744
|
+
}
|
|
1745
|
+
// loading && loading.close();
|
|
1746
|
+
this.currentInst={};
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
/**
|
|
1751
|
+
* 批量处理存草稿
|
|
1752
|
+
*/
|
|
1753
|
+
batchSaveDraft() {
|
|
1754
|
+
this.batchTabRemove(this.currentInst.dataId);
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
/**
|
|
1758
|
+
* 回退到上一步
|
|
1759
|
+
*/
|
|
1760
|
+
backToPrevious() {
|
|
1761
|
+
let loading = this.$this.$loading({
|
|
1762
|
+
lock: true,
|
|
1763
|
+
text: '正在退回,请稍后....',
|
|
1764
|
+
spinner: 'el-icon-loading',
|
|
1765
|
+
background: 'rgba(0, 0, 0, 0.7)'
|
|
1766
|
+
})
|
|
1767
|
+
let currentInst = this.currentInst;
|
|
1768
|
+
this.$this.$prompt('退回备注', '确定要退回至上一个节点吗?', {
|
|
1769
|
+
confirmButtonText: '确定',
|
|
1770
|
+
cancelButtonText: '取消',
|
|
1771
|
+
inputType: 'textarea',
|
|
1772
|
+
}).then(({ value }) => {
|
|
1773
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.backRewrite,
|
|
1774
|
+
{
|
|
1775
|
+
taskId:currentInst.taskId,
|
|
1776
|
+
remarks: value
|
|
1777
|
+
}).then(res => {
|
|
1778
|
+
if (res && res.data && res.data.operateSuccess) {
|
|
1779
|
+
this.$this.$message({type: "success", message: "退回成功!"});
|
|
1780
|
+
let currentNodeObj = this.flowNodeIdToInfo[currentInst.currentNode] ||{};
|
|
1781
|
+
this.exeNewFlowEvent("backSubmit",currentNodeObj.nodeLinkId);
|
|
1782
|
+
this.backSubmitEvent && this.backSubmitEvent(this.$this,this,currentInst);
|
|
1783
|
+
this.initTabNum && this.initTabNum();
|
|
1784
|
+
if (this.getFlowBatchDialog && this.getFlowBatchDialog()) {
|
|
1785
|
+
this.batchTabRemove(this.currentInst.dataId);
|
|
1786
|
+
} else {
|
|
1787
|
+
this.tabCrudSearch && this.tabCrudSearch();
|
|
1788
|
+
}
|
|
1789
|
+
} else {
|
|
1790
|
+
this.$this.$message({type: "error", message: res.data.operateMessage});
|
|
1791
|
+
}
|
|
1792
|
+
loading && loading.close();
|
|
1793
|
+
this.flowInstDataDialog = false;
|
|
1794
|
+
this.$flowDialog.operateDialog('flowInstDataDialog',false);
|
|
1795
|
+
})
|
|
1796
|
+
}).catch(() => {
|
|
1797
|
+
loading && loading.close();
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
|
|
1802
|
+
/**
|
|
1803
|
+
* 取回
|
|
1804
|
+
*/
|
|
1805
|
+
getBackPrevious() {
|
|
1806
|
+
let loading = this.$this.$loading({
|
|
1807
|
+
lock: true,
|
|
1808
|
+
text: '正在取回,请稍后....',
|
|
1809
|
+
spinner: 'el-icon-loading',
|
|
1810
|
+
background: 'rgba(0, 0, 0, 0.7)'
|
|
1811
|
+
})
|
|
1812
|
+
let currentInst = this.currentInst;
|
|
1813
|
+
this.$this.$confirm('确定要取回吗?', '警告', {
|
|
1814
|
+
confirmButtonText: '确定',
|
|
1815
|
+
cancelButtonText: '取消',
|
|
1816
|
+
}).then(() => {
|
|
1817
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.getBackRewrite,
|
|
1818
|
+
{
|
|
1819
|
+
flowInstId: currentInst.flowInstId,
|
|
1820
|
+
}).then(res => {
|
|
1821
|
+
if (res && res.data && res.data.operateSuccess) {
|
|
1822
|
+
this.$this.$message({type: "success", message: "取回成功!"});
|
|
1823
|
+
let currentNodeObj = this.flowNodeIdToInfo[currentInst.currentNode] ||{};
|
|
1824
|
+
this.exeNewFlowEvent("getBackSubmit",currentNodeObj.nodeLinkId);
|
|
1825
|
+
this.getBackSubmitEvent && this.getBackSubmitEvent(this.$this,this,currentInst);
|
|
1826
|
+
this.initTabNum && this.initTabNum();
|
|
1827
|
+
if (this.getFlowBatchDialog && this.getFlowBatchDialog()) {
|
|
1828
|
+
this.batchTabRemove(this.currentInst.dataId);
|
|
1829
|
+
} else {
|
|
1830
|
+
this.tabCrudSearch && this.tabCrudSearch();
|
|
1831
|
+
}
|
|
1832
|
+
} else {
|
|
1833
|
+
this.$this.$message({type: "error", message: res.data.operateMessage});
|
|
1834
|
+
}
|
|
1835
|
+
loading && loading.close();
|
|
1836
|
+
this.flowInstDataDialog = false;
|
|
1837
|
+
this.$flowDialog.operateDialog('flowInstDataDialog',false);
|
|
1838
|
+
})
|
|
1839
|
+
}).catch(() => {
|
|
1840
|
+
loading && loading.close();
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
/**
|
|
1845
|
+
* 打开退回节点窗口
|
|
1846
|
+
*/
|
|
1847
|
+
retSpecified(currentInst){
|
|
1848
|
+
let flowInstId = currentInst.flowInstId;
|
|
1849
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.getBackData,{"flowInstId":flowInstId}).then(res => {
|
|
1850
|
+
this.backNodeArr = [];
|
|
1851
|
+
if(res.data.operateSuccess){
|
|
1852
|
+
let result = res.data.resultObject || [];
|
|
1853
|
+
if(result.length == 0){
|
|
1854
|
+
this.$this.$message.warning("没有可以退回的节点!");
|
|
1855
|
+
return;
|
|
1856
|
+
}
|
|
1857
|
+
let arr = [];
|
|
1858
|
+
result.forEach((item,index) =>{
|
|
1859
|
+
// if(index != res.data.resultObject.length -1){
|
|
1860
|
+
// this.backNodeArr.push(item);
|
|
1861
|
+
// }
|
|
1862
|
+
if(item["endTimeNull"]){
|
|
1863
|
+
arr.push(item);
|
|
1864
|
+
}else{
|
|
1865
|
+
this.backNodeArr.push(item);
|
|
1866
|
+
}
|
|
1867
|
+
});
|
|
1868
|
+
this.backNodeArr = this.backNodeArr.concat(arr);
|
|
1869
|
+
this.backNodeArr.splice(this.backNodeArr.length - 1,1);
|
|
1870
|
+
this.isDisabled2 = true;
|
|
1871
|
+
this.backMsg = "";
|
|
1872
|
+
this.backNodeId = "";
|
|
1873
|
+
this.backDialogVisible = true;
|
|
1874
|
+
this.$flowDialog.operateDialog('backDialogVisible',true);
|
|
1875
|
+
}
|
|
1876
|
+
})
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
syncFlowDialogPrams(params){
|
|
1880
|
+
Object.keys(params).forEach(key => {
|
|
1881
|
+
this[key] = params[key];
|
|
1882
|
+
});
|
|
1883
|
+
this.setParams && this.setParams(params);
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
/**
|
|
1887
|
+
* 恢复方法
|
|
1888
|
+
*/
|
|
1889
|
+
restoreFlow() {
|
|
1890
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.stopFlow, {
|
|
1891
|
+
instId: this.currentInst.flowInstId, type: "1",
|
|
1892
|
+
procInstId: this.currentInst.linkProcId,
|
|
1893
|
+
taskId: this.currentInst.taskId
|
|
1894
|
+
}).then(res => {
|
|
1895
|
+
if (res && res.data) {
|
|
1896
|
+
if (res.data.operateSuccess) {
|
|
1897
|
+
this.$this.$message({type: "success", message: "恢复成功!"});
|
|
1898
|
+
this.flowInstDataDialog = false;
|
|
1899
|
+
this.$flowDialog.operateDialog('flowInstDataDialog',false);
|
|
1900
|
+
if (this.getFlowBatchDialog && this.getFlowBatchDialog()) {
|
|
1901
|
+
this.batchTabRemove(this.currentInst.dataId);
|
|
1902
|
+
} else {
|
|
1903
|
+
this.tabCrudSearch && this.tabCrudSearch();
|
|
1904
|
+
}
|
|
1905
|
+
this.initTabNum && this.initTabNum();
|
|
1906
|
+
} else {
|
|
1907
|
+
this.$this.$message({type: "error", message: res.data.operateMessage});
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
})
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
/**
|
|
1914
|
+
* 打开流转记录窗口
|
|
1915
|
+
* @param row 流程行数据
|
|
1916
|
+
*/
|
|
1917
|
+
openFlowRecord(row) {
|
|
1918
|
+
let arr = ["2", "3", "4"]; // 旧版本的已办结已撤销以及已中止数据通过旧版接口查询流转记录
|
|
1919
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
1920
|
+
flowRecordObj: this.flowRecordObj
|
|
1921
|
+
});
|
|
1922
|
+
if (arr.indexOf(row.flowStatus) > -1 && row.isOldData === "1") {
|
|
1923
|
+
this.flowRecordObj = {instId: row.flowInstId || "", oldDialogVisible: true};
|
|
1924
|
+
} else {
|
|
1925
|
+
this.flowRecordObj = {instId: row.flowInstId || "", dialogVisible: true};
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
openFlowChart(row) {
|
|
1930
|
+
let flowId = "";
|
|
1931
|
+
let instId = "";
|
|
1932
|
+
let linkProcId = "";
|
|
1933
|
+
let isRelease = "";
|
|
1934
|
+
if (row) {
|
|
1935
|
+
flowId = row.flowId;
|
|
1936
|
+
instId = row.flowInstId;
|
|
1937
|
+
linkProcId = row.linkProcId;
|
|
1938
|
+
isRelease = row.isRelease;
|
|
1939
|
+
}
|
|
1940
|
+
this.flowChartObj = {flowId: flowId,instId: instId,linkProcId:linkProcId,isRelease:isRelease, dialogVisible: true};
|
|
1941
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
1942
|
+
flowChartObj: this.flowChartObj,
|
|
1943
|
+
})
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
// end of button methods 按钮方法结束
|
|
1947
|
+
|
|
1948
|
+
// 功能区域,用于作为一些方法处理数据
|
|
1949
|
+
|
|
1950
|
+
// 自定义按钮窗口回调函数
|
|
1951
|
+
openDiyButtonEvent(type,row, button) {
|
|
1952
|
+
let formData = {};
|
|
1953
|
+
if(this.getFormInfo){
|
|
1954
|
+
formData = this.getFormInfo();
|
|
1955
|
+
}
|
|
1956
|
+
if(type === 'list') {
|
|
1957
|
+
this.execDiyBtnScripts(type,row,button.funcBody);
|
|
1958
|
+
}else {
|
|
1959
|
+
this.execDiyBtnScripts(type,formData,button.funcBody);
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
judeDiyButton(tabActive,button) { // 传过来的tabActive在实际使用中flowInstTab的时候没有更新,所以这里使用this.tabActive就行了
|
|
1964
|
+
if(this.tabActive === 'pending') {
|
|
1965
|
+
return button.position === 'table' && button.nodeId === this.currentInst.currentNode;
|
|
1966
|
+
}
|
|
1967
|
+
return button.position === 'table' && button.buttonSign.indexOf(this.tabActive) > -1;
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
execDiyBtnScripts(type,data,fnBody) {
|
|
1971
|
+
try {
|
|
1972
|
+
fnBody = this.replaceUrl(fnBody);
|
|
1973
|
+
fnBody = fnBody.replace(/\\'/g, "'").replace(/"/g, "\"");
|
|
1974
|
+
if(type === 'list') {
|
|
1975
|
+
new Function('vm,rowData,Ajax', fnBody)(this.$this,data,AjaxUtil);
|
|
1976
|
+
}else {
|
|
1977
|
+
new Function('vm,formData,Ajax', fnBody)(this.$this,data,AjaxUtil);
|
|
1978
|
+
}
|
|
1979
|
+
} catch (e) {
|
|
1980
|
+
console.log("自定义按钮事件执行错误!", e);
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
/**
|
|
1985
|
+
* 获取[添加、修改和处理]的操作按钮
|
|
1986
|
+
*/
|
|
1987
|
+
getAddAndUpdateFormBtn(row) {
|
|
1988
|
+
//走版本
|
|
1989
|
+
let arrNodeFormBtns = [];
|
|
1990
|
+
if(row.version){
|
|
1991
|
+
arrNodeFormBtns = this.nodeFormBtnObj[(this.flowVersionNodeObj[row.version][row.nodeKey || this.startNodeKeyObj[row.version]] || {}).id];
|
|
1992
|
+
}else {
|
|
1993
|
+
arrNodeFormBtns = this.nodeFormBtnObj[this.flowVersionNodeObj[this.flowDefine.releaseVersion][this.startNodeKeyObj[this.flowDefine.releaseVersion]].id];
|
|
1994
|
+
}
|
|
1995
|
+
let hideBtnTypes = new Set(["getBack"]);
|
|
1996
|
+
if (this.tabActive == "draft") {
|
|
1997
|
+
hideBtnTypes.add("flowRecord");
|
|
1998
|
+
hideBtnTypes.add("record");
|
|
1999
|
+
}else if(this.tabActive == "pending"){//待处理
|
|
2000
|
+
hideBtnTypes.add("cancel");
|
|
2001
|
+
if(row.operateStatus=='1'||row.operateStatus=='3'){//如果是加签转签 不需要部分按钮
|
|
2002
|
+
hideBtnTypes.add("retSpecified");
|
|
2003
|
+
hideBtnTypes.add("back");
|
|
2004
|
+
hideBtnTypes.add("completeSign");
|
|
2005
|
+
hideBtnTypes.add("turnSign");
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
return this.formatterFormBtnByHideBtnTypes(arrNodeFormBtns, hideBtnTypes);
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
/**
|
|
2013
|
+
* 根据隐藏按钮类型格式化按钮信息
|
|
2014
|
+
*/
|
|
2015
|
+
formatterFormBtnByHideBtnTypes(arrFormBtns, hideBtnTypes) {
|
|
2016
|
+
let arrResults = [];
|
|
2017
|
+
arrFormBtns.forEach(data => {
|
|
2018
|
+
let objTmp = Object.assign({}, data);
|
|
2019
|
+
hideBtnTypes.has(data.btnType) && (objTmp.show = false);
|
|
2020
|
+
if(this.tabActive == "discontinue" && data.btnType == "restore" && !hideBtnTypes.has(data.btnType)){
|
|
2021
|
+
objTmp.show = true;
|
|
2022
|
+
}
|
|
2023
|
+
if(this.tabActive == "processed" && data.btnType == "getBack" && !hideBtnTypes.has(data.btnType)){
|
|
2024
|
+
objTmp.show = true;
|
|
2025
|
+
}
|
|
2026
|
+
if(this.tabActive == "processed" && data.btnType == "cancel" && !hideBtnTypes.has(data.btnType)){
|
|
2027
|
+
objTmp.show = true;
|
|
2028
|
+
}
|
|
2029
|
+
arrResults.push(objTmp);
|
|
2030
|
+
});
|
|
2031
|
+
return arrResults;
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
/**
|
|
2035
|
+
* 获取[查看]的操作按钮
|
|
2036
|
+
*/
|
|
2037
|
+
getViewFormBtn(row) {
|
|
2038
|
+
//走版本
|
|
2039
|
+
let arrNodeFormBtns = [];
|
|
2040
|
+
if(row.version){
|
|
2041
|
+
arrNodeFormBtns = this.nodeFormBtnObj[(this.flowVersionNodeObj[row.version][row.nodeKey || this.startNodeKeyObj[row.version]] || {}).id];
|
|
2042
|
+
}else {
|
|
2043
|
+
arrNodeFormBtns = this.nodeFormBtnObj[this.flowVersionNodeObj[this.flowDefine.releaseVersion][this.startNodeKeyObj[this.flowDefine.releaseVersion]].id];
|
|
2044
|
+
}
|
|
2045
|
+
let hideBtnTypes = new Set(["getBack", "cancel", "restore"]);
|
|
2046
|
+
if (this.tabActive == "processed") { // 已处理
|
|
2047
|
+
|
|
2048
|
+
// 上个节点的处理可以取回(已开启按钮的情况下)
|
|
2049
|
+
if ((row.beforeDealer || "").split(",").indexOf(this.loginUser.id) > -1) {
|
|
2050
|
+
hideBtnTypes.delete("getBack");
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
// 流程的发起人可以撤销(已开启按钮的情况下)
|
|
2054
|
+
if (row.startUserId == this.loginUser.id) {
|
|
2055
|
+
// hideBtnTypes.delete("cancel");
|
|
2056
|
+
}
|
|
2057
|
+
//被挂起数据只有查看按钮
|
|
2058
|
+
if(row.hangUp == '1'){
|
|
2059
|
+
hideBtnTypes.add("getBack");
|
|
2060
|
+
hideBtnTypes.add("cancel");
|
|
2061
|
+
hideBtnTypes.add("restore");
|
|
2062
|
+
}
|
|
2063
|
+
} else if (this.tabActive == "discontinue" && row.discontinueUserId == this.loginUser.id) { // 已中止
|
|
2064
|
+
// 当前登陆用户是中止人才显示恢复按钮(已开启按钮的情况下)
|
|
2065
|
+
hideBtnTypes.delete("restore");
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
return this.formatterFormBtnByHideBtnTypes(arrNodeFormBtns, hideBtnTypes);
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
initFieldStatus(nodeKey,version,flowStatus) {
|
|
2072
|
+
return new Promise(resolve => {
|
|
2073
|
+
resolve();
|
|
2074
|
+
});
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
replaceUrl(value){
|
|
2078
|
+
if(window.ADMIN_URL && (value.indexOf("/admin/") > -1 || value.indexOf("/oaadmin/") > -1)){
|
|
2079
|
+
if(value.indexOf("/admin/") > -1){
|
|
2080
|
+
value = this.$this.platStringUtil.replaceAll(value,"/admin/", window.ADMIN_URL + "/");
|
|
2081
|
+
}else{
|
|
2082
|
+
value = this.$this.platStringUtil.replaceAll(value,"/oaadmin/",window.ADMIN_URL + "/");
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
if(window.FLOW_URL && (value.indexOf("/flow/") > -1 || value.indexOf("/oaflow/") > -1)){
|
|
2086
|
+
if(value.indexOf("/flow/") > -1){
|
|
2087
|
+
value = this.$this.platStringUtil.replaceAll(value,"/flow/", window.FLOW_URL + "/");
|
|
2088
|
+
}else{
|
|
2089
|
+
value = this.$this.platStringUtil.replaceAll(value,"/oaflow/",window.FLOW_URL + "/");
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
if(window.FORM_RENDER_URL && (value.indexOf("/form/") > -1|| value.indexOf("/oaform/") > -1)){
|
|
2093
|
+
if(value.indexOf("/form/") > -1){
|
|
2094
|
+
value = this.$this.platStringUtil.replaceAll(value,"/form/", window.FORM_RENDER_URL + "/");
|
|
2095
|
+
}else{
|
|
2096
|
+
value = this.$this.platStringUtil.replaceAll(value,"/oaform/",window.FORM_RENDER_URL + "/");
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
if(window.OA_URL && (value.indexOf("/project/") > -1 || value.indexOf("/oaproject/") > -1)){
|
|
2100
|
+
if(value.indexOf("/project/") > -1){
|
|
2101
|
+
value = this.$this.platStringUtil.replaceAll(value,"/project/", window.OA_URL + "/");
|
|
2102
|
+
}else{
|
|
2103
|
+
value = this.$this.platStringUtil.replaceAll(value,"/oaproject/",window.OA_URL + "/");
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
value = this.$this.platStringUtil.replaceAll(value,"window.JAVA_URL","''");
|
|
2107
|
+
value = this.$this.platStringUtil.replaceAll(value,"JAVA_URL","''");
|
|
2108
|
+
value = this.$this.platStringUtil.replaceAll(value,"window.baseUrl","''");
|
|
2109
|
+
value = this.$this.platStringUtil.replaceAll(value,"baseUrl","''");
|
|
2110
|
+
return value;
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
/**
|
|
2114
|
+
* 格式化表单操作按钮
|
|
2115
|
+
*/
|
|
2116
|
+
formatterFormButton(formButton) {
|
|
2117
|
+
|
|
2118
|
+
let formBtnObj = {};
|
|
2119
|
+
let formBtnArr = [];
|
|
2120
|
+
|
|
2121
|
+
for (let [key, data] of Object.entries(this.formBtnObjDefault)) {
|
|
2122
|
+
formBtnObj[key] = Object.assign({btnType: key}, data);
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
let objTmp;
|
|
2126
|
+
(formButton || []).forEach(data => {
|
|
2127
|
+
if (formBtnObj[data.type]) {
|
|
2128
|
+
objTmp = formBtnObj[data.type];
|
|
2129
|
+
objTmp.show = (data.isUse != '0');
|
|
2130
|
+
objTmp.text = data.showName || objTmp.text;
|
|
2131
|
+
}
|
|
2132
|
+
});
|
|
2133
|
+
|
|
2134
|
+
for (let [key, data] of Object.entries(formBtnObj)) {
|
|
2135
|
+
formBtnArr.push(data);
|
|
2136
|
+
}
|
|
2137
|
+
return formBtnArr;
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
sortButtonArr(formButton) {
|
|
2141
|
+
let objBtnOrder = {
|
|
2142
|
+
"saveDraft": 1,
|
|
2143
|
+
"nextStep": 2,
|
|
2144
|
+
"completeSign": 3,
|
|
2145
|
+
"turnSign": 4,
|
|
2146
|
+
"retSpecified": 5,
|
|
2147
|
+
"back": 6,
|
|
2148
|
+
"stopped": 7,
|
|
2149
|
+
"close": 8
|
|
2150
|
+
};
|
|
2151
|
+
(formButton || []).forEach(data => {
|
|
2152
|
+
data.order = objBtnOrder[data.type] || data.order;
|
|
2153
|
+
});
|
|
2154
|
+
return formButton;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
// 获取流程用户数据
|
|
2158
|
+
initUserData(){
|
|
2159
|
+
// 先载入系统接口数据
|
|
2160
|
+
let userArr = this.$this.INTER_CACHE.getUserArr();
|
|
2161
|
+
if(userArr && userArr.length > 0){
|
|
2162
|
+
this.userMap = this.$this.INTER_CACHE.getUserMap();
|
|
2163
|
+
this.userArr = userArr;
|
|
2164
|
+
}else{
|
|
2165
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowInterface.find,{sysInterName:'userData',interType:'sys',interStatus:'1'}).then(res => {
|
|
2166
|
+
if((res.data || []).length === 0){
|
|
2167
|
+
return;
|
|
2168
|
+
}
|
|
2169
|
+
let dataInter = res.data[0];
|
|
2170
|
+
this.loadUserData(dataInter);
|
|
2171
|
+
})
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
loadUserData(dataInter){
|
|
2175
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowDomain.findRealUrl,{status:'1'}).then(res => {
|
|
2176
|
+
(res.data || []).forEach(item => {
|
|
2177
|
+
this.doMainDatasObj[item.id] = item.domainUrl;
|
|
2178
|
+
})
|
|
2179
|
+
// 解析用户数据
|
|
2180
|
+
this.analyseRequest(dataInter).then(data => {
|
|
2181
|
+
let arr = [];
|
|
2182
|
+
let userIdArr = [];
|
|
2183
|
+
data.forEach(item => {
|
|
2184
|
+
item.dataUserId = item[dataInter["idCode"] || "userId"];
|
|
2185
|
+
item.dataKey = item.dataUserId;
|
|
2186
|
+
item.flowDataType = "user";
|
|
2187
|
+
item.dataLabel = item[dataInter["showCode"] || "userName"];
|
|
2188
|
+
item.dataOrgId = item[dataInter["orgCode"] || "orgId"];
|
|
2189
|
+
item.dataPosId = item[dataInter["posCode"] || "posId"];
|
|
2190
|
+
if(item.dataOrgId){
|
|
2191
|
+
item.dataParentId = item.orgId;
|
|
2192
|
+
}
|
|
2193
|
+
if(item.dataPosId){
|
|
2194
|
+
item.dataParentId = item.posId;
|
|
2195
|
+
}
|
|
2196
|
+
if(userIdArr.indexOf(item.dataKey) === -1){
|
|
2197
|
+
arr.push({
|
|
2198
|
+
id:item.dataKey,
|
|
2199
|
+
userName:item.dataLabel
|
|
2200
|
+
})
|
|
2201
|
+
userIdArr.push(item.dataKey);
|
|
2202
|
+
}
|
|
2203
|
+
})
|
|
2204
|
+
this.userArr = arr;
|
|
2205
|
+
this.$this.INTER_CACHE.setUserArr(arr);
|
|
2206
|
+
this.userMap = this.$this.INTER_CACHE.getUserMap();
|
|
2207
|
+
})
|
|
2208
|
+
})
|
|
2209
|
+
}
|
|
2210
|
+
analyseRequest(dataInter){
|
|
2211
|
+
return new Promise(resolve => {
|
|
2212
|
+
let domainUrl = this.doMainDatasObj[dataInter.domainId] || "";
|
|
2213
|
+
let url = domainUrl + dataInter.requestUrl;
|
|
2214
|
+
let requestParam = JSON.parse(dataInter.requestParam || "[]");
|
|
2215
|
+
let obj = {};
|
|
2216
|
+
requestParam.forEach(item => {
|
|
2217
|
+
if(!item.key){
|
|
2218
|
+
return;
|
|
2219
|
+
}
|
|
2220
|
+
obj[item.key] = item.value || ""; // 注意这里要replace ${userCode}
|
|
2221
|
+
})
|
|
2222
|
+
if(dataInter.requestType === 'post'){
|
|
2223
|
+
this.$this.saspFlowAxios.post(url,obj).then(res => {
|
|
2224
|
+
this.$this.INTER_CACHE.setCacheInfo(dataInter.sysInterName,res.data);
|
|
2225
|
+
resolve(res.data || []);
|
|
2226
|
+
})
|
|
2227
|
+
}else{
|
|
2228
|
+
let params = "";
|
|
2229
|
+
let arr = []
|
|
2230
|
+
Object.keys(obj).forEach(key => {
|
|
2231
|
+
arr.push(key + "=" + obj[key]);
|
|
2232
|
+
})
|
|
2233
|
+
params = arr.join("&");
|
|
2234
|
+
if(params){
|
|
2235
|
+
if(url.indexOf("?") > -1){
|
|
2236
|
+
url += "&" + params;
|
|
2237
|
+
}else{
|
|
2238
|
+
url += "?" + params;
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
this.$this.saspFlowAxios(url).then(res => {
|
|
2242
|
+
this.$this.INTER_CACHE.setCacheInfo(dataInter.sysInterName,res.data);
|
|
2243
|
+
resolve(res.data || []);
|
|
2244
|
+
})
|
|
2245
|
+
}
|
|
2246
|
+
})
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
/**
|
|
2250
|
+
*
|
|
2251
|
+
* @param dataId 数据ID
|
|
2252
|
+
* @param type 操作类型,view-查看、update-编辑
|
|
2253
|
+
* @param forceOpen 是否强制打开,默认false,为true时可以将非工作流列表数据自动插入草稿数据并打开
|
|
2254
|
+
* @param callback 回调函数
|
|
2255
|
+
*/
|
|
2256
|
+
open(dataId,type,forceOpen,callback){
|
|
2257
|
+
if(!this.tableviewId){
|
|
2258
|
+
this.$this.$message.error("请先设置tableviewId");
|
|
2259
|
+
return;
|
|
2260
|
+
}
|
|
2261
|
+
this.init().then(() => {
|
|
2262
|
+
this.formInfo["dataId"] = dataId;
|
|
2263
|
+
this.$flowDialog.fillFlowDialogParams({
|
|
2264
|
+
formId: this.formId,
|
|
2265
|
+
tableviewId: this.tableviewId,
|
|
2266
|
+
dataId: dataId || "",
|
|
2267
|
+
formInfo: this.formInfo
|
|
2268
|
+
});
|
|
2269
|
+
if(dataId){
|
|
2270
|
+
this.getDataByDataId(dataId,forceOpen).then(rowData => {
|
|
2271
|
+
if(!rowData){
|
|
2272
|
+
this.$this.$message.error("未获取到此流程数据!");
|
|
2273
|
+
return;
|
|
2274
|
+
}
|
|
2275
|
+
if(type !== "view" && rowData.operateAuth === "0"){
|
|
2276
|
+
console.log("当前登录用户无此流程数据操作权限,已自动切换为查看!");
|
|
2277
|
+
type = "view";
|
|
2278
|
+
}
|
|
2279
|
+
if(rowData.linkProcId){
|
|
2280
|
+
this.tabActive = "pending";
|
|
2281
|
+
}else{
|
|
2282
|
+
this.tabActive = "draft";
|
|
2283
|
+
}
|
|
2284
|
+
this.currentInst = rowData;
|
|
2285
|
+
if(type === "view"){
|
|
2286
|
+
this.openViewFlowForm(rowData).then(() => {
|
|
2287
|
+
callback && callback(this,this.$this);
|
|
2288
|
+
})
|
|
2289
|
+
}else{
|
|
2290
|
+
let executePosition = "update";
|
|
2291
|
+
if(rowData.linkProcId){
|
|
2292
|
+
executePosition = "handle";
|
|
2293
|
+
}
|
|
2294
|
+
this.openUpdateFlowForm(rowData,executePosition).then(() => {
|
|
2295
|
+
callback && callback(this,this.$this);
|
|
2296
|
+
})
|
|
2297
|
+
}
|
|
2298
|
+
});
|
|
2299
|
+
}else{
|
|
2300
|
+
this.currentInst = {};
|
|
2301
|
+
this.tabActive = "draft";
|
|
2302
|
+
this.openAddFlowForm().then(() => {
|
|
2303
|
+
callback && callback(this,this.$this);
|
|
2304
|
+
})
|
|
2305
|
+
}
|
|
2306
|
+
})
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
/**
|
|
2310
|
+
* 根据数据ID获取流程数据
|
|
2311
|
+
* @param dataId
|
|
2312
|
+
* @returns {Promise<unknown>}
|
|
2313
|
+
*/
|
|
2314
|
+
getDataByDataId(dataId,forceOpen){
|
|
2315
|
+
return new Promise(resolve => {
|
|
2316
|
+
this.getFlowInstByDataId(dataId).then(rowData => {
|
|
2317
|
+
if(!rowData) {
|
|
2318
|
+
if (forceOpen) {
|
|
2319
|
+
this.$this.axios.post(this.$this.api.flowEngine.saveFlowDraft, {
|
|
2320
|
+
flowId: this.flowId,
|
|
2321
|
+
dataId: dataId,
|
|
2322
|
+
userCode: this.loginUser.id
|
|
2323
|
+
}).then(flowDraftRes => {
|
|
2324
|
+
let flowDraftData = flowDraftRes.data || {};
|
|
2325
|
+
if (flowDraftData.requestStatus === "1") {
|
|
2326
|
+
this.getFlowInstByDataId(dataId).then(rowData => {
|
|
2327
|
+
resolve(rowData);
|
|
2328
|
+
});
|
|
2329
|
+
}else{
|
|
2330
|
+
resolve(false);
|
|
2331
|
+
}
|
|
2332
|
+
});
|
|
2333
|
+
}else{
|
|
2334
|
+
resolve(false);
|
|
2335
|
+
}
|
|
2336
|
+
}else{
|
|
2337
|
+
resolve(rowData);
|
|
2338
|
+
}
|
|
2339
|
+
})
|
|
2340
|
+
})
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
getFlowInstByDataId(dataId){
|
|
2344
|
+
return new Promise(resolve => {
|
|
2345
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.getFlowInstByFlowDataId,{flowId:this.flowId,dataId:dataId}).then(res => {
|
|
2346
|
+
if(!res.data){
|
|
2347
|
+
resolve(false);
|
|
2348
|
+
return;
|
|
2349
|
+
}
|
|
2350
|
+
let rowData = res.data || {};
|
|
2351
|
+
resolve(rowData);
|
|
2352
|
+
});
|
|
2353
|
+
})
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
openFlowDialog(args){
|
|
2357
|
+
this.$flowDialog.openFlowDialog(args);
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
openRecordEvent(dataId){ // 采用初始化构造类时传递flowId
|
|
2361
|
+
if(!this.flowId){
|
|
2362
|
+
this.$this.$message.error("请先设置flowId");
|
|
2363
|
+
return;
|
|
2364
|
+
}
|
|
2365
|
+
this.openRecord(this.flowId,dataId);
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
openRecord(flowId,dataId){
|
|
2369
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.getFlowInstByFlowDataId,{flowId:(flowId || this.flowId),dataId:dataId}).then(res => {
|
|
2370
|
+
if (!res.data) {
|
|
2371
|
+
this.$this.$message.error("未获取到此流程数据!");
|
|
2372
|
+
return;
|
|
2373
|
+
}
|
|
2374
|
+
let currentInst = res.data || {};
|
|
2375
|
+
this.openFlowRecord(currentInst);
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
openChartEvent(dataId){ // 采用初始化构造类时传递flowId
|
|
2380
|
+
if(!this.flowId){
|
|
2381
|
+
this.$this.$message.error("请先设置flowId");
|
|
2382
|
+
return;
|
|
2383
|
+
}
|
|
2384
|
+
this.openChart(this.flowId,dataId);
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
openChart(flowId,dataId){
|
|
2388
|
+
if(dataId){
|
|
2389
|
+
this.$this.saspFlowAxios.post(this.$this.api.plFlowInst.getFlowInstByFlowDataId,{flowId:flowId || this.flowId,dataId:dataId}).then(res => {
|
|
2390
|
+
if (!res.data) {
|
|
2391
|
+
this.$this.$message.error("未获取到此流程数据");
|
|
2392
|
+
return;
|
|
2393
|
+
}
|
|
2394
|
+
let currentInst = res.data || {};
|
|
2395
|
+
this.openFlowChart(currentInst);
|
|
2396
|
+
});
|
|
2397
|
+
}else{
|
|
2398
|
+
this.openFlowChart({flowId:(flowId || this.flowId)});
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
export default {
|
|
2404
|
+
workflow: WorkflowEngine
|
|
2405
|
+
}
|