<%@ 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="code-form">
                <div class="row g-3">
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-2 col-form-label text-sm-end" for="code"
                        >코드</label
                      >
                      <div class="col-sm-10">
                        <input name="code" type="text" required data-map="CODE" maxlength="15" class="form-control" placeholder="코드" />
                        <input name="groupID" type="hidden" data-map="GRP_ID" />
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-2 col-form-label text-sm-end" for="value"
                        >코드값</label
                      >
                      <div class="col-sm-10">
                        <input name="value" type="text" required  data-map="CODE_VAL" maxlength="60" class="form-control" placeholder="코드값" />
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-2 col-form-label text-sm-end" for="description"
                        >설명</label
                      >
                      <div class="col-sm-10">
                        <input name="description" type="text" data-map="DSCRP" maxlength="200" class="form-control" placeholder="코드 설명"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-2 col-form-label text-sm-end" for="etc1"
                        >기타값 1</label
                      >
                      <div class="col-sm-10">
                        <input name="etc1" type="text" data-map="ETC_1" maxlength="200" class="form-control" placeholder="기타값 1"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-2 col-form-label text-sm-end" for="etc2"
                        >기타값2</label
                      >
                      <div class="col-sm-10">
                        <input name="etc2" type="text" data-map="ETC_2" maxlength="200" class="form-control" placeholder="기타값 2"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-2 col-form-label text-sm-end" for="etc3"
                        >기타값3</label
                      >
                      <div class="col-sm-10">
                        <input name="etc3" type="text" data-map="ETC_3" maxlength="200" class="form-control" placeholder="기타값 3"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-2 col-form-label text-sm-end" for="createdBy"
                        >등록자</label
                      >
                      <div class="col-sm-10">
                        <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-2 col-form-label text-sm-end" for="description"
                        >등록일자</label
                      >
                      <div class="col-sm-10">
                        <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-2 col-form-label text-sm-end" for="description"
                        >사용여부</label
                      >
                      <div class="col-sm-10 p-2">
                      	<span id="codeInUse"></span>
                      </div>
                    </div>
                  </div>
                <div class="row mt-4 justify-content-end">
                      <div class="col-sm-12 text-end">
                        <button onclick="saveCode();" type="button" class="btn btn-primary">저장</button>
                      </div>
                </div>
              </form>
<script type="text/javascript">

var codeFields = new FormFields("#code-form");

codeControl.codes.setInfo = obj => {
	let info = obj.data;
	codeFields.set(codeControl, obj);
	let create = isEmpty(info.CODE);
	$("input[name='code']").prop("readonly", !create);
	$("#code-form input").onEnterPress(saveCode);
	$("#codeInUse").html("Y" == info.USE_YN ? "사용 중" : "사용하지 않음");
	document.querySelector("input[name='" + (create ? "code" : "value") + "']").focus();
}

codeControl.codes.onModify = (changed) => {
	if (["CODE", "CODE_VAL"].filter(e => changed.includes(e)).length < 1)
		return;
	
	renderCodeList();
	codeControl.codes.dataset.setState();
}

function saveCode() {
	if (!$("#code-form input").validInputs()) return;
	
	dialog.alert({
		content:"현재 코드 정보를 저장하시겠습니까?",
		onOK:() => {
			codeControl.codes.save(codeFields.get());
		}
	});
}
//# sourceURL=code-info.jsp
</script>