DailyOrderForm.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. <!DOCTYPE html>
  2. <html lang="ko"
  3. xmlns:th="http://www.thymeleaf.org">
  4. <!--
  5. *******************************************************************************
  6. * @source : DailyOrderForm.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.08.17 gagamel 최초 작성
  15. *******************************************************************************
  16. -->
  17. <div id="main">
  18. <!-- 메인타이틀 영역 -->
  19. <div class="main-title">
  20. </div>
  21. <!-- //메인타이틀 영역 -->
  22. <!-- 메뉴 설명 -->
  23. <div class="infoBox menu-desc">
  24. </div>
  25. <!-- //메뉴 설명 -->
  26. <!-- 검색조건 영역 -->
  27. <div class="panelStyle">
  28. <form id="searchForm" name="searchForm" action="#" th:action="@{'/statistics/daily/order/list'}" onsubmit="$('#btnSearch').trigger('click'); return false;">
  29. <input type="hidden" name="dayGb" value="D"/>
  30. <table class="frmStyle" aria-describedby="검색조건">
  31. <colgroup>
  32. <col style="width:10%;"/>
  33. <col style="width:25%;"/>
  34. <col style="width:10%;"/>
  35. <col style="width:25%;"/>
  36. <col style="width:10%;"/>
  37. <col style="width:20%;"/>
  38. </colgroup>
  39. <tr>
  40. <th>매출기간<i class="required" title="필수" aria-hidden="true"></i></th>
  41. <td colspan="3" id="terms">
  42. </td>
  43. <th>물류구분</th>
  44. <td>
  45. <label class="chkBox checked"><input type="checkbox" name="distributionGbScm" value="SCM" checked="checked"/>입점</label>
  46. <label class="chkBox checked"><input type="checkbox" name="distributionGbWms" value="WMS" checked="checked"/>위탁</label>
  47. </td>
  48. </tr>
  49. <tr>
  50. <th>디바이스</th>
  51. <td>
  52. <label class="chkBox checked"><input type="checkbox" name="frontGbP" value="P" checked="checked"/>PC웹</label>
  53. <label class="chkBox checked"><input type="checkbox" name="frontGbM" value="M" checked="checked"/>모바일웹</label>
  54. <label class="chkBox checked"><input type="checkbox" name="frontGbA" value="A" checked="checked"/>APP</label>
  55. </td>
  56. <th>제휴몰</th>
  57. <td>
  58. <input type="text" class="w100" name="extmallIdSearchTxt" id="extmallIdSearchTxt" maxlength="20"/>
  59. <button type="button" class="btn icn" onclick="cfnOpenExtmallListPopup('fnSetExtmallInfo', 'M');"><i class="fa fa-search"></i></button>
  60. <span id="extmallIdTxt"></span>
  61. <input type="hidden" name="extmallIdList"/>
  62. </td>
  63. <th>공급업체</th>
  64. <td>
  65. <input type="text" class="w100" name="supplyCompCdSearchTxt" id="supplyCompCdSearchTxt" maxlength="20"/>
  66. <button type="button" class="btn icn" onclick="cfnOpenCompanyListPopup('fnSetSupplyCompInfo', 'M');"><i class="fa fa-search"></i></button>
  67. <span id="supplyCompCdTxt"></span>
  68. <input type="hidden" name="supplyCompCdList"/>
  69. </td>
  70. </tr>
  71. <tr>
  72. <th>제휴채널</th>
  73. <td>
  74. <input type="text" class="w100" name="afLinkCdSearchTxt" id="afLinkCdSearchTxt" maxlength="20" />
  75. <button type="button" class="btn icn" onclick="cfnOpenAfLinkListPopup('fnSetAfLinkInfo', 'M');"><i class="fa fa-search"></i></button>
  76. <span id="afLinkCdTxt"></span>
  77. <input type="hidden" name="afLinkCdList"/>
  78. </td>
  79. <th>브랜드</th>
  80. <td>
  81. <input type="text" class="w100" name="brandCdSearchTxt" id="brandCdSearchTxt" maxlength="20" />
  82. <button type="button" class="btn icn" onclick="cfnOpenBrandListPopup('fnSetBrandInfo', 'M');"><i class="fa fa-search"></i></button>
  83. <span id="brandCdTxt"></span>
  84. <input type="hidden" name="brandCdList"/>
  85. </td>
  86. <th>품목</th>
  87. <td>
  88. <input type="text" class="w100" name="itemkindCdSearchTxt" id="itemkindCdSearchTxt" maxlength="20" />
  89. <button type="button" class="btn icn" onclick="cfnOpenItemkindListPopup('fnSetItemkindInfo', 'M');"><i class="fa fa-search"></i></button>
  90. <span id="itemkindCdTxt"></span>
  91. <input type="hidden" name="itemkindCdList"/>
  92. </td>
  93. </tr>
  94. </table>
  95. <ul class="panelBar">
  96. <li class="center">
  97. <button type="button" class="btn btn-base btn-lg" id="btnSearch">조회</button>
  98. <button type="button" class="btn btn-gray btn-lg" id="btnInit">초기화</button>
  99. </li>
  100. </ul>
  101. </form>
  102. </div>
  103. <!-- 검색조건 영역 -->
  104. <div class="panelStyle">
  105. <div id="chart" class="chartUnit"></div>
  106. </div>
  107. <!-- 리스트 영역 -->
  108. <div class="panelStyle">
  109. <!-- 버튼 배치 영역 -->
  110. <ul class="panelBar">
  111. <li class="left">
  112. <button type="button" class="btn btn-default btn-lg" id="btnExcel">엑셀다운로드</button>
  113. </li>
  114. <li class="right">
  115. <span class="btnGroup marR10">
  116. <button type="button" class="btn btn-default btn-lg active" id="dayGbD" onclick="fnSetDayGb('D');">일별</button>
  117. <button type="button" class="btn btn-default btn-lg" id="dayGbW" onclick="fnSetDayGb('W');">주별</button>
  118. <button type="button" class="btn btn-default btn-lg" id="dayGbM" onclick="fnSetDayGb('M');">월별</button>
  119. </span>
  120. </li>
  121. </ul>
  122. <!-- //버튼 배치 영역 -->
  123. <div id="gridList" style="width: 100%; height: 470px" class="ag-theme-balham"></div>
  124. </div>
  125. <!-- //리스트 영역 -->
  126. </div>
  127. <script th:inline="javascript">
  128. /*<![CDATA[*/
  129. let columnDefs = [
  130. { headerName: "일자", field: "day", width: 100, cellClass: 'text-center' },
  131. {
  132. headerName: "매출액", field: "totOrdAmt", width: 150, cellClass: 'text-right',
  133. cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
  134. },
  135. {
  136. headerName: "전년동기매출액", field: "yoyTotOrdAmt", width: 150, cellClass: 'text-right', hide: true,
  137. cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
  138. },
  139. { headerName: "YOY(%)", field: "yoyRate", width: 100, cellClass: 'text-center' },
  140. {
  141. headerName: "자사직방문", field: "selfAmt", width: 150, cellClass: 'text-right',
  142. cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
  143. },
  144. {
  145. headerName: "채널", field: "channelAmt", width: 150, cellClass: 'text-right',
  146. cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
  147. },
  148. {
  149. headerName: "제휴몰", field: "extmallAmt", width: 150, cellClass: 'text-right',
  150. cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
  151. },
  152. {
  153. headerName: "취/반품액", field: "cnclAmt", width: 120, cellClass: 'text-right',
  154. cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
  155. },
  156. {
  157. headerName: "주문수", field: "ordCnt", width: 150, cellClass: 'text-right',
  158. cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
  159. },
  160. {
  161. headerName: "판매수", field: "sellQty", width: 150, cellClass: 'text-right',
  162. cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
  163. },
  164. {
  165. headerName: "취/반품수", field: "cnclQty", width: 150, cellClass: 'text-right',
  166. cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
  167. }
  168. ];
  169. let gridOptions = gagaAgGrid.getGridOptions(columnDefs);
  170. gridOptions.autoGroupColumnDef = {
  171. headerName: "일자",
  172. field: "grouping",
  173. width: 200,
  174. cellRendererParams: {
  175. suppressCount: true
  176. }
  177. };
  178. // for expand everything
  179. gridOptions.groupDefaultExpanded = -1;
  180. // 제휴몰 조회 팝업에서 호출
  181. var fnSetExtmallInfo = function(result) {
  182. var arrExtmallId = [];
  183. var extmallIdTxt = "";
  184. var sIndex = 0;
  185. var extmallNm = "";
  186. $('#extmallIdTxt').html('');
  187. $('#searchForm input[name=extmallIdSearchTxt]').val('');
  188. result.forEach(function(extmall) {
  189. sIndex++;
  190. arrExtmallId.push(extmall.extmallId);
  191. extmallNm = extmall.extmallNm;
  192. });
  193. // 조회 값이 하나일 경우 화면에 코드 노출. 그 외는 갯수 처리
  194. if (sIndex == 1) {
  195. $('#searchForm input[name=extmallIdSearchTxt]').val(extmallNm);
  196. } else {
  197. extmallIdTxt = sIndex + " 개";
  198. $('#extmallIdTxt').html(extmallIdTxt);
  199. }
  200. var jsonData = JSON.stringify(arrExtmallId);
  201. $("#searchForm input[name=extmallIdList]").val(jsonData);
  202. }
  203. // 업체 조회 팝업에서 호출
  204. var fnSetSupplyCompInfo = function(result) {
  205. var arrSupplyCompCd = [];
  206. var supplyCompCdTxt = "";
  207. var sIndex = 0;
  208. var supplyCompNm = "";
  209. $('#supplyCompCdTxt').html('');
  210. $('#searchForm input[name=supplyCompCdSearchTxt]').val('');
  211. result.forEach(function(supplyComp) {
  212. sIndex++;
  213. arrSupplyCompCd.push(supplyComp.supplyCompCd);
  214. supplyCompNm = supplyComp.supplyCompNm;
  215. });
  216. // 조회 값이 하나일 경우 화면에 코드 노출. 그 외는 갯수 처리
  217. if (sIndex == 1) {
  218. $('#searchForm input[name=supplyCompCdSearchTxt]').val(supplyCompNm);
  219. } else {
  220. supplyCompCdTxt = sIndex + " 개";
  221. $('#supplyCompCdTxt').html(supplyCompCdTxt);
  222. }
  223. var jsonData = JSON.stringify(arrSupplyCompCd);
  224. $("#searchForm input[name=supplyCompCdList]").val(jsonData);
  225. }
  226. // 제휴채널 조회 팝업에서 호출
  227. var fnSetAfLinkInfo = function(result) {
  228. var arrAfLinkCd = [];
  229. var afLinkCdTxt = "";
  230. var sIndex = 0;
  231. var afLinkNm = "";
  232. $('#afLinkCdTxt').html('');
  233. $('#searchForm input[name=afLinkCdSearchTxt]').val('');
  234. result.forEach(function(afLink) {
  235. sIndex++;
  236. arrAfLinkCd.push(afLink.afLinkCd);
  237. afLinkNm = afLink.afLinkNm;
  238. });
  239. // 조회 값이 하나일 경우 화면에 코드 노출. 그 외는 갯수 처리
  240. if (sIndex == 1) {
  241. $('#searchForm input[name=afLinkCdSearchTxt]').val(afLinkNm);
  242. } else {
  243. afLinkCdTxt = sIndex + " 개";
  244. $('#afLinkCdTxt').html(afLinkCdTxt);
  245. }
  246. var jsonData = JSON.stringify(arrAfLinkCd);
  247. $("#searchForm input[name=afLinkCdList]").val(jsonData);
  248. }
  249. // 브랜드 조회 팝업에서 호출
  250. var fnSetBrandInfo = function(result) {
  251. var arrBrandCd = [];
  252. var brandCdTxt = "";
  253. var bIndex = 0;
  254. var brandNm = "";
  255. $('#brandCdTxt').html('');
  256. $('#searchForm input[name=brandCdSearchTxt]').val('');
  257. result.forEach(function(brand){
  258. bIndex++;
  259. arrBrandCd.push(brand.brandCd);
  260. brandNm = brand.brandKnm;
  261. });
  262. // 조회 값이 하나일 경우 화면에 코드 노출. 그 외는 갯수 처리
  263. if (bIndex == 1) {
  264. $('#searchForm input[name=brandCdSearchTxt]').val(brandNm);
  265. } else {
  266. brandCdTxt = bIndex + " 개";
  267. $('#brandCdTxt').html(brandCdTxt);
  268. }
  269. var jsonData = JSON.stringify(arrBrandCd);
  270. $("#searchForm input[name=brandCdList]").val(jsonData);
  271. }
  272. // 품목 조회 팝업에서 호출
  273. var fnSetItemkindInfo = function(result) {
  274. var arrItemkindCd = [];
  275. var itemkindCdTxt = "";
  276. var bIndex = 0;
  277. $('#itemkindCdTxt').html('');
  278. $('#searchForm input[name=itemkindCdSearchTxt]').val('');
  279. result.forEach(function(itemkind){
  280. bIndex++;
  281. arrItemkindCd.push(itemkind.itemkindCd);
  282. });
  283. // 조회 값이 하나일 경우 화면에 코드 노출. 그 외는 갯수 처리
  284. if (bIndex == 1) {
  285. $('#searchForm input[name=itemkindCdSearchTxt]').val(arrItemkindCd[0]);
  286. } else {
  287. itemkindCdTxt = bIndex + " 개";
  288. $('#itemkindCdTxt').html(itemkindCdTxt);
  289. }
  290. var jsonData = JSON.stringify(arrItemkindCd);
  291. $("#searchForm input[name=itemkindCdList]").val(jsonData);
  292. }
  293. // 검색
  294. $('#btnSearch').on('click', function() {
  295. // 입력 값 체크
  296. if (!gagajf.validation($('#searchForm')))
  297. return false;
  298. gagaAgGrid.fetch($('#searchForm').prop('action'), gridOptions, '#searchForm', fnCreateTotal);
  299. });
  300. // 합계 생성
  301. let fnCreateTotal = function() {
  302. // Draw chart
  303. fnDrawChart(gagaAgGrid.getAllRowData(gridOptions));
  304. let totOrdAmt = 0;
  305. let yoyTotOrdAmt = 0;
  306. let selfAmt = 0;
  307. let channelAmt = 0;
  308. let extmallAmt = 0;
  309. let cnclAmt = 0;
  310. let ordCnt = 0;
  311. let sellQty = 0;
  312. let cnclQty = 0;
  313. gridOptions.api.forEachNode(function(rowNode, index) {
  314. if (!rowNode.group) {
  315. if (typeof rowNode.data.totOrdAmt == 'number') { totOrdAmt += rowNode.data.totOrdAmt; }
  316. if (typeof rowNode.data.yoyTotOrdAmt == 'number') { yoyTotOrdAmt += rowNode.data.yoyTotOrdAmt; }
  317. if (typeof rowNode.data.selfAmt == 'number') { selfAmt += rowNode.data.selfAmt; }
  318. if (typeof rowNode.data.channelAmt == 'number') { channelAmt += rowNode.data.channelAmt; }
  319. if (typeof rowNode.data.extmallAmt == 'number') { extmallAmt += rowNode.data.extmallAmt; }
  320. if (typeof rowNode.data.cnclAmt == 'number') { cnclAmt += rowNode.data.cnclAmt; }
  321. if (typeof rowNode.data.ordCnt == 'number') { ordCnt += rowNode.data.ordCnt; }
  322. if (typeof rowNode.data.sellQty == 'number') { sellQty += rowNode.data.sellQty; }
  323. if (typeof rowNode.data.cnclQty == 'number') { cnclQty += rowNode.data.cnclQty; }
  324. }
  325. });
  326. let yoyRate = yoyTotOrdAmt > 0 ? gagaAgGrid.toFixed((totOrdAmt / yoyTotOrdAmt - 1) * 100, 1) : '';
  327. let data = {
  328. day: 'TOTAL',
  329. totOrdAmt: totOrdAmt, yoyTotOrdAmt: yoyTotOrdAmt, yoyRate: yoyRate,
  330. selfAmt: selfAmt, channelAmt: channelAmt, extmallAmt: extmallAmt,
  331. cnclAmt: cnclAmt, ordCnt: ordCnt, sellQty: sellQty, cnclQty: cnclQty
  332. };
  333. gagaAgGrid.setPinnedRowData(gridOptions, data, 'top');
  334. }
  335. // 초기화 클릭시
  336. $('#btnInit').on('click', function() {
  337. $('#searchForm')[0].reset();
  338. $('#extmallIdTxt').html('');
  339. $('#searchForm input[name=extmallIdList]').val('');
  340. $('#supplyCompCdTxt').html('');
  341. $('#searchForm input[name=supplyCompCdList]').val('');
  342. $('#afLinkCdTxt').html('');
  343. $('#searchForm input[name=afLinkCdList]').val('');
  344. $('#brandCdTxt').html('');
  345. $('#searchForm input[name=brandCdList]').val('');
  346. $('#itemkindCdTxt').html('');
  347. $('#searchForm input[name=itemkindCdList]').val('');
  348. });
  349. // 엑셀다운로드
  350. $('#btnExcel').on('click', function() {
  351. gagaAgGrid.exportToExcel('일자별주문 목록', gridOptions);
  352. });
  353. // 일자구분 변경 시
  354. var fnSetDayGb = function(dayGb) {
  355. $('#searchForm input[name=dayGb]').val(dayGb);
  356. $('#dayGbD').removeClass('active');
  357. $('#dayGbW').removeClass('active');
  358. $('#dayGbM').removeClass('active');
  359. $('#dayGb' + dayGb).addClass('active');
  360. $('#btnSearch').trigger('click');
  361. }
  362. // 그래프 그리기
  363. var chart1;
  364. var fnDrawChart = function(data) {
  365. let dayList = [];
  366. let totOrdAmtList = [];
  367. let ordCntList = [];
  368. $(data).each(function(idx, item) {
  369. if ($('#dayGbD').hasClass('active')) {
  370. dayList.push(item.day.toDate('YYYY-MM-DD').format('MM-DD'));
  371. } else {
  372. dayList.push(item.day);
  373. }
  374. totOrdAmtList.push((item.totOrdAmt / 1000).toFixed(0));
  375. ordCntList.push(item.ordCnt);
  376. });
  377. chart1 = c3.generate({
  378. bindto: "#chart",
  379. padding: {
  380. bottom: 20 //adjust chart padding bottom
  381. },
  382. data: {
  383. x: 'x',
  384. json: {
  385. x: dayList,
  386. 매출액: totOrdAmtList,
  387. 주문건수: ordCntList
  388. },
  389. types: {
  390. 매출액: 'bar',
  391. 주문건수: 'line'
  392. }/* ,
  393. regions: {
  394. 'data1': [
  395. {
  396. 'start': 1,
  397. 'end': 2,
  398. 'style': 'dashed'
  399. }, {
  400. 'start': 3
  401. }
  402. ]
  403. } */
  404. },
  405. color: {
  406. pattern: ['#48C9B0', '#FF7043', '#FF7043']
  407. },
  408. legend: { padding: 15 }, //범례 item 우측 간격
  409. axis: {
  410. x: {
  411. type: 'category',
  412. padding: { left: 0.5, right: 0.5 }
  413. }/* ,
  414. y: {
  415. tick: {
  416. format: function(d) { return Number(d).addComma() + 'K'; }
  417. }
  418. } */
  419. },
  420. tooltip: {
  421. format: {
  422. title: function (d) {
  423. return '주문 통계 Chart';
  424. }
  425. }
  426. }/* ,
  427. bar: {
  428. width: { ratio: 0.2 } // 막대 폭 20%로 조절
  429. } */
  430. });
  431. }
  432. // LNB 또는 GNB 클릭시 차트 넓이 변경
  433. var chartResize = function() {
  434. setTimeout(function () {
  435. // 모든 차트 ID객체에 적용
  436. chart1.resize();
  437. }, 300);
  438. }
  439. $(document).ready(function() {
  440. cfnCreateCalendar('#terms', 'startDt', 'endDt', true, '주문', undefined, ['btnToday']);
  441. $('.btnRecentWeek').trigger('click');
  442. // Create a agGrid
  443. gagaAgGrid.createGrid('gridList', gridOptions);
  444. });
  445. /*]]>*/
  446. </script>
  447. </html>