job.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. 任务分组:<select name="jobGroup" th:with="type=${@dict.getType('sys_job_group')}">
  18. <option value="">所有</option>
  19. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  20. </select>
  21. </li>
  22. <li>
  23. 任务状态:<select name="status" th:with="type=${@dict.getType('sys_job_status')}">
  24. <option value="">所有</option>
  25. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  26. </select>
  27. </li>
  28. <li>
  29. <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
  30. <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
  31. </li>
  32. </ul>
  33. </div>
  34. </form>
  35. </div>
  36. <div class="btn-group-sm" id="toolbar" role="group">
  37. <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="monitor:job:add">
  38. <i class="fa fa-plus"></i> 新增
  39. </a>
  40. <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="monitor:job:edit">
  41. <i class="fa fa-edit"></i> 修改
  42. </a>
  43. <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="monitor:job:remove">
  44. <i class="fa fa-remove"></i> 删除
  45. </a>
  46. <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:job:export">
  47. <i class="fa fa-download"></i> 导出
  48. </a>
  49. <a class="btn btn-primary" onclick="javascript:cron()">
  50. <i class="fa fa-code"></i> 生成表达式
  51. </a>
  52. <a class="btn btn-info" onclick="javascript:jobLog()" shiro:hasPermission="monitor:job:detail">
  53. <i class="fa fa-list"></i> 日志
  54. </a>
  55. </div>
  56. <div class="col-sm-12 select-table table-striped">
  57. <table id="bootstrap-table"></table>
  58. </div>
  59. </div>
  60. </div>
  61. <th:block th:include="include :: footer" />
  62. <script th:inline="javascript">
  63. var detailFlag = [[${@permission.hasPermi('monitor:job:detail')}]];
  64. var editFlag = [[${@permission.hasPermi('monitor:job:edit')}]];
  65. var removeFlag = [[${@permission.hasPermi('monitor:job:remove')}]];
  66. var statusFlag = [[${@permission.hasPermi('monitor:job:changeStatus')}]];
  67. var datas = [[${@dict.getType('sys_job_group')}]];
  68. var prefix = ctx + "monitor/job";
  69. $(function() {
  70. var options = {
  71. url: prefix + "/list",
  72. detailUrl: prefix + "/detail/{id}",
  73. createUrl: prefix + "/add",
  74. updateUrl: prefix + "/edit/{id}",
  75. removeUrl: prefix + "/remove",
  76. exportUrl: prefix + "/export",
  77. sortName: "createTime",
  78. sortOrder: "desc",
  79. modalName: "任务",
  80. columns: [{
  81. checkbox: true
  82. },
  83. {
  84. field: 'jobId',
  85. title: '任务编号'
  86. },
  87. {
  88. field: 'jobName',
  89. title: '任务名称',
  90. },
  91. {
  92. field: 'jobGroup',
  93. title: '任务分组',
  94. formatter: function(value, row, index) {
  95. return $.table.selectDictLabel(datas, value);
  96. }
  97. },
  98. {
  99. field: 'invokeTarget',
  100. title: '调用目标字符串',
  101. formatter: function(value, row, index) {
  102. return $.table.tooltip(value);
  103. }
  104. },
  105. {
  106. field: 'cronExpression',
  107. title: '执行表达式'
  108. },
  109. {
  110. visible: statusFlag == 'hidden' ? false : true,
  111. title: '任务状态',
  112. align: 'center',
  113. formatter: function (value, row, index) {
  114. return statusTools(row);
  115. }
  116. },
  117. {
  118. field: 'createTime',
  119. title: '创建时间',
  120. sortable: true
  121. },
  122. {
  123. title: '操作',
  124. align: 'center',
  125. formatter: function(value, row, index) {
  126. var actions = [];
  127. actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:;" onclick="$.operate.edit(\'' + row.jobId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
  128. actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:;" onclick="$.operate.remove(\'' + row.jobId + '\')"><i class="fa fa-remove"></i>删除</a> ');
  129. var more = [];
  130. more.push("<a class='btn btn-default btn-xs " + statusFlag + "' href='javascript:void(0)' onclick='run(" + row.jobId + ")'><i class='fa fa-play-circle-o'></i> 执行一次</a> ");
  131. more.push("<a class='btn btn-default btn-xs " + detailFlag + "' href='javascript:void(0)' onclick='$.operate.detail(" + row.jobId + ")'><i class='fa fa-search'></i>任务详细</a> ");
  132. more.push("<a class='btn btn-default btn-xs " + detailFlag + "' href='javascript:void(0)' onclick='jobLog(" + row.jobId + ")'><i class='fa fa-list'></i>调度日志</a>");
  133. actions.push('<a class="btn btn-info btn-xs" role="button" data-container="body" data-placement="left" data-toggle="popover" data-html="true" data-trigger="hover" data-content="' + more.join('') + '"><i class="fa fa-chevron-circle-right"></i>更多操作</a>');
  134. return actions.join('');
  135. }
  136. }]
  137. };
  138. $.table.init(options);
  139. });
  140. /* 调度任务状态显示 */
  141. function statusTools(row) {
  142. if (row.status == 1) {
  143. return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="start(\'' + row.jobId + '\', \'' + row.jobGroup + '\')"></i> ';
  144. } else {
  145. return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="stop(\'' + row.jobId + '\', \'' + row.jobGroup + '\')"></i> ';
  146. }
  147. }
  148. /* 立即执行一次 */
  149. function run(jobId) {
  150. $.modal.confirm("确认要立即执行一次任务吗?", function() {
  151. $.operate.post(prefix + "/run", { "jobId": jobId});
  152. })
  153. }
  154. /* 调度任务-停用 */
  155. function stop(jobId, jobGroup) {
  156. $.modal.confirm("确认要停用任务吗?", function() {
  157. $.operate.post(prefix + "/changeStatus", { "jobId": jobId, "jobGroup": jobGroup, "status": 1 });
  158. })
  159. }
  160. /* 调度任务-启用 */
  161. function start(jobId, jobGroup) {
  162. $.modal.confirm("确认要启用任务吗?", function() {
  163. $.operate.post(prefix + "/changeStatus", { "jobId": jobId, "jobGroup": jobGroup, "status": 0 });
  164. })
  165. }
  166. /* 调度日志查询 */
  167. function jobLog(jobId) {
  168. var url = ctx + 'monitor/jobLog';
  169. if ($.common.isNotEmpty(jobId)) {
  170. url += '?jobId=' + jobId;
  171. }
  172. $.modal.openTab("调度日志", url);
  173. }
  174. /* cron表达式生成 */
  175. function cron() {
  176. var url = prefix + '/cron';
  177. var height = $(window).height() - 50;
  178. top.layer.open({
  179. maxmin: true,
  180. title: "Cron表达式生成器",
  181. type: 2,
  182. area: ['800px', height + "px" ], //宽高
  183. shadeClose: true,
  184. content: url
  185. });
  186. }
  187. </script>
  188. </body>
  189. </html>