diff --git a/ruoyi-admin/src/main/resources/static/js/cron.js b/ruoyi-admin/src/main/resources/static/js/cron.js index 26de770e1..269e9600b 100644 --- a/ruoyi-admin/src/main/resources/static/js/cron.js +++ b/ruoyi-admin/src/main/resources/static/js/cron.js @@ -922,5 +922,37 @@ function gen_cron() { + $("#v_month").val() + " " + $("#v_week").val() + " " + $("#v_year").val(); - $("#cron").val(str); + var vals = $("input[name^='v_']"); + var cron = $("#cron"); + var item = []; + vals.each(function() { + item.push(this.value); + }); + // 修复表达式错误BUG,如果后一项不为* 那么前一项肯定不为*,要不然就成了每秒执行了 + // 获取当前选中tab + var currentIndex = 0; + $(".nav-tabs>li").each(function(i, item) { + if ($(item).hasClass("active")) { + currentIndex = i; + return false; + } + + }); + // 当前选中项之前的如果为*,则都设置成0 + for (var i = currentIndex; i >= 1; i--) { + if (item[i] != "*" && item[i - 1] == "*") { + item[i - 1] = "0"; + } + } + // 当前选中项之后的如果不为*则都设置成* + if (item[currentIndex] == "*") { + for (var i = currentIndex + 1; i < item.length; i++) { + if (i == 5) { + item[i] = "?"; + } else { + item[i] = "*"; + } + } + } + cron.val(item.join(" ")).change(); } \ No newline at end of file diff --git a/ruoyi-quartz/src/main/resources/templates/monitor/job/cron.html b/ruoyi-quartz/src/main/resources/templates/monitor/job/cron.html index d5e4af611..c6b1ee144 100644 --- a/ruoyi-quartz/src/main/resources/templates/monitor/job/cron.html +++ b/ruoyi-quartz/src/main/resources/templates/monitor/job/cron.html @@ -1105,13 +1105,13 @@ 表达式字段 - - - - - - - + + + + + + + Cron 表达式