layui 定时器表达式 插件 代码
layui.config({
base: '../../js/lay/modules/' //你存放新模块的目录,注意,不是layui的模块目录
}).use(['table'], function(){
var table = layui.table,
$=layui.$,
layer=layui.layer,
form=layui.form;
//选择定时器表达式
$('#corn').on("click",function () {
layer.open({
type: 2 //此处以iframe举例
, title: "选择时间调度"
, area: ['1000px','800px']
, shade: 0.3
, btnAlign: ''
, anim: 1
, btn: [''+i18nMap.get("cancel"), ''+i18nMap.get("sure")]
, maxmin: true
//, offset: [100,390]
, content: "/corn/cornExp.html"
, btn1:function (index, layero) {
layer.close(index);
}
, btn2: function (index, layero) {
var body = layer.getChildFrame('body', index);
var corn = body.find("#cron").val();
var cronDesc = body.find("#cronDesc").text();
$('#changeform input[id="corn"]').val(corn);
$('#changeform #cornDesc').text(cronDesc);
}
});
})
});
#cornExp.html
<!DOCTYPE html>
<html>
<head>
<title>Quartz定时表达式生成器</title>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Cache-Control" content="no cache"/>
<meta http-equiv="Expires" content="0"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no"/>
<link rel="stylesheet" type="text/css" href="/layui/css/layui.css">
<link rel="stylesheet" type="text/css" href="/corn/jquery.jsonview.min.css" media="all">
<style type="text/css">
.laydate-theme-hide-header .layui-laydate-header,
.laydate-theme-hide-header .laydate-ym-show i.laydate-next-y, .laydate-theme-hide-header .laydate-ym-show i.laydate-prev-y {
display: none !important;
}
.laydate-theme-hide-header .layui-laydate-content{
padding: 0;
height: 135px;
}
.laydate-theme-hide-header .laydate-month-list > li{
margin: 0;
}
.laydate-theme-hide-header table{
display: none;
}
.laydate-theme-hide-header .laydate-month-list .layui-this,
.laydate-month-list .layui-selected,
.laydate-month-list .layui-this.layui-selected {
background-color: #1E9FFF !important;
color: #fff !important;
border: 1px solid #fff;
}
.select-text {
float: left;
line-height: 20px;
padding: 9px 15px;
}
.layui-this .layui-form-checked[lay-skin=primary] i {
border: 1px solid #fff;
font-weight: bold;
}
.layui-this .layui-form-checkbox[lay-skin=primary] span {
color: #fff;
}
.layui-timeline-item{
padding-bottom: 0;
}
</style>
</head>
<body>
<!-- 表单 -->
<form class="layui-form" id="cronForm">
<div class="layui-col-xs7">
<div class="layui-card">
<div class="layui-card-body">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
<legend>定时规则生成</legend>
</fieldset>
<div class="layui-tab-content">
<div class="layui-form-item">
<label class="layui-form-label">每天执行</label>
<div class="layui-input-block">
<input type="radio" lay-filter="daily" name="rule[enable][daily]" value="yes" title="是">
<input type="radio" lay-filter="daily" name="rule[enable][daily]" value="no" title="否">
</div>
</div>
<div id="ruleOther" style="display: none">
<div class="layui-form-item">
<label class="layui-form-label">月份规则</label>
<div class="layui-input-inline">
<select name="cron[month][use]" lay-filter="month-rule">
<option value="every">每月</option>
<option value="in">多选月份</option>
<option value="between">指定月份范围</option>
<option value="interval">从 x 月开始执行,之后每间 x 月执行一次</option>
</select>
<input type="hidden" name="cron[month][every]" value="?">
</div>
<div class="layui-input-inline" id="month-in" style="display: none">
<div class="layui-hide">
<select multiple name="cron[month][in][]">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</div>
<div id="multi-month" readonly class="layui-laydate-main"></div>
</div>
<div class="layui-inline" id="month-between" style="display:none;">
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[month][between][start]" lay-search="">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</div>
<span class="select-text">至</span>
<div class="layui-input-inline" style="width: 80px;margin-right: 0;">
<select name="cron[month][between][end]" lay-search="">
<option value="1">1月</option>
<option value="2">2月</option>
<option value="3">3月</option>
<option value="4">4月</option>
<option value="5">5月</option>
<option value="6">6月</option>
<option value="7">7月</option>
<option value="8">8月</option>
<option value="9">9月</option>
<option value="10">10月</option>
<option value="11">11月</option>
<option value="12">12月</option>
</select>
</div>
</div>
<div class="layui-inline" id="month-interval" style="display: none">
<span class="select-text">从</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[month][interval][start]" lay-search="">
<option value="1">1月</option>
<option value="2">2月</option>
<option value="3">3月</option>
<option value="4">4月</option>
<option value="5">5月</option>
<option value="6">6月</option>
<option value="7">7月</option>
<option value="8">8月</option>
<option value="9">9月</option>
<option value="10">10月</option>
<option value="11">11月</option>
<option value="12">12月</option>
</select>
</div>
<span class="select-text">开始,每</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[month][interval][value]" lay-search="">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</div>
<span class="select-text">个月(不能跨年)</span>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">特殊规则</label>
<div class="layui-input-block">
<input type="radio" name="rule[enable][dayWeekday]" lay-filter="dayWeekday" checked value="day" title="月份天数规则">
<!--<input type="radio" name="rule[enable][dayWeekday]" lay-filter="dayWeekday" value="weekday" title="月份星期规则">-->
</div>
</div>
</div>
<div class="layui-form-item" id="rule-weekday" style="display: none">
<div class="layui-inline">
<label class="layui-form-label">星期规则</label>
<div class="layui-input-inline">
<select name="cron[weekday][use]" lay-filter="weekday-rule" style="width: 260px">
<option value="between">指定星期范围</option>
<option value="in">指定星期(可多选)</option>
<option value="last">月份规则下最后一个指定的星期</option>
<option value="week">月份规则下第 x 周的星期 x</option>
</select>
</div>
</div>
<div class="layui-inline" id="weekday-in" style="display: none">
<span class="select-text">星期</span>
<div class="layui-input-inline">
<select name="cron[weekday][in][]" multiple="multiple">
<option value="2">一</option>
<option value="3">二</option>
<option value="4">三</option>
<option value="5">四</option>
<option value="6">五</option>
<option value="7">六</option>
<option value="1">日</option>
</select>
</div>
</div>
<div class="layui-inline" id="weekday-between">
<div class="layui-input-inline" style="width: 90px;margin-right: 0;">
<select name="cron[weekday][between][start]">
<option value="2">星期一</option>
<option value="3">星期二</option>
<option value="4">星期三</option>
<option value="5">星期四</option>
<option value="6">星期五</option>
<option value="7">星期六</option>
<option value="1">星期日</option>
</select>
</div>
<span class="select-text">至</span>
<div class="layui-input-inline" style="width: 90px;margin-right: 0;">
<select name="cron[weekday][between][end]">
<option value="2">星期一</option>
<option value="3">星期二</option>
<option value="4">星期三</option>
<option value="5">星期四</option>
<option value="6">星期五</option>
<option value="7">星期六</option>
<option value="1">星期日</option>
</select>
</div>
</div>
<div class="layui-inline" id="weekday-last" style="display: none">
<span class="select-text">月份规则下最后一个</span>
<div class="layui-input-inline" style="width: 90px;margin-right: 0;">
<select name="cron[weekday][last]">
<option value="2L">星期一</option>
<option value="3L">星期二</option>
<option value="4L">星期三</option>
<option value="5L">星期四</option>
<option value="6L">星期五</option>
<option value="7L">星期六</option>
<option value="1L">星期日</option>
</select>
</div>
</div>
<div class="layui-inline" id="weekday-week" style="display: none">
<span class="select-text">月份规则下</span>
<div class="layui-input-inline" style="width: 90px;margin-right: 0;">
<select name="cron[weekday][week][at]">
<option value="1">第 1 周</option>
<option value="2">第 2 周</option>
<option value="3">第 3 周</option>
<option value="4">第 4 周</option>
<option value="5">第 5 周</option>
</select>
</div>
<span class="select-text">的</span>
<div class="layui-input-inline" style="width: 90px;margin-right: 0;">
<select name="cron[weekday][week][weekday]">
<option value="2">星期一</option>
<option value="3">星期二</option>
<option value="4">星期三</option>
<option value="5">星期四</option>
<option value="6">星期五</option>
<option value="7">星期六</option>
<option value="1">星期日</option>
</select>
</div>
</div>
</div>
<div class="layui-form-item" id="rule-day">
<div class="layui-inline">
<label class="layui-form-label">天数规则</label>
<div class="layui-input-inline" style="width: 300px">
<select name="cron[day][use]" lay-filter="day-rule">
<option value="interval">月份规则下指定从 x 号开始,每 x 天执行一次</option>
<option value="in">月份规则下指定一天或多天</option>
<option value="between">月份规则下指定多天(范围选择)</option>
<option value="last">月份规则下最后一天</option>
<option value="lastWorkday">月份规则下最后一个工作日</option>
<option value="recentWorkday">月份规则下指定一天最近的工作日(不能跨月)</option>
</select>
</div>
<input type="hidden" name="cron[day][last]" value="L">
<input type="hidden" name="cron[day][lastWorkday]" value="LW">
</div>
<div class="layui-inline" id="day-in" style="display: none">
<span class="select-text">月份规则的</span>
<div class="layui-input-inline" style="width: 200px;margin-right: 0;">
<select name="cron[day][in][]" multiple="multiple">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
</div>
<span class="select-text">号</span>
</div>
<div class="layui-inline" id="day-recentWorkday" style="display: none">
<span class="select-text">月份规则</span>
<div class="layui-input-inline" style="width: 100px;margin-right: 0;">
<select name="cron[day][recentWorkday]">
<option value="1W">1</option>
<option value="2W">2</option>
<option value="3W">3</option>
<option value="4W">4</option>
<option value="5W">5</option>
<option value="6W">6</option>
<option value="7W">7</option>
<option value="8W">8</option>
<option value="9W">9</option>
<option value="10W">10</option>
<option value="11W">11</option>
<option value="12W">12</option>
<option value="13W">13</option>
<option value="14W">14</option>
<option value="15W">15</option>
<option value="16W">16</option>
<option value="17W">17</option>
<option value="18W">18</option>
<option value="19W">19</option>
<option value="20W">20</option>
<option value="21W">21</option>
<option value="22W">22</option>
<option value="23W">23</option>
<option value="24W">24</option>
<option value="25W">25</option>
<option value="26W">26</option>
<option value="27W">27</option>
<option value="28W">28</option>
<option value="29W">29</option>
<option value="30W">30</option>
<option value="31W">31</option>
</select>
</div>
<span class="select-text">号最近的工作日(不能跨月)</span>
</div>
<div class="layui-inline" id="day-between" style="display: none">
<span class="select-text">月份规则从</span>
<div class="layui-input-inline" style="width: 80px;margin-right: 0;">
<select name="cron[day][between][start]">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
</div>
<span class="select-text">号到</span>
<div class="layui-input-inline" style="width: 80px;margin-right: 0;">
<select name="cron[day][between][end]">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
</div>
<span class="select-text">号</span>
</div>
<div class="layui-inline" id="day-interval">
<span class="select-text">月份规则从</span>
<div class="layui-input-inline" style="width: 80px;margin-right: 0;">
<select name="cron[day][interval][start]">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
</div>
<span class="select-text">号开始,每</span>
<div class="layui-input-inline" style="width: 80px;margin-right: 0;">
<select name="cron[day][interval][value]">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
</div>
<span class="select-text">天</span>
</div>
</div>
</div>
<div id="ruleEveryDay" style="display: none;">
<div class="layui-form-item">
<label class="layui-form-label">小时规则</label>
<div class="layui-input-inline">
<select name="cron[hour][use]" lay-filter="hour-rule">
<option value="at">指定小时</option>
<option value="in">指定小时(可多选)</option>
<option value="between">指定小时范围(0-23)</option>
<option value="interval">从 x 小时开始执行,之后每 x 小时执行一次</option>
</select>
</div>
<div class="layui-inline" id="hour-at">
<span class="select-text">于</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select lay-filter="hour-every" name="cron[hour][at]" lay-search="">
<option value="*">*</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>
</div>
<span class="select-text">时</span>
</div>
<div class="layui-inline" id="hour-in" style="display: none;">
<span class="select-text">第</span>
<div class="layui-input-inline" style="width: 200px;margin-right: 0;">
<select name="cron[hour][in][]" multiple="multiple">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>
</div>
<span class="select-text">小时</span>
</div>
<div class="layui-inline" id="hour-between" style="display: none;">
<span class="select-text">第</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[hour][between][start]" lay-search="">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>
</div>
<span class="select-text">至</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[hour][between][end]" lay-search="">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>
</div>
<span class="select-text">小时</span>
</div>
<div class="layui-inline" id="hour-interval" style="display: none;">
<span class="select-text">从</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select lay-filter="hour-interval-start" name="cron[hour][interval][start]" lay-search="">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>
</div>
<span class="select-text">小时开始,每</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select layer-filter="hour-interval-value" name="cron[hour][interval][value]" lay-search="">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>
</div>
<span class="select-text">小时</span>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">分钟规则</label>
<div class="layui-input-inline">
<select name="cron[minute][use]" lay-filter="minute-rule">
<option value="at">指定分钟</option>
<option value="in">指定分钟(可多选)</option>
<option value="between">指定分钟范围(0-59)</option>
<option value="interval">从 x 分钟开始执行,之后每间 x 分钟执行一次</option>
</select>
</div>
<div class="layui-inline" id="minute-at">
<span class="select-text"> 的</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select lay-filter="minute-at" name="cron[minute][at]" lay-search="">
<option value="*">*</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
</div>
<span class="select-text">分</span>
</div>
<div class="layui-inline" id="minute-in" style="display:none;">
<span class="select-text">第</span>
<div class="layui-input-inline" style="width: 200px;margin-right: 0;">
<select name="cron[minute][in][]" multiple="multiple">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
</div>
<span class="select-text">分钟</span>
</div>
<div class="layui-inline" id="minute-between" style="display:none;">
<span class="select-text">第</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[minute][between][start]" lay-search="">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
</div>
<span class="select-text">至</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[minute][between][end]" lay-search="">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
</div>
<span class="select-text">分钟</span>
</div>
<div class="layui-inline" id="minute-interval" style="display: none;">
<span class="select-text">从</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[minute][interval][start]" lay-search="">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
</div>
<span class="select-text">分钟开始,每</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[minute][interval][value]" lay-search="">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
</div>
<span class="select-text">分钟</span>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">秒规则</label>
<div class="layui-input-inline">
<select name="cron[seconds][use]" lay-filter="seconds-rule">
<option value="at">指定秒</option>
<option value="in">指定秒(可多选)</option>
<option value="between">指定秒范围(0-59)</option>
<option value="interval">从 x 秒开始执行,之后每 x 秒执行一次</option>
</select>
</div>
<div class="layui-inline" id="seconds-at">
<span class="select-text"> 于</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[seconds][at]" lay-search="">
<option value="*">*</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
</div>
<span class="select-text">秒</span>
</div>
<div class="layui-inline" id="seconds-in" style="display:none;">
<span class="select-text">第</span>
<div class="layui-input-inline" style="width: 200px;margin-right: 0;">
<select name="cron[seconds][in][]" multiple="multiple">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
</div>
<span class="select-text">秒</span>
</div>
<div class="layui-inline" id="seconds-between" style="display: none">
<span class="select-text">第</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[seconds][between][start]" lay-search="">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
</div>
<span class="select-text">至</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[seconds][between][end]" lay-search="">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
</div>
<span class="select-text">秒</span>
</div>
<div class="layui-inline" id="seconds-interval" style="display: none">
<span class="select-text">从</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[seconds][interval][start]" lay-search="">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
</div>
<span class="select-text">秒开始,每</span>
<div class="layui-input-inline" style="width: 66px;margin-right: 0;">
<select name="cron[seconds][interval][value]" lay-search="">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
</div>
<span class="select-text">秒</span>
</div>
</div>
</div>
</div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
<legend>生成结果</legend>
</fieldset>
<div class="layui-form layui-form-pane">
<div class="layui-form-item">
<label class="layui-form-label">cron表达式</label>
<div class="layui-input-block">
<input id="cron" autocomplete="off" class="layui-input" type="text">
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">表达式描述</label>
<p class="layui-textarea" id="cronDesc" style="height:50px;min-height:50px" placeholder="待生成"></p>
<p style="height:50px;min-height:50px">*点表示任意,例如 【* */1 * * * ?】表示 每隔1分钟 </p>
</div>
</div>
<fieldset class="layui-elem-field layui-field-title">
<legend>执行时间预览</legend>
</fieldset>
<ul id="executePreview" class="layui-timeline" style="padding-left: 50px">
</ul>
</div>
</div>
</div>
<!--<div class="layui-col-xs5">
<div class="layui-card">
<div class="layui-card-body">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
<legend>调试数据</legend>
</fieldset>
<div class="layui-form layui-form-pane">
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">调试数据</label>
<p class="layui-textarea" id="cronData"></p>
</div>
</div>
</div>
</div>
</div>-->
</form>
<script type="text/html" id="executePreviewTpl">
{{# layui.each(d, function(index, item){
if(item.length > 0){ }}
<li class="layui-timeline-item">
<i class="layui-icon layui-timeline-axis"></i>
<div class="layui-timeline-content layui-text">
<div class="layui-timeline-title">{{item}}</div>
</div>
</li>
{{# }
}) }}
</script>
<script type="text/javascript" src="/js/jquery-2.0.2.min.js"></script>
<script type="text/javascript" src="/corn/jquery.jsonview.min.js"></script>
<script type="text/javascript" src="/layui/layui.js"></script>
<script type="text/javascript" src="/corn/jquery.serializejson.min.js"></script>
<script type="text/javascript">
layui.config({
base: '/layui/lay/modules/'
}).extend({
multiSelect: 'multiple'
}).use(['form', 'multiSelect', 'laydate', 'laytpl'], function () {
var form = layui.form, multiSelect = layui.multiSelect, laydate = layui.laydate, laytpl = layui.laytpl;
var monthInput = '#multi-month';
layui.laydate.render({
elem: monthInput,
theme: 'hide-header',
type: 'month',
format: 'M',
position: 'static',
showBottom: false,
ready: function (date) {
$('.laydate-set-ym').html('<span>可以选择多个月份</span>');
$('.laydate-month-list li').removeClass('layui-this');
},
change: function (value, date, endDate) {
var select = $('#month-in select');
var ele = $('.laydate-month-list li:eq(' + (date.month - 1) + ')');
var remove = ele.hasClass('layui-selected');
ele.toggleClass('layui-selected').removeClass("layui-this");
var months = $(monthInput).data('selected');
if (months == null) {
months = [];
}
if (remove) {
months.splice($.inArray(date.month, months), 1);
} else {
months.push(date.month);
}
months = months.sort(function (a, b) {
return Number(a) - Number(b)
});
months = $.unique(months);
if (months.length > 0) {
select.children('option').each(function () {
var selected = $.inArray(Number(this.value), months) != -1;
$(this).prop('selected', selected);
});
} else {
select.children('option').prop('selected', false);
}
$(monthInput).data('selected', months);
syncCron();
}
});
form.on('radio(daily)', function (d) {
if (d.value == 'yes') {
$('#ruleOther').hide();
$('#ruleEveryDay').show();
} else if (d.value == 'no') {
$('#ruleOther').show();
$('#ruleEveryDay').show();
} else {
layer.msg('请选择是否每天执行');
}
});
form.on('radio(dayWeekday)', function (d) {
if (d.value == 'weekday') {
$('#rule-weekday').show();
$('#rule-day').hide();
} else if (d.value == 'day') {
$('#rule-day').show();
$('#rule-weekday').hide();
}
});
form.on('select(month-rule)', function (d) {
$('[id^="month-"]').hide();
$('#month-select').hide();
switch (d.value) {
case 'in':
$('#month-in').show();
$('#month-input').show();
$('#month-select').show();
break;
case 'between':
$('#month-between').show();
break;
case 'interval':
$('#month-interval').show();
break;
}
});
form.on('select(weekday-rule)', function (d) {
$('[id^="weekday-"]').hide();
switch (d.value) {
case 'in':
$('#weekday-in').show();
break;
case 'between':
$('#weekday-between').show();
break;
case 'last':
$('#weekday-last').show();
break;
case 'week':
$('#weekday-week').show();
break;
}
});
form.on('select(day-rule)', function (d) {
$('[id^="day-"]').hide();
switch (d.value) {
case 'in':
$('#day-in').show();
break;
case 'recentWorkday':
$('#day-recentWorkday').show();
break;
case 'between':
$('#day-between').show();
break;
case 'interval':
$('#day-interval').show();
break;
}
});
form.on('select(hour-rule)', function (d) {
if(d.value!="*"){
if($("select[name='cron[minute][at]']").val()=="*"){
$("select[name='cron[minute][at]']").val("0");
}
if($("select[name='cron[seconds][at]']").val()=="*"){
$("select[name='cron[seconds][at]']").val("0");
}
}
$('[id^="hour-"]').hide();
switch (d.value) {
case 'at':
$('#hour-at').show();
break;
case 'in':
$('#hour-in').show();
break;
case 'between':
$('#hour-between').show();
break;
case 'interval':
$('#hour-interval').show();
break;
}
});
form.on('select(minute-rule)', function (d) {
if(d.value!="*"){
if($("select[name='cron[seconds][at]']").val()=="*"){
$("select[name='cron[seconds][at]']").val("0");
}
}
$('[id^="minute-"]').hide();
switch (d.value) {
case 'at':
$('#minute-at').show();
break;
case 'in':
$('#minute-in').show();
break;
case 'between':
$('#minute-between').show();
break;
case 'interval':
$('#minute-interval').show();
break;
}
});
form.on('select(seconds-rule)', function (d) {
$('[id^="seconds-"]').hide();
switch (d.value) {
case 'at':
$('#seconds-at').show();
break;
case 'in':
$('#seconds-in').show();
break;
case 'between':
$('#seconds-between').show();
break;
case 'interval':
$('#seconds-interval').show();
break;
}
});
form.on('select(hour-every)', function (d) {
if(d.value!="*"){
if($("select[name='cron[minute][at]']").val()=="*"){
$("select[name='cron[minute][at]']").val("0");
}
if($("select[name='cron[seconds][at]']").val()=="*"){
$("select[name='cron[seconds][at]']").val("0");
}
}
});
form.on('select(minute-at)', function (d) {
if(d.value!="*"){
if($("select[name='cron[seconds][at]']").val()=="*"){
$("select[name='cron[seconds][at]']").val("0");
}
}
});
function syncCron(){
var data = $('#cronForm').serializeJSON({
customTypes:{
"cron[hour][in]": "array"
}
}), cron = '', cronDesc = '';
var rule = data.rule, cron = data.cron;
var expression = {
seconds: null,
minute: null,
hour: null,
day: null,
month: null,
weekday: null,
year: '*'
};
var desc = {
seconds: null,
minute: null,
hour: null,
day: null,
month: null,
weekday: null,
year: null
};
switch (cron.month.use) {
case 'every':
expression.month = '*';
desc.month = '每月';
desc.year = null;
break;
case 'in':
if (cron.month.in instanceof Array && cron.month.in.length > 0) {
expression.month = cron.month.in.join(',');
desc.month = expression.month + '月的 ';
}
break;
case 'between':
expression.month = cron.month.between.start + '-' + cron.month.between.end;
if(cron.month.between.start == cron.month.between.end){
desc.month = cron.month.between.start + '月的 ';
} else {
desc.month = cron.month.between.start + '月到' + cron.month.between.end + '月的 ';
}
break;
case 'interval':
expression.month = cron.month.interval.start + '/' + cron.month.interval.value;
var count = Number(cron.month.interval.value) == 1 ? '' : cron.month.interval.value;
desc.month = '从' + cron.month.interval.start + '月开始,每' + count + '个月的 ';
break;
}
if(rule.enable.daily == 'yes'){
expression.day = "*";
expression.weekday = "?";
expression.month = "*";
desc.day = '每天的';
desc.weekday = null;
desc.month = null;
}else{
if(cron.month.use != 'every'){
desc.year = '每年的 ';
}
//月份天数规则
if(rule.enable.dayWeekday == 'day'){
expression.weekday = "?";
desc.weekday = null;
switch (cron.day.use) {
case 'interval':
expression.day = cron.day.interval.start + '/' + cron.day.interval.value;
var count = Number(cron.day.interval.value) == 1 ? '' : cron.day.interval.value;
desc.day = '从' + cron.day.interval.start + '号开始,每' + count + '天的 ';
break;
case 'in':
if (cron.day.in instanceof Array && cron.day.in.length > 0) {
expression.day = cron.day.in.join(',');
desc.day = expression.day + '号的 ';
}
break;
case 'between':
expression.day = cron.day.between.start + '-' + cron.day.between.end;
if(cron.day.between.start == cron.day.between.end){
desc.day = cron.day.between.start + "的 ";
} else {
desc.day = cron.day.between.start + '号到' + cron.day.between.end + '号的 ';
}
break;
case 'last':
expression.day = 'L';
desc.day = '月末(最后一天)的 ';
break;
case 'lastWorkday':
expression.day = 'LW';
desc.day = '当月的最后一个工作日的 ';
break;
case 'recentWorkday':
expression.day = cron.day.recentWorkday;
desc.day = '当月' + parseInt(expression.day) + '号的最近的一个工作日的 ';
break;
}
} /*else {
//月份星期规则
expression.day = "?";
desc.day = null;
var weekDesc = {
"1": "星期日",
"2": "星期一",
"3": "星期二",
"4": "星期三",
"5": "星期四",
"6": "星期五",
"7": "星期六"
};
switch (cron.weekday.use) {
case 'between':
expression.weekday = cron.weekday.between.start + '-' + cron.weekday.between.end;
if(cron.weekday.between.start == cron.weekday.between.end){
desc.weekday = weekDesc[cron.weekday.between.start] + "的 ";
} else {
desc.weekday = weekDesc[cron.weekday.between.start] + '到' + weekDesc[cron.weekday.between.end] + "的 ";
}
break;
case 'in':
if (cron.weekday.in instanceof Array && cron.weekday.in.length > 0) {
expression.weekday = cron.weekday.in.join(',');
desc.weekday = $.map(cron.weekday.in, function (value) {
return weekDesc[value]
}).join('',) + "的 ";
}
break;
case 'last':
expression.weekday = cron.weekday.last;
desc.weekday = '当月最后一个' + weekDesc[parseInt(expression.weekday)] + "的 ";
break;
case 'week':
expression.weekday = cron.weekday.week.at + '/' + cron.weekday.week.weekday;
desc.weekday = '当月第 ' + cron.weekday.week.at + " 周的" + weekDesc[cron.weekday.week.weekday] + "的 ";
break;
}
}*/
}
switch (cron.hour.use) {
case 'at':
expression.hour = cron.hour.at;
if(expression.hour!="*"){
desc.hour = cron.hour.at + '点';
}
break;
case 'in':
if (cron.hour.in instanceof Array && cron.hour.in.length > 0) {
expression.hour = cron.hour.in.join(',');
desc.hour = expression.hour + '点的 ';
}
break;
case 'between':
expression.hour = cron.hour.between.start + '-' + cron.hour.between.end;
if(cron.hour.between.start == cron.hour.between.end){
desc.hour = cron.hour.between.start + '点的 ';
} else {
desc.hour = cron.hour.between.start + '点到' + cron.hour.between.end + '点的 ';
}
break;
case 'interval':
expression.hour = cron.hour.interval.start + '/' + cron.hour.interval.value;
desc.hour = '从' + cron.hour.interval.start + ' 点开始,每' + cron.hour.interval.value + '个小时的 ';
break;
}
switch (cron.minute.use) {
case 'at':
expression.minute = cron.minute.at;
if(expression.minute!="*") {
desc.minute = cron.minute.at + '分';
}
break;
case 'in':
if (cron.minute.in instanceof Array && cron.minute.in.length > 0) {
expression.minute = cron.minute.in.join(',');
desc.minute = expression.minute + '分的 ';
}
break;
case 'between':
expression.minute = cron.minute.between.start + '-' + cron.minute.between.end;
if(cron.minute.between.start == cron.minute.between.end){
desc.minute = cron.minute.between.start + '分的 ';
} else {
desc.minute = cron.minute.between.start + '分到' + cron.minute.between.end + '分的 ';
}
break;
case 'interval':
expression.minute = cron.minute.interval.start + '/' + cron.minute.interval.value;
desc.minute = '从' + cron.minute.interval.start + '分开始,每' + cron.minute.interval.value + '分钟的 ';
break;
}
switch (cron.seconds.use) {
case 'at':
expression.seconds = cron.seconds.at;
if(expression.seconds!="*"){
desc.seconds = cron.seconds.at + '秒 触发一次';
}else{
desc.seconds = '每秒 触发一次';
}
break;
case 'in':
if (cron.seconds.in instanceof Array && cron.seconds.in.length > 0) {
expression.seconds = cron.seconds.in.join(',');
desc.seconds = expression.seconds + '秒 触发一次';
}
break;
case 'between':
expression.seconds = cron.seconds.between.start + '-' + cron.seconds.between.end;
if(cron.seconds.between.start == cron.seconds.between.end){
desc.seconds = cron.seconds.between.start + '秒 触发一次';
} else {
desc.seconds = cron.seconds.between.start + '秒到' + cron.seconds.between.end + '秒 触发一次';
}
break;
case 'interval':
expression.seconds = cron.seconds.interval.start + '/' + cron.seconds.interval.value;
desc.seconds = '从' + cron.seconds.interval.start + '秒开始,每' + cron.seconds.interval.value + '秒 触发一次';
break;
}
var cronArr = [], cronDescArr = [];
cronArr.push(expression.seconds);
cronArr.push(expression.minute);
cronArr.push(expression.hour);
cronArr.push(expression.day);
cronArr.push(expression.month);
cronArr.push(expression.weekday);
cronArr.push(expression.year);
if (desc.year != null) {
cronDescArr.push(desc.year);
}
if (desc.month != null) {
cronDescArr.push(desc.month);
}
if (desc.weekday != null) {
cronDescArr.push(desc.weekday);
}
if (desc.day != null) {
cronDescArr.push(desc.day);
}
cronDescArr.push(desc.hour);
cronDescArr.push(desc.minute);
cronDescArr.push(desc.seconds);
var hasNull = false;
$.each(cronArr, function (i, v) {
if(v == null){
hasNull = true;
}
});
var cronStr = cronArr.join(' ');
cronDesc = cronDescArr.join(' ');
if(hasNull){
layer.msg('您使用了多选规则,请至少选择一项', {icon: 6, times: 1000});
} else {
if (cronStr != $('#cron').val()) {
$.support.cors = true;
$.post('http://api.bejson.com/btools/othertools/cron/',{crontxt: cronStr}).done(function (r) {
if(typeof r == 'string'){
r = $.parseJSON(r);
}
if (r.code == 0) {
var list = r.obj.split('<br>')
laytpl(document.getElementById('executePreviewTpl').innerHTML).render(list, function (html) {
document.getElementById('executePreview').innerHTML = html;
});
layer.msg('解析成功', {icon: 1, times: 1000});
} else {
//layer.msg('cron表达式解析失败', {icon: 2, times: 1000});
}
});
console.log("cronStr="+cronStr);
cronStr = cronStr.substring(0,cronStr.lastIndexOf("?")+1);
/*var cronStrArr = cronStr.split(" ");
for(var x=0;x<cronStrArr.length;x++){
if(cronStrArr[x]!="*"&&cronStrArr[x]!="?"){
}
}*/
$('#cron').val(cronStr);
//cronDesc = cronDesc.replace(/\*/g,"0");
$('#cronDesc').text(cronDesc);
//$('#cronData').JSONView(data);
}
}
}
form.on('select', function (data) {
syncCron();
});
form.on('radio', function (data) {
syncCron();
});
multiSelect.on('mselect', function (d) {
syncCron();
});
});
</script>
</body>
</html>