<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorator="mob/common/layout/MypageLayoutMob">
<!--
 *******************************************************************************
 * @source  : MypageCancelFormMob.html
 * @desc    : 마이페이지 > 취소신청 Page
 *============================================================================
 * STYLE24
 * Copyright(C) 2021 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2021.04.28   jsh77b     최초 작성
 *******************************************************************************
 -->
<body>

<th:block layout:fragment="content">

<main class="container my">
	<section class="content my_return">
		<form id="cancelForm" class="form_wrap">
			<input type="hidden" name="accountNo" 	th:value="${oneData.accountNo}"/>
			<input type="hidden" name="accountNm" 	th:value="${oneData.accountNm}"/>
			<input type="hidden" name="bankCd" 		th:value="${oneData.bankCd}"/>
					
			<div class="inner wide bg_beige">
				<div class="order_number">
					<dl class="clear">
						<dt>주문번호</dt>
						<dd th:text="${oneData.ordNo}"></dd>
					</dl>
				</div>
			</div>
			<div class="inner">
				<div class="part_goods">
					<div class="goods_top">
						<div th:unless="${oneData.giftPackYn == 'Y'}" class="goods_date">주문일<span class="date" th:text="${oneData.ordDt}"></span></div>
						<div th:if="${oneData.giftPackYn == 'Y'}" class="goods_date">선물일<span class="date" th:text="${oneData.ordDt}"></span></div>
					</div>
					
					<!-- 취소상품목록 -->
					<th:block th:if="${cancelList.cancelList}" th:each="cancel, status : ${cancelList.cancelList}" th:with="imageUrl=${@environment.getProperty('upload.goods.view')}">
						<div class="goods_section">
							<div class="goods_detail">
								<a href="javascript:void(0)" th:attr="goodsCd=${cancel.goodsCd}, optCd1=${cancel.goodsType == 'G056_N' ? cancel.optCd1 : ''}, ithrCd='IN21_03'" onclick="fnGoToGoodsDetail(this)">
									<div class="thumb_box">
										<img th:src="${imageUrl + '/' + cancel.sysImgNm + '?RS=90'}" width="100%" alt="">
									</div>
									<div class="info_box">
										<div class="od_name">
											<div class="brand">
												<span th:text="${cancel.brandNm}"></span>
												<div class="badge_wrap">
													<em class="order_badge order_bullet_badge"	th:if="${cancel.shotDelvYn == 'Y'}">총알배송</em>
													<em class="order_badge"						th:if="${cancel.shotDelvYn == 'N' and cancel.selfGoodsYn == 'Y'}">STYLE24 일반배송</em>
													<em class="order_badge"						th:if="${cancel.selfGoodsYn == 'N'}">업체직배송</em>
												</div>
											</div>
											<div class="name" th:text="${cancel.goodsNm}"></div>
										</div>
										<div class="od_opt">
											<!-- 세트상품일때 -->
											<th:block th:if="${cancel.goodsType} == 'G056_S'">
												<th:block th:each="option , index2 : ${cancel.colorNmArr}">
													<div class="option">
														<em th:text="${cancel.itemNmArr[index2.index]}"></em>
														<em th:text="${option}"></em>
														<em th:text="${cancel.optCd2Arr[index2.index]}"></em>
													</div>
												</th:block>
											</th:block>
											<!-- //세트상품일때 -->
											<!-- 단품상품일때 -->
											<th:block th:unless="${cancel.goodsType} == 'G056_S'">
												<div class="option">
													<em th:text="${cancel.colorNm}"></em>
													<em th:text="${cancel.optCd2}"></em>
												</div>
											</th:block>
											<!-- //단품상품일때 -->
										</div>
										<div class="od_calc">
											<th:block th:if="${(cancel.ordAmt - cancel.cnclRtnAmt) > (cancel.realOrdAmt + cancel.pntDcAmt + cancel.gfcdUseAmt)}">
												<p class="sale_price">
													<del><em th:text="${#numbers.formatInteger(cancel.ordAmt - cancel.cnclRtnAmt, 1, 'COMMA')}"></em>원</del>
												</p>
											</th:block>
											<p class="price">
												<span class="selling_price">
													<em th:text="${#numbers.formatInteger(cancel.realOrdAmt + cancel.pntDcAmt + cancel.gfcdUseAmt, 1, 'COMMA')}"></em>원
												</span>
											</p>
										</div>
									</div>
								</a>
							</div>
							<div class="goods_select">
								<div class="select_custom select_count">
									<div class="combo">
										<input type="hidden" name="chgQty" value="0" th:attr="ordDtlNo=${cancel.ordDtlNo}, ordCanChgQty=${cancel.ordCanChgQty}"/>
										<div class="select">수량 0개</div>
									</div>
								</div>
							</div>
							<th:block th:if="${#lists.size(cancelList.cancelList) == status.count}">
								<div class="goods_txt">
									<p class="cf_txt cf_desc">취소하실 상품의 수량을 선택하신 후<br>주문 취소를 하실 수 있습니다.</p>
								</div>
							</th:block>
						</div>
					</th:block>
					<!-- //취소상품목록 -->
					
				</div>
			</div>
			<div class="inner">
				<div class="tbl_wrap pay_wrap">
					<div class="tbl_tit"> 
						<h3>환불 정보</h3>
						<strong class="pay"><span id="returnAmt">0</span>원</strong>
					</div>
					<div class="tbl type1">
						<table>
							<colgroup>
								<col width="227">
								<col width="*">
							</colgroup>   
							<tr>
								<td>
									<dl class="refund_deduct">
										<div>
											<dt>상품 취소 금액</dt>
											<dd>
												<div>
													<span id="goodsCancelAmt">0</span>원
												</div>
											</dd>
										</div>
										<div>
											<dt>배송비</dt>
											<dd>
												<div>
													<span id="deliveryFee">0</span>원
												</div>
											</dd>
										</div>
										<div>
											<dt>할인 금액 차감</dt>
											<dd>
												<div>
													<span id="deductDcAmt">0</span>원
												</div>
											</dd>
										</div>
									</dl>
									<dl class="refund_detail">
										<div>
											<dt>환불 수단</dt>
											<dd>
												<div>
													<span th:if="${paymentInfo.pgGb == 'KCP'}" th:text="${paymentInfo.payMeansNm}"></span>
													<span th:if="${paymentInfo.pgGb == 'NAVER'}" th:text="|네이버페이|"></span>
													<span th:if="${paymentInfo.pgGb == 'KAKAO'}" th:text="|카카오페이|"></span>
													<span th:if="${paymentInfo.pgGb == 'PAYCO'}" th:text="|PAYCO|"></span>
												</div>
											</dd>
										</div>
										<div>
											<dt>결제금액 환불</dt>
											<dd>
												<div>
													<span id="refundPayAmt">0</span>원
												</div>
											</dd>
										</div>
										<div>
											<dt>포인트 환불</dt>
											<dd>
												<div>
													<span id="refundPoint">0</span>P
												</div>
											</dd>
										</div>
										<div>
											<dt>상품권 환불</dt>
											<dd>
												<div>
													<span id="refundGiftCard">0</span>원
												</div>
											</dd>
										</div>
									</dl>
								</td>
							</tr>
						</table>
					</div>
				</div>
				<div class="desc_txt">카드사로 결제 취소 요청이 전달된 후 환불까지는 평일 기준 3 ~7일이 소요될 수 있습니다.</div>
				<div class="required_group" id="addDeliveryFee" style="display:none">
					<p>배송비 <span class="c_primary" id="addPayCost">0원</span> 추가 결제가 필요합니다.</p>
				</div>
				<div class="btn_group btn_group_flex">
					<div><button type="button" class="btn btn_default" onclick="cfnGoToPage(_PAGE_MYPAGE_ORDER_LIST);"><span>취소</span></button></div>
					<div><button type="button" class="btn btn_dark" onclick="fnCancel();"><span>주문 취소</span></button></div>
				</div>
			</div>
		</form>
	</section>
