截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. {layout name="layout1" /}
  2. <div class="wrapper">
  3. <div class="layui-card">
  4. <div class="layui-card-body">
  5. <div class="layui-collapse like-layui-collapse" lay-accordion="" style="border:1px dashed #c4c4c4">
  6. <div class="layui-colla-item">
  7. <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示</h2>
  8. <div class="layui-colla-content layui-show">
  9. <p>1.请在linux环境使用crontab命令添加定时任务:*/1 * * * * php think crontab 。</p>
  10. <p>2.规则如下:</p>
  11. <p>*(0~59分)&nbsp;&nbsp;*(0~23小时)&nbsp;&nbsp;*(1~31号)&nbsp;&nbsp;*(1-12月)&nbsp;&nbsp;*(0-7星期,0和7都代表星期日)</p>
  12. <p>*(星号):代表任何时刻都接受的意思。例:0 10 * * * command 日、月、周都是*,就代表着不论何月、何日的星期几的10:00都执行后续命令的意思。</p>
  13. <p>,(逗号):代表分隔时段的意思。例:要执行的工作是2:00与3:00时,就会是:0 2,3 * * * command时间还是有五列,不过第二列是 2,3 ,代表2与3都适用。</p>
  14. <p>-(减号): 代表一段时间范围内,例:8点到11点之间的每小时的18分都进行一项工作:18 8-11 * * * command仔细看到第二列变成8-11.代表 8,9,10,11,12 都适用的。</p>
  15. <p>/n(斜线):那个n代表数字,即是每隔n单位间隔的意思,例:每五分钟进行一次,则:*/5 * * * * 。</p>
  16. </div>
  17. </div>
  18. </div>
  19. <br>
  20. <div style="padding-bottom: 10px;">
  21. <button class="layui-btn layui-btn-sm layuiadmin-btn-crontab {$view_theme_color}" data-type="add">添加</button>
  22. </div>
  23. <table id="crontab-lists" lay-filter="crontab-lists"></table>
  24. <script type="text/html" id="status">
  25. {{# if(d.status == 1){ }}
  26. <button class="layui-btn layui-btn-sm {$view_theme_button}">运行</button>
  27. {{# } }}
  28. {{# if(d.status == 2){ }}
  29. <button class="layui-btn layui-btn-sm layui-btn-danger">停止</button>
  30. {{# } }}
  31. {{# if(d.status == 3){ }}
  32. <button class="layui-btn layui-btn-sm layui-btn-danger">错误</button>
  33. {{# } }}
  34. </script>
  35. <script type="text/html" id="operation">
  36. <a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="edit">编辑</a>
  37. {{# if(d.system == 0){ }}
  38. <a class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delete">删除</a>
  39. {{# } }}
  40. {{# if(d.system == 1){ }}
  41. <a class="layui-btn layui-btn-sm layui-btn-danger layui-btn-disabled">删除</a>
  42. {{# } }}
  43. </script>
  44. </div>
  45. </div>
  46. </div>
  47. <script>
  48. layui.config({
  49. version:"{$front_version}",
  50. base: '/static/lib/' //静态资源所在路径
  51. }).use(['table'], function () {
  52. var $ = layui.$
  53. , form = layui.form
  54. , table = layui.table;
  55. table.render({
  56. elem: '#crontab-lists'
  57. , url: '{:url("system.Crontab/lists")}' //模拟接口
  58. , cols: [[
  59. {field: 'name', width: 150, title: '名称'}
  60. , {field: 'type_desc', width: 90, title: '类型'}
  61. , {field: 'command', width: 150, title: '命令'}
  62. , {field: 'parameter', width: 100, title: '参数'}
  63. , {field: 'expression', width: 100, title: '规则'}
  64. , {width:80,title: '状态', templet: '#status', align: 'center',sort: true}
  65. , {field: 'error', width: 120, title: '错误原因'}
  66. , {field: 'last_time_str', width: 160, title: '最后执行时间'}
  67. , {field: 'time', width: 90, title: '时长'}
  68. , {field: 'max_time', width: 90, title: '最大时长'}
  69. , {fixed: 'right', title: '操作',width: 300,align: 'center', toolbar: '#operation'}
  70. ]]
  71. , text: {none: '暂无数据!'}
  72. , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
  73. return {
  74. "code": res.code,
  75. "msg": res.msg,
  76. "count": res.data.count, //解析数据长度
  77. "data": res.data.lists, //解析数据列表
  78. };
  79. },
  80. response: {
  81. statusCode: 1
  82. }
  83. ,done: function(res, curr, count){
  84. // 解决操作栏因为内容过多换行问题
  85. $(".layui-table-main tr").each(function (index, val) {
  86. $($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
  87. $($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
  88. });
  89. }
  90. });
  91. //监听工具条
  92. table.on('tool(crontab-lists)', function (obj) {
  93. var operation = obj.event;
  94. var id = obj.data['id'];
  95. switch (operation) {
  96. case 'delete':
  97. layer.confirm('确定删除定时任务吗?', function(index){
  98. like.ajax({
  99. url:'{:url("system.Crontab/del")}',
  100. data:{'id':id},
  101. type:"post",
  102. success:function(res)
  103. {
  104. if(res.code == 1) {
  105. obj.del();
  106. layui.layer.msg(res.msg, {
  107. offset: '15px'
  108. , icon: 1
  109. , time: 1000
  110. });
  111. layer.close(index);
  112. }
  113. }
  114. });
  115. });
  116. break;
  117. case 'edit':
  118. layer.open({
  119. type: 2
  120. ,title: '编辑系统任务'
  121. ,content: '{:url("system.Crontab/edit")}?id='+id
  122. ,area: ['90%', '90%']
  123. ,btn: ['确定', '取消']
  124. ,yes: function(index, layero){
  125. var iframeWindow = window['layui-layer-iframe'+ index]
  126. ,submitID = 'crontab-submit-edit'
  127. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  128. //监听提交
  129. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  130. var field = data.field;
  131. like.ajax({
  132. url:'{:url("system.Crontab/edit")}',
  133. data:field,
  134. type:"post",
  135. success:function(res)
  136. {
  137. if(res.code == 1) {
  138. layui.layer.msg(res.msg, {
  139. offset: '15px'
  140. , icon: 1
  141. , time: 1000
  142. });
  143. layer.close(index); //关闭弹层
  144. table.reload('crontab-lists'); //数据刷新
  145. }
  146. }
  147. });
  148. });
  149. submit.trigger('click');
  150. }
  151. })
  152. }
  153. });
  154. var active = {
  155. add: function(){
  156. layer.open({
  157. type: 2
  158. ,title: '添加系统任务'
  159. ,content: '{:url("system.Crontab/add")}'
  160. ,area: ['90%', '90%']
  161. ,btn: ['确定', '取消']
  162. ,yes: function(index, layero){
  163. var iframeWindow = window['layui-layer-iframe'+ index]
  164. ,submitID = 'crontab-submit'
  165. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  166. //监听提交
  167. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  168. var field = data.field;
  169. like.ajax({
  170. url:'{:url("system.Crontab/add")}',
  171. data:field,
  172. type:"post",
  173. success:function(res)
  174. {
  175. if(res.code == 1) {
  176. layui.layer.msg(res.msg, {
  177. offset: '15px'
  178. , icon: 1
  179. , time: 1000
  180. });
  181. layer.close(index); //关闭弹层
  182. table.reload('crontab-lists'); //数据刷新
  183. }
  184. }
  185. });
  186. });
  187. submit.trigger('click');
  188. }
  189. });
  190. },
  191. }
  192. $('.layui-btn.layuiadmin-btn-crontab').on('click', function(){
  193. var type = $(this).data('type');
  194. active[type] ? active[type].call(this) : '';
  195. });
  196. });
  197. </script>