<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : WithdrawExceptionListForm.html
 * @desc    : 회수예외관리 Page
 *=============================================================
 * STYLE24
 * Copyright(C) 2021 TSIT, All rights reserved.
 *=============================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  ==================================
 * 1.0  2021.02.22   moon        최초 작성
 * 1.1  
 ********************************************************************************
 -->
 
	<div id="main">
		<!-- 메인타이틀 영역 -->
		<div class="main-title">
		</div>
		<!-- //메인타이틀 영역 -->
		<!-- 메뉴 설명 -->
		<div class="infoBox menu-desc">
		</div>
		<!-- //메뉴 설명 -->
		
		<!-- 검색조건 영역 -->
		<form id="searchForm" name="searchForm" action="#" th:action="@{'/withdraw/exception/list'}" onsubmit="fnSearchList(); return false;">
		<div class="panelStyle">
			<!-- TITLE -->
			<div class="panelTitle">
				<h3><i class="fa fa-info-circle"></i>아래 검색조건 중 <font color="red">등록일</font>은 꼭 입력해 주세요.</h3>
				<span class="panelControl">
					<i class="fa fa-chevron-up"></i>
				</span>
			</div>
			<!-- //TITLE -->
			<div class="panelContent">	
				
					<table class="frmStyle">
						<colgroup>
							<col style="width:8%;"/>
							<col style="width:12%;"/>
							<col style="width:8%;"/>
							<col style="width:12%;"/>
							<col style="width:8%;"/>
							<col style="width:12%;"/>
						</colgroup>
						<tr>
							<th class="dashR">주문자명</th>
							<td class="dashR">
								<input type="text" class="w40p" name="customerName" placeholder="" maxlength="20" />
							</td>
							<th class="dashR">주문번호</th>
							<td class="dashR">
								<input type="text" class="w40p" name="orderNo" placeholder="" maxlength="20" data-valid-type="numeric"/>
							</td>
							<th class="dashR">처리상태</th>
							<td class="dashR">
								<select name="recallStat" id="recallStat" class="w40p">
									<option value="">전체</option>
									<option value="P" selected>대기</option>
									<option value="S">처리완료</option>
								</select>
							</td>
						</tr>
						<tr>
							<th class="dashR">예외사유</th>
							<td class="dashR">
								<select name="reasonCode" id="reasonCode">
									<option value="">전체</option>
									<option th:if="${reasonCodeList}" th:each="oneData, status : ${reasonCodeList}" th:value="${oneData.cd}" th:text="${oneData.cdNm}"></option>
								</select>
							</td>
							<th class="dashR">회수요청구분</th>
							<td class="dashR">
								<select name="chgGb" id="chgGb" class="w40p">
									<option value="">전체</option>
									<option value="G680">회수예외</option>
									<option value="G680_00">출고예외</option>
									<option value="G680_30">반품요청</option>
									<option value="G680_40">교환요청</option>
								</select>
							</td>
							<th class="dashR">작업자</th>
							<td class="dashR">
								<input type="text" class="w40p" name="userNameCreated" placeholder="" maxlength="20" />
							</td>
						</tr>						
						<tr>
							<th class="dashR">등록일</th>
							<td colspan="6" class="dashR">
								<span id="terms"></span>
							</td>
						</tr>
					</table>
	
					<ul class="panelBar">
						<li class="center">
						<button type="button" class="btn btn-base btn-lg" id="btnSearch">조회</button>
						<button type="button" class="btn btn-gray btn-lg" onclick="$('#searchForm')[0].reset(); fnInitCalendar();">초기화</button>
						<button type="button" id="btnExcel" class="btn btn-info btn-lg" >엑셀다운로드</button>
						</li>
					</ul>

				</div>
		</div>
		<!-- //검색조건 영역 -->

		<!-- 리스트 영역 -->
		<div class="panelStyle">
			<ul class="panelBar">
				<li class="right">
					검색결과 : <strong><span id="gridRowTotalCount">0</span> 건</strong>&nbsp;
					쪽번호 <span id="pgNo">0</span>/ <strong id="endPgNo">0</strong>&nbsp;&nbsp;
					<select id="pageSize" name="pageSize">
						<option value="20" selected="selected">20개씩 보기</option>
						<option value="50">50개씩 보기</option>
						<option value="100">100개씩 보기</option>
						<option value="500">500개씩 보기</option>
						<option value="1000">1000개씩 보기</option>
					</select>
					<input type="hidden" name="pageNo" id="pageNo" value ="1"/>
				</li>
			</ul>
			<div id="gridList" style="width:100%; height: 500px;" class="ag-theme-balham"></div>
			<ul class="panelBar">
				<li class="center">
					<div class="tablePaging" id="withdrawExceptionListPagination"></div>
				</li>
			</ul>
		</div>
		</form>
		<!-- //리스트 영역 -->
	</div>