</main>

<!-- 210408_취소 수량 선택 팝업 -->
<th:block th:if="${cancelList.cancelList}" th:each="cancel, status : ${cancelList.cancelList}">
	<div class="popup_box cancelCountPop">
		<div class="lap">
			<div class="popup_close">카테고리닫기</div>
			<div class="popup_head sr-only">
				<h2 class="">주문상태 선택 팝업</h2>
			</div>
			<div class="popup_con">
				<div class="button_list clear">
					<button type="button" class="on" qty=0 onclick="fnChangeCancelQty(this);"><span>수량 0개</span></button>
					<th:block th:each="num : ${#numbers.sequence(1, cancel.ordCanChgQty)}">
						<button type="button" th:qty="${num}" onclick="fnChangeCancelQty(this);"><span th:text="|수량 ${num}개|"></span></button>
					</th:block>
					<input type="hidden" name="ordDtlNo" th:value="${cancel.ordDtlNo}">
				</div> 
			</div>
		</div>
	</div>
</th:block>
<!-- //210408_취소 수량 선택 팝업 -->

<!-- 210408_ 추가 : 환불 계좌 등록 팝업 -->
<div id="refundAccountPop" class="popup_box refundAccountPop">
	<input type="hidden" name="confirmedAccountNo"/>
	<input type="hidden" name="confirmedAccountNm"/>
	<input type="hidden" name="confirmedBankCd"/>
	<div class="lap">
		<div class="popup_close">카테고리닫기</div>
		<div class="popup_head sr-only">
			<h2 class="">환불 계좌 등록 팝업</h2>
		</div>
		<div class="popup_con">
			<div class="tbl_wrap">
				<div class="tbl_tit"> 
					<h3>환불 계좌 등록</h3>
				</div>
				<div class="tbl type1">
					<table>
						<colgroup>
							<col width="*">
						</colgroup>   
						<tbody>
							<tr>
								<th>예금주</th>
								<td>
									<div class="form_field">
										<input type="text" name="accountNm" class="form_control" th:value="${customerInfo.custNm}" placeholder="이름를 입력해 주세요" readonly="readonly">
									</div>
								</td>
							</tr>
							<tr>
								<th>은행명</th>
								<td>
									<div class="form_field">
										<div class="select_custom select_bank">
											<div class="combo">
												<div class="select">선택</div>
												<input type="hidden" name="bankCd" value=""/>
											</div>
										</div>
									</div>
								</td>
							</tr>
							<tr>
								<th>계좌번호</th>
								<td>
									<div class="input_wrap certi_wrap">
										<input type="tel" name="accountNo" class="form_control" value="" placeholder="">
										<button type="button" id="btn_bank_certi" class="btn btn_dark"><span>계좌인증</span></button>
									</div>
								</td>
							</tr>
						</tbody>
					</table>
				</div>
			</div>
			
		</div>
		<div class="pop_foot">
			<div class="btn_group_flex">
				<div class="">
					<button type="submit" id="btn_bank_return" class="btn btn_dark btn_block"><span>계좌 등록 후 환불 신청</span></button>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- //210408_ 추가 : 환불 계좌 등록 토스트 팝업 -->

