/**
|
* Created by dengbk on 2019/4/26.
|
* 执行中的流程.已挂起流程,已终止流程,已完成流程公用页面
|
*/
|
layui.define(['layer','element','form','table','vciWebDataGrid','flow','process/vciWebProExecuteTask','vciWebFileManager'],function(exports){
|
/**
|
* 主区域为待办任务的列表
|
* 下方的区域分为三个选项卡【关联数据】【流程历史】【流程图】
|
* 主区域的待办任务列表的后台路径与主页中的挂件一致
|
* 主页中的查看数据的后台路径与此页面的【关联数据】中一致
|
*/
|
var ExecutPro = function(){
|
this.moduleKey = "vciWebProExecutingTab";
|
this.id='vciWebProExecutingTab';
|
this.sourceData={};
|
this.columns = [];
|
this.backPath = configData.compatibility ? path : configData.processServicePath;//默认流程和项目的路径是一样的
|
this.isDebug = false;
|
this.url={
|
task:'processDefineController/getMyUndoTask',
|
dataDefine:'processDefineController/getDataDefine',//从后台获取显示关联数据的列表的code
|
data:'processDefineController/getDataByTask',
|
history:'processDefineController/getHistory',
|
picture:'processDefineController/getProcessPic',
|
dataGridDetail:'webTrailorderplanController/getOrderItemByOidUnAccept',//trailorderplan获取详细
|
executing:'processDefineController/getMyExecutingProcess',//执行中的流程
|
allExecuting:'processDefineController/getAllExecutingProcess',//执行中的全部流程
|
suspended:'processDefineController/getMySuspendedProcess',//已挂起流程
|
allSuspended:'processDefineController/getAllSuspendedProcess',//全部挂起的流程
|
end:'processDefineController/getMyEndProcess',//已终止流程
|
allEnd:'processDefineController/getAllEndProcess',//全部已终止的流程
|
finish:'processDefineController/getMyFinishProcess',//已完成流程
|
allFinish:'processDefineController/getAllFinishProcess',//全部完成的流程
|
done:'processDefineController/getMyDoneProcessTask',//已办任务
|
endProcess:'webProcessCommandController/endProcess',//终止流程
|
suspendProcess:'webProcessCommandController/suspendProcess',//冻结流程
|
resumeProcess:'webProcessCommandController/resumeProcess'//回复流程
|
};
|
this.defaults = {
|
dataShowByOid:true,//是否根据任务的不同来显示不同的数据列表--如果流程中没有添加dataDisplayTable变量请设置为false
|
dataTableBtmType:"input",//关联数据的表格在的业务类型,用于查询平台中的列表
|
dataTableCode:"ShowMyTaskLinkDataList"//关联数据的表格代号
|
};
|
this.limit={
|
task:10,
|
data:5,
|
history:5
|
};
|
this.getContent=function(){//返回这个组件的基础html
|
var me = this;
|
if(me.sourceData && "page" in me.sourceData){
|
me.id = me.id + "_" + me.sourceData.page;
|
}
|
var html = [ '<div class="layui-layout-border">',
|
'<div layui-filter="toolbar_',me.id, '" class="layui-btn-container">',//主列表的按钮
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',me.id,'_freez" compid ="',me.id,'" style="display:none"><i class="layui-icon layui-icon-logo"></i>冻结</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',me.id,'_stop" compid ="',me.id,'" style="display:none"><i class="layui-icon layui-icon-refresh-2"></i>终止</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',me.id,'_resume" compid ="',me.id,'" style="display:none"><i class="layui-icon layui-icon-refresh-2"></i>恢复</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',me.id,'_refresh" compid ="',me.id,'" ><i class="layui-icon layui-icon-refresh-2"></i>刷新</button>',
|
|
'</div>',
|
'<div class="layui-center" style="max-height:400px">',
|
|
'<table id="table_', me.id , '" lay-filter="table_',me.id , '"></table>',//主列表
|
'</div>',
|
'<div class="layui-south" style="min-height:100px;padding:0 5px">',
|
'<div layui-filter="south_toolbar_',me.id, '" class="layui-btn-container">',//主列表的按钮
|
|
'</div>',
|
'<div class="layui-tab">' ,//底部选项卡
|
'<ul class="layui-tab-title">',
|
'<li class="layui-this">关联数据</li>',
|
'<li>审批历史</li>',
|
'<li>流程图</li>',
|
'</ul>',
|
'<div class="layui-tab-content">',
|
'<div class="layui-tab-item layui-show">', //默认显示关联数据
|
'<div id="data_div_' , me.id , '" layui-filter="data_div_',me.id,'" ></div>',
|
'</div>',
|
'<div class="layui-tab-item" style="width:100%"><div id="history_div_' , me.id , '" lay-filter="history_div_' , me.id , '" ></div></div>' ,
|
'<div class="layui-tab-item" id="picture_parent_',me.id,'" style="overflow-y:auto;"><span>点击图片可以放大查看</span><img layer-pid="picture_' , me.id , '" lay-filter="picture_' , me.id , '" src="" alt="流程图" style="width:1000px;display:block" /></div>',
|
'</div>',
|
'</div>',
|
'</div>',
|
'</div>'
|
].join("");
|
return html;
|
};
|
this.getUrlByPage = function(){
|
var url = '',that = this,urlArr = that.url;
|
var page = that.sourceData.page;
|
if(page){
|
for(var item in urlArr){
|
if(item == page){
|
url = urlArr[item];
|
}
|
}
|
if(page == 'executing'){
|
$("button[layui-filter='toolbar_"+that.id+"_freez']").show();
|
$("button[layui-filter='toolbar_"+that.id+"_stop']").show()
|
}
|
if(page == 'suspended'){
|
$("button[layui-filter='toolbar_"+that.id+"_resume']").show()
|
}
|
}else{
|
url = urlArr.task;
|
}
|
return url;
|
};
|
this.init=function(){//基础的html被添加后,再执行初始化
|
var me = this;
|
me.columns = null;
|
$webUtil.copyConfig(me,me.moduleKey);
|
var table = layui.table;
|
me.checkColumns();//主列表中列。
|
table.render({
|
elem:'#table_' + me.id,
|
id:'table_' + me.id,
|
url:me.backPath + me.getUrlByPage(),
|
page:{
|
limit:me.limit.task,
|
page:1
|
},
|
height:400,
|
cols:[me.columns],
|
done:function(res,cur,count){
|
table.selectRecord('table_' + me.id,[{index:0}]);
|
},
|
rowClick:function(thisTableFilter,record){
|
me.showDataTable(record);
|
me.showHistoryPic(record.executionid,record.oid);
|
}
|
});
|
var searchFieldObject = {
|
name: "流程名称",
|
executionid:"所属流程模板",
|
description:"流程启动时描述"
|
};
|
if("done" == me.sourceData.page){
|
searchFieldObject['name'] = '任务名称';
|
}
|
$webUtil.createSearchHtml(searchFieldObject, $('[layui-filter="toolbar_' + me.id + '"]'), 'table_' +me.id);
|
me.bindListeners();
|
};
|
this.bindListeners = function(){
|
var that = this;
|
$("img[layer-pid='picture_" + that.id + "']").click(function(){
|
that.showImgFullScreen();
|
});
|
$("[layui-filter='toolbar_" + that.id + "_execute']").click(function(){
|
var table = layui.table;
|
var checkData = table.checkStatus('table_' + that.id);
|
if(checkData && checkData.data && checkData.data.length>0){
|
var executeTask = layui['process/vciWebProExecuteTask'];
|
executeTask.init();
|
var taskInfo = [];
|
layui.each(checkData.data,function(_index,_item){
|
var task = _item;
|
task.taskOid = _item.oid;
|
task.taskName = _item.name;
|
task.executionId=_item.executionid
|
task.creator=_item.creator
|
taskInfo.push(task);
|
});
|
executeTask.showExecuteWindow(taskInfo,{
|
fullScreen:true
|
},function(finish){
|
if(finish){
|
table.reload('table_' + that.id);
|
}
|
});
|
}else{
|
$webUtil.showErrorMsg("没有选择流程任务");
|
}
|
});
|
$("[layui-filter='toolbar_" + that.id + "_stop']").click(function(){
|
var compid = $(this).attr("compid");
|
that.stop(compid);
|
});
|
$("[layui-filter='toolbar_" + that.id + "_freez']").click(function(){
|
var compid = $(this).attr("compid");
|
that.freez(compid);
|
});
|
$("[layui-filter='toolbar_" + that.id + "_resume']").click(function(){
|
var compid = $(this).attr("compid");
|
that.resume(compid);
|
});
|
$("[layui-filter='toolbar_" + that.id + "_refresh']").click(function(){
|
var compid = $(this).attr("compid");
|
that.refresh(compid);
|
});
|
};
|
this.refresh = function(id){
|
var table = layui.table;
|
table.reload("table_" + id,{});
|
};
|
this.refreshAll = function() {
|
var that = this;
|
var btns = $('.layui-buttons .layui-btn[layui-filter$="_refresh"]');
|
layui.each(btns, function (i, btn) {
|
var compid = $(btn).attr("compid");
|
that.refresh(compid)
|
})
|
};
|
|
//冻结
|
this.freez = function(id){
|
var that = this;
|
var executionid = $webUtil.getOidFromGrid("table_" + id,true,false,'executionid');
|
if(!executionid){
|
return;
|
}
|
$webUtil.showConfirmMsg("您确定要冻结这个流程吗?",function(){
|
$webUtil.post(that.url.suspendProcess,{processOids:executionid},function(result){
|
if(result.success){
|
$webUtil.showMsg("冻结流程成功");
|
that.refresh();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function(){
|
// $webUtil.showErrorMsg("连接服务出现了问题");
|
},that.backPath);
|
});
|
|
};
|
//终止
|
this.stop = function(id){
|
var that = this;
|
var executionid = $webUtil.getOidFromGrid("table_" + id,true,false,'executionid');
|
if(!executionid){
|
return;
|
}
|
$webUtil.showConfirmMsg("您确定要终止这个流程吗?",function() {
|
$webUtil.post(that.url.endProcess, {processOids: executionid}, function (result) {
|
if (result.success) {
|
$webUtil.showMsg("终止流程成功");
|
that.refresh();
|
} else {
|
$webUtil.showErrorMsg(result.msg);
|
}
|
}, function () {
|
// $webUtil.showErrorMsg("连接服务出现了问题");
|
}, that.backPath);
|
});
|
};
|
//恢复
|
this.resume = function(id){
|
var that = this;
|
var executionid = $webUtil.getOidFromGrid("table_" + id,true,false,'executionid');
|
if(!executionid){
|
return;
|
}
|
$webUtil.showConfirmMsg("您确定要冻结这个流程吗?",function() {
|
$webUtil.post(that.url.resumeProcess, {processOids: executionid}, function (result) {
|
if (result.success) {
|
$webUtil.showMsg("恢复流程成功");
|
that.refresh();
|
} else {
|
$webUtil.showErrorMsg(result.msg);
|
}
|
}, function () {
|
}, that.backPath);
|
});
|
};
|
this.checkColumns = function(){
|
var that = this;
|
var table = layui.table;
|
var page = that.sourceData.page;
|
var finishTimeTitle = "完成时间";
|
if('suspended' == page){
|
finishTimeTitle = "冻结时间";
|
}
|
if(that.columns==null || that.columns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
|
if('done' == page){
|
that.columns = [table.getIndexColumn(),table.getCheckColumn(),{
|
field:'name',
|
title:'任务名称',
|
width:300
|
},{
|
field:'createtime',
|
title:'任务开始时间',
|
width:150,
|
templet:function(d){
|
return $webUtil.formateDateTimeNoSecond(d.createtime);
|
}
|
},{
|
field:'creator_name',
|
title:'上一步操作人',
|
width:120,
|
templet:function(d){
|
return d.creator_name + "(" + d.creator+")";
|
}
|
},{
|
field: 'ts',
|
title: '任务完成时间',
|
width: 150,
|
templet: function (d) {
|
return $webUtil.formateDateTimeNoSecond(d.ts);
|
}
|
},{
|
field: 'executionid',
|
title: '所属流程模板',
|
width: 200,
|
templet: function (d) {
|
if($webUtil.isNotNull(d.executionid) && d.executionid.indexOf(".") > -1){
|
return d.executionid.substring(0,d.executionid.indexOf("."));
|
}else{
|
return d.executionid;
|
}
|
}
|
},{
|
field:'secretgrade',
|
title:'密级',
|
width:80,
|
templet:function (d) {
|
if(d.secretgrade == '10' || d.secretgrade == 10){
|
return '非密';
|
}else if(d.secretgrade == '20' || d.secretgrade == 20){
|
return '秘密';
|
}else if(d.secretgrade == '30' || d.secretgrade == 30){
|
return '机密';
|
}else{
|
return '';
|
}
|
}
|
},{
|
field:'description',
|
title:'流程启动时描述',
|
width:200
|
}]
|
}else {
|
that.columns = [table.getIndexColumn(), table.getCheckColumn(), {
|
field: 'name',
|
title: '流程名称',
|
width: 300
|
}, {
|
field: 'creator_name',
|
title: '发起人',
|
width: 120,
|
templet:function(d){
|
return d.creator_name + "(" + d.creator +")";
|
}
|
}, {
|
field: 'createtime',
|
title: '发起时间',
|
width: 150,
|
templet: function (d) {
|
return $webUtil.formateDateTimeNoSecond(d.createtime);
|
}
|
}, {
|
field: 'ts',
|
title: finishTimeTitle,
|
width: 150,
|
hidden: (($webUtil.inArray(['finish', 'suspended'], page)) ? false : true),
|
templet: function (d) {
|
return $webUtil.formateDateTimeNoSecond(d.ts);
|
}
|
},{
|
field: 'executionid',
|
title: '所属流程模板',
|
width: 200,
|
templet: function (d) {
|
if($webUtil.isNotNull(d.executionid) && d.executionid.indexOf(".") > -1){
|
return d.executionid.substring(0,d.executionid.indexOf("."));
|
}else{
|
return d.executionid;
|
}
|
}
|
},{
|
field:'description',
|
title:'流程启动时描述',
|
width:200
|
}]
|
}
|
}
|
};
|
this.showDataTable = function(data){//获取数据表格中的相关定义
|
var me = this;
|
var compIdFix = data.oid;
|
$webUtil.post(me.url.dataDefine,{executionid:data.executionid},function(result){
|
if(result.success){
|
var businessDataComp = layui['process/vciWebProBusinessData'];//业务数据
|
var processHistoryComp = layui['process/vciWebProHistory'];//操作历史
|
|
businessDataComp.businessBtmInProcess = result.obj.UIType;
|
businessDataComp.businessOidsInProcess = result.obj.businessOids;
|
businessDataComp.processOid = data.oid;
|
businessDataComp.tableCode = result.obj.tableCode;
|
businessDataComp.detailUrl = result.obj.detailUrl;
|
businessDataComp.UIContentCode = result.obj.UIContentCode;
|
result.obj.UIContentCode && (businessDataComp.UIContentSelectData = data)
|
businessDataComp.viewProcessLinkBusinessToken = result.obj.viewProcessLinkBusinessToken;//用来在查看流程的数据时,告诉后台跳过权限的
|
businessDataComp.executionidNoInProcess = result.obj.executionidno;
|
businessDataComp.executionid = data.executionid;
|
businessDataComp.id = "vciProcessBusinessData_" +me.id+'_'+ compIdFix;
|
|
$("#data_div_" + me.id ).html(businessDataComp.getContent());
|
businessDataComp.init();
|
|
|
processHistoryComp.executionId=data.executionid;
|
processHistoryComp.id = "vciProcessHistory_" +me.id+'_' + compIdFix;
|
$("#history_div_" + me.id ).html(processHistoryComp.getContent());
|
processHistoryComp.init();
|
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function(){
|
$webUtil.showErrorMsg("连接服务出现了问题");
|
},me.backPath,true);
|
};
|
this.showHistoryPic = function(executionId,taskOid){
|
var that = this;
|
var url = "";
|
if(layui.util.isNotNull(executionId)){
|
url = that.backPath + that.url.picture + "?executionId=" + executionId + "&" + TOKEN_KEY + "=" + $webUtil.getToken();
|
}
|
$("img[layer-pid='picture_" + that.id + "']").attr("src",url);
|
};
|
this.destroy = function(){
|
var that = this;
|
that.taskDataConfig = null;
|
that.columns = null;
|
that.historyColumns = null;
|
var vciWebDataGrid = layui.vciWebDataGrid;
|
vciWebDataGrid.destroy("table_" + that.id);
|
};
|
this.showImgFullScreen = function(){//全屏显示图片
|
var that = this;
|
var layer = layui.layer;
|
var url = $("img[layer-pid='picture_" + that.id + "']").attr("src");
|
var alt = "流程图";
|
if(url && url.indexOf("executionId=")>-1){
|
alt = url.substring(url.indexOf("executionId=") + "executionId=".length );
|
if(alt.indexOf(".")>-1){
|
alt = alt.substring(0,alt.indexOf("."));
|
}
|
}
|
layer.photos({
|
photos:{
|
title:'查看流程图',
|
id:'show_picture_' +that.id,
|
start:0,
|
data:[{
|
alt:alt,
|
pid:0,
|
src:url,
|
thumb:url
|
}]
|
}
|
});
|
};
|
};
|
var ep = new ExecutPro();
|
exports('process/vciWebProMonitor',ep);
|
});
|