scheduleJobList.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <script>
  3. $(document).ready(function() {
  4. $('#table').bootstrapTable({
  5. //请求方法
  6. method: 'post',
  7. //类型json
  8. dataType: "json",
  9. contentType: "application/x-www-form-urlencoded",
  10. //显示刷新按钮
  11. showRefresh: true,
  12. //显示切换手机试图按钮
  13. showToggle: true,
  14. //显示检索按钮
  15. showSearch: true,
  16. //显示 内容列下拉框
  17. showColumns: true,
  18. //显示到处按钮
  19. showExport: true,
  20. //显示切换分页按钮
  21. showPaginationSwitch: true,
  22. //最低显示2行
  23. minimumCountColumns: 2,
  24. //是否显示行间隔色
  25. striped: true,
  26. //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  27. cache: false,
  28. //是否显示分页(*)
  29. pagination: true,
  30. //排序方式
  31. sortOrder: "asc",
  32. //初始化加载第一页,默认第一页
  33. pageNumber:1,
  34. //每页的记录行数(*)
  35. pageSize: 10,
  36. //可供选择的每页的行数(*)
  37. pageList: [10, 25, 50, 100],
  38. onShowSearch: function () {
  39. $("#search-collapse").slideToggle();
  40. },
  41. //这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据
  42. url: "${ctx}/monitor/scheduleJob/data",
  43. //默认值为 'limit',传给服务端的参数为:limit, offset, search, sort, order Else
  44. //queryParamsType:'',
  45. ////查询参数,每次调用是会带上这个参数,可自定义
  46. queryParams : function(params) {
  47. var searchParam = $("#searchForm").serializeJSON();
  48. searchParam.pageNo = params.limit === undefined? "1" :params.offset/params.limit+1;
  49. searchParam.pageSize = params.limit === undefined? -1 : params.limit;
  50. searchParam.orderBy = params.sort === undefined? "" : params.sort+ " "+ params.order;
  51. return searchParam;
  52. },
  53. //分页方式:client客户端分页,server服务端分页(*)
  54. sidePagination: "server",
  55. contextMenuTrigger:"right",//pc端 按右键弹出菜单
  56. contextMenuTriggerMobile:"press",//手机端 弹出菜单,click:单击, press:长按。
  57. contextMenu: '#context-menu',
  58. onContextMenuItem: function(row, $el){
  59. if($el.data("item") == "edit"){
  60. jp.go("${ctx}/monitor/scheduleJob/form?id=" + row.id);
  61. } else if($el.data("item") == "delete"){
  62. jp.confirm('确认要删除该定时任务记录吗?', function(){
  63. jp.loading();
  64. jp.get("${ctx}/monitor/scheduleJob/delete?id="+row.id, function(data){
  65. if(data.success){
  66. $('#table').bootstrapTable('refresh');
  67. jp.success(data.msg);
  68. }else{
  69. jp.error(data.msg);
  70. }
  71. })
  72. });
  73. }
  74. },
  75. onClickRow: function(row, $el){
  76. },
  77. columns: [{
  78. checkbox: true
  79. }
  80. ,{
  81. field: 'name',
  82. title: '任务名',
  83. sortable: true
  84. }
  85. ,{
  86. field: 'group',
  87. title: '任务组',
  88. sortable: true,
  89. formatter:function(value, row , index){
  90. return jp.getDictLabel(${fns:toJson(fns:getDictList('schedule_task_group'))}, value, "-");
  91. }
  92. }
  93. ,{
  94. field: 'cronExpression',
  95. title: '定时规则',
  96. sortable: true
  97. }
  98. ,{
  99. field: 'status',
  100. title: '启用状态',
  101. sortable: true,
  102. formatter:function(value, row , index){
  103. return jp.getDictLabel(${fns:toJson(fns:getDictList('yes_no'))}, value, "-");
  104. }
  105. }
  106. ,{
  107. field: 'isInfo',
  108. title: '通知用户',
  109. sortable: true,
  110. formatter:function(value, row , index){
  111. return jp.getDictLabel(${fns:toJson(fns:getDictList('schedule_task_info'))}, value, "-");
  112. }
  113. }
  114. ,{
  115. field: 'className',
  116. title: '任务类',
  117. sortable: true
  118. }
  119. ,{
  120. field: 'description',
  121. title: '描述',
  122. sortable: true
  123. }, {
  124. field: 'operate',
  125. title: '操作',
  126. align: 'center',
  127. events: {
  128. 'click .resume': function (e, value, row, index) {
  129. resume(row.id);
  130. },
  131. 'click .stop': function (e, value, row, index) {
  132. stop(row.id);
  133. }
  134. },
  135. formatter: function operateFormatter(value, row, index) {
  136. return [
  137. <shiro:hasPermission name="monitor:scheduleJob:resume">
  138. '<a href="#" class="resume" title="启动" >【启动】</a>',
  139. </shiro:hasPermission>
  140. <shiro:hasPermission name="monitor:scheduleJob:stop">
  141. '<a href="#" class="stop" title="暂停">【暂停】 </a>'
  142. </shiro:hasPermission>
  143. ].join('');
  144. }
  145. }]
  146. });
  147. if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端
  148. $('#table').bootstrapTable("toggleView");
  149. }
  150. $('#table').on('check.bs.table uncheck.bs.table load-success.bs.table ' +
  151. 'check-all.bs.table uncheck-all.bs.table', function () {
  152. $('#remove').prop('disabled', ! $('#table').bootstrapTable('getSelections').length);
  153. $('#edit,#stop,#resume,#startNow').prop('disabled', $('#table').bootstrapTable('getSelections').length!=1);
  154. });
  155. $("#search").click("click", function() {// 绑定查询按扭
  156. $('#table').bootstrapTable('refresh');
  157. });
  158. $("#reset").click("click", function() {// 绑定查询按扭
  159. $("#searchForm input").val("");
  160. $("#searchForm select").val("");
  161. $('#table').bootstrapTable('refresh');
  162. });
  163. });
  164. function getIdSelections() {
  165. return $.map($("#table").bootstrapTable('getSelections'), function (row) {
  166. return row.id
  167. });
  168. }
  169. function deleteAll(){
  170. jp.confirm('确认要删除该定时任务记录吗?', function(){
  171. jp.loading();
  172. jp.get("${ctx}/monitor/scheduleJob/deleteAll?ids=" + getIdSelections(), function(data){
  173. if(data.success){
  174. $('#table').bootstrapTable('refresh');
  175. jp.success(data.msg);
  176. }else{
  177. jp.error(data.msg);
  178. }
  179. })
  180. })
  181. }
  182. function edit(){
  183. jp.go("${ctx}/monitor/scheduleJob/form?id=" + getIdSelections());
  184. }
  185. //暂停
  186. function stop(id){
  187. if(!id){
  188. id = getIdSelections();
  189. }
  190. jp.confirm('确定要暂停任务?', function(){
  191. jp.loading();
  192. jp.get("${ctx}/monitor/scheduleJob/stop?id=" + id, function(data){
  193. if(data.success){
  194. $('#table').bootstrapTable('refresh');
  195. jp.success(data.msg);
  196. }else{
  197. jp.error(data.msg);
  198. }
  199. })
  200. })
  201. }
  202. //恢复
  203. function resume(id){
  204. if(!id){
  205. id = getIdSelections();
  206. }
  207. jp.confirm('确定要恢复任务?', function(){
  208. jp.loading();
  209. jp.get("${ctx}/monitor/scheduleJob/resume?id=" + id, function(data){
  210. if(data.success){
  211. $('#table').bootstrapTable('refresh');
  212. jp.success(data.msg);
  213. }else{
  214. jp.error(data.msg);
  215. }
  216. })
  217. })
  218. }
  219. //立即运行一次
  220. function startNow(){
  221. jp.confirm('确定要立即运行一次该任务?', function(){
  222. jp.loading();
  223. jp.get("${ctx}/monitor/scheduleJob/startNow?id=" + getIdSelections(), function(data){
  224. if(data.success){
  225. $('#table').bootstrapTable('refresh');
  226. jp.success(data.msg);
  227. }else{
  228. jp.error(data.msg);
  229. }
  230. })
  231. })
  232. };
  233. </script>