<!-- 210408_ 추가 : 은행 선택 팝업 -->
<div id="refundBankPop" class="popup_box refundBankPop">
	<div class="lap">
		<div class="popup_close">카테고리닫기</div>
		<div class="popup_head sr-only">
			<h2 class="">은행 선택 팝업</h2>
		</div>
		<div class="popup_con">
			<div class="button_list clear">
				<th:block th:if="${bankList}" th:each="oneData, status : ${bankList}">
					<button type="button" th:id="|bankCd_${oneData.cd}|" th:attr="bankCd=${oneData.cd}, bankNm=${oneData.cdNm}"><span th:text="${oneData.cdNm}"></span></button>
				</th:block>
			</div>
		</div>
	</div>
</div>
<!-- //210408_ 추가 : 은행 선택 팝업 -->

<script src="/ux/plugins/gaga/gaga.paging.js"></script>
<script th:inline="javascript">
let cancelList 		= [[${cancelList}]];
let oneData 		= [[${oneData}]];
let paymentInfo 	= [[${paymentInfo}]];
var isLogin = [[${isLogin}]];
let addPayCost 		= 0;

$(document).ready(function() {
	// 타이틀명
	$('#htopTitle').text('주문취소');
});

// 취소수량버튼기능
$("#cancelForm .select_custom.select_count").each(function(idx){
	$(this).on("click", function(){
		// 전체비활성화
		$(".cancelCountPop").hide();
		
		// 수량팝업활성화
		$(".cancelCountPop").eq(idx).show().addClass("active");
		$("body").css({"overflow":"hidden"});
	});
});

