提交 | 用户 | 时间
|
1ac2bc
|
1 |
layui.use(['table', 'admin', 'ax', 'func'], function () { |
懒 |
2 |
var $ = layui.$; |
|
3 |
var table = layui.table; |
|
4 |
var $ax = layui.ax; |
|
5 |
var admin = layui.admin; |
|
6 |
var func = layui.func; |
|
7 |
var form = layui.form; |
|
8 |
|
|
9 |
/** |
|
10 |
* 定时任务调度表管理 |
|
11 |
*/ |
|
12 |
var SysJob = { |
|
13 |
tableId: "sysJobTable" |
|
14 |
}; |
|
15 |
|
|
16 |
/** |
|
17 |
* 初始化表格的列 |
|
18 |
*/ |
|
19 |
SysJob.initColumn = function () { |
|
20 |
return [[ |
|
21 |
{type: 'checkbox'}, |
|
22 |
{field: 'id', hide: true, title: '任务ID'}, |
|
23 |
{field: 'jobName', sort: true, title: '任务名称'}, |
|
24 |
// {field: 'jobGroup', sort: true, title: '任务组名'}, |
|
25 |
{field: 'invokeTarget', sort: true, title: '调用目标字符串'}, |
|
26 |
{field: 'cronExpression', sort: true, title: 'cron执行表达式'}, |
|
27 |
// {field: 'misfirePolicy', sort: true, title: '计划执行错误策略'}, |
|
28 |
// {field: 'concurrent', sort: true, title: '是否并发执行(0允许 1禁止)'}, |
|
29 |
// {field: 'status', sort: true, title: '状态'}, |
|
30 |
{field: 'status', sort: true, templet: '#stateTpl', title: '状态'}, |
|
31 |
{field: 'createBy', sort: true, title: '创建者'}, |
|
32 |
{field: 'createTime', sort: true, title: '创建时间',width:160}, |
|
33 |
{field: 'updateBy', sort: true, title: '更新者'}, |
|
34 |
{field: 'updateTime', sort: true, title: '更新时间',width:160}, |
|
35 |
{field: 'remark', sort: true, title: '备注信息'}, |
|
36 |
{align: 'center', toolbar: '#tableBar', title: '操作'} |
|
37 |
]]; |
|
38 |
}; |
|
39 |
|
|
40 |
/** |
|
41 |
* 点击查询按钮 |
|
42 |
*/ |
|
43 |
SysJob.search = function () { |
|
44 |
var queryData = {}; |
|
45 |
|
|
46 |
queryData['jobName'] = $('#jobName').val(); |
|
47 |
queryData['status'] = $('#status').val(); |
|
48 |
|
|
49 |
table.reload(SysJob.tableId, { |
|
50 |
where: queryData, page: {curr: 1} |
|
51 |
}); |
|
52 |
}; |
|
53 |
|
|
54 |
/** |
|
55 |
* 跳转到添加页面 |
|
56 |
*/ |
|
57 |
SysJob.jumpAddPage = function () { |
|
58 |
window.location.href = Feng.ctxPath + '/sysJob/add' |
|
59 |
}; |
|
60 |
|
|
61 |
/** |
|
62 |
* 跳转到编辑页面 |
|
63 |
* |
|
64 |
* @param data 点击按钮时候的行数据 |
|
65 |
*/ |
|
66 |
SysJob.jumpEditPage = function (data) { |
|
67 |
window.location.href = Feng.ctxPath + '/sysJob/edit?id=' + data.id |
|
68 |
}; |
|
69 |
|
|
70 |
form.on('switch(status)', function (obj) { |
|
71 |
var id = obj.elem.value; |
|
72 |
var checked = obj.elem.checked ? 1 : 0; |
|
73 |
SysJob.changeStatus(id, checked); |
|
74 |
}); |
|
75 |
|
|
76 |
// 修改状态方法 |
|
77 |
SysJob.changeStatus = function (id, checked) { |
|
78 |
var ajax = new $ax(Feng.ctxPath + "/sysJob/editState", function (data) { |
|
79 |
Feng.success("修改成功!"); |
|
80 |
}, function (data) { |
|
81 |
Feng.error("修改失败!" + data.message); |
|
82 |
}); |
|
83 |
ajax.set("id", id); |
|
84 |
ajax.set("status", checked); |
|
85 |
ajax.start(); |
|
86 |
}; |
|
87 |
|
|
88 |
/** |
|
89 |
* 导出excel按钮 |
|
90 |
*/ |
|
91 |
SysJob.exportExcel = function () { |
|
92 |
var checkRows = table.checkStatus(SysJob.tableId); |
|
93 |
if (checkRows.data.length === 0) { |
|
94 |
Feng.error("请选择要导出的数据"); |
|
95 |
} else { |
|
96 |
table.exportFile(tableResult.config.id, checkRows.data, 'xls'); |
|
97 |
} |
|
98 |
}; |
|
99 |
|
|
100 |
/** |
|
101 |
* 点击删除 |
|
102 |
* |
|
103 |
* @param data 点击按钮时候的行数据 |
|
104 |
*/ |
|
105 |
SysJob.onDeleteItem = function (data) { |
|
106 |
var operation = function () { |
|
107 |
var ajax = new $ax(Feng.ctxPath + "/sysJob/delete", function (data) { |
|
108 |
Feng.success("删除成功!"); |
|
109 |
table.reload(SysJob.tableId); |
|
110 |
}, function (data) { |
|
111 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
112 |
}); |
|
113 |
ajax.set("id", data.id); |
|
114 |
ajax.start(); |
|
115 |
}; |
|
116 |
Feng.confirm("是否删除?", operation); |
|
117 |
}; |
|
118 |
|
|
119 |
// 渲染表格 |
|
120 |
var tableResult = table.render({ |
|
121 |
elem: '#' + SysJob.tableId, |
|
122 |
url: Feng.ctxPath + '/sysJob/list', |
|
123 |
page: true, |
|
124 |
height: "full-158", |
|
125 |
cellMinWidth: 100, |
|
126 |
cols: SysJob.initColumn() |
|
127 |
}); |
|
128 |
|
|
129 |
// 搜索按钮点击事件 |
|
130 |
$('#btnSearch').click(function () { |
|
131 |
SysJob.search(); |
|
132 |
}); |
|
133 |
|
|
134 |
// 添加按钮点击事件 |
|
135 |
$('#btnAdd').click(function () { |
|
136 |
|
|
137 |
SysJob.jumpAddPage(); |
|
138 |
|
|
139 |
}); |
|
140 |
|
|
141 |
// 导出excel |
|
142 |
$('#btnExp').click(function () { |
|
143 |
SysJob.exportExcel(); |
|
144 |
}); |
|
145 |
|
|
146 |
// 工具条点击事件 |
|
147 |
table.on('tool(' + SysJob.tableId + ')', function (obj) { |
|
148 |
var data = obj.data; |
|
149 |
var layEvent = obj.event; |
|
150 |
|
|
151 |
if (layEvent === 'edit') { |
|
152 |
SysJob.jumpEditPage(data); |
|
153 |
} else if (layEvent === 'delete') { |
|
154 |
SysJob.onDeleteItem(data); |
|
155 |
} |
|
156 |
}); |
|
157 |
}); |