Ldc
2024-04-07 0652600959e5e3b5796fb6e8da129704ca95347a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
/**
 * Created by weidy on 2018/5/17.
 * 流程执行窗口
 */
layui.define(['table','element','layer','form','vciWebComboxStore','vciWebFileManager','vciWebDataGrid',
            'process/vciWebProBusinessData','process/vciWebProBusinessDoc',
            'process/vciWebProHistory','process/vciWebProExecutePanel'],function(exports){
    var ExecuteTask = function(){
        this.moduleKey = "vciWebProExecuteTask";
        this.rejectRouteName="不同意";
        this.backPath = configData.compatibility ? path : configData.processServicePath;//默认流程和项目的路径是一样的
        this.url = {
            getOutcome: 'processDefineController/getOutcomes',
            checkUserSameTemplate:'processDefineController/checkUseSameTemplate',
            dataDefine:'processDefineController/getDataDefine'//从后台获取显示关联数据的列表的code
        };
        this.allowMutiExecuteTask = false;//是否允许批量执行任务
        this.id="vciWebProExecuteTask";
        this.dialogForm ='';
        this.defaults = {
            dataTableBtmType:"input",//关联数据的表格在的业务类型,用于查询平台中的列表
            dataTableCode:"ShowMyTaskLinkDataList"//关联数据的表格代号
        };
    };
    ExecuteTask.prototype.getContent = function(){//获取基础的html
        return "";
    };
    ExecuteTask.prototype.init = function(){//初始化
        var that = this;
        $webUtil.copyConfig(that,that.moduleKey);
    };
    ExecuteTask.prototype.showExecuteWindow=function(taskInfo,options,closeCallback){
        var that = this;
        if(!taskInfo){
            $webUtil.showErrorMsg("没有流程相关的信息");
            return;
        }
        var isMutiTask = false;
        if(!$webUtil.isArray(taskInfo)){
            taskInfo = [taskInfo];
        }
        if(taskInfo.length == 0 ){
            $webUtil.showErrorMsg("没有流程相关的信息");
            return;
        }
        if(taskInfo.length >1){
            isMutiTask = true;
        }
        if(!that.allowMutiExecuteTask && isMutiTask){
            $webUtil.showErrorMsg("不允许批量执行流程");
            return false;
        }
        var taskOids = "";
        var taskName = taskInfo[0].taskName;
        var executionId = taskInfo[0].executionId;
        layui.each(taskInfo,function(_index,_item){
            taskOids += _item.taskOid + ",";
        });
        taskOids = layui.util.removeComma(taskOids);
 
        var taskCodes = "";
        layui.each(taskInfo,function(_index,_item){
            taskCodes += _item.code + ",";
        });
        taskCodes = layui.util.removeComma(taskCodes);
        var firstOid = taskInfo[0].taskOid;
        //如果是批量执行流程,那就需要先是否使用相同的流程模板和相同的任务节点
        if(isMutiTask){
            $webUtil.post(that.url.checkUserSameTemplate,{taskOids:taskOids},function(result){
                if(result.success){
                    $webUtil.showErrorMsg("暂时还没有添加对于批量执行任务的支持");
                    //批量的任务时,是不能查看数据,文件和流程历史的
                    //直接显示批量执行的窗口
                    //that.gotoShowWindow(taskOids,taskCodes,firstOid,taskName,isMutiTask,options,closeCallback,taskInfo);
                }else{
                    $webUtil.showErrorMsg(result.msg);
                }
            },function(){},that.backPath,true);
        }else{
            that.gotoShowWindow(taskOids,taskCodes,executionId,taskName,isMutiTask,options,closeCallback,taskInfo);
        }
    };
    ExecuteTask.prototype.gotoShowWindow = function(taskOids,taskCodes,executionId,taskName,isMutiTask,options,closeCallback,taskInfo){
        var that = this;
        var form = layui.form;
        var formId = "execute_task_form_" + taskOids;
        var title = "执行[" + taskName + "]" + (isMutiTask?"等任务":"");
        var tree = layui.tree;
        var canSelectUserMap = null;
        var windowArea= [(($webUtil.isNotNull(options.width) || options.width*1>1) ?options.width*1 : 950) +'px',
        (($webUtil.isNotNull(options.height) && options.height*1>1) ?options.height*1 : 600) + 'px'];
        if(options.fullScreen){
            if(window.innerWidth){
                windowArea = [(window.innerWidth-50) + "px",(window.innerHeight-50) + "px"];
            }else{
                windowArea = [(document.documentElement.clientWidth-50) + "px",(document.documentElement.clientHeight-50) + "px"];
            }
        }
        var divWidth = windowArea[0].substring(0,windowArea[0].indexOf("px")) - 295;
        that.closeedWindow = false;
        var taskWindowIndex = layer.open({
            type:1,
            title:title,
            //btn:['取消'],//感觉直接关闭比较好,取消占用太多纵向空间
            //skin:'layui-layer-lan',
            content:'<div id="processbusniessdata_' + formId + '_div" class="layui-layout-center" style="margin-left:5px;width:' + divWidth + 'px;max-width:'+ divWidth +'px;overflow:auto;" >' +
                        '<div lay-filter="processbusniessdata_' + formId + '" class="layui-tab layui-tab-card" lay-allowClose="false">'+
                            '<ul class="layui-tab-title" lay-allowClose="false">' +
                            '</ul>' +
                            '<div class="layui-tab-content"></div>' +
                        '</div> '+
                    '</div>' +
                '<div id="processtaskdo_' + formId + '" class="layui-layout-east" style="display:block;position:absolute;top:0;right:0;margin:10px 5px 0 0;padding:0 5px;max-width:300px;min-width:150px;border:1px solid #e1e1e1"></div>',
            area:windowArea,
            closeBtn:(options.full)?0:1,
            shade:true,
            shadeClose:true,
            resize:true,
            resizing:function(layero){
                form.doResize();
            },
            yes:function(index,layero){
                layer.close(taskWindowIndex);
                if(closeCallback){
                    closeCallback(false);
                }
            },
            success:function(layero){
                //特别注意,多任务处理的,页面只能显示列表;而且多任务中的业务数据必须是同一个业务类型下;这个需要各自展示的页面中自行处理
                //1. 添加关联的业务数据展示表单的选项卡,需要从后台去查询参数里定义,如果定义了tableCode,说明是显示平台的表格,如果是detailUrl说明是显示自定义的页面,否则显示默认的
                //2. 添加关联文档的选项卡,只显示当前业务数据关联的文档,如果是明细数据,需要使用自定义的页面内容中展示
                //3. 添加流程历史的选项卡,其中包含流程图和流程历史
                //从后台先获取流程相关的配置
                var compIdFix =  taskOids;
                $webUtil.post(that.url.dataDefine,{executionid:executionId},function(result){
                    if(result.success){
                        var businessDataComp = layui['process/vciWebProBusinessData'];//业务数据
                        var businessDocComp = layui['process/vciWebProBusinessDoc'];//关联文档
                        var processHistoryComp = layui['process/vciWebProHistory'];//操作历史
 
                        businessDataComp.businessBtmInProcess = result.obj.UIType;
                        businessDataComp.businessOidsInProcess = result.obj.businessOids;
                        businessDataComp.taskOidInProcess = taskOids;
                        businessDataComp.taskCodeInProcess = taskCodes;
                        businessDataComp.tableCode = result.obj.tableCode;
                        businessDataComp.detailUrl = result.obj.detailUrl;
                        businessDataComp.UIContentCode = result.obj.UIContentCode;
                        result.obj.UIContentCode && (businessDataComp.UIContentSelectData = taskInfo)
                        businessDataComp.viewProcessLinkBusinessToken = result.obj.viewProcessLinkBusinessToken;//用来在查看流程的数据时,告诉后台跳过权限的
                        businessDataComp.executionidNoInProcess = result.obj.executionidno;
                        businessDataComp.executionid = executionId;
                        businessDataComp.maxWidth = divWidth;
                        businessDataComp.maxHeight = null;
                        businessDataComp.id = "vciProcessBusinessData_executeTask_" + compIdFix;
 
                        businessDocComp.businessBtmInProcess = result.obj.UIType;
                        businessDocComp.businessOidsInProcess = result.obj.businessOids;
                        businessDocComp.taskOidInProcess = taskOids;
                        businessDocComp.taskCodeInProcess = taskCodes;
                        businessDocComp.id = "vciProcessBusinessDoc_executeTask_" + compIdFix;
 
                        processHistoryComp.taskOidInProcess = taskOids;
                        processHistoryComp.taskCodeInProcess = taskCodes;
                        processHistoryComp.executionId=executionId;
                        processHistoryComp.maxWidth = divWidth;
                        processHistoryComp.id = "vciProcessHistory_executeTask_" + compIdFix;
 
                        webUtil.ajax('get','/uiDataController/getDataAttr',{oid: result.obj.businessOids, btmname: result.obj.UIType} , function (res) {
                            if (res.success) {
                                if(res.data){
                                    businessDataComp.businessDataInProcess=res.data;
                                    processHistoryComp.businessDataInProcess=res.data;
                                    businessDocComp.businessDataInProcess=res.data;
                                }else{
                                    businessDataComp.businessDataInProcess=[res.obj];
                                    processHistoryComp.businessDataInProcess=[res.obj];
                                    businessDocComp.businessDataInProcess=[res.obj];
                                }
                                layui.element.tabAdd('processbusniessdata_' + formId,{
                                    title:'业务数据信息',
                                    id: "tab_" + businessDataComp.id,
                                    unAllowClose:true,
                                    item:businessDataComp
                                });
 
                                /*layui.element.tabAdd('processbusniessdata_' + formId,{
                                    title:'业务数据关联文档',
                                    id: "tab_" + businessDocComp.id,
                                    unAllowClose:true,
                                    item:businessDocComp
                                });*/
 
                                layui.element.tabAdd('processbusniessdata_' + formId,{
                                    title:'流程跟踪',
                                    id: "tab_" + processHistoryComp.id,
                                    unAllowClose:true,
                                    item:processHistoryComp
                                });
                                if(result.defaultDisplayDoc || result.defaultDisplayDoc == "true"){ //如果用户想优先看文件
                                    layui.element.tabChange('processbusniessdata_' + formId, "tab_" + businessDocComp.id);
                                }else{
                                    layui.element.tabChange('processbusniessdata_' + formId, "tab_" + businessDataComp.id);
                                }
                            } else {
                                webUtil.showErrorMsg(res.msg);
                            }
                        }, function (xhr, err) {
                            webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
                        }, that.backPath,true);
 
                    }else{
                        if(!that.closeedWindow){
                            $webUtil.showErrorMsg(result.msg,function(){
                                that.closeedWindow = true;
                                layer.close(taskWindowIndex);
                                if(closeCallback){
                                    closeCallback(false);
                                }
                            });
                        }
                    }
                },function(){
                    $webUtil.showErrorMsg("连接服务出现了问题");
                },that.backPath,true);
                //处理面板是同步处理的。
                $webUtil.post(that.url.getOutcome,{taskOid:taskOids},function(result){
                    if(result.success&&result.obj && result.obj.length > 0){
                        //查询成功的
                        var outcomeMap = [];
                        var canSelectUserMap = null;
                        var end = false;
                        layui.each(result.obj,function(_index,_item){
                           if(!_item.processUser || _item.processUser == null || _item.processUser.length == 0){
                                if(_item.nextNodeUser && _item.nextNodeUser != null && _item.nextNodeUser.length > 0){
                                    if(canSelectUserMap == null){
                                        canSelectUserMap = {};
                                    }
                                     canSelectUserMap[_item.name] = _item.nextNodeUser;
                                }
                            }
                            outcomeMap.push({
                                key:_item.name,
                                value:_item.name
                            });
                            if(_item.nextTaskName == "结束"){
                                end = true;
                            }
                        });
                        var executePanel = layui['process/vciWebProExecutePanel'];
                        executePanel.id = "execute_" + compIdFix;
                        executePanel.taskOidInProcess = taskOids;
                        executePanel.outcomeMap = outcomeMap;
                        executePanel.executionId = executionId;
                        executePanel.taskName = taskName;
                        executePanel.creator = end?taskInfo[0].creator:"";
                        executePanel.canSelectUserMap = canSelectUserMap;
                        executePanel.finishListener = function(success){
                            if(success){
                                that.closeedWindow = false;
                                layer.close(taskWindowIndex);
                                if(closeCallback){
                                    closeCallback(true);
                                }
                            }
                        };
                        $('#processtaskdo_' + formId).html(executePanel.getContent());
                        executePanel.init();
                    }else{//说明这些任务可能不是同一个流程模板,同一个的流程任务节点
                        if(!that.closeedWindow){
                            $webUtil.showErrorMsg(result.msg,function(){
                                that.closeedWindow = true;
                                layer.close(taskWindowIndex);
                                if(closeCallback){
                                    closeCallback(false);
                                }
                            });
                        }
                    }
                },function(){
                    $webUtil.showErrorMsg("连接服务出现了问题");
                },that.backPath,true);
            }
        });
        if(options.full){
            layer.full(taskWindowIndex);
        }
 
    };
    var et = new ExecuteTask();
    exports("process/vciWebProExecuteTask",et);
});