var mmg;
function initGrid(){
var h = WST.pageHeight();
var cols = [
{title:'计划任务名称', name:'cronName', width: 80},
{title:'计划任务描述', name:'cronDesc', width: 150},
{title:'上次执行时间', name:'runTime', width: 70, renderer: function(val,item,rowIndex){
return (item['runTime']==0)?'-':item['runTime'];
}},
{title:'执行状态', name:'isEnable', width: 20, renderer: function(val,item,rowIndex){
return (item['isRunSuccess']==1)?' 成功':' 失败';
}},
{title:'下次执行时间', name:'nextTime', width: 70, renderer: function(val,item,rowIndex){
return (item['nextTime']==0)?'-':item['nextTime'];
}},
{title:'作者', name:'auchor', width: 20, renderer: function(val,item,rowIndex){
return ''+item['author']+'';
}},
{title:'计划状态', name:'isEnable', width: 20, renderer: function(val,item,rowIndex){
return (item['isEnable']==1)?' 启用':' 停用';
}},
{title:'操作', name:'' ,width:120, align:'center', renderer: function(val,item,rowIndex){
var h="";
if(WST.GRANT.CRON_JHRW_04){
h += "修改 ";
if(item['isEnable']==0){
h += "启用 ";
}else{
h += "停用 ";
h += '执行';
}
}
return h;
}}
];
mmg = $('.mmg').mmGrid({height: h-115,indexCol: true, cols: cols,method:'POST',
url: WST.AU('cron://cron/pageQuery'), fullWidthRows: true, autoLoad: true,
plugins: [
$('#pg').mmPaginator({})
]
});
$('#headTip').WSTTips({width:90,height:35,callback:function(v){
var diff = v?115:88;
mmg.resize({height:h-diff})
}});
}
function toEdit(id){
location.href=WST.AU('cron://cron/toEdit','id='+id);
}
function checkType(v){
$('.cycle').hide();
$('.cycle'+v).show();
}
function run(id){
var box = WST.confirm({content:'你确定要执行该任务吗?',yes:function(){
var loading = WST.msg('正在执行计划任务,请稍后...',{icon: 16,time:6000000000});
$.post(WST.AU('cron://cron/runCron'),{id:id},function(data,textStatus){
layer.close(loading);
var json = WST.toAdminJson(data);
if(json.status=='1'){
WST.msg(json.msg,{icon:1});
layer.close(box);
mmg.load();
}else{
WST.msg(json.msg,{icon:2});
}
})
}});
}
function edit(id){
var params = WST.getParams('.ipt');
params.id = id;
var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
$.post(WST.AU('cron://cron/edit'),params,function(data,textStatus){
layer.close(loading);
var json = WST.toAdminJson(data);
if(json.status=='1'){
WST.msg("操作成功",{icon:1},function(){
location.href=WST.AU('cron://cron/index');
});
}else{
WST.msg(json.msg,{icon:2});
}
});
}
function changgeEnableStatus(id,type){
var msg = (type==1)?"您确定要启用该计划任务吗?":"您确定要停用该计划任务吗?"
var box = WST.confirm({content:msg,yes:function(){
var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
$.post(WST.AU('cron://cron/changeEnableStatus'),{id:id,status:type},function(data,textStatus){
layer.close(loading);
var json = WST.toAdminJson(data);
if(json.status=='1'){
WST.msg(json.msg,{icon:1});
layer.close(box);
mmg.load();
}else{
WST.msg(json.msg,{icon:2});
}
});
}});
}