<script type="text/javascript" src="/ux/plugins/gaga/gaga.paging.js?v=20210114"></script>
<script th:inline="javascript">
/*<![CDATA[*/
	
	/*************************************************************************
	* AG-GRID 영역 
	**************************************************************************/
	var uploadGoodsUrl = [[${@environment.getProperty('upload.goods.view')}]]; 
	var roleCd = [[${sessionInfo.roleCd}]]; 

	$("#reasonCode option[value='07']").remove();
	$("#reasonCode option[value='08']").remove();
	$("#reasonCode option[value='10']").remove();
	
	var columnDefs = [
		{headerName: "반품예외처리번호",		field: "recallExceptionNo", width: 50,	cellClass: 'text-center', hide: true},
		//{headerName: "No.",				field: "rnum",				width: 50,	cellClass: 'text-center'},
		{headerName: "",			field: "recallStat",		width: 100,	cellClass: 'text-center',
			/*
			rowSpan: params => params.data.rowspanRank === 1 ? params.data.rowspanCnt : 1,  
		    cellClassRules: {
		        'cell-span': "data.rowspanRank == 1"
		      }, */
			cellRenderer: function(params) {
				var btnText = '';
				if(params.data.recallStat == 'P') {
					if(params.data.chgStat == 'G685_21' || params.data.chgStat == 'G685_51'){
						btnText= '추가결제대기';
					} else {
						btnText= '<a href="javascript:void(0);"  class="btn btn-success btn-ssm">완료</a>';
					}
				} else { btnText = '완료' }
				return btnText;
			}			
		},
		{headerName: "처리상태",			field: "recallStat",		width: 80,	cellClass: 'text-center',
			/*
			rowSpan: params => params.data.rowspanRank === 1 ? params.data.rowspanCnt : 1,  
			    cellClassRules: {
			        'cell-span': "data.rowspanRank == 1"
			      }, */
				cellRenderer: function(params) {
					var btnText = '';
					if(params.data.recallStat == 'P') {
						if(params.data.chgStat == 'G685_21' || params.data.chgStat == 'G685_51'){
							btnText= '추가결제대기';
						} else {
							btnText= '대기';
						}
					} else { btnText = '완료' }
					return btnText;
				}			
			},		
		{headerName: "주문번호",			field: "orderNo",			width: 100,	cellClass: 'text-center', 
			/*
			rowSpan: params => params.data.rowspanRank === 1 ? params.data.rowspanCnt : 1,  
		    cellClassRules: {
		        'cell-span': "data.rowspanRank == 1"
		      },
			*/
			cellRenderer: function (params) {
			if (roleCd.indexOf("C") < 0) {
				
				return "<a href=\"javascript:void(0);\" onclick=\"fnOrderDetailPopup('" + params.data.orderNo + "');\">" + params.data.orderNo + "</a>";
			} else {
				return params.value;
			}
			}
		},
		
		{headerName: "주문변경번호",			field: "ordChgSq",			width: 100,	cellClass: 'text-center', 
			
			/*
			rowSpan: params => params.data.rowspanRank === 1 ? params.data.rowspanCnt : 1,  
			    cellClassRules: {
			        'cell-span': "data.rowspanRank == 1"
			      },
			*/	
				cellRenderer	: function(params) {
					var rtnStr = "";
					
					var paramData 	= params.data.orderNo;
					paramData 		+= '@' + params.data.orderDtlNo;
					paramData 		+= '@' + params.data.delvFeeCd;
					paramData 		+= '@' + 'WMS';
					 
					// 반품접수, 반품대기, 회수요청, 상품검수중, 결제대기, 반품진행중
					if (params.data.chgStat == 'G685_50' || params.data.chgStat == 'G685_51' 
							|| params.data.chgStat == 'G685_30' || params.data.chgStat == 'G685_31' || params.data.chgStat == 'G685_32' || params.data.chgStat == 'G685_33') {
						rtnStr = '<a href="javascript:void(0);" onclick="fnReturnRequest(\'' + paramData + '\',\'' + params.value + '\');">' + params.value + '</a>';
					}
					// 교환접수, 교환대기, 회수요청, 상품검수중, 결제대기, 교환진행중
					else if (params.data.chgStat == 'G685_20' || params.data.chgStat == 'G685_21' 
							|| params.data.chgStat == 'G685_30' || params.data.chgStat == 'G685_31' || params.data.chgStat == 'G685_32' || params.data.chgStat == 'G685_34') {
						rtnStr = '<a href="javascript:void(0);" onclick="fnExchangeRequest(\'' + paramData + '\',\'' + params.value + '\');">' + params.value + '</a>';
					} 
					else {
						rtnStr = params.value;
					}
					return  rtnStr;
				}		
		},
			
		{headerName: "주문자명",			field: "customerName",		width: 100,	cellClass: 'text-center'},
		{headerName: "휴대번호",			field: "ordPhnno",			width: 100,	cellClass: 'text-center'},
		{headerName: "LMS", 			field: "ordPhnno",			width: 80, cellClass: "text-center",
			cellRenderer: function(params) {
				return '<button type="button" class="btn btn-base btn-sm" onclick="fnLms(\'' + params.data.ordPhnno + '\',\'' + params.data.custNo + '\');">&nbsp;LMS&nbsp;</button>';
			}			
		},
		{headerName: "회수요청구분",		field: "chgGbNm",			width: 90,	cellClass: 'text-left'},
		{headerName: "예외사유",			field: "reasonCd",			width: 150,	cellClass: 'text-center'},
		{headerName: "WMS메시지",		field: "adminMemo",			width: 300,	cellClass: 'text-left'},
		{headerName: "반품교환사유",		field: "chgReasonNm",		width: 150,	cellClass: 'text-left'},
		{headerName: "네이버 주문형",		field: "payGb",				width: 100,	cellClass: 'text-center'},
		{headerName: "반품/사유변경",	field: "chgReason",			width: 120,	cellClass: 'text-center',
			/*
			rowSpan: params => params.data.rowspanRank === 1 ? params.data.rowspanCnt : 1,  
			    cellClassRules: {
			        'cell-span': "data.rowspanRank == 1"
			      }, */
				cellRenderer: function(params) {
					var btnText = '';
					if(params.data.recallStat === 'P' && params.data.chgStat != null) {
						
						if(params.data.reasonCode == '00'){ // 타택배착불
							btnText = '';
						} else if(params.data.reasonCode == '01'){ // 반품미접수
							if(params.data.chgGb == 'G680_30'){
								btnText= '<a href="javascript:void(0);"  class="btn btn-success btn-ssm">반품신청</a>';
							} else {
								btnText= '<a href="javascript:void(0);"  class="btn btn-success btn-ssm">교환신청</a>';
							}
						}else if(params.data.reasonCode == '02'){ // 미착 
							if(params.data.chgGb == 'G680_30'){
								btnText= '<a href="javascript:void(0);"  class="btn btn-success btn-ssm">반품변경</a>';
							}else if(params.data.chgGb == 'G680_40'){
								btnText= '<a href="javascript:void(0);"  class="btn btn-success btn-ssm">교환변경</a>';
							}
						} else if(params.data.reasonCode == '03'){ // 과착 
							if(params.data.chgGb == 'G680_30'){
								btnText= '<a href="javascript:void(0);"  class="btn btn-success btn-ssm">반품신청</a>';
							} else {
								btnText= '<a href="javascript:void(0);"  class="btn btn-success btn-ssm">교환신청</a>';
							}
						} else if(params.data.reasonCode == '04' ){ // 배송비 미동봉 
							btnText= '<a href="javascript:void(0);"  class="btn btn-success btn-ssm">사유변경</a>';
						} else if(params.data.reasonCode == '06'){ // 배송비 일부동봉
							btnText= '';
						} else if(params.data.reasonCode == '05'){ // 다른상품 반품
							btnText= '';
						} else {
							btnText= '<a href="javascript:void(0);"  class="btn btn-success btn-ssm">사유변경</a>';
						}
					} else if(params.data.recallStat === 'P' && params.data.chgStat == null){
						btnText= '<a href="javascript:void(0);"  class="btn btn-success btn-ssm">반품신청</a>';
					} else { btnText = '' }
					return btnText;
				}		
		},
		{headerName: "요금구분",			field: "chargeType",		width: 80,	cellClass: 'text-center'},
		{headerName: "동봉비",			field: "chargeAmount",		width: 100,	cellClass: 'text-right'
			,valueFormatter: function(params) {
				if (params.value > 0) {
					return params.value.addComma();
				}else{
					return '0';
				}
			}
		},
		{headerName: "착불비",			field: "codFee",		width: 100,	cellClass: 'text-right'
			,valueFormatter: function(params) {
				if (params.value > 0) {
					return params.value.addComma();
				}else{
					return '0';
				}
			}
		},		
		{headerName: "*추가비용",			field: "csAddFee",		width: 100,	cellClass: 'text-right',editable: true,
			cellEditor: 'textCellEditor',
			cellEditorParams: { maxlength: 20, validType: "numeric" }
		},		
		{headerName: "*CS메모",			field: "csMemo",		width: 200,	cellClass: 'text-left',editable: true,
			cellEditor: 'textCellEditor',
			cellEditorParams: { maxlength: 1000, required: true }
		},			
		{headerName: "작업자",			field: "userNameCreated",	width: 100,	cellClass: 'text-center'},
		{headerName: "브랜드명",			field: "brandNm",			width: 150,	cellClass: 'text-center'},
		{headerName: "상품명",			field: "productName",		width: 200,	cellClass: 'text-left'},
		{headerName: "상품코드",			field: "productCode",		width: 100,	cellClass: 'text-center',
			cellRenderer: function (params) {
				if (roleCd.indexOf("C") < 0) {
					return "<a href=\"javascript:void(0);\" onclick=\"cfnOpenGoodsDetailPopup('U','" + params.data.goodsCd + "');\">" + params.value + "</a>";
				} else {
					return params.value;
				}
			}
		},
		{headerName: "SKU코드",			field: "skuCode",			width: 100,	cellClass: 'text-center'},
		{headerName: "속성",		    	field: "skuValue",			width: 80,	cellClass: 'text-center'},
		{headerName: "원코드",			field: "skuModelNo",		width: 150,	cellClass: 'text-left'},
		{headerName: "주문수량",			field: "qty",				width: 80,	cellClass: 'text-right'},
		{headerName: "입고수량",			field: "exceptionQty",		width: 80,	cellClass: 'text-right'},
		{headerName: "택배사명",			field: "logisticsName",		width: 100,	cellClass: 'text-center'},
		{headerName: "반송장번호",			field: "invoiceNo",			width: 120,	cellClass: 'text-center'},
		{headerName: "주문경로",			field: "siteCd",			width: 100,	cellClass: 'text-left'},
		{headerName: "등록일시",			field: "dateCreated",		width: 150,	cellClass: 'text-center'}
		
	];

	var gridOptions = gagaAgGrid.getGridOptions(columnDefs);
	gridOptions.suppressRowTransform =true;
	//gridOptions.defaultColDef.editable = true;
	//gridOptions.columnDefs[9].cellEditor=true;
	//gridOptions.columnDefs[10].cellEditor=true;
	
	//gridOptions.rowSelection = 'multiple';
	
	gridOptions.rowHeight = 35;
	
	var currOrdNo ="";
	var refreshFlag = "";
	/*************************************************************************
	*  조회 버튼 클릭 시
	**************************************************************************/
	$('#btnSearch').on('click', function() {
		fnSearchList();
	});
	
	/*************************************************************************
	*  조회 
	**************************************************************************/
	var fnSearchList = function() {
		if($('#stDate').val() == ''){
			mcxDialog.alert('시작 기간을 입력하세요.');
			return;
		}

		if($('#edDate').val() == ''){
			mcxDialog.alert('종료 기간을 입력하세요.');
			return;
		}

		// 날짜 유효성 체크
		if (Number($('#stDate').val().replaceAll("-", "")) > Number($('#edDate').val().replaceAll("-", ""))) {
			mcxDialog.alert("시작일은 종료일보다 클 수 없습니다.");
			return;
		}

		gagaPaging.init('searchForm', fnSearchCallBack, 'withdrawExceptionListPagination', $('#searchForm').find('#pageSize').val());
	    gagaPaging.load($("#searchForm input[name=pageNo]").val());
	}
	
	/*************************************************************************
	*  조회 콜백
	**************************************************************************/
	var fnSearchCallBack = function(result){

		$('#searchForm').find('#gridRowTotalCount').html(result.pageing.pageable.totalCount.addComma());
		$('#searchForm').find('#pageNo').val(result.pageing.pageable.pageNo.addComma());
		$('#searchForm').find('#pgNo').html(result.pageing.pageable.pageNo.addComma());
		$('#searchForm').find('#endPgNo').html(result.pageing.pageable.totalPage.addComma());
		gridOptions.api.setRowData(result.withdrawExceptionList);
		gagaPaging.createPagination(result.pageing.pageable);
		
	}
	
	
	var fnOrderDetailPopup = function(orderNo){
		currOrdNo = orderNo;
		refreshFlag = "ordDtl";
		cfnOpenOrderDetailPopup(currOrdNo);
	}
	
	/*************************************************************************
	*  팝업 콜백 
	**************************************************************************/		
	var fnReOpenOrderDetailPopup = function () {
		if(refreshFlag == "ordDtl"){
			cfnOpenOrderDetailPopup(currOrdNo);
		} else if(refreshFlag == "ban"){

		} else if(refreshFlag == "change"){
			
		}
		fnSearchList();
	};
	
	
	/*************************************************************************
	*  달력 초기화 
	**************************************************************************/		
	var fnInitCalendar = function() {
		gagajf.setDate('#terms', 'stDate', 'edDate', '7d');
	}
	
	/*************************************************************************
	*  회수예외 처리완료 버튼 - 대기->완료  업데이트
	**************************************************************************/	
	gridOptions.onCellClicked = function(event) {
		//if(params.data.chgStat == 'G685_21' || params.data.chgStat == 'G685_51'){
			
		
		if (event.colDef.field == 'recallStat'){
			if(event.data.chgStat == "G685_21" || event.data.chgStat == "G685_51"){
				return;
			}
			//if(event.data.recallStat == "P" && event.data.rowspanRank == "1"){
			if(event.data.recallStat == "P"){	
				var params = {};
				params.recallExceptionNo = event.data.recallExceptionNo;
				params.csAddFee = event.data.csAddFee;
				params.csMemo = event.data.csMemo;
				
				mcxDialog.confirm('처리완료 하시겠습니까?', {
					cancelBtnText: "취소",
					sureBtnText: "확인",
					sureBtnClick: function(){
						var jsonData = JSON.stringify(params);
						gagajf.ajaxJsonSubmit('/withdraw/exception/complete', jsonData, fnCompleteCallback);
					}
				});
			}
		} else if(event.colDef.field == 'chgReason'){
			//if(event.data.recallStat == "P" && event.data.rowspanRank == "1" && event.data.chgStat != null){
			if(event.data.recallStat == "P"  && event.data.chgStat != null){
				if (event.data.reasonCode == '00'){
					
				} else if(event.data.reasonCode == '01'){ // 반품미접수 
					// ?? 확인~~~
					/*
					if (event.data.chgGb == 'G680_30') { // 반품요청
						refreshFlag  = "ban";
						var ordChgSq = 0;
						var param    = "";
						var ordDtlNoList ="";
						
						var allData =  gagaAgGrid.getAllRowData(gridOptions);

						allData.forEach(function(item, index) {
							if (event.data.orderNo == item.orderNo ){
								ordDtlNoList = ordDtlNoList+","+item.orderDtlNo;
							}
						});
						ordDtlNoList = ordDtlNoList.substring(1,ordDtlNoList.length);
						
						param += "&ordNo=" 			+ event.data.orderNo;
						param += "&ordDtlNo=" 		+ event.data.orderDtlNo;
						param += "&delvFeeCd="		+ event.data.delvFeeCd;
						param += "&ordChgGb="		+ "G681_50"";
						param += "&delvFeeCdGrp="	+ "WMS";
						param += "&ordChgSq=" 		+ ordChgSq;
						param += "&ordDtlNoArr=" 	+ ordDtlNoList.split(",");

						var actionUrl = "/orderChange/rtn/req/form?" + param;
						cfnOpenModalPopup(actionUrl, 'popupReturnRequestForm');
					}
				*/

					
				} else if (event.data.reasonCode == '02' || event.data.reasonCode == '03') { // 미착 , 과착 
					param += "&ordNo=" 			+ event.data.orderNo;
					param += "&ordDtlNo=" 		+ event.data.orderDtlNo;
					param += "&ordChgSq=" 		+ event.data.ordChgSq;
					param += "&delvFeeCd="		+ event.data.delvFeeCd;
					param += "&delvFeeCdGrp="	+ "WMS";
					
					if (event.data.chgGb == 'G680_30') { // 반품요청
						param += "&ordChgGb=G681_30";    // 반품TO반품
						actionUrl = "/orderChange/rtn/req/form?" + param;

						cfnOpenModalPopup(actionUrl, 'popupReturnRequestForm');
					} else if (event.data.chgGb == 'G680_40') { // 교환요청
						param += "&ordChgGb=G681_20";           // 교환TO교환
						actionUrl = "/orderChange/exchange/request/form?" + param;
						
						cfnOpenModalPopup(actionUrl, 'popupExchangeRequestForm');
					}
				} else if(event.data.reasonCode == '04'){ // 배송비 미동봉
					actionUrl = "/withdraw/exception/change/form?ordChgSq=" + event.data.ordChgSq + '&chgGb=' + event.data.chgGb;
					cfnOpenModalPopup(actionUrl, 'popupWithdrawChangeForm');
				} else if(event.data.reasonCode == '05'){ // 다른상품 반품 
					param += "&ordNo=" 			+ event.data.orderNo;
					param += "&ordDtlNo=" 		+ event.data.orderDtlNo;
					param += "&ordChgSq=" 		+ event.data.ordChgSq;
					param += "&delvFeeCd="		+ event.data.delvFeeCd;
					param += "&delvFeeCdGrp="	+ "WMS";
					
					if (event.data.chgGb == 'G680_30') { // 반품요청
						param += "&ordChgGb=G681_30";    // 반품TO반품
						actionUrl = "/orderChange/rtn/req/form?" + param;

						cfnOpenModalPopup(actionUrl, 'popupReturnRequestForm');
					} else if (event.data.chgGb == 'G680_40') { // 교환요청
						param += "&ordChgGb=G681_20";           // 교환TO교환
						actionUrl = "/orderChange/exchange/request/form?" + param;
						
						cfnOpenModalPopup(actionUrl, 'popupExchangeRequestForm');
					}					
					
				} else if(event.data.reasonCode == '06'){ // 배송비 일부동봉
					
				} else {
					
				}
				
			//} else if(event.data.recallStat == "P" && event.data.rowspanRank == "1" && event.data.chgStat == null){
			} else if(event.data.recallStat == "P" && event.data.chgStat == null){
				refreshFlag  = "ban";
				var ordChgSq = 0;
				var param    = "";
				var ordDtlNoList ="";
				
				var allData =  gagaAgGrid.getAllRowData(gridOptions);

				allData.forEach(function(item, index) {
					if (event.data.orderNo == item.orderNo ){
						ordDtlNoList = ordDtlNoList+","+item.orderDtlNo;
					}
				});
				ordDtlNoList = ordDtlNoList.substring(1,ordDtlNoList.length);
				
				
				
				param += "&ordNo=" 			+ event.data.orderNo;
				param += "&ordDtlNo=" 		+ event.data.orderDtlNo;
				param += "&delvFeeCd="		+ event.data.delvFeeCd;
				param += "&ordChgGb="		+ "G681_50"";
				param += "&delvFeeCdGrp="	+ "WMS";
				param += "&ordChgSq=" 		+ ordChgSq;
				param += "&ordDtlNoArr=" 	+ ordDtlNoList.split(",");
				

				
				var actionUrl = "/orderChange/rtn/req/form?" + param;
				cfnOpenModalPopup(actionUrl, 'popupReturnRequestForm');
			}
		}
	}

	
	/*************************************************************************
	*  LMS
	**************************************************************************/	
	var fnLms = function(chgerPhnno, custNo){
		let param = {};
		param.elementCellPhnno = chgerPhnno; //'010-4016-1558'; //'#custInfoForm input[name=cellPhnno]';
		param.elementCustNo =    custNo; //'100025';// '#custInfoForm input[name=custNo]';
		param.pageGb = 'delv';
		cfnOpenLmsPopup(param);
	};
	
	/*************************************************************************
	*  반품요청
	**************************************************************************/		
	var fnReturnRequest = function (paramData, ordChgSq) {
		
		// 취소요청 구분 (orChgSq null 이면 취소요청화면 있으면 취소요청정보화면)
		if (ordChgSq == null) {
			ordChgSq = 0;
		}
		
		var param 		= "";
		var paramArr 	= paramData.split("@");
		param += "&ordNo=" 			+ paramArr[0];
		param += "&ordDtlNo=" 		+ paramArr[1];
		param += "&delvFeeCd="		+ paramArr[2];
		param += "&delvFeeCdGrp="	+ paramArr[3];
		
		param += "&ordChgSq=" 		+ ordChgSq;
		var actionUrl = "/orderChange/rtn/req/form?" + param;
		cfnOpenModalPopup(actionUrl, 'popupReturnRequestForm');
	};

	/*************************************************************************
	*  교환요청
	**************************************************************************/			
	var fnExchangeRequest = function (paramData, ordChgSq) {
		console.log(paramData);
		// 취소요청 구분 (orChgSq null 이면 취소요청화면 있으면 취소요청정보화면)
		if (ordChgSq == null) {
			ordChgSq = 0;
		}
		
		var paramArr 	= paramData.split("@");
		var param 		= "";
		param += "&ordNo=" 			+ paramArr[0];
		param += "&ordDtlNo=" 		+ paramArr[1];
		param += "&delvFeeCd="		+ paramArr[2];
		param += "&delvFeeCdGrp="	+ paramArr[3];
		param += "&ordChgSq=" 		+ ordChgSq;
		
		var actionUrl = "/orderChange/exchange/request/form?" + param;
		cfnOpenModalPopup(actionUrl, 'popupExchangeRequestForm');
	};	
	
	/*************************************************************************
	*  회수예외 처리완료 콜백
	**************************************************************************/		
	var fnCompleteCallback = function() {
		fnSearchList();
	};
	

	/*************************************************************************
	*  엑셀다운로드
	**************************************************************************/		
	$('#btnExcel').on('click', function() {
		var totalRows = gridOptions.api.getDisplayedRowCount();
		if(totalRows==0){
			mcxDialog.alert('조회된 내역이 없습니다.');
			return;
		}

		var date = new Date().format("YYYYMMDDHHmmss");
		var params = {
			fileName : "WMS회수예외목록_"+ date,
			sheetName: "DATA"
		}
		gridOptions.excelStyles = [
			{
				id: 'dateFormat',
				dataType: 'dateTime',
				numberFormat: {
					format: 'YYYY-MM-DD;@'
				}
			},
			{
				id: 'textFormat',
				dataType: 'string'
			}
		]
		gridOptions.api.exportDataAsExcel(params);
	});

	/*************************************************************************
	*  init
	**************************************************************************/		
	$(document).ready(function() {
		gagaAgGrid.createGrid('gridList', gridOptions);
		cfnCreateCalendar('#terms', 'stDate', 'edDate', true, '');
		fnInitCalendar();
	});

/*]]>*/
</script>
</html>
