v2版本正式上线测试版
This commit is contained in:
@@ -1,170 +1,161 @@
|
||||
<!-- 任务列表 -->
|
||||
<div class="container-fluid">
|
||||
<div class="info-center">
|
||||
<!--title-->
|
||||
<div class="info-center">
|
||||
<div class="page-header">
|
||||
<div class="pull-left">
|
||||
<h4>{{.pageTitle}}</h4>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<!-- <button type="button" class="btn btn-mystyle btn-sm refresh">刷新</button>
|
||||
<button type="button" class="btn btn-mystyle btn-sm reback">返回</button> -->
|
||||
</div>
|
||||
<div class="layui-layout layui-layout-admin" style="padding-left: 20px;">
|
||||
<div class="layui-row" style="margin-top: 20px;">
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-btn-group">
|
||||
<a class="layui-btn" data-type="tabAdd" href="/task/add">新增</a>
|
||||
<button class="layui-btn batch" data-type="batchstart" >启动</button>
|
||||
<button class="layui-btn layui-btn-danger batch" data-type="batchpause" >暂停</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<!--content-list-->
|
||||
<div class="content-list">
|
||||
<div class="search-box row">
|
||||
<div class="col-md-4">
|
||||
<div class="btn-group pull-left" role="group" aria-label="...">
|
||||
<a href='{{urlfor "TaskController.Add"}}' class="btn btn-primary"><span class="glyphicon glyphicon-plus"></span> 新增任务</a>
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="glyphicon glyphicon-edit"></span> 批量操作
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="javascript:;" onclick="javascript:batch('active');"><span class="glyphicon glyphicon-expand" aria-hidden="true"></span> 激活</a></li>
|
||||
<li><a href="javascript:;" onclick="javascript:batch('pause');"><span class="glyphicon glyphicon-pause" aria-hidden="true"></span> 暂停</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="javascript:;" onclick="javascript:batch('delete');"><span class="glyphicon glyphicon-remove-sign" aria-hidden="true"></span> 删除</a></li>
|
||||
</ul>
|
||||
<div class="layui-col-xs6 search_text">
|
||||
<form class="layui-form" action="" onsubmit="javascript:return false;">
|
||||
<div class="demoTable">
|
||||
|
||||
<div class="layui-inline" style="width: 40%">
|
||||
|
||||
<input class="layui-input" name="taskName" id="taskName" autocomplete="off" placeholder="任务名称" >
|
||||
</div>
|
||||
<button class="layui-btn" data-type="reload" id="reload">查询</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class=" btn-large pull-right" >
|
||||
<form method="post" name="s" action="{{urlfor "TaskController.List"}}">
|
||||
<select name="groupid" class="btn-large form-control">
|
||||
<option value="99">全部分组</option>
|
||||
{{range $k, $v := .groups}}
|
||||
<option value="{{$v.Id}}" {{if eq $v.Id $.groupid}}selected{{end}} >{{$v.GroupName}}</option>
|
||||
{{end}}
|
||||
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<div class="table-margin">
|
||||
<form id="form-list" method="post" action="">
|
||||
<table class="table table-bordered table-header">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="all_check" /></td>
|
||||
<td>ID</td>
|
||||
<td width="20%">任务名称</td>
|
||||
<td>服务器</td>
|
||||
<td>任务说明</td>
|
||||
<td>上次执行时间</td>
|
||||
<td>下次执行时间</td>
|
||||
<td width="25%">操作</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range $k,$v := .list}}
|
||||
<tr {{if eq $v.is_odd 0 }} style="background: #FFFFFF " {{else}} style="background: #f8f8f8" {{end}}>
|
||||
<td class="chk"><input type="checkbox" name="ids" value="{{$v.id}}" /></td>
|
||||
<td> {{$v.id}} </td>
|
||||
<td>
|
||||
{{if eq $v.running 0}}
|
||||
<span class="glyphicon glyphicon-minus-sign brand-danger" aria-hidden="true"></span>
|
||||
{{else}}
|
||||
<span class="glyphicon glyphicon-ok-sign brand-success " aria-hidden="true"></span>
|
||||
{{end}}
|
||||
{{$v.group_name}}-{{$v.name}}
|
||||
</td>
|
||||
<td> {{$v.server_name}} </td>
|
||||
|
||||
<td> {{$v.description}} </td>
|
||||
<td> {{$v.prev_time}} </td>
|
||||
<td> {{$v.next_time}} </td>
|
||||
<td>
|
||||
{{if eq $v.status 0}}
|
||||
<a class="btn btn-danger btn-xs" href="{{urlfor "TaskController.Start"}}?id={{$v.id}}">
|
||||
<span class="glyphicon glyphicon-expand" aria-hidden="true"></span> 激活
|
||||
</a>
|
||||
<a class="btn btn-info btn-xs" href="{{urlfor "TaskController.Edit"}}?id={{$v.id}}">
|
||||
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span> 编辑
|
||||
</a>
|
||||
{{else}}
|
||||
<a class="btn btn-success btn-xs" href="{{urlfor "TaskController.Pause"}}?id={{$v.id}}">
|
||||
<span class="glyphicon glyphicon-pause" aria-hidden="true"></span> 暂停
|
||||
</a>
|
||||
<a class="btn btn-default btn-xs" href="javascript:void(0)" onclick="alert('激活状态无法编辑任务,请先暂停任务');">
|
||||
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span> 编辑
|
||||
</a>
|
||||
{{end}}
|
||||
<a class="btn btn-info btn-run btn-xs" href="{{urlfor "TaskController.Run"}}?id={{$v.id}}">
|
||||
<span class="glyphicon glyphicon-flash" aria-hidden="true"></span> 执行
|
||||
</a>
|
||||
<a class="btn btn-info btn-xs" href="{{urlfor "TaskController.Logs"}}?id={{$v.id}}">
|
||||
<span class="glyphicon glyphicon-file" aria-hidden="true"></span> 日志
|
||||
</a>
|
||||
|
||||
<a class="btn btn-info btn-xs" href="{{urlfor "TaskController.Copy"}}?id={{$v.id}}">
|
||||
<span class="glyphicon glyphicon-copy" aria-hidden="true"></span> 复制
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
<div class="pull-right">
|
||||
{{str2html .pageBar}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="layui-hide" id="table_list" lay-filter="table_filter">
|
||||
</table>
|
||||
|
||||
<script type="text/html" id="bar">
|
||||
{{/*<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="status">启|停</a>*/}}
|
||||
{{/*<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>*/}}
|
||||
<a class="layui-btn layui-btn-xs " lay-event="detail">详细</a>
|
||||
<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="run">测试</a>
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="log">日志</a>
|
||||
</script>
|
||||
</div>
|
||||
<script>
|
||||
$(function() {
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
$("select[name='groupid']").change(function () {
|
||||
$("form[name='s']").submit();
|
||||
});
|
||||
$(".btn-run").click(function () {
|
||||
return confirm("该功能建议只用来做任务测试,确定要立即执行该任务吗?");
|
||||
});
|
||||
});
|
||||
|
||||
function batch(action) {
|
||||
|
||||
if ($("input[name=ids]:checked").size() < 1) {
|
||||
alert_message("请选择要操作的任务","alert-danger","alert-success");
|
||||
} else {
|
||||
|
||||
if(action=='delete'){
|
||||
if(!confirm("确定要删除所选吗?")) return;
|
||||
layui.use(['table','form','element'], function(){
|
||||
var table = layui.table;
|
||||
var form = layui.form;
|
||||
var element = layui.element;
|
||||
var error_info = "{{.flash.error}}";
|
||||
if(error_info){
|
||||
layer.msg(error_info,{icon: 2,shade:0.3},function () {
|
||||
window.history.go(-1)
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
var url = "{{urlfor "TaskController.Batch"}}";
|
||||
$.post(url + "?action=" + action, $("#form-list").serialize(), function(out) {
|
||||
if (out.status != 0) {
|
||||
alert_message(out.msg,"alert-danger","alert-success");
|
||||
} else {
|
||||
window.location.reload();
|
||||
//方法级渲染
|
||||
table.render({
|
||||
elem: '#table_list'
|
||||
,url: '/task/table'
|
||||
,cols: [[
|
||||
{checkbox: true, fixed: true},
|
||||
{field:'id', title: 'ID', align:'center',sort: true, width:50}
|
||||
,{field:'task_name',title: '任务名称'}
|
||||
,{field:'description',title: '任务说明'}
|
||||
|
||||
,{field:'next_time', width:170,title: '下次执行时间'}
|
||||
,{field:'pre_time', width:170,title: '上次执行时间'}
|
||||
,{field:'execute_times', width:70,title: '次数'}
|
||||
,{fixed: 'right', width:260, align:'center', title:'操作', toolbar: '#bar'}
|
||||
]]
|
||||
,id: 'listReload'
|
||||
,page: true
|
||||
,height: "full-130"
|
||||
});
|
||||
|
||||
var $ = layui.$, active = {
|
||||
reload: function(){
|
||||
table.reload('listReload', {
|
||||
where: {
|
||||
taskName: $('#taskName').val(),
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "json");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//点击行换色
|
||||
$('tbody tr').click(function(){
|
||||
$(this).addClass("warning").siblings().removeClass("warning");
|
||||
});
|
||||
};
|
||||
|
||||
//监听工具条
|
||||
table.on('tool(table_filter)', function(obj){
|
||||
var data = obj.data;
|
||||
if(obj.event === 'edit'){
|
||||
window.location.href="/task/edit?id="+data.id
|
||||
} else if(obj.event === 'log'){
|
||||
window.location.href="/tasklog/list?task_id="+data.id;
|
||||
}else if (obj.event==='detail'){
|
||||
window.location.href='/task/detail?id='+data.id;
|
||||
}else if (obj.event==='run'){
|
||||
layer.confirm("测试执行任务,注意不要超时,请确认执行", {icon: 3, title:'提示'}, function(index){
|
||||
layer.load();
|
||||
$.post('/task/ajaxrun', {id:data.id}, function (out) {
|
||||
if (out.status == 0) {
|
||||
layer.msg("操作成功",{icon: 1},function () {
|
||||
window.location.href="/tasklog/list?task_id="+data.id
|
||||
})
|
||||
} else {
|
||||
layer.msg(out.message)
|
||||
return
|
||||
}
|
||||
}, "json");
|
||||
setTimeout(function(){
|
||||
layer.closeAll('loading');
|
||||
}, 2000);
|
||||
layer.close(index);
|
||||
});
|
||||
}else if (obj.event==='status'){
|
||||
layer.msg("状态")
|
||||
}else{
|
||||
layer.msg('操作不存在')
|
||||
}
|
||||
});
|
||||
|
||||
$(".batch").on('click',function (obj) {
|
||||
var action = $(this).attr('data-type');
|
||||
var checkStatus = table.checkStatus('listReload');
|
||||
var data = checkStatus.data;
|
||||
if(data.length<1){
|
||||
layer.msg("请选择操作数据");
|
||||
return;
|
||||
}
|
||||
|
||||
var msg = "确认启动这些任务吗";
|
||||
if (action=='batchpause'){
|
||||
msg = "确定暂定这些任务吗";
|
||||
}
|
||||
|
||||
layer.confirm(msg, {icon: 3, title:'提示'}, function(index){
|
||||
var ids = "";
|
||||
$.each(data,function (k,v) {
|
||||
ids += v.id+",";
|
||||
});
|
||||
ids = ids.substr(0,ids.length-1);
|
||||
|
||||
layer.load();
|
||||
$.post('/task/ajax'+action, {"ids":ids}, function (out) {
|
||||
if (out.status == 0) {
|
||||
layer.msg("操作成功",{icon: 1},function () {
|
||||
$('#reload').click();
|
||||
})
|
||||
} else {
|
||||
layer.msg(out.message)
|
||||
return
|
||||
}
|
||||
}, "json");
|
||||
setTimeout(function(){
|
||||
layer.closeAll('loading');
|
||||
}, 2000);
|
||||
|
||||
|
||||
layer.close(index);
|
||||
});
|
||||
return ;
|
||||
})
|
||||
|
||||
$('.demoTable .layui-btn').on('click', function(){
|
||||
var type = $(this).data('type');
|
||||
active[type] ? active[type].call(this) : '';
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user