<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增门店')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-dept-add">
			<input id="treeId" name="parentId" type="hidden" th:value="${dept?.deptId}"   />
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">上级门店：</label>
				<div class="col-sm-8">
				    <div class="input-group">
						<input class="form-control" type="text" onclick="selectDeptTree()" id="treeName" readonly="true" th:value="${dept?.deptName}" required>
					    <span class="input-group-addon"><i class="fa fa-search"></i></span>
				    </div>
				</div>
			</div>
			<div class="customize-form-group">
				<label class="col-sm-1 control-label is-required">门店名称：</label>
				<input name="deptName" id="deptName" placeholder="请输入门店名称" class="styled-input" type="text" required>
			</div>
			<div class="customize-form-group">
				<label class="col-sm-1 control-label is-required">门店地址：</label>
				<input name="address" id="address" placeholder="请输入门店地址" class="styled-input" type="text" required>
			</div>
			<div class="customize-form-group">
				<label class="col-sm-1 control-label">门店编码：</label>
				<input name="storeCode" id="storeCode" placeholder="请输入门店编码" class="styled-input" type="text">
			</div>
			<div class="customize-form-group">
				<label class="col-sm-1 control-label is-required">显示排序：</label>
				<input name="orderNum" id="orderNum" placeholder="显示排序" class="styled-input"  required>
			</div>
			<div class="customize-form-group">
				<label class="col-sm-1 control-label">负责人：</label>
				<input name="leader" id="leader" placeholder="请输入负责人" class="styled-input" type="text">
			</div>

			<div class="customize-form-group">
				<label class="col-sm-1 control-label">联系电话：</label>
				<input name="phone" placeholder="请输入联系电话" class="styled-input" type="text">
			</div>
			<div class="customize-form-group">
				<label class="col-sm-1 control-label">邮箱：</label>
				<input name="email" id="email" placeholder="请输入邮箱" class="styled-input" type="text">
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">门店状态：</label>
				<div class="col-sm-8">
					<div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
						<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}">
						<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
					</div>
				</div>
			</div>
			<div class="customize-form-group">
				<label class="col-sm-1 control-label">所在城市：</label>
				<input name="city" id="city" placeholder="请输入所在城市" class="styled-input" type="text">
			</div>
			<div class="customize-form-group">
				<label class="col-sm-1 control-label">所在省份或州：</label>
				<input name="province" id="province" placeholder="请输入所在省份或州" class="styled-input" type="text">
			</div>
			<div class="customize-form-group">
				<label class="col-sm-1 control-label">纬度坐标：</label>
				<input name="latitude" id="latitude" placeholder="请输入纬度坐标" class="styled-input" type="text">
			</div>
			<div class="customize-form-group">
				<label class="col-sm-1 control-label">经度坐标：</label>
				<input name="longitude" id="longitude" placeholder="请输入经度坐标" class="styled-input" type="text">
			</div>

			<div class="customize-form-group">
				<label class="col-sm-1 control-label">营业执照编号：</label>
				<input name="licenseNumber" id="licenseNumber" placeholder="请输入营业执照编号" class="styled-input" type="text">
			</div>

			<div class="customize-form-group select-time">
				<label class="col-sm-1 control-label">许可证有效期截止：</label>
				<div class="input-group select-time">
					<input name="pharmacyLicenseExpiryDate" id="pharmacyLicenseExpiryDate" placeholder="许可证有效期截止日期" class="time-input time-input2" type="text">
				</div>
			</div>

			<div class="customize-form-group">
				<label class="col-sm-1 control-label">注册资本：</label>
				<input name="registeredCapital" id="registeredCapital" placeholder="请输入注册资本" class="styled-input" type="text">
			</div>
			<div class="customize-form-group">
				<label class="col-sm-1 control-label">经营范围描述：</label>
				<input name="businessScope" id="businessScope" placeholder="请输入经营范围描述" class="styled-input" type="text">
			</div>
			<div class="customize-form-group">
				<label class="col-sm-1 control-label">备注：</label>
				<input name="remark" id="remark" placeholder="备注" class="styled-input" type="text">
			</div>

		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "system/dept";

		$("#form-dept-add").validate({
			onkeyup: false,
			rules:{
				deptName:{
					remote: {
		                url: prefix + "/checkDeptNameUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"parentId": function() {
		                		return $("input[name='parentId']").val();
		                    },
		                	"deptName" : function() {
		                        return $.common.trim($("#deptName").val());
		                    }
		                }
		            }
				},
				orderNum:{
					digits:true
				},
				email:{
                    email:true,
        		},
        		phone:{
        			isPhone:true,
        		},
			},
			messages: {
		        "deptName": {
		            remote: "门店已经存在"
		        }
		    },
		    focusCleanup: true
		});

		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/add", $('#form-dept-add').serialize());
	        }
	    }

		/*门店管理-新增-选择父门店树*/
		function selectDeptTree() {
			var treeId = $("#treeId").val();
			if ($.common.isEmpty(treeId)) {
       			$.modal.alertWarning("请先添加用户所属的门店！");
       			return;
       		}
			var options = {
				title: '门店选择',
				width: "380",
				url: prefix + "/selectDeptTree/" + treeId + "/0",
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}

		function doSubmit(index, layero){
			var body = $.modal.getChildFrame(index);
   			$("#treeId").val(body.find('#treeId').val());
   			$("#treeName").val(body.find('#treeName').val());
   			$.modal.close(index);
		}
	</script>
</body>
</html>
