截流自动化的商城平台
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. {layout name="layout2" /}
  2. <style>
  3. .layui-form-item .layui-input-inline {
  4. width: 240px;
  5. }
  6. </style>
  7. <div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
  8. <input type="hidden" value="0" name="id">
  9. <div class="layui-form-item">
  10. <input type="hidden" name="id" value="{$info.id}">
  11. <label class="layui-form-label">名称</label>
  12. <div class="layui-input-inline">
  13. <input type="text" name="name" lay-verify="required" lay-vertype="tips" placeholder="请输入名称"
  14. autocomplete="off" class="layui-input" value="{$info.name}">
  15. </div>
  16. </div>
  17. <div class="layui-form-item">
  18. <label class="layui-form-label">类型</label>
  19. <div class="layui-input-inline">
  20. <input type="radio" lay-filter="type" name="type" value="1" title="定时任务" {eq name="info.type" value="1"}checked{/eq}>
  21. <!--<input type="radio" lay-filter="type" name="type" value="2" title="守护进程" {eq name="info.type" value="2"}checked{/eq}>-->
  22. </div>
  23. </div>
  24. <div class="layui-form-item">
  25. <label class="layui-form-label">命令</label>
  26. <div class="layui-input-inline">
  27. <input type="text" name="command" lay-verify="required" lay-vertype="tips"
  28. placeholder="请输入thinkphp命令,例:version" autocomplete="off" class="layui-input" value="{$info.command}">
  29. </div>
  30. </div>
  31. <div class="layui-form-item">
  32. <label class="layui-form-label">参数</label>
  33. <div class="layui-input-inline">
  34. <input type="text" name="parameter" placeholder="请输入参数,例:--id 8 --name 测试" autocomplete="off"
  35. class="layui-input" value="{$info.parameter}">
  36. </div>
  37. </div>
  38. <div class="layui-form-item">
  39. <label class="layui-form-label">状态</label>
  40. <div class="layui-input-inline">
  41. <input type="checkbox" lay-filter="disable" name="status" lay-skin="switch" lay-text="立即启动|停止" {eq name="info.status" value="1"}checked{/eq}>
  42. </div>
  43. </div>
  44. <div class="layui-form-item" id="expression">
  45. <label class="layui-form-label">规则</label>
  46. <div class="layui-input-inline">
  47. <input type="text" name="expression" lay-verify="expression_required" lay-vertype="tips"
  48. placeholder="请输入crontab规则,例:59 * * * *" autocomplete="off" class="layui-input" value="{$info.expression}">
  49. </div>
  50. </div>
  51. <div class="layui-form-item" id="preview" style="display: none">
  52. <label class="layui-form-label">执行预览</label>
  53. <div class="layui-input-inline">
  54. <table class="layui-table">
  55. <colgroup>
  56. <col width="60">
  57. <col width="160">
  58. </colgroup>
  59. <thead>
  60. <tr>
  61. <th>次数</th>
  62. <th>执行时间</th>
  63. </tr>
  64. </thead>
  65. <tbody id="tbody_lists">
  66. </tbody>
  67. </table>
  68. </div>
  69. </div>
  70. <div class="layui-form-item layui-form-text">
  71. <label class="layui-form-label">备注</label>
  72. <div class="layui-input-inline">
  73. <textarea name="remark" placeholder="请输入内容" class="layui-textarea">{$info.remark}</textarea>
  74. </div>
  75. </div>
  76. <div class="layui-form-item layui-hide">
  77. <input type="button" lay-submit lay-filter="crontab-submit-edit" id="crontab-submit-edit" value="确认">
  78. </div>
  79. </div>
  80. <script src="/static/common/js/array.js"></script>
  81. <script>
  82. var code;
  83. layui.config({
  84. version:"{$front_version}",
  85. base: '/static/lib/' //静态资源所在路径
  86. }).use(['form'], function () {
  87. var $ = layui.$
  88. , form = layui.form;
  89. function preview() {
  90. expression = $("[name=expression]").val();
  91. if (isEmptyString(expression)) {
  92. $('#tbody_lists').html('');
  93. $('#preview').hide();
  94. return;
  95. }
  96. var data = {'expression': expression};
  97. like.ajax({
  98. url: '{:url("system.Crontab/expression")}',
  99. data: data,
  100. type: "get",
  101. success: function (res) {
  102. if (res.code == 1) {
  103. var html = '';
  104. var data = res.data;
  105. for (var i in data) {
  106. html += '<tr>';
  107. html += '<td>' + data[i]['time'] + '</td>';
  108. html += '<td>' + data[i]['date'] + '</td>';
  109. html += '</tr>';
  110. }
  111. $('#preview').show();
  112. $('#tbody_lists').html(html);
  113. }
  114. }
  115. });
  116. }
  117. $("[name=expression]").bind('input propertychange', function () {
  118. clearTimeout(code);
  119. code = setTimeout(function () {
  120. preview();
  121. }, 1000);
  122. });
  123. form.on('radio(type)', function (data) {
  124. if (data.value == 1) {
  125. $('#expression').show();
  126. preview();
  127. } else {
  128. $('#expression').hide();
  129. $('#preview').hide();
  130. }
  131. });
  132. form.verify({
  133. expression_required: function (value, item) {
  134. if ($('input[name="type"]:checked').val() == 2) {
  135. return;
  136. }
  137. if(isEmptyString(value)){
  138. return '定时任务的规则不能为空';
  139. }
  140. }
  141. });
  142. if ('{$info.type}' == '1') {
  143. $('#expression').show();
  144. preview();
  145. } else {
  146. $('#expression').hide();
  147. $('#preview').hide();
  148. }
  149. preview();
  150. })
  151. </script>