<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
<c:set var="pageKorName" scope="request">민원답변대상자료</c:set>
<div class="content-wrapper" data-doctx="${pageName}">
	<div class="container-xxl flex-grow-1 px-0">
		<div class="card wrapper-list">

		    <div class="container-page-btn">
		        <button type="button" name="btnReset" class="btn btn-outline-dark w-px-120" title="초기화">
		        초기화
		        </button>
		        <span class="container-window-btn-right">
		            <button type="button" name="btnSearch" class="btn btn-search w-px-120" title="검색">
		            검색
		            </button>
		        	<button type="button" name="btnExcel" class="btn btn-excel w-px-120" title="엑셀 저장">
		        	엑셀
		        	</button>
		        	<button type="button" name="btnExcelForApproval" class="btn btn-excel w-px-120" title="엑셀 저장">
		            엑셀(사진 포함)
		            </button>
		        </span>
		    </div>

		    <form name="frmSearch">
		        <div class="container-search">
                    <div class="row g-1">
                        <div class="col-12">
                            <span class="form-label fw-bold form-search-title w-px-120 text-end">업무구분</span>
                            <span class="form-search-linebox">
								<c:forEach items="${TaskListForSgg}" var="item">
									<label>
										<input name="taskSeCd" type="radio" value="${item.code}"
										class="form-check-input" alt="업무구분"
										onchange="pageObject['${pageName}'].fnResetAndChangeBiz(this.value);">
										${item.value}
									</label>
								</c:forEach>
                            </span>
                        </div>
                        <div class="col-6">
							<span class="form-label fw-bold form-search-title w-px-120 text-end">접수일자</span>
                        	<span class="form-search-linebox">
                                <input type="text" name="schCvlcptRcptYmdFrom"
                                class="form-control form-date"
                                	data-fmt-type="day"   title="시작 날짜 선택" />
                                <button type="button" class="bx bx-lg bx-calendar bg-white"></button>
                                ~
                                <input type="text" name="schCvlcptRcptYmdTo"
                                class="form-control form-date"
                                	data-fmt-type="day" title="종료 날짜 선택">
                                <button type="button" class="bx bx-lg bx-calendar bg-white"></button>
                            </span>
                        </div>
                        <div class="col-6">
                        	<label is="name-label" for="cvlcptPrcsCd" class="form-label fw-bold form-search-title w-px-120 text-end">처리구분</label>
                            <select is="id-select" name="cvlcptPrcsCd" class="form-select w-px-160">
                            	<option value="">전체</option>
                            	<c:forEach items="${FIM017List}" var="item">
                            		<c:if test="${item.code == '02' or item.code == '03' or item.code == '04'}">
                            			<option value="${item.code}">${item.value}</option>
                            		</c:if>
                            	</c:forEach>
                            </select>
                        </div>
                        <div class="col-6">
							<span class="form-label fw-bold form-search-title w-px-120 text-end">처리기한</span>
                        	<span class="form-search-linebox">
                                <input type="text" name="schCvlcptPrcsPrnmntDtFrom"
                                class="form-control form-date"
                                	data-fmt-type="day"   title="시작 날짜 선택" />
                                <button type="button" class="bx bx-lg bx-calendar bg-white"></button>
                                ~
                                <input type="text" name="schCvlcptPrcsPrnmntDtTo"
                                class="form-control form-date"
                                	data-fmt-type="day" title="종료 날짜 선택">
                                <button type="button" class="bx bx-lg bx-calendar bg-white"></button>
                            </span>
                        </div>
                       	<div class="col-6">
                        	<input type="hidden" name="by" />
							<input type="text" class="form-control fw-bold w-px-120 text-end" name="byOutput" value="동적 검색" readonly />
							<input type="hidden" name="mainOption" />
							<input type="hidden" name="subOption" />
							<input type="text" class="form-control w-px-400" name="term" autocomplete="off" />
							<!-- 상세 검색조건 버튼 -->
							<span class="flr">
								<button type="button" class="btn btn-open-detail" data-bs-toggle="collapse"
								data-bs-target="[data-doctx='${pageName}'] [name='searchDetail']">
									<i class="bx bx-chevron-down"></i>
									상세검색
								</button>
							</span>
						</div>
                    </div>
		        </div>
		        <div name="searchDetail" class="container-search container-search-detail collapse">
		            <div class="row">
		            	<div class="col-6">
							<select class="form-select w-px-120 text-center" name="schRegDateOpt">
								<option value="regDt">등록일자</option>
								<option value="mdfcnDt">수정일자</option>
							</select>
							<span class="form-search-linebox">
								<input type="text" class="form-control form-date" name="schRegDateFrom"
                                	data-fmt-type="day" title="시작 날짜 선택" />
								<button type="button" class="bx bx-lg bx-calendar bg-white"></button>
                                ~
								<input type="text" class="form-control form-date" name="schRegDateTo"
                                	data-fmt-type="day" title="종료 날짜 선택">
								<button type="button" class="bx bx-lg bx-calendar bg-white"></button>
							</span>
                        </div>
		            </div>
		        </div>
		    </form>

			<div class="text-red">
				빨간색 글자로 표시된 자료는 복사등록 자료가 있습니다.
			</div>
		    <div>
		        <span class="container-page-btn">
		            <div class="d-flex flex-row justify-content-between">
						<span is="paging-info" name="crdnPagingInfo" class="dataTables_info"></span>
		                <ul name="crdnPaging" class="pagination pagination-primary"></ul>
					</div>
		            <span name="gridbuttonArea" class="container-window-btn-right">
		            	<button type="button" name="btnOpenCvlcptOrgnl"
		            	class="btn btn-primary" title="민원원본보기">민원원본보기</button>
		            	<button type="button" name="btnOpenAnswerPreview"
		            	class="btn btn-primary" title="답변미리보기">답변미리보기</button>
		            	<button type="button" name="btnExecuteAnswer"
		            	class="btn btn-primary" title="답변등록 실행">&#x2611; 답변등록 실행</button>
		            	<button type="button" name="btnAnswerComplete"
		            	class="btn btn-primary" title="답변완료로 수정">&#x2611; 답변완료로 수정</button>
		            	<span slot="button">
							<template class="dpv">
								<slot>
									<button type="button" name="btnExecuteDisabledTagInfoInquire"
		            				class="btn btn-primary" title="표지정보 조회">&#x2611; 표지정보 조회</button>
								</slot>
							</template>
						</span>
		            </span>
		        </span>
		    </div>

		    <div class="card-datatable text-nowrap">
		        <div class="dataTables_wrapper dt-bootstrap5 no-footer">
					<div name="table-responsive"
					class="table-responsive ox-scroll oy-scroll h-px-500">
						<table name="crdnTable" class="table-layout-fixed datatables-ajax table table-bordered dataTable no-footer">
							<thead name="crdnThead" class="sticky-thead">
								<tr data-search-target="[data-doctx='${pageName}']">
									<th style="width: 80px;">No.</th>
									<th style="width: 60px;">
										<input type="checkbox" name="gridAllCheckbox"
										onchange="pageObject['${pageName}'].checkCrdnList(this, this.checked);" />
									</th>
									<th onclick="FimsSupport.searchFromGridTitle('CVLCPT_RCPT_NO',this.innerText,'match','part');"
									style="width: 180px;">접수번호</th>
									<th onclick="FimsSupport.searchFromGridTitle('CVLCPT_LIST_NO',this.innerText,'match','part');"
									style="width: 160px;">목록번호</th>
									<th onclick="FimsSupport.searchFromGridTitle('CVLCPT_APLCNT_NM',this.innerText,'match','part');"
									style="width: 160px;">신고자</th>
									<th onclick="FimsSupport.searchFromGridTitle('CVLCPT_PRCS_PIC_NM',this.innerText,'match','part');"
									style="width: 160px;">담당자</th>
									<th onclick="FimsSupport.searchFromGridTitle('CVLCPT_PRCS_PIC_TELNO',this.innerText,'match','part');"
									style="width: 160px;">담당자전화번호</th>
									<th onclick="FimsSupport.searchFromGridTitle('CVLCPT_RCPT_YMD',this.innerText,'ymd','');"
									style="width: 160px;">접수일자</th>
									<th onclick="FimsSupport.searchFromGridTitle('CVLCPT_PRCS_PRNMNT_DT',this.innerText,'ymd','');"
									style="width: 180px;">처리기한</th>
									<th onclick="FimsSupport.searchFromGridTitle('CRDN_YMD','위반일자','ymd','');"
									style="width: 180px;">위반일시</th>
									<th onclick="FimsSupport.searchFromGridTitle('VLTN_ARTCL',this.innerText);"
									style="width: 160px;">위반내용</th>
									<th onclick="FimsSupport.searchFromGridTitle('VHRNO',this.innerText,'match','part');"
									style="width: 160px;">차량번호</th>
									<th onclick="FimsSupport.searchFromGridTitle('LEVY_EXCL_RSN_CD',this.innerText,'codeValue','FIM022');"
									style="width: 160px;">서손/계도사유</th>
									<th onclick="FimsSupport.searchFromGridTitle('ETC_CN',this.innerText,'match','part');"
									style="width: 160px;">특기사항</th>
									<th class="dummy-th"></th>
								</tr>
							</thead>
		                    <tbody name="crdnTbody"></tbody>
							<template is="curly-brackets" name="crdnRow">
								<tr data-index="DATA-INDEX">
									<td onclick ondblclick class="text-end">ROW_NUM</td>
									<td class="text-center">
										<input type="checkbox" name="gridCheckbox" name="gridCheckbox" value="DATA-INDEX"
										onchange="pageObject['${pageName}'].checkCrdnList(this, this.checked);" />
									</td>
		                    		<td onclick ondblclick class="text-center">CVLCPT_RCPT_NO</td>
		                    		<td onclick ondblclick class="text-center">CVLCPT_LIST_NO</td>
		                    		<td onclick ondblclick class="text-center">CVLCPT_APLCNT_NM</td>
		                    		<td onclick ondblclick class="text-center">CVLCPT_PRCS_PIC_NM</td>
		                    		<td onclick ondblclick class="text-center">CVLCPT_PRCS_PIC_TELNO</td>
		                    		<td onclick ondblclick class="text-center">CVLCPT_RCPT_YMD</td>
		                    		<td onclick ondblclick class="text-center">CVLCPT_PRCS_PRNMNT_DT</td>
		                    		<td onclick ondblclick class="text-center">CRDN_YMD_TM</td>
		                    		<td onclick ondblclick class="text-center">VLTN_ARTCL</td>
		                    		<td onclick ondblclick class="text-center">VHRNO</td>
		                    		<td onclick ondblclick class="text-center">LEVY_EXCL_RSN_NM</td>
		                    		<td onclick ondblclick class="text-center">ETC_CN</td>
		                    		<td class="dummy-td"></td>
		                    	</tr>
							</template>
							<template name="crdnNotFound">
								<tr>
									<td valign="top" colspan="15" class="dataTables_empty text-center">
									민원 정보를 찾지 못했습니다.
									</td>
								</tr>
							</template>
						</table>
					</div>
				</div>
		    </div>


		</div>
	</div>



  	<div class="content-backdrop fade"></div>
