<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : OrderSellerClaimListForm.html
 * @desc    : 입점클레임목록 Page
 *============================================================================
 * SISUN
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2021.05.17   jsh77b       최초 작성
 *******************************************************************************
 -->
 
<div id="main">
	<!-- 메인타이틀 영역 -->
	<div class="main-title"></div>
	<!-- //메인타이틀 영역 -->
	
	<!-- 메뉴 설명 -->
	<div class="infoBox menu-desc"></div>
	<!-- //메뉴 설명 -->
	
	<form id="searchForm" name="searchForm" action="#" th:action="@{'/order/seller/claim/list'}">
		<input type="hidden" id="searchGb" name="searchGb" />
		
		<!-- 패널 영역1 -->
		<div class="panelStyle" >
			<!-- 검색조건 영역 -->
			<!-- TITLE -->
			<div class="panelTitle">
				<h3>
					<i class="fa fa-info-circle"></i>아래 검색조건 중 <font color="red">주문번호</font> 또는 <font color="red">검색조건</font> 하나를 꼭 입력해 주세요.
				</h3>
				<span class="panelControl">
					<i class="fa fa-chevron-up"></i>
				</span>
			</div>
			
			<div class="panelContent">
				<table class="frmStyle">
					<colgroup>
						<col style="width:10%;"/>
						<col style="width:15%;"/>
						<col style="width:10%;"/>
						<col style="width:15%;"/>
						<col style="width:10%;"/>
						<col style="width:15%;"/>
						<col style="width:10%;"/>
						<col style="width:15%;"/>
					</colgroup>
					<tr>
						<th>업체/브랜드<em class="required" title="필수"></em></th>
						<td colspan="7">
							<select name="supplyCompCd" id="supplyCompCd">
								<option th:if="${supplyCompList}" th:each="oneData, status : ${supplyCompList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
							<span id="multiBrand"></span>
						</td>
					</tr>
					<tr>
						<th>주문번호</th>
						<td>
							<input type="text" name="ordNo" placeholder="" maxlength="20"/>
						</td>
						<th>변경요청자명</th>
						<td>
							<input type="text" name="chgerNm" placeholder="" maxlength="20"/>
						</td>
						<th>상품코드</th>
						<td>
							<input type="text" name="goodsCd" placeholder="" maxlength="20"/>
						</td>
						<th>변경구분</th>
						<td>
							<select name="chgGb" id="chgGb">
								<option value="">전체</option>
								<option value="G680_20">취소</option>
								<option value="G680_30">반품</option>
								<option value="G680_40">교환</option>
							</select>
						</td>
					</tr>
					<tr>
						<th>조회일자</th>
						<td colspan="7">
							<select name="searchDateGb">
								<option value="ordDt">요청일자</option>
							</select>
							<span id="terms"></span>
						</td>
					</tr>
				</table>
				
				<ul class="panelBar">
					<li class="center">
						<button type="button" class="btn btn-info btn-lg" id="btnOrderSearch">조회</button>
						<button type="button" class="btn btn-gray btn-lg" id="btnInit">초기화</button>
					</li>
				</ul>
				
			</div>
		</div>
		
		<div class="panelStyle">
			<ul class="panelBar">
				<!-- 
				<li class="aR">
					<button type="button" id="btnSave" class="btn btn-success btn-lg">입고확인</button>
				</li>
				 -->
				<li class="aR">
					검색결과 : <strong><span id="rowCntOrderList">0</span> 건</strong>&nbsp;
					쪽번호 <span id="pgNo">0</span>/ <strong id="endPgNo">0</strong>&nbsp;&nbsp;
					<select id="pageSize" name="pageSize">
						<option value="100" selected="selected">100개씩 보기</option>
						<option value="500">500개씩 보기</option>
						<option value="1000">1000개씩 보기</option>
						<option value="5000">5000개씩 보기</option>
					</select>
					<input type="hidden" name="pageNo" id="pageNo" value ="1"/>
				</li>
			</ul>
			
			<div class="panelContent" style="overflow: hidden;">
				<div id="gridList" style="width: 100%; height: 700px;" class="ag-theme-balham lh30"></div>
			</div>
			
			<ul class="panelBar">
				<li class="center">
					<div class="tablePaging" id="orderListPagination"></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 sessRoleCd 			= [[${sessionInfo.roleCd}]];

