/**
|
* Created by weidy on 2018/5/22
|
* 流程代理
|
*/
|
layui.define(['layer','table','form'],function(exports){
|
var WorkFlowProxy = function(){
|
this.moduleKey = "vciWebProProxy";
|
this.id = "vciWebProProxy_table";
|
this.backPath = configData.compatibility ? path : configData.processServicePath;//默认流程和项目的路径是一样的
|
this.userBackPath = path;//用户的后台路径,默认和项目路径是一样的
|
this.url = {
|
getProxy :'webProcessCommandController/getProxy',
|
startProxy: 'webProcessCommandController/startProxy',
|
endProxy:'webProcessCommandController/endProxy',
|
referUser:'userQueryController/refDataGrid'//queryUserTree'
|
};
|
this.columns = [];
|
};
|
WorkFlowProxy.prototype.getContent = function(){//获取基础的html
|
var that = this;
|
return ['<div layui-filter="toolbar_',that.id, '" class="layui-btn-container">',//主列表的按钮
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_startProxy"><i class="layui-icon layui-icon-logo"></i>添加代理</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_endProxy"><i class="layui-icon layui-icon-haoyouqingqiu"></i>停止代理</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_refresh"><i class="layui-icon layui-icon-refresh-2"></i>刷新</button>',
|
'</div>',
|
'<table id="table_', that.id , '" lay-filter="',that.id , '"></table>'].join("");//主列表
|
};
|
WorkFlowProxy.prototype.init = function(){//初始化
|
var that = this;
|
$webUtil.copyConfig(that,that.moduleKey);
|
//显示表格信息
|
that.checkColumns();
|
var table =layui.table;
|
table.render({
|
elem: "#table_" + that.id,
|
id: that.id,
|
backPath:that.backPath,
|
url:that.url.getProxy,
|
height:150,
|
cols:[that.columns],
|
done:function(res,cur,count){
|
that.proxyCount = count;
|
}
|
});
|
that.bindButtonListener();
|
};
|
WorkFlowProxy.prototype.checkColumns=function(){
|
var that = this;
|
var table = layui.table;
|
if(!that.columns || that.columns.length == 0){
|
that.columns = [table.getIndexColumn(),{
|
field:'tasksName',
|
title:'代理人账号',
|
width:150
|
},{
|
field:'userName',
|
title:'代理人',
|
width:220
|
},{
|
field:'startTime',
|
title:'开始日期',
|
width:135
|
},{
|
field:'endTime',
|
title:'结束日期',
|
width:135
|
},{
|
field:'isTrue',
|
title:'启用状态',
|
width:150,
|
templet:function(d){
|
if(d.isTrue == 1){
|
return "启用";
|
}else{
|
return "停用";
|
}
|
}
|
}]
|
}
|
};
|
WorkFlowProxy.prototype.bindButtonListener=function(){
|
var that =this;
|
$("[layui-filter='toolbar_" + that.id + "_startProxy']").click(function(){
|
if(that.proxyCount>0){
|
$webUtil.showConfirmMsg("已经设置过代理人,只能设置一个代理人,继续操作将会覆盖原来的设置。是否继续?",function(){
|
that.showStartProxy();
|
});
|
}else{
|
that.showStartProxy();
|
}
|
});
|
$("[layui-filter='toolbar_" + that.id + "_refresh']").click(function(){
|
that.refresh();
|
});
|
$("[layui-filter='toolbar_" + that.id + "_endProxy']").click(function(){
|
that.endProxy();
|
});
|
};
|
WorkFlowProxy.prototype.refresh = function(){
|
var that =this;
|
var table = layui.table;
|
table.reload(that.id);
|
};
|
/**
|
* 设置流程代理人窗口
|
* 需要选择一个用户
|
* 然后选择开始日期
|
*/
|
WorkFlowProxy.prototype.showStartProxy = function(){
|
var that = this;
|
var formId = "start_process_proxy_form" ;
|
var form = layui.form;
|
var table = layui.table;
|
var startProxyIndex = layer.open({
|
type:1,
|
title:'设置流程代理人',
|
btn:['确定','取消'],
|
skin:'layui-layer-lan',
|
content:'<form id="' + formId + '" lay-filter="' + formId + '" class="layui-form" ></form>',
|
area:[620 +'px', 300 + 'px'],
|
closeBtn:2,
|
shade:true,
|
shadeClose:true,
|
resize:true,
|
resizing:function(layero){
|
form.doResize();
|
},
|
yes:function(index,layero){
|
if(form.validata(formId)){
|
//校验通过
|
var values = form.getValues(formId);
|
delete values.name;
|
$webUtil.post(that.url.startProxy,values,function(result){
|
if(result.success){
|
$webUtil.showMsg("设置流程代理人成功");
|
layer.close(startProxyIndex);
|
that.refresh();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function(result){},that.backPath);
|
}
|
},
|
btn2:function(index,layero){
|
layer.close(startProxyIndex);
|
that.refresh();
|
},
|
cancel:function(index,layero){
|
that.refresh();
|
},
|
success:function(layero) {
|
var formItems = [{
|
type: 'refer',
|
name: 'userId',
|
text: '流程代理人',
|
required: true,
|
labelWidth: 120,
|
textWidth: 400,
|
showField:'userName',
|
referConfig:{
|
type:'refer/SmUserRefer',
|
valueField:'id'
|
}
|
}, {
|
type: 'date',
|
name: 'startTime',
|
text: '开始时间',
|
textWidth: 400,
|
required:true,
|
labelWidth: 120,
|
value:$webUtil.getSystemVar($webUtil.systemValueKey.currentDate),
|
min:$webUtil.getSystemVar($webUtil.systemValueKey.currentDate)
|
},{
|
type:'date',
|
name:'endTime',
|
text:'结束时间',
|
textWidth:400,
|
required:true,
|
labelWidth:120,
|
min:$webUtil.getSystemVar($webUtil.systemValueKey.currentDate)
|
}];
|
form.addItems(formId,formItems,function() {
|
//form.setValues({
|
//startTime: $webUtil.getSystemVar($webUtil.systemValueKey.currentDate)
|
//});
|
form.on('select(' + formId + ')', function (data) {
|
if (data.name == 'startTime') {
|
var values = form.getValues(formId);
|
if (values.endTime <= data.value) {
|
form.setValues({endTime: ''}, formId);
|
}
|
} else if (data.name == 'endTime') {
|
var values = form.getValues(formId);
|
if (values.startTime >= data.value) {
|
form.setValues({startTime: ''}, formId);
|
}
|
}
|
})
|
},{},{
|
defaultColumnOneRow:1,
|
inDialog:true
|
});
|
}
|
});
|
};
|
/**
|
* 停止代理,会将设置的代理的信息直接删除
|
*/
|
WorkFlowProxy.prototype.endProxy =function(){
|
var that =this;
|
$webUtil.showConfirmMsg("是否停止代理流程",function(){
|
$webUtil.post(that.url.endProxy,{},function(result){
|
if(result.success){
|
$webUtil.showMsg("停止代理流程成功");
|
that.refresh();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function(result){},that.backPath);
|
});
|
};
|
|
var sp = new WorkFlowProxy();
|
exports("process/vciWebProProxy",sp);
|
});
|