CustomerAgeOrderForm.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <!DOCTYPE html>
  2. <html lang="ko"
  3. xmlns:th="http://www.thymeleaf.org">
  4. <!--
  5. *******************************************************************************
  6. * @source : CustomerAgeOrderForm.html
  7. * @desc : 연령별주문현황 Page
  8. *============================================================================
  9. * STYLE24
  10. * Copyright(C) 2020 TSIT, All rights reserved.
  11. *============================================================================
  12. * VER DATE AUTHOR DESCRIPTION
  13. * === =========== ========== =============================================
  14. * 1.0 2021.09.28 swkim 최초 작성
  15. *******************************************************************************
  16. -->
  17. <div id="main">
  18. <!-- 메인타이틀 영역 -->
  19. <div class="main-title"></div>
  20. <!-- //메인타이틀 영역 -->
  21. <!-- 메뉴 설명 -->
  22. <div class="infoBox menu-desc"></div>
  23. <!-- //메뉴 설명 -->
  24. <!-- 검색조건 영역 -->
  25. <div class="panelStyle">
  26. <form id="searchForm" name="searchForm" action="#" th:action="@{'/statistics/customer/age/order/list'}" onsubmit="$('#btnSearch').trigger('click'); return false;">
  27. <input type="hidden" name="dayGb" value="D"/>
  28. <table class="frmStyle" aria-describedby="검색조건">
  29. <colgroup>
  30. <col style="width:10%;"/>
  31. <col style="width:25%;"/>
  32. <col style="width:10%;"/>
  33. <col/>
  34. </colgroup>
  35. <tr>
  36. <th>기간<i class="required" title="필수" aria-hidden="true"></i></th>
  37. <td colspan="3" id="terms"></td>
  38. </tr>
  39. <tr>
  40. <th>디바이스</th>
  41. <td colspan="3">
  42. <label class="chkBox checked"><input type="checkbox" name="multiFrontGb" value="P" checked="checked"/>PC웹</label>
  43. <label class="chkBox checked"><input type="checkbox" name="multiFrontGb" value="M" checked="checked"/>모바일웹</label>
  44. <label class="chkBox checked"><input type="checkbox" name="multiFrontGb" value="A" checked="checked"/>APP</label>
  45. </td>
  46. </tr>
  47. <tr>
  48. <th>등급</th>
  49. <td colspan="3">
  50. <label th:if="${gradeGbList}" th:each="oneData, status : ${gradeGbList}" class="chkBox checked"><input type="checkbox" name="multiGradeGb" th:value="${oneData.cd}" th:text="${oneData.cdNm}" checked="checked"/></label>
  51. </td>
  52. </tr>
  53. <tr>
  54. <th>브랜드</th>
  55. <td>
  56. <input type="text" class="w100" name="brandCdSearchTxt" id="brandCdSearchTxt" maxlength="20" />
  57. <button type="button" class="btn icn" onclick="cfnOpenBrandListPopup('fnSetBrandInfo', 'M');"><i class="fa fa-search"></i></button>
  58. <span id="brandCdTxt"></span>
  59. <input type="hidden" name="brandCdList"/>
  60. </td>
  61. <th>매출카테고리</th>
  62. <td>
  63. <input type="text" class="w100" name="itemkindCdSearchTxt" id="itemkindCdSearchTxt" maxlength="20" />
  64. <button type="button" class="btn icn" onclick="cfnOpenItemkindListPopup('fnSetItemkindInfo', 'M');"><i class="fa fa-search"></i></button>
  65. <span id="itemkindCdTxt"></span>
  66. <input type="hidden" name="itemkindCdList"/>
  67. </td>
  68. </tr>
  69. </table>
  70. <ul class="panelBar">
  71. <li class="center">
  72. <button type="button" class="btn btn-base btn-lg" id="btnSearch">조회</button>
  73. <button type="button" class="btn btn-gray btn-lg" id="btnInit">초기화</button>
  74. </li>
  75. </ul>
  76. </form>
  77. </div>
  78. <!-- 검색조건 영역 -->
  79. <!-- 리스트 영역 -->
  80. <div class="panelStyle">
  81. <ul class="panelBar">
  82. <li>
  83. <button type="button" class="btn btn-default btn-lg" onclick="fnExcelDownLoad();">엑셀다운로드</button>
  84. </li>
  85. </ul>
  86. <div id="gridList" style="width: 100%; height: 470px" class="ag-theme-balham"></div>
  87. </div>
  88. <!-- //리스트 영역 -->
  89. </div>
  90. <style>
  91. .ag-header-group-text{
  92. margin-left: calc(50% - 25px);
  93. }
  94. </style>
  95. <script th:inline="javascript">
  96. /*<![CDATA[*/
  97. let columnDefs = [
  98. { headerName: "연령", field: "age", width: 100, cellClass: 'text-center' },
  99. { headerName: "성별", field: "sexGb", width: 100, cellClass: 'text-center' },
  100. {
  101. headerName: "주문 현황", field: "", width: 1200, cellClass: 'text-center',
  102. children: [
  103. {headerName: "총매출액(A+B)", field: "totOrdAmt", width: 150, cellClass: 'text-center',
  104. cellRenderer: function(params) {
  105. return gagaAgGrid.toAddComma(params.value);
  106. }
  107. },
  108. {headerName: "매출액(A)", field: "ordAmt", width: 150, cellClass: 'text-center',
  109. cellRenderer: function(params) {
  110. return gagaAgGrid.toAddComma(params.value);
  111. }
  112. },
  113. {headerName: "취/반품액(B)", field: "cnclAmt", width: 150, cellClass: 'text-center',
  114. cellRenderer: function(params) {
  115. return gagaAgGrid.toAddComma(params.value);
  116. }
  117. },
  118. {headerName: "주문수", field: "ordCnt", width: 150, cellClass: 'text-center',
  119. cellRenderer: function(params) {
  120. return gagaAgGrid.toAddComma(params.value);
  121. }
  122. },
  123. {headerName: "취/반품갯수", field: "cnclQty", width: 150, cellClass: 'text-center',
  124. cellRenderer: function(params) {
  125. return gagaAgGrid.toAddComma(params.value);
  126. }
  127. },
  128. {headerName: "기간평균주문수", field: "avgOrdCnt", width: 150, cellClass: 'text-center',
  129. cellRenderer: function(params) {
  130. return gagaAgGrid.toAddComma(params.value);
  131. }
  132. },
  133. {headerName: "평균주문상품개수", field: "avgSellQty", width: 150, cellClass: 'text-center',
  134. cellRenderer: function(params) {
  135. return gagaAgGrid.toAddComma(params.value);
  136. }
  137. },
  138. {headerName: "객단가", field: "custPrice", width: 150, cellClass: 'text-center',
  139. cellRenderer: function(params) {
  140. return gagaAgGrid.toAddComma(params.value);
  141. }
  142. }
  143. ]
  144. }
  145. ];
  146. let gridOptions = gagaAgGrid.getGridOptions(columnDefs);
  147. gridOptions.excelStyles = [
  148. {
  149. id: 'text-center',
  150. dataType: 'string',
  151. font: {size : 10, bold: false}
  152. },
  153. {
  154. id: 'text-left',
  155. dataType: 'string',
  156. font: {size : 10, bold: false}
  157. },
  158. {
  159. id: 'text-right',
  160. dataType: 'number',
  161. font: {size : 10, bold: false}
  162. }
  163. ];
  164. var fnExcelDownLoad = function(){
  165. var totalRows = gridOptions.api.getDisplayedRowCount();
  166. if(totalRows==0){
  167. mcxDialog.alert('조회된 내역이 없습니다.');
  168. return;
  169. }
  170. var date = new Date().format("YYYYMMDDHHmmss");
  171. var params = {
  172. fileName : "연령별주문현황_"+ date,
  173. sheetName: "DATA"
  174. };
  175. gridOptions.api.exportDataAsExcel(params);
  176. }
  177. // 브랜드 조회 팝업에서 호출
  178. var fnSetBrandInfo = function(result) {
  179. var arrBrandCd = [];
  180. var brandCdTxt = "";
  181. var bIndex = 0;
  182. $('#brandCdTxt').html('');
  183. $('#searchForm input[name=brandCdSearchTxt]').val('');
  184. result.forEach(function(brand){
  185. bIndex++;
  186. arrBrandCd.push(brand.brandCd);
  187. });
  188. // 조회 값이 하나일 경우 화면에 코드 노출. 그 외는 갯수 처리
  189. if (bIndex == 1) {
  190. $('#searchForm input[name=brandCdSearchTxt]').val(arrBrandCd[0]);
  191. } else {
  192. brandCdTxt = bIndex + " 개";
  193. $('#brandCdTxt').html(brandCdTxt);
  194. }
  195. var jsonData = JSON.stringify(arrBrandCd);
  196. $("#searchForm input[name=brandCdList]").val(arrBrandCd.join(","));
  197. }
  198. // 품목 조회 팝업에서 호출
  199. var fnSetItemkindInfo = function(result) {
  200. var arrItemkindCd = [];
  201. var itemkindCdTxt = "";
  202. var bIndex = 0;
  203. $('#itemkindCdTxt').html('');
  204. $('#searchForm input[name=itemkindCdSearchTxt]').val('');
  205. result.forEach(function(itemkind){
  206. bIndex++;
  207. arrItemkindCd.push(itemkind.itemkindCd);
  208. });
  209. // 조회 값이 하나일 경우 화면에 코드 노출. 그 외는 갯수 처리
  210. if (bIndex == 1) {
  211. $('#searchForm input[name=itemkindCdSearchTxt]').val(arrItemkindCd[0]);
  212. } else {
  213. itemkindCdTxt = bIndex + " 개";
  214. $('#itemkindCdTxt').html(itemkindCdTxt);
  215. }
  216. var jsonData = JSON.stringify(arrItemkindCd);
  217. $("#searchForm input[name=itemkindCdList]").val(arrItemkindCd.join(','));
  218. }
  219. // 검색
  220. $('#btnSearch').on('click', function() {
  221. // 입력 값 체크
  222. if (!gagajf.validation($('#searchForm')))
  223. return false;
  224. gagaAgGrid.fetch($('#searchForm').prop('action'), gridOptions, '#searchForm', fnCreateTotal);
  225. });
  226. // 합계 생성
  227. let fnCreateTotal = function() {
  228. let len = 0;
  229. let totInfo = {};
  230. totInfo.age = '';
  231. totInfo.sexGb = 'TOTAL';
  232. totInfo.totOrdAmt = 0;
  233. totInfo.ordAmt = 0;
  234. totInfo.cnclAmt = 0;
  235. totInfo.ordCnt = 0;
  236. totInfo.cnclQty = 0;
  237. totInfo.avgOrdCnt = 0;
  238. totInfo.avgSellQty = 0;
  239. totInfo.custPrice = 0;
  240. gridOptions.api.forEachNode(function(rowNode, index) {
  241. if (!rowNode.group) {
  242. if( typeof rowNode.data.totOrdAmt == 'number') { totInfo.totOrdAmt += rowNode.data.totOrdAmt ; }
  243. if( typeof rowNode.data.ordAmt == 'number') { totInfo.ordAmt += rowNode.data.ordAmt ; }
  244. if( typeof rowNode.data.cnclAmt == 'number') { totInfo.cnclAmt += rowNode.data.cnclAmt ; }
  245. if( typeof rowNode.data.ordCnt == 'number') { totInfo.ordCnt += rowNode.data.ordCnt ; if (rowNode.data.ordCnt > 0) len++; }
  246. if( typeof rowNode.data.cnclQty == 'number') { totInfo.cnclQty += rowNode.data.cnclQty ; }
  247. if( typeof rowNode.data.avgOrdCnt == 'number') { totInfo.avgOrdCnt += rowNode.data.avgOrdCnt ; }
  248. if( typeof rowNode.data.avgSellQty == 'number') { totInfo.avgSellQty += rowNode.data.avgSellQty ; }
  249. if( typeof rowNode.data.custPrice == 'number') { totInfo.custPrice += rowNode.data.custPrice ; }
  250. }
  251. });
  252. totInfo.avgOrdCnt = (Math.round(totInfo.avgOrdCnt / len * 10) / 10);
  253. totInfo.avgSellQty = (Math.round(totInfo.avgSellQty / len * 10) / 10);
  254. totInfo.custPrice = Math.floor(totInfo.custPrice / len);
  255. gagaAgGrid.setPinnedRowData(gridOptions, totInfo, 'top');
  256. }
  257. // 초기화 클릭시
  258. $('#btnInit').on('click', function() {
  259. $('#searchForm')[0].reset();
  260. $('#brandCdTxt').html('');
  261. $('#searchForm input[name=brandCdList]').val('');
  262. $('#itemkindCdTxt').html('');
  263. $('#searchForm input[name=itemkindCdList]').val('');
  264. });
  265. // 엑셀다운로드
  266. $('#btnExcel').on('click', function() {
  267. gagaAgGrid.exportToExcel('일자별주문 목록', gridOptions);
  268. });
  269. $(document).ready(function() {
  270. cfnCreateCalendar('#terms', 'startDt', 'endDt', true, '주문', undefined, ['btnToday']);
  271. $('.btnYesterday').trigger('click');
  272. // Create a agGrid
  273. gagaAgGrid.createGrid('gridList', gridOptions);
  274. });
  275. /*]]>*/
  276. </script>
  277. </html>