田源
2024-04-07 2ac55ce0edf4870a29691b56bfad59f4830a11a2
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
/**
 * 流程关联的业务数据查看器
 * 分为三种的查看方式
 * 1. 默认的表格,这个是在平台提前定义的,是一个表格,请在平台的input链接类型上定义 ShowMyTaskLinkDataList这个表格
 * 2. 定义了tableCode的话,则是在平台中定义好这个表格,此处会自动显示
 * 3. 发起流程的时候定义detailUrl,这个的值是两种
 *    a: usejs:/jspath/jsfile#contentMethod|initMethod?param
 *    b: http://url ;或者是与main.html的相对路径
 */
layui.define(['layer','element','form','table','vciWebDataGrid'],function(exports){
    var BusinessDataInProcess = function(){
        this.id = "vciWebProBusinessData";
        this.modelKey = "vciWebProBusinessData";
        this.businessBtmInProcess = "";
        this.businessOidsInProcess = "";
        this.taskOidInProcess = "";
        this.tableCode = "";
        this.detailUrl = "";
        this.UIContentCode = "";
        this.viewProcessLinkBusinessToken = "";
        this.backPath = path;
        this.maxWidth = 1000;
        this.executionidNoInProcess = "";
        this.executionid = "";
        this.url={
            data:'processDefineController/getDataByTask'
        };
        this.defaults = {//默认设置
            dataTableBtmType:"input",//关联数据的表格在的业务类型,用于查询平台中的列表
            dataTableCode:"ShowMyTaskLinkDataList"//关联数据的表格代号
        };
    };
 
    BusinessDataInProcess.prototype.getContent = function(){
        var that = this;
        if($webUtil.isNotNull(that.taskOidInProcess) && that.taskOidInProcess.indexOf(",")>-1){
            return '<div><span>只有单个流程的时候才能查看关联文件</span></div>';
        }
        var html = '<div id="webProBusinessDataPanel_' + that.id + '">' ;
        if($webUtil.isNull(that.detailUrl)){
            html += '<table id="data_'  + that.id  + '" lay-filter="data_' + that.id + '" ></table>';
        }
        html += '</div>'
        return html;
    }
    BusinessDataInProcess.prototype.init = function() {
        var that = this;
        if ($webUtil.isNotNull(that.taskOidInProcess) && that.taskOidInProcess.indexOf(",") > -1) {
            return false;
        }
        if ($webUtil.isNotNull(that.detailUrl)) {
            //说明是自定义的页面
            var url = that.detailUrl;
            if ($webUtil.startWith(url.toUpperCase(), "USEJS:")) {
                url = url.substring(6);
                var contentMethod = "";
                var initMethod = "";
                var compJsPath = "";
                var params = "";
                if (url.indexOf("?") > -1) {
                    params = url.substring(url.indexOf("?") + 1);
                    url = url.substring(0, url.indexOf("?"));
                }
                if (url.indexOf("#") > -1) {
                    compJsPath = url.substring(0, url.indexOf("#"));
                    var methods = url.substring(url.indexOf("#") + 1);
                    if ($webUtil.isNotNull(methods) && methods.indexOf("|") > -1) {
                        //说明单独设置了的
                        contentMethod = methods.substring(0, methods.indexOf("|"));
                        initMethod = methods.substring(methods.indexOf("|") + 1);
                    } else {
                        if ($webUtil.isNotNull(methods)) {
                            initMethod = methods;
                        } else {
                            initMethod = "init";
                        }
                        contentMethod = "getContent";
                    }
                } else {
                    compJsPath = url;
                }
                var sourceData = {};
                if ($webUtil.isNotNull(params)) {
                    var paramsArray = params.split("&");
                    for (var i = 0; i < paramsArray.length; i++) {
                        var preParam = paramsArray[i].split("=");
                        sourceData[preParam[0]] = preParam[1];
                    }
                }
                sourceData['businessBtmInProcess'] = that.businessBtmInProcess;
                sourceData['businessOidsInProcess'] = that.businessOidsInProcess;
                sourceData['taskOidInProcess'] = that.taskOidInProcess;
                sourceData['processOid'] = that.processOid;
                sourceData['oids'] = that.businessOidsInProcess;
                sourceData['viewProcessLinkBusinessToken'] = that.viewProcessLinkBusinessToken;
                sourceData['executionidNo'] = that.executionidNoInProcess;
                sourceData['executionid'] = that.executionid;
                sourceData['maxWidth'] = that.maxWidth;
                sourceData['maxHeight'] = that.maxHeight;
                sourceData['dataStore'] = that.businessDataInProcess;
                layui.use(compJsPath, function () {
                    var comp = layui[compJsPath];
                    comp.id = that.id + "_js";
                    comp.sourceData = sourceData;
                    $("#webProBusinessDataPanel_" + that.id).html(comp[contentMethod]());
                    comp[initMethod]();
                });
            } else {
                //使用iframe包裹,需要先处理参数
                var url = that.detailUrl;
                if (url.indexOf("?")) {
                    url += "&";
                } else {
                    url += "?";
                }
                var params = "businessBtmInProcess=" + that.businessBtmInProcess + "&businessOidsInProcess=" + that.businessOidsInProcess +
                    "&taskOidInProcess=" + that.taskOidInProcess +"&processOid=" + that.processOid +"&oids=" + that.businessOidsInProcess +
                    "&viewProcessLinkBusinessToken=" + that.viewProcessLinkBusinessToken +
                    "&executionid=" + that.executionid + "&executionidNo=" + that.executionidNoInProcess +
                    "&maxWidth=" + that.maxWidth;
                $("#webProBusinessDataPanel_" + that.id).html('<iframe src="' + url + params + '" style="width:100%;height:100%" frameborder=0 frameScroll=auto ></iframe>');
            }
        } else if ($webUtil.isNotNull(that.tableCode)) {
            //表格定义
            that.renderDataTable(that.businessBtmInProcess, that.tableCode, that.taskOidInProcess,that.processOid);
        } else if ($webUtil.isNotNull(that.UIContentCode)) {
            //UI上下文
            layui.use('platform/objectService/VciUIContentViewer', function () {
                var newTabClass = layui['platform/objectService/VciUIContentViewer'];
                newTabClass.id = that.id;
                newTabClass.multiCompent = true;
                newTabClass.sourceData = {
                    btmType: that.businessBtmInProcess,
                    content: that.UIContentCode,
                    dataOid:that.businessOidsInProcess,
                    actionData: {
                        isOpen: true,
                        paramVOS:{
                            taskOidInProcess: that.taskOidInProcess,
                            taskNodeName: that.taskCodeInProcess,
                            oids:that.businessOidsInProcess,
                            processOid: that.processOid,
                            viewProcessLinkBusinessToken: that.viewProcessLinkBusinessToken,
                            executionidNo:that.executionidNoInProcess,
                            executionid: that.executionid
                        },
                        dataStore:that.businessDataInProcess
                    }
                };
                $('#webProBusinessDataPanel_' + that.id).html(newTabClass.getContent(that.id))
                newTabClass.init(that.id, newTabClass.sourceData)
            });
 
        } else {
            that.renderDataTable(that.defaults.dataTableBtmType, that.defaults.dataTableCode, that.taskOidInProcess,that.processOid);
        }
    }
    BusinessDataInProcess.prototype.renderDataTable = function(btmType,tableCode,taskOid,processOid,callback){//使用平台的来显示
        var me = this;
        var requestData = {
            "conditionMap['taskOid']":taskOid,
            "conditionMap['processOid']":processOid,
            "conditionMap['viewProcessLinkBusinessToken']":me.viewProcessLinkBusinessToken,
            "isMuti":true,
            "btmType":btmType,
            "id":tableCode,
            "tableCode":tableCode
        };
 
        $webUtil.get('webUIController/getTableDefineById', requestData, function (result) {
            if (result.success) {
                requestData['queryScheme'] = result.obj.querySchema;
                var cols = [];
                for (var i = 0; i < result.obj.cols.length; i++) {
                    layui.each(result.obj.cols[i], function (_index, record) {
                        if (record.field.indexOf("t_oid.") > -1) {
                            record.field = record.field.replace("t_oid.", "");
                        }
                        result.obj.cols[i][_index]=record;
                    });
                    if (i == 0) {
                        result.obj.cols[i].unshift({
                            field: layui.table.config.indexName,
                            type: 'numbers',
                            title: '序号',
                            rowspan: result.obj.cols.length,
                            width: 40
                        })
                    }
                    cols.push(result.obj.cols[i]);
                }
                //可以定义表格了
                layui.table.render({
                    elem: "#data_" + me.id,
                    id: "data_" + me.id,
                    url: me.url.data,
                    backPath: me.backPath,
                    page: {
                        limit: result.obj.limit ? result.obj.limit : 10,
                        page: result.obj.page? result.obj.page :1
                    },
                    limits: result.obj.limits,
                    where: requestData,
                    method: 'get',
                    selectMode: layui.table.selectMode.single,
                    cols: cols,
                    done: function (res, cur, total) {
                        if (total > 0) {
                            layui.table.selectRecord("data_" + me.id, {index: 0});
                        }
                        if(callback){
                            callback()
                        }
                    },
                    rowClick: function (thisTableFilter, record,isChecked) {
                    },
                    rowDBLClick:function (thisTableFilter, record){
                    }
                })
            } else {
                $webUtil.showErrorMsg(result.msg);
            }
        });
    };
 
    var bdp = new BusinessDataInProcess();
    exports('process/vciWebProBusinessData',bdp);
});