{{template "inc"}}
<!-- Main Header -->
{{template "header"}}
<!-- Left side column. 权限菜单 -->
{{template "memu"}}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
	<section class="content-header">
		<ol class="breadcrumb">
		  <li><a href="/admin/versionclear"><i class="fa fa-dashboard"></i>清理版本</a></li>
		  <li><a href="/admin/clearversion/info?vid={{.vid}}">属性配置</a></li>
		  <li><a href="/admin/clearulelogic?vid={{.vid}}&pid={{.pid}}">清理逻辑</a></li>
		 <li class="active"><a href="/admin/check/lua/clearlogic?vid={{.vid}}&pid={{.pid}}&s_code={{.code}}">{{.code}}</a></li>
		</ol>
    </section>
  <!-- Main content -->
  <section class="content"><br/>
    	<form id="dataform" class="form-horizontal">
			<div class="form-group">
				<div class="col-sm-12">
					<div class="col-sm-4">
						<div class="row form-group">
							<label for="lastname" class="col-sm-3 control-label">结果表：</label>
							<div class="col-sm-8">
								<input type="text" name="resultcoll" class="form-control" must="true">
							</div>
						</div>
					</div>
					<div class="col-sm-4">
						<div class="row form-group">
							<label for="lastname" class="col-sm-2 control-label">id：</label>
							<div class="col-sm-8">
								<input type="text" name="rid" class="form-control" must="true">
							</div>
						</div>
					</div>
					<!--<div class="col-sm-4">
						<div class="row form-group">
							<label for="lastname" class="col-sm-3 control-label">合并表：</label>
							<div class="col-sm-8">
								<input type="text" name="projectset" class="form-control" must="true">
							</div>
						</div>
					</div>-->
				</div>
				<label for="code" class="col-sm-1 control-label">代码: {{.rule.s_code}}</label>
			    <label for="code" class="col-sm-3 control-label">名称: {{.rule.s_name}}</label>
			</div>
			<fieldset class="col-sm-6" data-mode="expert">
				<textarea id="s_luascript" name="s_luascript">{{.rule.s_luascript}}</textarea>
			</fieldset>
			<fieldset class="col-sm-6" data-mode="expert">
				<textarea id="result" style="height:400px;width:100%"></textarea>
			</fieldset>
			<input type="hidden" name="_id" value="{{.rule._id}}">
			<input type="hidden" name="s_code" value="{{.rule.s_code}}">
			<input type="hidden" name="s_name" value="{{.rule.s_name}}">
		</form>
		
		<h1><div class="btn-center">
			<button type="button" class="btn btn-success" onclick="check()">测试</button>
			<button type="button" class="btn btn-primary" onclick="save()">保存</button>
		</div></h1>
</section>

</div>
{{template "luares"}}
{{template "footer"}}
<script>
com.initMirror(400)
menuActive("versionclear")
function check(){
	$.post("/admin/check/lua/checkclearlua",
		com.serializeArray("dataform"), 
		function(r) {
			if(r.rep){	
				$("#result").html(JSON.stringify(r.rep, null, 2)) 
			}else{
				showTip("表单信息填写错误！",1000)
			}
		}
	);
}
function save(){
	$.post("/admin/clearulelogic/save",
		com.serializeArray("dataform"),
		function(r){
			if(r){
				showTip("保存成功",1000)
			}
		}
	);
}
</script>

