截流自动化的商城平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

add.html 5.4KB

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