<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="修改定时任务" bodyClass="white-bg" libs=["bootstrapSelect"]/>
<div class="wrapper wrapper-content ibox-content">
<@f.form id="form-job-edit" class="form-horizontal">
	<@f.hidden id="id" name="id" value="${job.id}"/>
	<h4 class="form-header h4">基本信息</h4>
	<div class="row">
		<div class="col-xs-6">
			<div class="form-group">
				<label class="col-sm-4 control-label"><span style="color: red; ">*</span>任务名称:</label>
				<div class="col-sm-8">
					<@f.input name="jobName" value="${job.jobName}" placeholder="请输入任务名称" required=true/>
				</div>
			</div>
		</div>
		<div class="col-xs-6">
			<div class="form-group">
				<label class="col-sm-4 control-label"><span style="color: red; ">*</span>任务分组：</label>
				<div class="col-sm-8">
					<@f.select name="jobGroup" value="${job.jobGroup}" dictType="sys_job_group" required=true/>
				</div>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-xs-12">
			<div class="form-group">
				<label class="control-label col-sm-2" title="">
					<span style="color: red; ">*</span>调用目标:</label>
				<div class="col-sm-10">
					<@f.input name="invokeTarget" value="${job.invokeTarget}" placeholder="调用目标" required=true
					helpTip="SpringBean 调用示例：@Component(\"jobTaskTest\") 填写 jobTaskTest.fastParams(\"123\")"/>
				</div>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-xs-12">
			<div class="form-group">
				<label class="control-label col-sm-2" title="">
					<span style="color: red; ">*</span>执行失败策略:</label>
				<div class="col-sm-10">
					<label class="radio-box"> <input type="radio" <#if job.misfirePolicy == "1" >checked</#if> name="misfirePolicy" value="1" /> 立即执行 </label>
					<label class="radio-box"> <input type="radio" <#if job.misfirePolicy == "2" >checked</#if>name="misfirePolicy" value="2" /> 执行一次 </label>
					<label class="radio-box"> <input type="radio" <#if job.misfirePolicy == "3" >checked</#if> name="misfirePolicy" value="3" /> 放弃执行 </label>
				</div>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-xs-12">
			<div class="form-group">
				<label class="control-label col-sm-2" title="">
					<span style="color: red; ">*</span>是否允许并发进行:</label>
				<div class="col-sm-10">
					<label class="radio-box"> <input type="radio" <#if job.concurrent == "0" >checked</#if> name="concurrent" value="0"/> 允许 </label>
					<label class="radio-box"> <input type="radio" <#if job.concurrent == "1" >checked</#if> name="concurrent" value="1"/> 禁止 </label>
				</div>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-xs-12">
			<div class="form-group">
				<label class="control-label col-sm-2" title="">
					<span style="color: red; ">*</span> Cron执行表达式:</label>
				<div class="col-sm-10">
					<@f.hidden name="cronExpression" value="${job.cronExpression?default('')}"/>
					<iframe id="cronFrame" src="${ctxStatic}/sys/schedule/cron" style="width:100%;height:530px;border:0;"></iframe>
					<script type="text/javascript">
						$('#cronFrame').on("load",function () {
							var win = $(this)[0].contentWindow;
							win.$('#cron').val($('#cronExpression').val());
							win.$("input[name^='v_'],#cron").change(function(){
								$('#cronExpression').val(win.$('#cron').val());
							});
							win.$('#btnFan').click();
						})
					</script>
				</div>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-xs-6">
			<div class="form-group">
				<label class="col-sm-4 control-label">状态：</label>
				<div class="col-sm-8">
					<@f.radio name="status" value="${job.status}" dictType="sys_job_status"/>
				</div>
			</div>
		</div>
	</div>
	<h4 class="form-header h4">其它信息</h4>
	<div class="row">
		<div class="col-xs-12">
			<div class="form-group">
				<label class="col-sm-2 control-label">备注：</label>
				<div class="col-sm-10">
					<@f.textarea  name="remark" value="${job.remark?default('')}"/>
				</div>
			</div>
		</div>
	</div>
</@f.form>
	<div class="hr-line-dashed"></div>
	<div class="row" id="_addTab">
		<div class="col-sm-offset-5 col-sm-10">
			<button type="button" class="btn btn-sm btn-primary" onclick="opt.form.submit()"><i class="fa fa-check"></i><@ctx.i18n text = "保存"/></button>&nbsp;
			<button type="button" class="btn btn-sm btn-danger" onclick="opt.modal.closeTab()"><i class="fa fa-reply-all"></i><@ctx.i18n text = "关闭"/></button>
		</div>
	</div>
</div>
<@footer>
	<script type="text/javascript">
		var prefix = baseURL + "sys/schedule";
		$("#form-job-edit").validate({
			onkeyup: false,
			rules:{
				cronExpression:{
					required:true,
					remote: {
	                    url: prefix + "/checkCronExpressionIsValid",
	                    type: "post",
	                    dataType: "html",
	                    data: {
	                        "cronExpression": function() {
	                            return opt.common.trim($("#cronExpression").val());
	                        }
	                    },
	                    dataFilter: function(data, type) {
							return opt.validate.unique(data);
	                    }
	                }
				},
			},
			messages: {
	            "cronExpression": {
	                remote: "表达式不正确"
	            }
	        },
	        focusCleanup: true
		});
		
		function submitHandler() {
	        if (opt.validate.form()) {
	        	opt.operate.saveTab(prefix + "/edit", $('#form-job-edit').serialize());
	        }
	    }
	</script>
</@footer>
</@pageTheme>