<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org"        >
<!--
 *****************************************************************************
 * @source  : HilandDeliveryFeeListForm.html
 * @desc    : 도서산간배송비
 *============================================================================
 * SISUN
 * Copyright(C) 2019 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2020.03.16   Daehyoung       최초 작성
 *****************************************************************************
 -->
	<div id="main">
		<!-- 메인타이틀 영역 -->
		<div class="main-title">
		</div>
		<!-- //메인타이틀 영역 -->
		
		<!-- 검색조건 영역 -->
		<form id="hilandDeliveryFeeForm" name="hilandDeliveryFeeForm" action="#" th:action="@{'/system/hiland/deliveryfee/list'}" onsubmit="$('#btnSearch').trigger('click'); return false;">
			<div class="panelStyle2">
				<ul class="lrStyle">
					<li>
						<p class="dot">사이트에서 사용할 도서산간지역을 설정합니다.</p>
					</li>
				</ul>
			</div>
			<div class="panelStyle2">
				<ul class="lrStyle">
					<li class="aR">
						<button type="button" id="btnRegist" class="btn btn-success btn-lg btnRight">등록</button>
					</li>
				</ul>
				<!-- 검색결과 영역 -->
				<div class="panelContent">
					<div id="gridList" style="width: 100%;" class="ag-theme-balham"></div>
				</div>
				<!-- 검색결과 영역 -->
			</div>
			<!-- //검색조건 영역 -->
		</form>
	</div>

<script th:inline="javascript">
/*<![CDATA[*/
	var supplyCompList = gagajf.convertToArray([[${supplyCompList}]]);
	
	var columnDefs = [
		//{width: 100, minWidth: 100, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
		{headerName: "공급업체명",			field: "supplyCompCd",	width: 200, cellClass: 'text-center',
			valueFormatter: function (params) { return gagaAgGrid.lookupValue(supplyCompList, params.value); }
		},
		{headerName: "지역명(도서, 산간 등)",	field: "hilandNm",		width: 400, cellClass: 'text-center'},
		{headerName: "우편번호 범위",		field: "postFno",		width: 350, cellClass: 'text-center',
			cellRenderer: function(params) {
				return '[' + params.data.postFno + '] 부터 [' + params.data.postTno + '] 까지';
			}	
		},
		{headerName: "배송비",			field: "addDelvFee",	width: 150, cellClass: 'text-center',
			valueFormatter: function(params) {return params.value.addComma();}	
		},
		{headerName: "관리",				field: "", 				width: 120, cellClass: 'text-center',
			cellRenderer: function(params) {
				return '<button type="button" class="btn btn-danger btn-sm" onclick="fnHilandDeliveryDetailPopup(\'' + params.data.postFno + '\', \'' + params.data.postTno + '\');">&nbsp;&nbsp;상세&nbsp;&nbsp;</button>';
			}
		}
	];

	// Get GridOptions
	var gridOptions = gagaAgGrid.getGridOptions(columnDefs);
	
	// 검색
	var fnSearch = function() {
		var formId = '#hilandDeliveryFeeForm';
		gagaAgGrid.fetch($(formId).prop('action'), gridOptions, formId);
	}
	
	// 등록
	$('#btnRegist').on('click', function() {
		var actionUrl = '/system/hiland/deliveryfee/detail/N/null/null';
		cfnOpenModalPopup(actionUrl, 'hilandDeliveryFeeDetail');
	});
	
	// 상세
	var fnHilandDeliveryDetailPopup = function(postFno, postTno) {
		var actionUrl = '/system/hiland/deliveryfee/detail/U/' + postFno + '/'+ postTno;
		cfnOpenModalPopup(actionUrl, 'hilandDeliveryFeeDetail');
	}
	
	$(document).ready(function() {
		gagaAgGrid.createGrid('gridList', gridOptions);
		
		// Grid 높이 자동 조정
		uifnFitGrid('auto');
		
		fnSearch();
	});
/*]]>*/
</script>
</html>