<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>

<!-- inner page html -->
<div class="content-wrapper">
	<!-- Content -->
	<div class="container-xxl flex-grow-1 px-0">
		<c:set var="prefixName" scope="request">단속 상태 정보</c:set>

		<!-- Page Body -->
		<div class="card">
			<!-- 입력 영역 -->
			<form id="frmEdit--${pageName}" name="frmEdit">
				<!-- hidden -->
				<input type="hidden" id="crdnId--${pageName}" name="crdnId" data-map="CRDN_ID" />
				<input type="hidden" id="sggCd--${pageName}" name="sggCd" data-map="SGG_CD" />
				<input type="hidden" id="taskSeCd--${pageName}" name="taskSeCd" data-map="TASK_SE_CD" />

				<div class="row g-1">
					<!-- 단속 처리 상태 코드 -->
					<div class="col-md-12">
						<label for="crdnSttsCd--${pageName}" class="w-px-120 bg-lighter pe-2 col-form-label text-sm-end required">처리 상태</label>
						<select class="form-select" id="crdnSttsCd--${pageName}" name="crdnSttsCd" data-map="CRDN_STTS_CD" required>
							<option value="">선택하세요</option>
							<c:forEach items="${FIM010List}" var="item">
								<option value="${item.code}">${item.value}</option>
							</c:forEach>
						</select>
					</div>
					<!-- 기타 내용 -->
					<div class="col-md-12">
						<label for="etcCn--${pageName}" class="w-px-120 bg-lighter pe-2 col-form-label text-sm-end">기타 내용</label>
						<input type="text" class="form-control w-80" id="etcCn--${pageName}" name="etcCn" data-map="ETC_CN" data-maxlengthb="1000" />
					</div>
				</div>
			</form>	<!-- /입력 영역 -->
		</div> <!-- <div class="card"> -->

		<!-- 업무 버튼 표시 -->
		<div>
			<span class="container-page-btn">
				<span class="container-window-btn-right">
					<!-- 업무 버튼 -->
					<button type="button" class="btn btn-primary" id="btnSave--${pageName}" title="저장" onclick="fnSave${pageName}()">저장</button>
				</span>
			</span>
		</div>
		<!-- / 업무 버튼 표시 -->

	</div> <!-- / Content <div class="container-xxl flex-grow-1 px-0"> -->
</div> <!-- / inner page html <div class="content-wrapper"> -->

<script>
	/**************************************************************************
	 * Global Variable
	 **************************************************************************/
	// URL
	var ${pageName}PrefixUrl = "/crdn/crdn06";
	// FormFields
 	var ${pageName}Fields = new FormFields("#frmEdit--${pageName}");

	/**************************************************************************
	 * DatasetControl
	 **************************************************************************/
	var ${pageName}Control = new DatasetControl({
		  prefix : "crdnSttsCd"
		, prefixName : "단속 상태"
		, keymapper : info => info ? info.CRDN_ID : ""
		, dataGetter : obj => obj.crdnInfo
		, urls : {
			update : wctx.url(${pageName}PrefixUrl + "/030/update.do")			// 저장
		}
	});

	${pageName}Control.onCurrentChange = item => {
		${pageName}Fields.set(item);

		// 업무구분에 따른 url 변경
		${pageName}Control.urls.update = wctx.url($("#taskSeCd--${pageName}").val() + ${pageName}PrefixUrl + "/030/update.do");
	}

	/**************************************************************************
	 * DatasetControl 이벤트
	 **************************************************************************/
	// 저장 callback
	${pageName}Control.onSave = (resp) => {
  		let dialogTitle = $("#" + ${pageName}Control.prefix + "Dialog").find("h5.modal-title").html();
  		let showMessage = resp.retMessage.replace(/[S]|[F]/g, dialogTitle);

		dialog.alert(showMessage);

		if (resp.saved) {
			dialog.close(${pageName}Control.prefix + "Dialog");
		}
	}

	// 저장
	${pageName}Control.save = (info) => {
		if (!info) return;

		ajax.post({
			  url : ${pageName}Control.urls.update
			, data : info
			, success : resp => ${pageName}Control.onSave(resp)
		});
	}

	/**************************************************************************
	 * 초기 셋팅
	 **************************************************************************/
	// 검색조건 초기값 셋팅
	initForm${pageName} = () => {

	}

	// 이벤트 설정
	setEvent${pageName} = () => {

	}

	/**************************************************************************
	 * function
	 **************************************************************************/
	// 저장
	fnSave${pageName} = () => {
		// validate 확인
		if (!customValidate($("#frmEdit--${pageName}").find("input, select, textarea"))) return;

		dialog.alert({
			  content : "현재 " + ${pageName}Control.prefixName + " 정보를 저장하시겠습니까?"
			, onOK : () => {
				${pageName}Control.save(${pageName}Fields.get());
			}
		});
	}

	/**************************************************************************
	 * script 진입
	 **************************************************************************/
	$(document).ready(function() {
		// 이벤트 설정
		setEvent${pageName}();

		// 화면 초기 설정
		initForm${pageName}();

		// Dataset 셋팅 - 단건일 경우 setData
		${pageName}Control.setData([${crdnInfo}]);
	});

// #sourceURL=crdn06030-info.jsp
</script>
