<%@ page language="java" contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fastboot" prefix="fb"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro"%>
<fb:ui src="base/main">

	<fb:property name="title">机构管理</fb:property>

	<fb:css href="${base}/static/js/city-picker/city-picker.css"></fb:css>

	<fb:script src="${base}/static/js/city-picker/city-picker.data.js"></fb:script>

	<fb:script type="text/javascript">
		<script>
			layui.use(['tool', 'form', 'city', 'sug'],function() {
				// 操作对象
				var $ = layui.$,tool = layui.tool,form = layui.form, sug = layui.sug;
				// 城市赋值
				// 初始赋值
				form.val('inputForm', ${json});
				// 监听提交
				form.on('submit(go)',function(data) {
					console.log($("#inputForm").serializeArray());
					tool.submit('${base}/organ/submit', $("#inputForm").serializeArray());
					return false;
				});

				// 初始化姓名输入提示框
				sug.render({
					id: "parentOrgan", //设置容器唯一id
					height: "267",
					cols: [
						[{
							field: 'company',
							title: '公司'
						}, {
							field: 'contacts',
							title: '联系人'
						}, {
							field: 'tel',
							title: '电话'
						}]
					],
					params: [{
						name: 'parentOrgan',
						field: 'company'
					}, {
						name: 'parentContacts',
						field: 'contacts'
					}, {
						name: 'parentId',
						field: 'id'
					}],
					type: 'sugTable',
					url: "${base}/organ/centerSelect?isCenter=1&keyword="
				});

				$("#parentOrgan").blur(function(){
					let organ = $.trim($("#parentOrgan").val());
					if (organ == "") {
						$("#parentOrgan").val("");
						$("#parentId").val("");
					}
				})

			});
		</script>

	</fb:script>

	<fb:layout>

		<div class="layui-card">

			<form id="inputForm" class="layui-form layui-form-pane" action="" lay-filter="inputForm">
				<input type="hidden" id="parentId" name="parentId"  />
				<input type="hidden" name="id" />

				<div class="layui-tab layui-tab-brief">
					<ul class="layui-tab-title">
						<li class="layui-this">基本信息</li>
					</ul>
					<div class="layui-tab-content">
						<div class="layui-tab-item layui-show">

							<div class="layui-form-item">
								<label class="layui-form-label">父机构</label>
								<div class="layui-input-block">
									<input type="text" id="parentOrgan" name="parentOrgan" value="${organ.parent != null ? organ.parent.company :''}"   lay-verType="tips" autocomplete="off" placeholder="请输入机构名称" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">单位类型</label>
								<div class="layui-input-block">
									<input type="radio" name="isBureau" ${organ.isBureau == 1 ?'':'checked'}  value="0" title="派出机构"/>
									<input type="radio" name="isBureau" ${organ.isBureau == 1 ?'checked':''} value="1" title="县级机构"/>
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">公司</label>
								<div class="layui-input-block">
									<input type="text" name="company" lay-verify="required" lay-verType="tips" autocomplete="off" placeholder="请输入机构名称" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">联系人 </label>
								<div class="layui-input-block">
									<input type="text" name="contacts" lay-verify="required" lay-verType="tips" autocomplete="off" placeholder="请输入联系人" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">地区 </label>
								<div class="layui-input-block">
									<select lay-filter="cityName" name="cityName" id="cityName">
										<option value="">请选择</option>
										<option value="佛冈县">佛冈县</option>
										<option value="连南瑶族自治县">连南瑶族自治县</option>
										<option value="连山壮族瑶族自治县">连山壮族瑶族自治县</option>
										<option value="连州市">连州市</option>
										<option value="清城区">清城区</option>
										<option value="清新区">清新区</option>
										<option value="阳山县">阳山县</option>
										<option value="英德市">英德市</option>
									</select>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">地址 </label>
								<div class="layui-input-block">
									<input type="text" name="address" lay-verify="required" lay-verType="tips" autocomplete="off" placeholder="请输入地址" class="layui-input">
								</div>
							</div>
						</div>
					</div>
				</div>
				<button id="submit" lay-submit lay-filter="go" hidden="true" />
				<button id="reset" type="reset" hidden="true" />
			</form>
		</div>
	</fb:layout>
</fb:ui>