// 취소 처리
var fnCancel = function() {
	// 주문상세번호 및 취소 수량 설정
	let ordDtlNoArr 			= [];
	let cnclRtnReqQtyArr 		= [];
	let chkQty 					= 0;
	
	$.each($('#cancelForm input[name=chgQty]'), function(idx, item) {
		let chgQty 		= $(item).val();
		let ordDtlNo 	= $(item).attr('ordDtlNo');
		
		ordDtlNoArr.push(Number(ordDtlNo));
		cnclRtnReqQtyArr.push(Number(chgQty));
		chkQty += chgQty;
	});

	// 취소 수량 체크
	if (chkQty == 0) {
		mcxDialog.alert('취소하실 상품의 수량을 선택해주세요.');
		return false;
	}

	// 환불계좌 체크
	let accountNo 	= $('#cancelForm input[name=accountNo]').val();
	let accountNm 	= $('#cancelForm input[name=accountNm]').val();
	let bankCd 		= $('#cancelForm input[name=bankCd]').val();

	// 무통장입금, 결제완료 일때 환불계좌정보 체크
	let chk = false;
	if (paymentInfo.payMeans == 'G014_20' && paymentInfo.payStat == 'G016_30') {
		if (gagajf.isNull(accountNo) || gagajf.isNull(accountNm) || gagajf.isNull(bankCd)) {
			let data = {};
			data.ordNo = oneData.ordNo;
			data.accountNm = oneData.accountNm;
			
			$('#refundAccountPop').show().addClass("active");
			$("body").css({"overflow": "hidden"});
			
			return false;
		} else {
			chk = true;
		}
	} else {
		accountNo = null;
		accountNm = null;
		bankCd = null;
	}

	// 취소요청 데이터 설정
	let url = '/mypage/cancel';

	// 취소 처리
	let data 				= {};
	data.ordNo 				= oneData.ordNo;
	data.chgReason 			= 'G686_10';
	data.chgReasonNm 		= '고객변심';
	data.accountNo 			= accountNo;
	data.accountNm 			= accountNm;
	data.bankCd 			= bankCd;
	data.isCustomer 		= true;
	data.reqGbn 			= 'cnclComplete';
	data.pgTid 				= paymentInfo.pgTid;
	data.payAmt 			= paymentInfo.payAmt;
	data.ordDtlNoArr 		= ordDtlNoArr;
	data.cnclRtnReqQtyArr 	= cnclRtnReqQtyArr;

	let jsonData = JSON.stringify(data);
	
	// 무통장입금 취소의 경우 계좌인증처리 후 취소 진행
	if (chk) {
		// 무통장입금 계좌인증
		gagajf.ajaxJsonSubmit('/order/account/check', jsonData, function (result) {
			if (result.isValid) { // 유효하면 true
				// 취소 처리 가능 여부 조회
				gagajf.ajaxJsonSubmit('/mypage/wms/cancel/available', jsonData, function (result) {
					if (result.cancelYn == 'Y') {
						// 취소 처리
						gagajf.ajaxJsonSubmit(url, jsonData, function (result) {
							cfnGoToPage(_PAGE_MYPAGE_CRE_LIST);
						}, true);
					} else {
						mcxDialog.alert('이미 배송처리 되어 취소 처리에 실패 하였습니다.');
					}
				});
			} else {
				mcxDialog.alert('환불계좌가 유효하지 않습니다.');
				return false;
			}
		});
	} else {
		// 취소 처리 가능 여부 조회
		gagajf.ajaxJsonSubmit('/mypage/wms/cancel/available', jsonData, function (result) {
			if (result.cancelYn == 'Y') {
				// 취소 처리
				gagajf.ajaxJsonSubmit(url, jsonData, function (result) {
					cfnGoToPage(_PAGE_MYPAGE_CRE_LIST);
				}, true);
			} else {
				mcxDialog.alert('이미 배송처리 되어 취소 처리에 실패 하였습니다.');
			}
		});
	}
}

