BrandTradingForm.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <!DOCTYPE html>
  2. <html lang="ko"
  3. xmlns:th="http://www.thymeleaf.org">
  4. <!--
  5. *******************************************************************************
  6. * @source : BrandTradingForm.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-16 목 lmc 최초 작성
  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/brand/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>
  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. <th>제휴몰</th>
  47. <td>
  48. <input type="text" class="w100" name="extmallIdSearchTxt" id="extmallIdSearchTxt" maxlength="20"/>
  49. <button type="button" class="btn icn" onclick="cfnOpenExtmallListPopup('fnSetExtmallInfo', 'M');"><i class="fa fa-search"></i></button>
  50. <span id="extmallIdTxt"></span>
  51. <input type="hidden" name="extmallIdList"/>
  52. </td>
  53. </tr>
  54. <tr>
  55. <th>물류구분</th>
  56. <td colspan="3">
  57. <label class="chkBox checked"><input type="checkbox" name="multiDistributionGb" value="SCM" checked="checked"/>입점</label>
  58. <label class="chkBox checked"><input type="checkbox" name="multiDistributionGb" value="WMS" checked="checked"/>위탁</label>
  59. </td>
  60. </tr>
  61. <tr>
  62. <th>공급업체</th>
  63. <td>
  64. <input type="text" class="w100" name="supplyCompCdSearchTxt" id="supplyCompCdSearchTxt" maxlength="20"/>
  65. <button type="button" class="btn icn" onclick="cfnOpenCompanyListPopup('fnSetSupplyCompInfo', 'M');"><i class="fa fa-search"></i></button>
  66. <span id="supplyCompCdTxt"></span>
  67. <input type="hidden" name="supplyCompCdList"/>
  68. </td>
  69. <th>제휴채널</th>
  70. <td>
  71. <input type="text" class="w100" name="afLinkCdSearchTxt" id="afLinkCdSearchTxt" maxlength="20" />
  72. <button type="button" class="btn icn" onclick="cfnOpenAfLinkListPopup('fnSetAfLinkInfo', 'M');"><i class="fa fa-search"></i></button>
  73. <span id="afLinkCdTxt"></span>
  74. <input type="hidden" name="afLinkCdList"/>
  75. </td>
  76. </tr>
  77. <tr>
  78. <th>브랜드</th>
  79. <td>
  80. <input type="text" class="w100" name="brandCdSearchTxt" id="brandCdSearchTxt" maxlength="20" />
  81. <button type="button" class="btn icn" onclick="cfnOpenBrandListPopup('fnSetBrandInfo', 'M');"><i class="fa fa-search"></i></button>
  82. <span id="brandCdTxt"></span>
  83. <input type="hidden" name="brandCdList"/>
  84. </td>
  85. <th>품목</th>
  86. <td>
  87. <input type="text" class="w100" name="itemkindCdSearchTxt" id="itemkindCdSearchTxt" maxlength="20" />
  88. <button type="button" class="btn icn" onclick="cfnOpenItemkindListPopup('fnSetItemkindInfo', 'M');"><i class="fa fa-search"></i></button>
  89. <span id="itemkindCdTxt"></span>
  90. <input type="hidden" name="itemkindCdList"/>
  91. </td>
  92. </tr>
  93. </table>
  94. <ul class="panelBar">
  95. <li class="center">
  96. <button type="button" class="btn btn-base btn-lg" id="btnSearch">조회</button>
  97. <button type="button" class="btn btn-gray btn-lg" id="btnInit">초기화</button>
  98. </li>
  99. </ul>
  100. </form>
  101. </div>
  102. <!-- 검색조건 영역 -->
  103. <!-- 리스트 영역 -->
  104. <div class="panelStyle">
  105. <ul class="panelBar">
  106. <li>
  107. <button type="button" class="btn btn-default btn-lg" onclick="fnExcelDownLoad();">엑셀다운로드</button>
  108. </li>
  109. </ul>
  110. <div id="gridList" style="width: 100%; height: 470px" class="ag-theme-balham"></div>
  111. </div>
  112. <!-- //리스트 영역 -->
  113. </div>
  114. <style>
  115. .ag-header-group-text{
  116. margin-left: calc(50% - 25px);
  117. }
  118. </style>
  119. <script th:inline="javascript">
  120. /*<![CDATA[*/
  121. let columnDefs = [
  122. { headerName: "브랜드번호", field: "brandCd", width: 100, cellClass: 'text-center' },
  123. { headerName: "브랜드명", field: "brandEnm", width: 180, cellClass: 'text-center'},
  124. { headerName: "브랜드 매출액", field: "", width: 120, cellClass: 'text-right',
  125. children: [
  126. {headerName: "총매출액(A+B+C)", field: "totAmt", width: 120, cellClass: 'text-center',
  127. cellRenderer: function(params) {
  128. return !gagajf.isNull(params.value) ? params.value.addComma() : '0';
  129. }
  130. },
  131. {headerName: "판매 개수", field: "sellQty", width: 120, cellClass: 'text-right',
  132. cellRenderer: function(params) {
  133. return !gagajf.isNull(params.value) ? params.value.addComma() : '0';
  134. }
  135. },
  136. {headerName: "YOY(%)", field: "yoyRate", width: 100, cellClass: 'text-right',
  137. cellRenderer: function(params) {
  138. return params.value +'%';
  139. }
  140. },
  141. ]
  142. },
  143. { headerName: "매출 현황", field: "", width: 100, cellClass: 'text-center',
  144. children: [
  145. {headerName: "자사몰 매출액(A)", field: "selfmallAmt", width: 120, cellClass: 'text-right',
  146. cellRenderer: function (params) {
  147. return !gagajf.isNull(params.value) ? params.value.addComma() : '0';
  148. }
  149. },
  150. {headerName: "제휴몰 매출액(B)", field: "extmallAmt", width: 150, cellClass: 'text-right',
  151. cellRenderer: function (params) {
  152. return !gagajf.isNull(params.value) ? params.value.addComma() : '0';
  153. }
  154. },
  155. {headerName: "취/반품액(C)", field: "cnclAmt", width: 150, cellClass: 'text-right',
  156. cellRenderer: function (params) {
  157. return !gagajf.isNull(params.value) ? params.value.addComma() : '0';
  158. }
  159. },
  160. ]
  161. },
  162. { headerName: "정상이월 결제비중", field: "", width: 100, cellClass: 'text-center',
  163. children: [
  164. {headerName: "정상", field: "totAmt10", width: 150, cellClass: 'text-right',
  165. cellRenderer: function (params) {
  166. return !gagajf.isNull(params.value) ? params.value.addComma() : '0';
  167. }
  168. },
  169. {headerName: "이월", field: "totAmt20", width: 120, cellClass: 'text-right',
  170. cellRenderer: function (params) {
  171. return !gagajf.isNull(params.value) ? params.value.addComma() : '0';
  172. }
  173. },
  174. {headerName: "정상비", field: "amtRate10", width: 100, cellClass: 'text-right',
  175. cellRenderer: function(params) {
  176. return params.value +'%';
  177. }
  178. }
  179. ]
  180. },
  181. ];
  182. let gridOptions = gagaAgGrid.getGridOptions(columnDefs);
  183. // Row Click
  184. gridOptions.onCellClicked = function(event) {
  185. var goodsCd = event.data.goodsCd;
  186. if (event.colDef.field == "goodsCd"){
  187. cfnOpenGoodsDetailPopup('U',goodsCd);
  188. }
  189. if (event.colDef.field == "goodsNm"){
  190. cfnOpenGoodsDetailPopup('U',goodsCd);
  191. }
  192. }
  193. gridOptions.excelStyles = [
  194. {
  195. id: 'text-center',
  196. dataType: 'string',
  197. font: {size : 10, bold: false}
  198. },
  199. {
  200. id: 'text-left',
  201. dataType: 'string',
  202. font: {size : 10, bold: false}
  203. },
  204. {
  205. id: 'text-right',
  206. dataType: 'number',
  207. font: {size : 10, bold: false}
  208. }
  209. ];
  210. var fnExcelDownLoad = function(){
  211. var totalRows = gridOptions.api.getDisplayedRowCount();
  212. if(totalRows==0){
  213. mcxDialog.alert('조회된 내역이 없습니다.');
  214. return;
  215. }
  216. var date = new Date().format("YYYYMMDDHHmmss");
  217. var params = {
  218. fileName : "브랜드별 주문목록_"+ date,
  219. sheetName: "DATA"
  220. };
  221. gridOptions.api.exportDataAsExcel(params);
  222. }
  223. // 제휴몰 조회 팝업에서 호출
  224. var fnSetExtmallInfo = function(result) {
  225. var arrExtmallId = [];
  226. var extmallIdTxt = "";
  227. var sIndex = 0;
  228. var extmallNm = "";
  229. $('#extmallIdTxt').html('');
  230. $('#searchForm input[name=extmallIdSearchTxt]').val('');
  231. result.forEach(function(extmall) {
  232. sIndex++;
  233. arrExtmallId.push(extmall.extmallId);
  234. extmallNm = extmall.extmallNm;
  235. });
  236. // 조회 값이 하나일 경우 화면에 코드 노출. 그 외는 갯수 처리
  237. if (sIndex == 1) {
  238. $('#searchForm input[name=extmallIdSearchTxt]').val(extmallNm);
  239. } else {
  240. extmallIdTxt = sIndex + " 개";
  241. $('#extmallIdTxt').html(extmallIdTxt);
  242. }
  243. var jsonData = JSON.stringify(arrExtmallId);
  244. $("#searchForm input[name=extmallIdList]").val(arrExtmallId.join(','));
  245. }
  246. // 업체 조회 팝업에서 호출
  247. var fnSetSupplyCompInfo = function(result) {
  248. var arrSupplyCompCd = [];
  249. var supplyCompCdTxt = "";
  250. var sIndex = 0;
  251. var supplyCompNm = "";
  252. $('#supplyCompCdTxt').html('');
  253. $('#searchForm input[name=supplyCompCdSearchTxt]').val('');
  254. result.forEach(function(supplyComp) {
  255. sIndex++;
  256. arrSupplyCompCd.push(supplyComp.supplyCompCd);
  257. supplyCompNm = supplyComp.supplyCompNm;
  258. });
  259. // 조회 값이 하나일 경우 화면에 코드 노출. 그 외는 갯수 처리
  260. if (sIndex == 1) {
  261. $('#searchForm input[name=supplyCompCdSearchTxt]').val(supplyCompNm);
  262. } else {
  263. supplyCompCdTxt = sIndex + " 개";
  264. $('#supplyCompCdTxt').html(supplyCompCdTxt);
  265. }
  266. var jsonData = JSON.stringify(arrSupplyCompCd);
  267. $("#searchForm input[name=supplyCompCdList]").val(arrSupplyCompCd.join(','));
  268. }
  269. // 제휴채널 조회 팝업에서 호출
  270. var fnSetAfLinkInfo = function(result) {
  271. var arrAfLinkCd = [];
  272. var afLinkCdTxt = "";
  273. var sIndex = 0;
  274. var afLinkNm = "";
  275. $('#afLinkCdTxt').html('');
  276. $('#searchForm input[name=afLinkCdSearchTxt]').val('');
  277. result.forEach(function(afLink) {
  278. sIndex++;
  279. arrAfLinkCd.push(afLink.afLinkCd);
  280. afLinkNm = afLink.afLinkNm;
  281. });
  282. // 조회 값이 하나일 경우 화면에 코드 노출. 그 외는 갯수 처리
  283. if (sIndex == 1) {
  284. $('#searchForm input[name=afLinkCdSearchTxt]').val(afLinkNm);
  285. } else {
  286. afLinkCdTxt = sIndex + " 개";
  287. $('#afLinkCdTxt').html(afLinkCdTxt);
  288. }
  289. var jsonData = JSON.stringify(arrAfLinkCd);
  290. $("#searchForm input[name=afLinkCdList]").val(arrAfLinkCd.join(","));
  291. }
  292. // 브랜드 조회 팝업에서 호출
  293. var fnSetBrandInfo = function(result) {
  294. var arrBrandCd = [];
  295. var brandCdTxt = "";
  296. var bIndex = 0;
  297. var brandNm = "";
  298. $('#brandCdTxt').html('');
  299. $('#searchForm input[name=brandCdSearchTxt]').val('');
  300. result.forEach(function(brand){
  301. bIndex++;
  302. arrBrandCd.push(brand.brandCd);
  303. brandNm = brand.brandKnm;
  304. });
  305. // 조회 값이 하나일 경우 화면에 코드 노출. 그 외는 갯수 처리
  306. if (bIndex == 1) {
  307. $('#searchForm input[name=brandCdSearchTxt]').val(brandNm);
  308. } else {
  309. brandCdTxt = bIndex + " 개";
  310. $('#brandCdTxt').html(brandCdTxt);
  311. }
  312. var jsonData = JSON.stringify(arrBrandCd);
  313. $("#searchForm input[name=brandCdList]").val(arrBrandCd.join(","));
  314. }
  315. // 품목 조회 팝업에서 호출
  316. var fnSetItemkindInfo = function(result) {
  317. var arrItemkindCd = [];
  318. var itemkindCdTxt = "";
  319. var bIndex = 0;
  320. $('#itemkindCdTxt').html('');
  321. $('#searchForm input[name=itemkindCdSearchTxt]').val('');
  322. result.forEach(function(itemkind){
  323. bIndex++;
  324. arrItemkindCd.push(itemkind.itemkindCd);
  325. });
  326. // 조회 값이 하나일 경우 화면에 코드 노출. 그 외는 갯수 처리
  327. if (bIndex == 1) {
  328. $('#searchForm input[name=itemkindCdSearchTxt]').val(arrItemkindCd[0]);
  329. } else {
  330. itemkindCdTxt = bIndex + " 개";
  331. $('#itemkindCdTxt').html(itemkindCdTxt);
  332. }
  333. var jsonData = JSON.stringify(arrItemkindCd);
  334. $("#searchForm input[name=itemkindCdList]").val(arrItemkindCd.join(','));
  335. }
  336. // 검색
  337. $('#btnSearch').on('click', function() {
  338. // 입력 값 체크
  339. if (!gagajf.validation($('#searchForm')))
  340. return false;
  341. gagaAgGrid.fetch($('#searchForm').prop('action'), gridOptions, '#searchForm', fnCreateTotal);
  342. });
  343. // 합계 생성
  344. let fnCreateTotal = function() {
  345. let totInfo = {};
  346. totInfo.brandCd = 'TOTAL';
  347. totInfo.totAmt = 0;
  348. totInfo.sellQty = 0;
  349. totInfo.selfmallAmt = 0;
  350. totInfo.extmallAmt = 0;
  351. totInfo.cnclAmt = 0;
  352. totInfo.totAmt10 = 0;
  353. totInfo.totAmt20 = 0;
  354. totInfo.yoyRate = 0;
  355. totInfo.yoyTotOrdAmt= 0;
  356. gridOptions.api.forEachNode(function(rowNode, index) {
  357. if (!rowNode.group) {
  358. if( typeof rowNode.data.totAmt == 'number') { totInfo.totAmt += rowNode.data.totAmt ; }
  359. if( typeof rowNode.data.sellQty == 'number') { totInfo.sellQty += rowNode.data.sellQty ; }
  360. if( typeof rowNode.data.selfmallAmt == 'number') { totInfo.selfmallAmt += rowNode.data.selfmallAmt ; }
  361. if( typeof rowNode.data.extmallAmt == 'number') { totInfo.extmallAmt += rowNode.data.extmallAmt ; }
  362. if( typeof rowNode.data.cnclAmt == 'number') { totInfo.cnclAmt += rowNode.data.cnclAmt ; }
  363. if( typeof rowNode.data.totAmt10 == 'number') { totInfo.totAmt10 += rowNode.data.totAmt10 ; }
  364. if( typeof rowNode.data.totAmt20 == 'number') { totInfo.totAmt20 += rowNode.data.totAmt20 ; }
  365. if( typeof rowNode.data.yoyTotOrdAmt== 'number') { totInfo.yoyTotOrdAmt += rowNode.data.yoyTotOrdAmt; }
  366. }
  367. });
  368. /*if(totInfo.totAmt > 0 && totInfo.yoyTotOrdAmt > 0){
  369. totInfo.yoyRate = (totInfo.totAmt / totInfo.yoyTotOrdAmt * 100 - 100).toFixed(1);
  370. }else{
  371. totInfo.yoyRate = 0;
  372. }*/
  373. var mod = 1;
  374. if(totInfo.yoyTotOrdAmt > 0) mod = totInfo.yoyTotOrdAmt;
  375. totInfo.yoyRate = Math.floor(totInfo.totAmt / mod * 100 * 100) / 100;
  376. mod = 1;
  377. if(totInfo.totAmt > 0) mod = totInfo.totAmt;
  378. totInfo.amtRate10 = Math.floor(totInfo.totAmt10 / mod * 100 * 100) / 100;
  379. gagaAgGrid.setPinnedRowData(gridOptions, totInfo, 'top');
  380. }
  381. // 초기화 클릭시
  382. $('#btnInit').on('click', function() {
  383. $('#searchForm')[0].reset();
  384. $('#extmallIdTxt').html('');
  385. $('#searchForm input[name=extmallIdList]').val('');
  386. $('#supplyCompCdTxt').html('');
  387. $('#searchForm input[name=supplyCompCdList]').val('');
  388. $('#afLinkCdTxt').html('');
  389. $('#searchForm input[name=afLinkCdList]').val('');
  390. $('#brandCdTxt').html('');
  391. $('#searchForm input[name=brandCdList]').val('');
  392. $('#itemkindCdTxt').html('');
  393. $('#searchForm input[name=itemkindCdList]').val('');
  394. });
  395. // 엑셀다운로드
  396. $('#btnExcel').on('click', function() {
  397. gagaAgGrid.exportToExcel('일자별주문 목록', gridOptions);
  398. });
  399. $(document).ready(function() {
  400. cfnCreateCalendar('#terms', 'startDt', 'endDt', true, '주문', undefined, ['btnToday']);
  401. $('.btnYesterday').trigger('click');
  402. // Create a agGrid
  403. gagaAgGrid.createGrid('gridList', gridOptions);
  404. });
  405. /*]]>*/
  406. </script>
  407. </html>