</div>


<script>
LoadScript("cvlc02010Script",wctx.url("/resources/js/fims/cvlc/cvlc02010.js?ver=${ver}"));

/**************************************************************************
 * Global Variable
 **************************************************************************/
var FIM022 = new CommonCodes(${FIM022});
var FIM026 = new CommonCodes(${FIM026});
pageObject["${pageName}"] = newDoctxFinder("${pageName}");


$(document).ready(function(){

	var $P = pageObject["${pageName}"];

	/**************************************************************************
	* DatasetControl, DatasetSupport, FormFields
	**************************************************************************/
	var ctrl = newCvlc02010Control($P);
	ctrl.defaultFetchSize = FETCH_XS;
	ctrl.query = { pageNum : 1, fetchSize : ctrl.defaultFetchSize };

	ctrl.dataset.onDatasetChange = (obj, option) => {

		var t = $P.getGridTemplate();
		var trs = Apply.fromDataset.getTbody(ctrl.dataset, t.found, t.notFound, t.replacer);
		$P.renderCrdnList(obj?.Paging?.totalSize, ctrl.dataset.length, trs, option);

		$P.pagingSupport.setPagingInfo(obj);
	};

	ctrl.dataset.onCurrentChange = (dataItem) => {
		Apply.fromDataset.currentRow(ctrl.dataset, dataItem, $P.findn("crdnTbody"));
	}

	ctrl.dataset.onSelectionChange = (selectedArr) => {
		Apply.fromDataset.gridCheckbox(ctrl.dataset, $P.findn("crdnTbody"), 1, selectedArr);
		Apply.fromDataset.gridButton(ctrl.dataset, $P.findn("btnExecuteAnswer"), selectedArr);
		Apply.fromDataset.gridButton(ctrl.dataset, $P.findn("btnAnswerComplete"), selectedArr);
		Apply.fromDataset.gridButton(ctrl.dataset, $P.findn("btnExecuteDisabledTagInfoInquire"), selectedArr);
	};

	$P.pagingSupport = new FimsPagingSupport({
		doq: $P,
        linkContainer: "[name='crdnPaging']"
	});

	/**************************************************************************
	* pageObject.function
	**************************************************************************/
	$P.fnReset = () => {
		var searchForm = $P.$findn("frmSearch");
		searchForm.find("input[type='radio']").not("[name='taskSeCd']").prop("checked", false);
		searchForm.find("input[type='checkbox']").prop("checked", false);
		searchForm.find("input[type='text']").val("");
		searchForm.find("input[type='hidden']").val("");
		searchForm.find("select").each(function(){ $(this).find("option:eq(0)").prop("selected", true); });

		$P.$findn("byOutput").val("동적 검색");
		$P.$findn("schCvlcptRcptYmdFrom").datepicker('setDate', DateSupport.getAddDay(-31));
		$P.$findn("schCvlcptRcptYmdTo").datepicker('setDate', TODAY());

		ctrl.dataset.setData([]);
	}

	$P.fnResetAndChangeBiz = taskSeCd => {
		var clsForTask = taskSeCd.toLowerCase();
		//업무별 버튼
		FimsSupport.renderForTask($P.findn("gridbuttonArea"), clsForTask);
		//버튼 이벤트 재매핑
		$P.$findn("btnExecuteDisabledTagInfoInquire").off("click");
		$P.$findn("btnExecuteDisabledTagInfoInquire").on("click", () => $P.fnExecuteDisabledTagInfoInquire());

		$P.fnReset();
		ctrl.urls.load = wctx.url("/cvlc/cvlc02/030/list.do");
		ctrl.urls.update = wctx.url("/cvlc/cvlc02/030/update.do");
		ctrl.urls.getInfo = wctx.url("/sprt/sprt02/010/main.do");
	}

	$P.getParams = () => {
		var formFields = new FimsFormFields($P.selectorn("frmSearch"));
		var data = formFields.get();
		data.fetchSize = ctrl.defaultFetchSize;

		return data;
	}

	$P.searchCrdnList = () => {
		ctrl.query = $P.getParams();
	    ctrl.load(1);
	}

	$P.scrollCrdnList = () => {
		ctrl.load(ctrl.query.pageNum + 1);
	}

	$P.refreshCrdnList = () => {

	    ctrl.reload({all : true});
    }

	$P.fnExcelDown = (forApproval) => {

    	if(ctrl.dataset.empty){
    		alert("조회된 자료가 없습니다.");
    		return;
    	}

		var cellDefs = AppSupport.getCellDefs(
			$P.$findn("crdnThead").find("th").not(".dummy-th").not(":eq(0)").not(":eq(0)"),
    		$($P.findn("crdnRow").content).find("td").not(".dummy-td").not(":eq(0)").not(":eq(0)")
    	);
		ctrl.query.cellDefs = cellDefs;

		if(forApproval){
			ctrl.query.includePhoto = "Y";
		} else {
			ctrl.query.includePhoto = "N";
		}

    	ctrl.download();

    	ctrl.query.includePhoto = null;
    };


	$P.getGridTemplate = () => {
		var notFound = [$P.findn("crdnNotFound").innerHTML];
		var found = $P.findn("crdnRow").innerHTML;
		var replacer = (str, dataItem) => str
			.replace(/{onclick}/gi, "pageObject['${pageName}'].clickCrdnList('{DATA-INDEX}');")
			.replace(/{ondblclick}/gi, "pageObject['${pageName}'].dblclickCrdnList('{CRDN_ID}');");

		return {
			found : found,
			notFound : notFound,
			replacer : replacer
		};
	}

	$P.renderCrdnList = (total, listLength, trs, option) => {

		let noMore = (listLength >= total);
		var initScroll = (ctrl.query.pageNum < 2);
		if(option != null && option.reloaded){
			initScroll = false;
		}

		$P.findn("table-responsive").changeContent(trs, initScroll, noMore);

		//보안모드
	    fn_securityModeToggle($("#securityMode--top").is(":checked"));


	    $P.$findn("crdnTbody").find("tr[data-index]").each(function(item){
	    	var dataIndex = this.dataset.index;

	    	var data = ctrl.dataset.getData(dataIndex);

	    	if(data.COPY_EXIST_YN == "Y"){
		    	$(this).addClass("text-red");
		    } else {
		    	$(this).removeClass("text-red");
		    }

	    });

	}

	$P.checkCrdnList = (element, bool) => {
		GRID.checkbox.sync(element, bool);

		var atLeastOne = GRID.checkbox.countChecked(element) > 0;
		$P.$findn("btnExecuteAnswer").prop("disabled", !atLeastOne);
		$P.$findn("btnAnswerComplete").prop("disabled", !atLeastOne);
		$P.$findn("btnExecuteDisabledTagInfoInquire").prop("disabled", !atLeastOne);

		Apply.toDataset.selection(ctrl.dataset, element, bool);
	}

	$P.clickCrdnList = (dataIndex) => {
		if(dataIndex == ""){
			return;
		}
		$P.$findn("crdnTbody").setCurrentRow(dataIndex);

		Apply.toDataset.current(ctrl.dataset, dataIndex);
	}

	$P.dblclickCrdnList = (dataKey) => {
		let params = {
			callPageName : "${pageName}",
			crdnId : dataKey
		}

		ajax.get({
			url : ctrl.urls.getInfo,
			data : params,
			success : (resp) => {
				let dialogName = "totalInfoMainDialog";
				let dialogId = dialogName+"-"+uuid();

				dialog.open({
					id : dialogId,
					title : "개별총정보", size : "xxl", content : resp,
					init : () => {
						$("#"+dialogId).attr("name", dialogName);
						$("#"+dialogId).attr("data-ref-doctx","${pageName}");
					}
				});

			}
		});

	}

	$P.fnOpenCvlcptOrgnl = () => {
		var cur = ctrl.dataset.getCurrent();
		if(cur == null){
			return;
		}

		var taskSeCd = $P.$findn("frmSearch").find("input[name='taskSeCd']:checked").val();

		ajax.get({
			url : wctx.url("/cvlc/cvlc01/050/info.do"),
			data : { crdnId : cur["CRDN_ID"] },
			success : (resp) => {

				let dialogName = "cvlcptOrgnlDialog";
				let dialogId = dialogName+"-"+uuid();

				dialog.open({
					id : dialogId,
					title : "민원내역 원본",
					content : resp,
					size : "xl",
					init : () => {
						$("#"+dialogId).attr("name", dialogName);
						$("#"+dialogId).attr("data-ref-doctx","${pageName}");

						var parentRes = new Object();
						var childReq = pageObject.childReq.pop();

						for(var reqKey in childReq) {
						    if($P.provide[reqKey]){
						    	parentRes[reqKey] = $P.provide[reqKey];
						    } else {
						    	parentRes[reqKey] = function(){};
						    }
						}

						pageObject.parentRes.push(parentRes);
					}
				});
			}
		});
	}

	$P.fnOpenAnswerPreview = () => {
		var cur = ctrl.dataset.getCurrent();
		if(cur == null){
			return;
		}

		var taskSeCd = $P.$findn("frmSearch").find("input[name='taskSeCd']:checked").val();


		ajax.get({
			url : wctx.url("/cvlc/cvlc02/060/info.do"),
			data : { crdnId : cur["CRDN_ID"] },
			success : (resp) => {
				let dialogName = "answerPreviewDialog";
				let dialogId = dialogName+"-"+uuid();

				dialog.open({
					id : dialogId,
					title : "답변내용 미리보기",
					content : resp,
					size : "xl",
					init : () => {
						$("#"+dialogId).attr("name", dialogName);
						$("#"+dialogId).attr("data-ref-doctx","${pageName}");

						var parentRes = new Object();
						var childReq = pageObject.childReq.pop();

						for(var reqKey in childReq) {
						    if($P.provide[reqKey]){
						    	parentRes[reqKey] = $P.provide[reqKey];
						    } else {
						    	parentRes[reqKey] = function(){};
						    }
						}

						pageObject.parentRes.push(parentRes);
					}
				});
			}
		});
	}

	$P.fnExecuteAnswer = () => {

		var count = ctrl.dataset.getDataset("selected").length;

		dialog.alert({
			content : "선택된 "+count+"건의 자료를 답변등록을 실행하시겠습니까?",
			init : function() {
				AppSupport.focusOK();
			},
			onOK : () => {
				$P.save('answerExecute');
			}
		});
	}

	$P.fnAnswerComplete = () => {

		var count = ctrl.dataset.getDataset("selected").length;

		dialog.alert({
			content : "선택된 "+count+"건의 자료를 답변완료 상태로 변경하시겠습니까?",
			init : function() {
				AppSupport.focusOK();
			},
			onOK : () => {
				$P.save('answerComplete');
			}
		});
	}

	//
	$P.save = (processType) => {

		ajax.post({
			url : ctrl.urls.update,
			data : {
				"processType" : processType,
				"crdnIds" : ctrl.dataset.getDataset("selected").map(item=>item.CRDN_ID).join(",")
			},
			success : (resp) => {
				if(resp.saved){
					dialog.alert({
						content : "처리되었습니다.",
						init : function() {
							AppSupport.focusClose();
						}
					});
					$P.refreshCrdnList();
				}
			}
		});
	}

	//표지정보 조회
	$P.fnExecuteDisabledTagInfoInquire = () => {

		var keys = [];

		var selected = ctrl.dataset.getDataset("selected");

		for(var i=0; i < selected.length; i++){
			if(selected[i].CVLCPT_PRCS_CD == "02"){
				keys.push(selected[i].CRDN_ID);
			}
		}

		if(keys.length == 0){
			dialog.alert({
				content : "표지조회는 부과대상자료만 가능합니다.<br/>선택된 자료 중에 부과대상자료가 없습니다.",
				init : function() {
					AppSupport.focusClose();
				}
			});
			return;
		}

		var message = "※표지정보 조회 후 장애인차량이 아닌 자료는 서손처리 됩니다."
			  +"<br/>※현재 날짜("+TODAY()+")를 기준으로 차량번호로 조회합니다."
			  +"<br/>표지조회를 실행하시겠습니까?"
			  +"<br/>부과대상 자료 : "+keys.length+"건";

		dialog.alert({
			content : message,
			init : function() {
				AppSupport.setDialogZindex();
				AppSupport.focusOK();
			},
			onOK : () => {
				ajax.get({
					url : wctx.url("/DPV/cvlc/cvlc02/040/update.do"),
					data : {
						"crdnIds" : keys.join(",")
					},
					success : (resp) => {
						dialog.alert({
							content : "표지정보조회가 실행되었습니다.",
							init : function() {
								AppSupport.setDialogZindex();
								AppSupport.focusClose();
							}
						});

						$P.refreshCrdnList();

					}
				});
			}
		});
	}

	$P.provide = {
		"getCountStatus" : function(currentCrdnId){
			var dsArray = ctrl.dataset.getDataset();
    		var arrayIndex = dsArray.findIndex(item => item.CRDN_ID == currentCrdnId);
    		return (arrayIndex+1) + " of " + dsArray.length;
    	},
		"getNextKey" : function(currentCrdnId){
    		var dsArray = ctrl.dataset.getDataset();
    		var arrayIndex = dsArray.findIndex(item => item.CRDN_ID == currentCrdnId);
    		if(dsArray.length > arrayIndex+1){
    			return dsArray[arrayIndex+1]["CRDN_ID"];
    		} else {
    			return "";
    		}
    	},
    	"getPrevKey" : function(currentCrdnId){
			var dsArray = ctrl.dataset.getDataset();
    		var arrayIndex = dsArray.findIndex(item => item.CRDN_ID == currentCrdnId);
    		if(arrayIndex != 0 && dsArray.length > 1){
    			return dsArray[arrayIndex-1]["CRDN_ID"];
    		} else {
    			return "";
    		}
    	},
    	"selectRow" : function(currentCrdnId){
    		let filtered = ctrl.dataset.getDataset("item").filter(item => item.data.CRDN_ID == currentCrdnId);
    		if(filtered.length > 0){
    			$P.clickCrdnList(filtered[0].index);
			}
    	},
    	"refreshList" : function(){
    		$P.refreshCrdnList();
    	}
	};

	/**************************************************************************
	* element.on
	**************************************************************************/
	$P.$findn("btnReset").on('click', () => $P.fnReset());
	$P.$findn("btnSearch").on('click', () => $P.searchCrdnList());
	$P.$findn("btnExcel").on('click', () => $P.fnExcelDown(false));
	$P.$findn("btnExcelForApproval").on('click', () => $P.fnExcelDown(true));

	// 동적검색에서 엔터(Enter) 키를 누르면 검색한다.
	$P.$findn("term").onEnterPress($P.searchCrdnList);


	$P.$findn("btnOpenCvlcptOrgnl").on("click", () => $P.fnOpenCvlcptOrgnl());
	$P.$findn("btnOpenAnswerPreview").on("click", () => $P.fnOpenAnswerPreview());
	$P.$findn("btnExecuteAnswer").on("click", () => $P.fnExecuteAnswer());
	$P.$findn("btnAnswerComplete").on("click", () => $P.fnAnswerComplete());

	Componentization.fnMakeResizableTable($P.findn("table-responsive"));
	Componentization.fnMakeScrollableTable($P.findn("table-responsive"), $P.scrollCrdnList);

	/**************************************************************************
	* 초기화
	**************************************************************************/
  	//달력 초기화
    AppSupport.initDatepicker($P.findn("frmSearch"));
    AppSupport.initDetailSearchButton($P.findn("frmSearch"));

    var defaultBizValue = $("#layout-navbar input[name='taskSeCd']:checked").val();
    $P.$findn("frmSearch").find("input[name='taskSeCd'][value='" + defaultBizValue + "']").prop("checked",true);
	$P.fnResetAndChangeBiz(defaultBizValue);

	//보안모드
    fn_securityModeToggle($("#securityMode--top").is(":checked"));

    $P.$findn("frmSearch").find("input[name='taskSeCd']").each(function(i) {
		$(this).prop("disabled", "true");
	});
});


</script>