// 취소 수량 변경 이벤트 처리
var fnChangeCancelQty = function(param) {
	let url = '/mypage/cancel/refund/amt/calculate';
	
	// 취소수량설정
	if (param != null) {
		$("#cancelForm input[name=chgQty]").each(function(idx){
			var ordDtlNo = $(this).attr("ordDtlNo");
			if (ordDtlNo == $(param).parent().find("input[name=ordDtlNo]").val()) {
				$(this).val($(param).attr("qty"));
				$(this).parent().find(".select").text($(param).find("span").text());
			}
		});
	}

	// 취소 수량 설정
	let cnclRtnReqQtyArr 	= [];
	let ordDtlNoArr 		= [];
	let ordCanChgQtyArr 	= [];
	
	$.each($('#cancelForm input[name=chgQty]'), function(idx, item) {
		let chgQty 			= $(item).val();
		let ordDtlNo		= $(item).attr('ordDtlNo');
		let ordCanChgQty 	= $(item).attr('ordCanChgQty');
		
		cnclRtnReqQtyArr.push(Number(chgQty));
		ordDtlNoArr.push(Number(ordDtlNo));
		ordCanChgQtyArr.push(Number(ordCanChgQty));
	});

	let data = {};
	data.ordNo 				= oneData.ordNo;
	data.ordDtlNoArr 		= ordDtlNoArr;
	data.cnclRtnReqQtyArr 	= cnclRtnReqQtyArr;

	let jsonData = JSON.stringify(data);

	gagajf.ajaxJsonSubmit(url, jsonData, function (result) {
		let refundPoint 		= Number(result.spanPntDcAmt);							// 환불 포인트 금액
		let spanGfcdUseAmt 		= Number(result.spanGfcdUseAmt);						// 환불 상품권 금액
		let spanDelvGfcdUseAmt 	= Number(result.spanDelvGfcdUseAmt);					// 환불 배송비 상품권 금액
		let spanCnclRtnAmt 		= Number(result.spanCnclRtnAmt);						// 환불 상품 금액
		let spanCpnDcAmt 		= Number(result.spanCpnDcAmt);							// 쿠폰 할인 차감 금액 (즉시할인쿠폰 + 상품쿠폰 + 장바구니쿠폰 + 배송비쿠폰)
		let spanCpn1DcAmt 		= Number(result.spanCpn1DcAmt);							// 즉시할인 쿠폰 차감 금액
		let spanTmtbDcAmt 		= Number(result.spanTmtbDcAmt);							// 다다익선 할인 차감 금액
		let spanPrePntDcAmt 	= Number(result.spanPrePntDcAmt);						// 선포인트 할인 차감 금액
		let sumDeliveryFee 		= Number(result.sumDeliveryFee);						// 원주문배송비
		let spanTotDeliveryFee 	= Number(result.spanTotDeliveryFee);					// 추가배송비 (무료배송비 허들 깨져서 발생한 배송비)
		let spanRealCnclRtnAmt 	= Number(result.spanRealCnclRtnAmt);					// 환불 상품 실결제 금액 (환불상품금액 - 할인차감금액)
		let goodsCancelAmt 		= spanCnclRtnAmt + spanCpn1DcAmt;						// 상품취소금액
		let deductDcAmt 		= 0 - spanCpnDcAmt - spanTmtbDcAmt - spanPrePntDcAmt;	// 할인금액 차감 (쿠폰+다다익선+선포인트)
		let refundGiftCard		= spanGfcdUseAmt + spanDelvGfcdUseAmt;					// 환불 상품권 금액 합계
		let spanRefundAmt 		= spanRealCnclRtnAmt + sumDeliveryFee;					// 환불예정금액 (환불상품실결제금액 + 원주문배송비)
		let deliveryFee 		= sumDeliveryFee - spanTotDeliveryFee;					// 배송비 (마지막 취소 시 돌려줘야할 원주문 배송비 - 추가배송비)

		// 2021.08.10 card007 상품권100% 결제 로직 수정
		let refundAmt = spanRefundAmt + spanGfcdUseAmt;
		let leftAddDelvFee = spanTotDeliveryFee;

		if (refundAmt < spanTotDeliveryFee) {
			addPayCost = spanTotDeliveryFee;
		} else {
			if (leftAddDelvFee > spanRefundAmt) {
				leftAddDelvFee -= spanRefundAmt;
				spanRefundAmt = 0;
			} else {
				spanRefundAmt -= leftAddDelvFee;
				leftAddDelvFee = 0;
			}

			if (leftAddDelvFee > 0) {
				refundGiftCard -= leftAddDelvFee;
				leftAddDelvFee = 0;
			}

			addPayCost = 0;
		}

		let refundPayAmt		= spanRefundAmt - spanDelvGfcdUseAmt - leftAddDelvFee;	// 결제금액 환불 (환불예정금액 - 환불 배송비 상품권 금액)
		let returnAmt 			= refundPayAmt + refundPoint + refundGiftCard;			// 환불예정금액

		// 금액 설정
		$('#returnAmt').text(returnAmt.addComma());
		$('#goodsCancelAmt').text(goodsCancelAmt.addComma());
		$('#deliveryFee').text(deliveryFee.addComma());
		$('#deductDcAmt').text(deductDcAmt.addComma());
		$('#refundPayAmt').text(refundPayAmt.addComma());
		$('#refundPoint').text(refundPoint.addComma());
		$('#refundGiftCard').text(refundGiftCard.addComma());
	});

	// 팝업 닫기
	$(".popup_close").trigger("click");
}

