<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
              <form id="dept-form">
                <div class="row g-3">
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="deptID">부서코드</label>
                      <div class="col-sm-9">
                        <input name="deptID" type="text" required data-map="DEPT_CD" maxlength="7" class="form-control" placeholder="부서코드" />
                        <input name="sggID" type="hidden" data-map="SGG_CD" />
                        <input name="instCode" type="hidden" data-map="INST_CD" />
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="name">부서이름</label>
                      <div class="col-sm-9">
                        <input name="name" type="text" required  data-map="DEPT_NM" maxlength="100" class="form-control" placeholder="부서이름" />
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="telno">전화번호</label>
                      <div class="col-sm-9">
                        <input name="telno" type="text" data-map="DEPT_TELNO" maxlength="20" class="form-control" placeholder="전화번호"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="faxno">팩스번호</label>
                      <div class="col-sm-9">
                        <input name="faxno" type="text" data-map="DEPT_FXNO" maxlength="20" class="form-control" placeholder="팩스번호"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="createdBy">등록자</label>
                      <div class="col-sm-9">
                        <input type="text" data-map="RGTR" readonly class="form-control" placeholder="등록자"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="description">등록일자</label>
                      <div class="col-sm-9">
                        <input type="text" data-map="REG_DT" readonly class="form-control" placeholder="등록일자"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-3 col-form-label text-sm-end" for="description">사용여부</label>
                      <div class="col-sm-9" style="padding:.5em .7em;">
                        <input name="useYN" type="hidden" data-map="USE_YN" />
                      	<span id="deptInUse"></span>
                      </div>
                    </div>
                  </div>
                <div class="row mt-4 justify-content-end">
                      <div class="col-sm-12" style="text-align:right;">
                        <button onclick="saveDept();" type="button" class="btn btn-primary">저장</button>
                      </div>
                </div>
              </form>
<script type="text/javascript">

var deptFields = new FormFields("#dept-form");

sggDeptControl.depts.setInfo = obj => {
	let info = obj.data;
	deptFields.set(sggDeptControl.depts, obj);
	let create = isEmpty(info.DEPT_CD);
	$("input[name='deptID']").prop("readonly", !create);
	$("#dept-form input").onEnterPress(saveDept);
	$("#deptInUse").html("Y" == info.USE_YN ? "사용 중" : "사용하지 않음");
	document.querySelector("input[name='" + (create ? "deptID" : "name") + "']").focus();
}

sggDeptControl.depts.onModify = (changed) => {
	if (["DEPT_NM"].filter(e => changed.includes(e)).length < 1)
		return;
	
	renderDeptList();
	sggDeptControl.depts.dataset.setState();
}

function saveDept() {
	if (!$("#dept-form input").validInputs()) return;
	
	dialog.alert({
		content:"현재 부서 정보를 저장하시겠습니까?",
		onOK:() => sggDeptControl.depts.save(deptFields.get())
	});
}
//# sourceURL=dept-info.jsp
</script>