<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>机构管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		var validateForm;
		function doSubmit(){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
		  if(validateForm.form()){
			  $("#inputForm").submit();
			  return true;
		  }
	
		  return false;
		}
		$(document).ready(function() {
			$("#name").focus();
			validateForm = $("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
                rules : {
                    name: {
                        remote: "${ctx}/sys/company/validateCompany",
                    }
                },
                messages: {
                    name:{remote: "此公司名称已经被注册!", required: "公司名称不能为空."},
                },
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});

            if('${sessionScope.state}' =='disabled'){
                $('select').attr('disabled','<%=session.getAttribute("state")%>');
            }else if('${sessionScope.state}' !='disabled'){
                $('select').removeAttr('disabled');
            }
			//设置非必填
            $("#type").change(function(){
                if($("#type").val() == 1){
                    $("#masterId").attr("class","form-control required");
                    $("#masterName").attr("class","form-control required");
                }else{
                    $("#masterId").attr("class","form-control");
                    $("#masterName").attr("class","form-control");
				}
            });
		});
	</script>
</head>
<body>
<div class="single-form">
	<div class="container view-form">
	<form:form id="inputForm" modelAttribute="office" action="${ctx}/sys/office/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<c:set var="officedis" scope="session" value='<%=session.getAttribute("state")%>' />
		<sys:message content="${message}"/>

		<div class="form-group layui-row first">
			<div class="form-group-label"><h2>机构信息</h2></div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label">上级机构：</label>
				<div class="layui-input-block with-icon">
					<input htmlEscape="false" readonly="true" class="form-control layui-input" value="${office.parent.name}"/>
				</div>
			</div>
			<%--<div class="layui-item layui-col-sm6">
				<label class="layui-form-label">归属区域：</label>
				<div class="layui-input-block with-icon">
					<input htmlEscape="false" readonly="true" class="form-control layui-input" value="${office.parent.name}"/>
				</div>
			</div>--%>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>机构名称：</label>
				<div class="layui-input-block with-icon">
					<input htmlEscape="false" readonly="true" class="form-control layui-input" value="${office.name}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>机构全称：</label>
				<div class="layui-input-block with-icon">
					<input htmlEscape="false" readonly="true" class="form-control layui-input" value="${office.topCompany}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>机构编码：</label>
				<div class="layui-input-block with-icon">
					<input htmlEscape="false" readonly="true" class="form-control layui-input" value="${office.code}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label">机构类型：</label>
				<div class="layui-input-block with-icon">
					<input htmlEscape="false" readonly="true" class="form-control layui-input" value="${fns:getDictLabel(office.type, 'sys_office_type', '')}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label">机构状态：</label>
				<div class="layui-input-block with-icon">
					<input htmlEscape="false" readonly="true" class="form-control layui-input" value="${fns:getDictLabel(office.useable, 'office_useable', '')}"/>
				</div>
			</div>

		<%--<div class="layui-item layui-col-sm6">
				<label class="layui-form-label">负责人：</label>
				<div class="layui-input-block with-icon">
					<input htmlEscape="false" readonly="true" class="form-control layui-input" value="${office.masterName}"/>
				</div>
			</div>
			<input type="hidden" name="useable" value="1">
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label">邮箱：</label>
				<div class="layui-input-block with-icon">
					<input htmlEscape="false" readonly="true" class="form-control layui-input" value="${office.email}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label">联系地址：</label>
				<div class="layui-input-block with-icon">
					<input htmlEscape="false" readonly="true" class="form-control layui-input" value="${office.address}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label">传真：</label>
				<div class="layui-input-block with-icon">
					<input htmlEscape="false" readonly="true" class="form-control layui-input" value="${office.fax}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label">电话：</label>
				<div class="layui-input-block with-icon">
					<input htmlEscape="false" readonly="true" class="form-control layui-input" value="${office.phone}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label">公司简称：</label>
				<div class="layui-input-block with-icon">
					<input htmlEscape="false" readonly="true" class="form-control layui-input" value="${office.simpleName}"/>
				</div>
			</div>--%>
			<div class="layui-item layui-col-sm12">
				<label class="layui-form-label">备注：</label>
				<div class="layui-input-block with-icon">
					<textarea readonly="true" htmlEscape="false" rows="4" maxlength="200" class="form-control">${office.remarks}</textarea>
				</div>
			</div>
		</div>
	</form:form>
	</div>
</div>
</body>
</html>