<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="修改公司" bodyClass="white-bg"/>
<div class="wrapper wrapper-content ibox-content">
<@f.form id="form-comp-edit" class="form-horizontal">
	<@f.hidden id="id" name="id" value="${comp.id}"/>
	<@f.hidden name="type" value="${comp.type}"/>
	<div class="form-group">
		<label class="col-sm-3 control-label "><span style="color: red; ">*</span>上级公司：</label>
		<div class="col-sm-8">
			<@f.treeselect id="parentId" name="parentId" boxTitle="选择归属公司" url="sys/comp/treeData?type=0"
			expandLevel=true value="${comp.parentId}" labelValue="${comp.parentName?default('总公司')}" isParentIds=true
			parenIdsValue="${comp.parentIds}"
			placeholder="请选择归属公司" required=true/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label"><span style="color: red; ">*</span>公司名称：</label>
		<div class="col-sm-8">
			<@f.input name="name" value="${comp.name}"  required=true/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label"><span style="color: red; ">*</span>公司全称：</label>
		<div class="col-sm-8">
			<@f.input name="fullName" value="${comp.fullName}" required=true/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label "><span style="color: red; ">*</span>管理地区：</label>
		<div class="col-sm-8">
			<@f.treeselect id="areaId" name="areaIds" boxTitle="请选择管理地区" url="sys/area/treeData" labelValue="${areaNames}" value="${comp.areaIds?default('')}"
			checked=true correlationId="parentId" placeholder="请选择管理地区"/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label">显示排序：</label>
		<div class="col-sm-8">
			<input class="form-control" type="text" name="orderNum"  value="${comp.orderNum?default("0")}"  required>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label"><span style="color: red; ">*</span>状态：</label>
		<div class="col-sm-8">
			<@f.radio name="status" value="${comp.status}" dictType="sys_normal_disable"/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label">备注：</label>
		<div class="col-sm-8">
			<@f.textarea name="remark" value="${comp.remark?default('')}"/>
		</div>
	</div>
</@f.form>
</div>
<@footer>
<script type="text/javascript">
	var prefix = baseURL + "sys/comp";

	$("#form-comp-edit").validate({
		onkeyup: false,
		rules:{
			name:{
				remote: {
					url: prefix + "/checkCompNameUnique",
					type: "POST",
					dataType: "html",
					data: {
						"parentId": function() {
							return $("input[name='parentId']").val();
						},
						"name" : function() {
							return opt.common.trim($("#name").val());
						},
						"id":function() {
							return opt.common.trim($("#id").val());
						}
					},
					dataFilter: function(data, type) {
						return opt.validate.unique(data);
					}
				}
			},
			orderNum:{
				digits:true
			}
		},
		messages: {
			"name": {
				remote: "已经存在"
			}
		},
		focusCleanup: true
	});

	function submitHandler() {
		if (opt.validate.form()) {
			opt.operate.save(prefix + "/edit", $('#form-comp-edit').serialize());
		}
	}
</script>
</@footer>
</@pageTheme>
