/**
* 流程关联的业务数据查看器
* 分为三种的查看方式
* 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 '
只有单个流程的时候才能查看关联文件
';
}
var html = '' ;
if($webUtil.isNull(that.detailUrl)){
html += '
';
}
html += '
'
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('');
}
} 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);
});