let isValid = false;

// 계좌인증
$('#btn_bank_certi').on('click', function () {
	
	if (gagajf.isNull($('#refundAccountPop input[name=bankCd]').val())) {
		mcxDialog.alert('은행을 선택해주세요.');
		return false;
	}
	
	if (gagajf.isNull($('#refundAccountPop input[name=accountNo]').val())) {
		mcxDialog.alert('계좌번호를 입력해주세요.');
		return false;
	}
	
	// 승인된 계좌 정보
	let confirmedAccountNm 	= $('#refundAccountPop input[name=confirmedAccountNm]').val();
	let confirmedAccountNo 	= $('#refundAccountPop input[name=confirmedAccountNo]').val();
	let confirmedBankCd 	= $('#refundAccountPop input[name=confirmedBankCd]').val();
	
	// 계좌정보
	let accountNm 			= $('#refundAccountPop input[name=accountNm]').val();
	let accountNo 			= $('#refundAccountPop input[name=accountNo]').val();
	let bankCd 				= $('#refundAccountPop input[name=bankCd]').val();
	
	if (accountNm != confirmedAccountNm || accountNo != confirmedAccountNo || bankCd != confirmedBankCd) {
		isValid = false;
	}
	
	if (!isValid) {
		let url 		= '/mypage/account/check';
		
		let data = {};
		data.accountNm 	= accountNm;
		data.accountNo 	= accountNo;
		data.bankCd 	= bankCd;
		data.ordNo 		= oneData.ordNo;
		
		let jsonData = JSON.stringify(data);
		
		gagajf.ajaxJsonSubmit(url, jsonData, function (result) {
			isValid = result.isValid;
			
			if (isValid) {
				mcxDialog.alert('계좌인증에 성공했습니다.');
				// 계좌인증 성공 시 Disabled 처리
				//$('#refundAccountPop .select_custom.select_bank').attr('disabled', true);
				//$('#refundAccountPop input[name=accountNo]').attr('disabled', true);
				
				$('#refundAccountPop input[name=confirmedAccountNm]').val(accountNm);
				$('#refundAccountPop input[name=confirmedAccountNo]').val(accountNo);
				$('#refundAccountPop input[name=confirmedBankCd]').val(bankCd);
				
				return false;
			} else {
				mcxDialog.alert('계좌정보를 다시 확인해주세요.');
				return false;
			}
		});
	}
});

