<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : ExchangeApprovalListForm.html
 * @desc    : 교환접수 승인 목록 Page
 *=============================================================
 * ISTYLE24
 * Copyright(C) 2021 TSIT, All rights reserved.
 *=============================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  ==================================
 * 1.0  2021.08.18   card007     최초 작성
 *******************************************************************************
 -->
 	<div id="main">
		<!-- 메인타이틀 영역 -->
		<div class="main-title">
		</div>
		<!-- //메인타이틀 영역 -->
		<!-- 메뉴 설명 -->
		<div class="infoBox menu-desc">
		</div>
		<!-- //메뉴 설명 -->
		
		<!-- 검색조건 영역 -->
		<form id="searchForm" name="searchForm" action="#" th:action="@{'/orderChange/exchange/approval/list'}" onsubmit="$('#btnSearch').trigger('click'); 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>주문자명</th>
							<td>
								<input type="text" class="w40p" name="ordNm" placeholder="" maxlength="20"/>
							</td>
							<th>주문번호</th>
							<td>
								<input type="text" class="w40p" name="ordNo" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" placeholder="" maxlength="20"/>
							</td>
							<th>주문변경번호</th>
							<td>
								<input type="text" class="w40p" name="ordChgSq" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" placeholder="" maxlength="20"/>
							</td>
						</tr>
						<tr>
							<th>조회일자</th>
							<td colspan="5" id="terms">
							</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>
						</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="10" >10개씩 보기</option>
						<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;justify-content: center" class="ag-theme-balham lh60"></div>
			<ul class="panelBar">
				<li class="center">
					<div class="tablePaging" id="exchangeApprovalListPagination"></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[*/
// 사이트목록
var columnDefs = [
	{headerName: "주문번호"		, field: "ordNo"			, width: 100	, cellClass: "text-center"},
	{headerName: "주문상세번호"		, field: "ordDtlNo"			, width: 100	, cellClass: "text-center"},
	{headerName: "주문변경번호"		, field: "ordChgSq"			, width: 100	, cellClass: "text-center"},
	{headerName: "교환승인"		, field: "approval"			, width: 100	, cellClass: 'text-center',
		cellRenderer: function(params) {
			var btnText 	= '';
			var paramData 	= params.data.ordNo;
			paramData 		+= '@' + params.data.ordChgSq;
			paramData 		+= '@' + params.data.delvFeeCd;

			if (params.data.rowspanRank == 1) {
				btnText 	= '<a href="javascript:void(0);" class="btn btn-success btn-ssm" onclick="fnExchangeRequest(\'' + paramData + '\');">교환승인</a>';
			}

			return btnText;
		}
	},
	{headerName: "주문자"			, field: "maskingOrdNm"		, width: 140	, cellClass: "text-left"},
	{headerName: "휴대폰번호"		, field: "maskingOrderPhnno", width: 140	, cellClass: "text-left"},
	{
		headerName		: "주문일시"
		, field			: "ordDt"
		, width			: 140
		, cellClass		: 'text-center'
		, valueGetter	: function (params) {
			return gagaAgGrid.toDateTimeFormat(params.data.ordDt);
		}
	},
	{
		headerName		: "이미지"
		, field			: "sysImgNm"
		, width			: 100
		, height		: 60
		, cellClass		: 'text-center'
		,cellRenderer	: function(params) {
			return '<img width="60" src="'+ _goodsUrl+ "/" + params.value + '" alt=""  onerror="this.src=\'/image/no.gif\';"/>';
		}
	},
	{headerName: "상품코드"		, field: "goodsCd"			, width: 100	, cellClass: 'text-center'	, sortable: true},
	{headerName: "브랜드"			, field: "brandGroupNm"		, width: 150	, cellClass: 'text-center'	, sortable: true},
	{headerName: "구성유형"		, field: "goodsTypeNm"		, width: 80		, cellClass: 'text-center'	, sortable: true},
	{headerName: "상품명"			, field: "goodsNm"			, width: 300	, cellClass: 'text-left'	, sortable: true},
];

var gridOptions = gagaAgGrid.getGridOptions(columnDefs);
gridOptions.rowHeight = 60; //이미지가 있을경우 높이 지정해야함.

// 셀 클릭 이벤트
gridOptions.onCellClicked = function(event) {
	
};

// 조회 버튼 클릭 이벤트
$('#btnSearch').on('click', function() {
	$("#searchForm input[name=pageNo]").val('1');
	fnSearchList();
});

// 조회 처리
var fnSearchList = function() {
	//var searchChk = "N";
	//
	//if ($('#searchForm input[name=ordNo]').val() != '' || $('#searchForm input[name=ordChgSq]').val() != '') {
	//	searchChk = "Y";
	//}
	//
	//if(searchChk == "N"){
	//	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, 'exchangeApprovalListPagination', $('#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.dataList);
	gagaPaging.createPagination(result.pageing.pageable);
}

// 페이징
$('#searchForm select[name=pageSize]').on('change', function() {
	$("#searchForm input[name=pageNo]").val('1');
	fnSearchList();
});

$(document).ready(function() {
	gagaAgGrid.createGrid('gridList', gridOptions);
	//var hideList = ["btnThisWeek", "btnYesterWeek", "btnThisMonth", "btnYesterMonth", "btnRecent3Month"];
	cfnCreateCalendar('#terms', 'stDate', 'edDate', true, '','');
	gagajf.setDate('#terms', 'stDate', 'edDate', '7d');

});

// 교환승인 버튼 클릭 이벤트
var fnExchangeRequest = function (paramData) {
	var paramArr 	= paramData.split("@");
	var param 		= "";
	param 			+= "&ordNo=" 		+ paramArr[0];
	param 			+= "&ordChgSq=" 	+ paramArr[1];
	param 			+= "&delvFeeCd="	+ paramArr[2];
	param 			+= "&delvFeeCdGrp="	+ paramArr[2];
	
	var actionUrl = "/orderChange/exchange/request/form?" + param;
	cfnOpenModalPopup(actionUrl, 'popupExchangeRequestForm');
};

/*]]>*/
</script>

</html>