job.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
  3. <head>
  4. <th:block th:include="include :: header('定时任务列表')" />
  5. </head>
  6. <body class="gray-bg">
  7. <div class="container-div">
  8. <div class="row">
  9. <div class="col-sm-12 search-collapse">
  10. <form id="job-form">
  11. <div class="select-list">
  12. <ul>
  13. <li>
  14. 任务名称:<input type="text" name="jobName"/>
  15. </li>
  16. <li>
  17. 方法名称:<input type="text" name="methodName"/>
  18. </li>
  19. <li>
  20. 任务状态:<select name="status" th:with="type=${@dict.getType('sys_job_status')}">
  21. <option value="">所有</option>
  22. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  23. </select>
  24. </li>
  25. <li>
  26. <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
  27. <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
  28. </li>
  29. </ul>
  30. </div>
  31. </form>
  32. </div>
  33. <div class="btn-group-sm" id="toolbar" role="group">
  34. <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="monitor:job:add">
  35. <i class="fa fa-plus"></i> 新增
  36. </a>
  37. <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:job:edit">
  38. <i class="fa fa-edit"></i> 修改
  39. </a>
  40. <a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="monitor:job:remove">
  41. <i class="fa fa-remove"></i> 删除
  42. </a>
  43. <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:job:export">
  44. <i class="fa fa-download"></i> 导出
  45. </a>
  46. <a class="btn btn-info" onclick="javascript:jobLog()" shiro:hasPermission="monitor:job:list">
  47. <i class="fa fa-list"></i> 日志
  48. </a>
  49. </div>
  50. <div class="col-sm-12 select-table table-striped">
  51. <table id="bootstrap-table" data-mobile-responsive="true"></table>
  52. </div>
  53. </div>
  54. </div>
  55. <th:block th:include="include :: footer" />
  56. <script th:inline="javascript">
  57. var detailFlag = [[${@permission.hasPermi('monitor:job:detail')}]];
  58. var editFlag = [[${@permission.hasPermi('monitor:job:edit')}]];
  59. var removeFlag = [[${@permission.hasPermi('monitor:job:remove')}]];
  60. var statusFlag = [[${@permission.hasPermi('monitor:job:changeStatus')}]];
  61. var datas = [[${@dict.getType('sys_job_status')}]];
  62. var prefix = ctx + "monitor/job";
  63. $(function() {
  64. var options = {
  65. url: prefix + "/list",
  66. detailUrl: prefix + "/detail/{id}",
  67. createUrl: prefix + "/add",
  68. updateUrl: prefix + "/edit/{id}",
  69. removeUrl: prefix + "/remove",
  70. exportUrl: prefix + "/export",
  71. sortName: "createTime",
  72. sortOrder: "desc",
  73. modalName: "任务",
  74. columns: [{
  75. checkbox: true
  76. },
  77. {
  78. field: 'jobId',
  79. title: '任务编号'
  80. },
  81. {
  82. field: 'jobName',
  83. title: '任务名称',
  84. sortable: true
  85. },
  86. {
  87. field: 'jobGroup',
  88. title: '任务组名',
  89. sortable: true
  90. },
  91. {
  92. field: 'methodName',
  93. title: '方法名称'
  94. },
  95. {
  96. field: 'methodParams',
  97. title: '方法参数'
  98. },
  99. {
  100. field: 'cronExpression',
  101. title: '执行表达式'
  102. },
  103. {
  104. visible: statusFlag == 'hidden' ? false : true,
  105. title: '任务状态',
  106. align: 'center',
  107. formatter: function (value, row, index) {
  108. return statusTools(row);
  109. }
  110. },
  111. {
  112. field: 'createTime',
  113. title: '创建时间',
  114. sortable: true
  115. },
  116. {
  117. title: '操作',
  118. align: 'center',
  119. formatter: function(value, row, index) {
  120. var actions = [];
  121. actions.push('<a class="btn btn-primary btn-xs ' + statusFlag + '" href="#" onclick="run(\'' + row.jobId + '\')"><i class="fa fa-play-circle-o"></i> 执行一次</a> ');
  122. actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="#" onclick="$.operate.detail(\'' + row.jobId + '\')"><i class="fa fa-search"></i>详细</a> ');
  123. return actions.join('');
  124. }
  125. }]
  126. };
  127. $.table.init(options);
  128. });
  129. /* 调度任务状态显示 */
  130. function statusTools(row) {
  131. if (row.status == 1) {
  132. return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="start(\'' + row.jobId + '\')"></i> ';
  133. } else {
  134. return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="stop(\'' + row.jobId + '\')"></i> ';
  135. }
  136. }
  137. /* 立即执行一次 */
  138. function run(jobId) {
  139. $.modal.confirm("确认要立即执行一次任务吗?", function() {
  140. $.operate.post(prefix + "/run", { "jobId": jobId});
  141. })
  142. }
  143. /* 调度任务-停用 */
  144. function stop(jobId) {
  145. $.modal.confirm("确认要停用任务吗?", function() {
  146. $.operate.post(prefix + "/changeStatus", { "jobId": jobId, "status": 1 });
  147. })
  148. }
  149. /* 调度任务-启用 */
  150. function start(jobId) {
  151. $.modal.confirm("确认要启用任务吗?", function() {
  152. $.operate.post(prefix + "/changeStatus", { "jobId": jobId, "status": 0 });
  153. })
  154. }
  155. /* 调度日志查询 */
  156. function jobLog(id) {
  157. var url = ctx + 'monitor/jobLog';
  158. createMenuItem(url, "调度日志");
  159. }
  160. </script>
  161. </body>
  162. </html>