//계좌등록 후 환불신청 버튼 클릭 이벤트
$('#btn_bank_return').click(function() {
	if (isValid) {
		// 승인된 계좌 정보
		let confirmedAccountNm 	= $('#refundAccountPop input[name=confirmedAccountNm]').val();
		let confirmedAccountNo 	= $('#refundAccountPop input[name=confirmedAccountNo]').val();
		let confirmedBankCd 	= $('#refundAccountPop input[name=confirmedBankCd]').val();
		
		// 계좌정보
		let accountNm 	= $('#refundAccountPop input[name=accountNm]').val();
		let accountNo 	= $('#refundAccountPop input[name=accountNo]').val();
		let bankCd 		= $('#refundAccountPop input[name=bankCd]').val();
		
		if (accountNm == confirmedAccountNm && accountNo == confirmedAccountNo && bankCd == confirmedBankCd) {
			// 부모창의 input 값으로 환불계좌정보 설정
			$('#cancelForm input[name=accountNo]').val(accountNo);
			$('#cancelForm input[name=accountNm]').val(accountNm);
			$('#cancelForm input[name=bankCd]').val(bankCd);
			
			// 팝업 닫기
			$("#refundAccountPop .popup_close").trigger("click");
			
			// 취소신청
			fnCancel();
		} else {
			mcxDialog.alert('인증받은 계좌정보와 다릅니다.');
		}
	} else {
		mcxDialog.alert('계좌인증이 필요합니다.');
	}
});

//팝업_닫기
$('.popup_close').on("click",function(){
	let id = $(this).parent().parent().attr('id');
	$(this).parent().parent().hide().removeClass('active');
	
	if (id != 'refundBankPop') {
		$("body").css({"overflow": "visible"});
	}
});
</script>

<script>
// 버튼 색
$(document).on('click','.popup_box .button_list button',function(){
	//$('.popup_box .button_list button').removeClass('on');
	$.each($(this).parent().find('button'), function(idx, item) {
		$(item).removeClass('on');
	});
	$(this).addClass('on');
});

// 210408_송장번호 input 글자 수 제한
function handleOnInput(el, maxlength) {
	if(el.value.length > maxlength)  {
		el.value = el.value.substr(0, maxlength);
	}
}

//210408_ 추가 : 환불계좌등록 팝업 스크립트
$(document).on("click","#btn_refund_pop",function(e){
	$('#refundAccountPop').show().addClass("active");
	$("body").css({"overflow":"hidden"});
});

//210408_ 추가 : 은행선택 팝업 스크립트
$(document).on("click","#refundAccountPop .select_bank",function(e){
	$('#refundBankPop').show().addClass("active");
	$('#refundBankPop').css({"z-index":"1000"});
	$("body").css({"overflow":"hidden"});
});

//210510_추가 : 토스트 팝업 button 클릭 시 팝업 닫기.
$(document).on('click','.popup_box.refundBankPop .button_list button',function(){
	let bankCd = $(this).attr('bankCd');
	let bankNm = $(this).attr('bankNm');
	
	$('#refundAccountPop input[name=bankCd]').val(bankCd);
	$('#refundAccountPop .select_custom.select_bank .combo .select').text(bankNm);
	
	$(this).parents('.popup_box.refundBankPop').hide().removeClass('active');
	$("body").css({"overflow":"visible"});
});
</script>

</th:block>

</body>
</html>