var columnDefs = [
	{headerName: 'No', width: 60, cellClass: 'text-center', valueGetter: function(params) { return params.node.rowIndex + 1 }},
	{headerName: "입점업체",			field:"supplyCompNm",		width:120, cellClass: 'text-center'},
	{headerName: "입점업체코드",		field:"supplyCompCd",		width:120, cellClass: 'text-center', hide: true},
	{headerName: "브랜드",			field:"brandKnm",			width:100, cellClass: 'text-center'},
	{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:"chgGbNm", 			width:100, cellClass: 'text-center'},
	{headerName: "클레임상태",			field:"chgStatNm", 			width:100, cellClass: 'text-center'},
	{headerName: "요청일시",			field:"regDt", 				width:150, cellClass: 'text-center'},
	{headerName: "요청자명",			field:"chgerNm",			width:100, cellClass: 'text-center'},
	{headerName: "휴대전화",			field:"chgerPhnno",			width:120, cellClass: 'text-center'},
	{headerName: "회수지우편번호",		field:"chgerZipcode",		width:120, cellClass: 'text-center'},
	{headerName: "회수지기본주소",		field:"chgerBaseAddr",		width:150, cellClass: 'text-left'},
	{headerName: "회수지상세주소",		field:"chgerDtlAddr",		width:120, cellClass: 'text-left'},
	{headerName: "업체상품코드",		field:"supplyGoodsCd",		width:100, cellClass: 'text-center'},
	{headerName: "상품코드",			field:"goodsCd",			width:100, cellClass: 'text-center'},
	{headerName: "상품명",			field:"goodsNm",			width:100, cellClass: 'text-center'},
	{headerName: "옵션1",			field:"optCd1",				width:100, cellClass: 'text-center'},
	{headerName: "옵션2",			field:"optCd2",				width:100, cellClass: 'text-center'},
	{headerName: "요청수량",			field:"chgQty",				width:100, cellClass: 'text-center'},
	{headerName: "교환상세번호",		field:"exchangeOrdDtlNo",	width:100, cellClass: 'text-center'},
	{headerName: "교환옵션1",			field:"optCd11",			width:100, cellClass: 'text-center'},
	{headerName: "교환옵션2",			field:"optCd12",			width:100, cellClass: 'text-center'}
];

var gridOptions = gagaAgGrid.getGridOptions(columnDefs);

// 초기화 클릭시
$('#btnInit').on('click', function() {
	$('#searchForm')[0].reset();
	$("#multiBrand").empty();
});

// 입고확인
$('#btnSave').on('click', function () {
	
	var selectedData = gridOptions.api.getSelectedRows();
	if (selectedData.length == 0) {
		mcxDialog.alert('선택된 행이 없습니다.');
		return;
	}
	
	mcxDialog.confirm('입고확인 하시겠습니까?', {
		cancelBtnText	: "취소",
		sureBtnText		: "확인",
		sureBtnClick	: function(){
			var jsonData = JSON.stringify(selectedData);
			gagajf.ajaxJsonSubmit('/order/seller/claim/chgStat31/save', jsonData, fnSaveCallback);
		}
	});
});

// 입고확인후실행 
var fnSaveCallback = function(result){
	mcxDialog.alert(result.msg);
	fnSearch();
	return;
}

// 업체 브랜드 초기화
var fnSupplyBrandInit = function(){
	$("#searchForm select[name=supplyCompCd]").val([[${sessionInfo.supplyCompCd}]]);
	$('#searchForm').find('#multiBrand').empty();
	
	var actionUrl = '/renderer/brand/AuthBrandlist';
	
	cfnCreateMultiCombo(actionUrl, "multiBrand",  "[전체]", null, 'Y');
}

// 업체변경시
$('#searchForm select[name=supplyCompCd]').on('change', function() {
	var actionUrl = '/renderer/supplyCompany/brand/list/' + $(this).val();

	if (sessRoleCd == "G001_B000") {
		actionUrl = '/renderer/brand/AuthBrandlist';
	}
	
	cfnCreateMultiCombo(actionUrl,"multiBrand",  "[전체]",null, 'Y');
});

// 조회버튼
$('#btnOrderSearch').on('click', function() {
	// 페이징처리
	$("#searchForm input[name=pageNo]").val('1');
	fnSearch();
});

// 검색
var fnSearch = function() {	
	var formId 		= '#searchForm';
	
	gagaPaging.init('searchForm', fnSearchCallBack, 'orderListPagination', $('#searchForm').find('#pageSize').val());
	gagaPaging.load($("#searchForm input[name=pageNo]").val());
	
	//gagaAgGrid.fetch($(formId).prop('action'), gridOptions, formId);
}

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.orderSellerClaimList);
	gagaPaging.createPagination(result.pageing.pageable);
}

//초기설정
$(document).ready(function() {
	// 달력기능 활성화
	cfnCreateCalendar('#terms', 'stDate', 'edDate', true, '주문', 'X');
	
	gagaAgGrid.createGrid('gridList', gridOptions);
	gridOptions.api.hideOverlay();
	
	// 최근한주검색
	$('.btnRecentWeek').trigger('click');
	
	if(sessRoleCd == "G001_B000") {
		fnSupplyBrandInit();
	}
});

</script>

</html>





