ShoplinkerGoodsSendForm.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <!DOCTYPE html>
  2. <html lang="ko"
  3. xmlns:th="http://www.thymeleaf.org">
  4. <!--
  5. *******************************************************************************
  6. * @source : ShoplinkerGoodsSendForm.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.05.20 jmh 최초 작성
  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. <form id="searchForm" name="searchForm" action="#" th:action="@{'/shoplinker/goods/send/list'}" onsubmit="$('#btnSearch').trigger('click'); return false;">
  27. <!-- 검색조건 영역 -->
  28. <div class="panelStyle">
  29. <div class="panelTitle">
  30. <h3><i class="fa fa-info-circle"></i>아래 검색조건 중 상품코드나 등록일을 꼭 입력해 주세요.</h3>
  31. <span class="panelControl">
  32. <i class="fa fa-chevron-up"></i>
  33. </span>
  34. </div>
  35. <div class="panelContent">
  36. <table class="frmStyle">
  37. <colgroup>
  38. <col style="width: 8%;"/>
  39. <col style="width: 18%;"/>
  40. <col style="width: 8%;"/>
  41. <col style="width: 18%;"/>
  42. <col style="width: 8%;"/>
  43. <col style="width: 19%;"/>
  44. <col style="width: 8%;"/>
  45. <col style="width: 13%;"/>
  46. </colgroup>
  47. <tr>
  48. <th>전송일자<em class="required" title="필수"></em></th>
  49. <td colspan="5" id="sellTerms"></td>
  50. <th rowspan="2">상품코드<em class="required" title="필수"></em></th>
  51. <td rowspan="2">
  52. <textarea class="textareaR2 w90p" name="condition" id="condition"></textarea>
  53. </td>
  54. </tr>
  55. <tr>
  56. <th>브랜드</th>
  57. <td>
  58. <input type="text" class="w100" name="searchTxt" id="searchTxt" maxlength="20" />
  59. <button type="button" class="btn icn" id="btnSearchBrand"><i class="fa fa-search"></i></button>
  60. <!-- <input type="text" class="w100" name="brandCd" readonly="readonly"/> -->
  61. <span id="brandText"></span>
  62. <input type="hidden" name="brandList"/>
  63. </td>
  64. <th>API구분</th>
  65. <td>
  66. <select name="apiType" id="apiType" required="required" data-valid-name="API구분">
  67. <option value="">[전체]</option>
  68. <option value="OPTION">단품</option>
  69. <option value="PRODUCT">상품</option>
  70. <option value="NOTI">품목(고시)</option>
  71. <option value="CERT">인증</option>
  72. <option value="IMAGE">이미지</option>
  73. </select>
  74. </td>
  75. <th>IF결과</th>
  76. <td>
  77. <select name="apiResult" id="apiResult">
  78. <option value="">[전체]</option>
  79. <option value="true">전송완료</option>
  80. <option value="false">전송실패</option>
  81. <option value="error">오류</option>
  82. </select>
  83. </td>
  84. </tr>
  85. </table>
  86. <ul class="panelBar">
  87. <li class="center">
  88. <button type="button" class="btn btn-base btn-lg" id="btnSearch">조회</button>
  89. <button type="button" class="btn btn-gray btn-lg" id="btnInit">초기화</button>
  90. <button type="button" class="btn btn-primary btn-lg" id="btnGoodsUpload">엑셀업로드</button>
  91. <button type="button" class="btn btn-primary btn-lg" id="btnGoodsPlanning">샵링커기획전생성엑셀</button>
  92. <!-- <button th:if="${sessionInfo.userId == 'jmh'}" type="button" class="btn btn-default btn-lg" onclick="fnTest();">테스트</button> -->
  93. </li>
  94. </ul>
  95. <p class="dot">엑셀업로드시 한번에 최대 500개까지 가능합니다.</p>
  96. <p class="dot">업로드 후 약 10분 이상 작업소요시간이 걸릴 수 있습니다.</p>
  97. </div>
  98. </div>
  99. <!-- 검색조건 영역 -->
  100. <!-- 리스트 영역 -->
  101. <div class="panelStyle">
  102. <ul class="panelBar">
  103. <li>
  104. <button type="button" class="btn btn-default btn-lg" onclick="cfnDownloadSampleFile('SF003');">엑셀업로드 양식 다운로드</button>
  105. <button type="button" class="btn btn-default btn-lg" onclick="fnExcelDownLoad();">엑셀다운로드</button>
  106. </li>
  107. <li class="right">
  108. 검색결과 : <strong><span id="gridRowTotalCount">0</span> 건</strong>&nbsp;
  109. 쪽번호 <span id="pgNo">0</span>/ <strong id="endPgNo">0</strong>&nbsp;&nbsp;
  110. <select id="pageSize" name="pageSize">
  111. <option value="50" selected="selected">50개씩 보기</option>
  112. <option value="100">100개씩 보기</option>
  113. <option value="500">500개씩 보기</option>
  114. <option value="1000">1000개씩 보기</option>
  115. </select>
  116. <input type="hidden" name="pageNo" id="pageNo" value ="1"/>
  117. </li>
  118. </ul>
  119. <div id="gridList" style="width: 100%; height: 470px" class="ag-theme-balham"></div>
  120. <ul class="panelBar">
  121. <li class="center">
  122. <div class="tablePaging" id="goodsListPagination"></div>
  123. </li>
  124. </ul>
  125. </div>
  126. <!-- //리스트 영역 -->
  127. <a href="javascript:void(0);" id="ExcelList" style="display: none;">엑셀다운로드</a>
  128. </form>
  129. </div>
  130. <script type="text/javascript" src="/ux/plugins/gaga/gaga.paging.js?v=20210114"></script>
  131. <script th:inline="javascript">
  132. /*<![CDATA[*/
  133. var sessRoleCd = [[${sessionInfo.roleCd}]];
  134. var apiTypeValue = {"OPTION":"단품", "PRODUCT":"상품", "NOTI":"품목(고시)", "CERT":"인증", "IMAGE":"이미지" };
  135. var procGbValue = {"true":"전송완료", "false":"전송실패", "error":"오류"};
  136. let columnDefs1 = [
  137. {headerName: "No", width: 60, cellClass: 'text-center',
  138. valueGetter: function(params) { return cfnGridNumner('searchForm',params.node.rowIndex, 'A');}
  139. },
  140. {headerName: "샵링커 상품코드", field: "apiProductId", width: 130, cellClass: 'text-center'},
  141. {
  142. headerName: "API구분", field: "apiType", width: 100, cellClass: 'text-center',
  143. valueFormatter: function (params) { return gagaAgGrid.lookupValue(apiTypeValue, params.value); }
  144. },
  145. {headerName: "IF결과", field: "apiResult", width: 100, cellClass: 'text-center',
  146. valueFormatter: function (params) { return gagaAgGrid.lookupValue(procGbValue, params.value); }
  147. },
  148. {
  149. headerName: "IF결과메세지", field: "apiMessage", width: 300, cellClass: 'text-left',
  150. cellRenderer: function (params) { return params.value}
  151. },
  152. {headerName: "자사 상품코드", field: "goodsCd", width: 150, cellClass: 'text-center'},
  153. {headerName: "옵션코드", field: "optCd", width: 150, cellClass: 'text-center'},
  154. {headerName: "상품명", field: "goodsNm", width: 300, cellClass: 'text-left'
  155. ,cellRenderer: function(params) {
  156. return '<a href="javascript:void(0);">' + params.value + '</a>';
  157. }
  158. },
  159. {
  160. headerName: "미리보기", field:"preview", width: 100, cellClass: 'text-center',
  161. cellRenderer: function(params) {
  162. if("PRODUCT" == params.data.apiType){
  163. return '<button="javascript:void(0);" class="btn btn-info btn-sm">미리보기</button>';
  164. }else{
  165. return "";
  166. }
  167. }
  168. },
  169. {headerName: "등록자", field: "regNm", width: 100, cellClass: 'text-center'},
  170. {
  171. headerName: "전송일자", field: "regDt", width: 150, cellClass: 'text-center',
  172. cellRenderer: function (params) { return gagaAgGrid.toDateTimeFormat(params.value); }
  173. }
  174. ];
  175. let gridOptions = gagaAgGrid.getGridOptions(columnDefs1);
  176. // Row Click
  177. gridOptions.onCellClicked = function(event) {
  178. var goodsCd = event.data.goodsCd;
  179. if (event.colDef.field == "goodsNm"){
  180. cfnOpenGoodsDetailPopup('U',goodsCd);
  181. }else if (event.colDef.field == "goodsCd"){
  182. //cfnOpenFrontGoodsPopup(goodsCd, event.data.siteCd);
  183. }else if (event.colDef.field == 'preview') {
  184. // 미리보기 팝업
  185. if( "PRODUCT" == event.data.apiType){
  186. fnOpenPreviewPopup(event.data.logSq);
  187. }
  188. }
  189. }
  190. //페이징
  191. $('#searchForm select[name=pageSize]').on('change', function() {
  192. $("#searchForm input[name=pageNo]").val('1');
  193. fnGoodsListSearch();
  194. });
  195. // 브랜드 조회 선택시
  196. $('#btnSearchBrand').on('click', function() {
  197. cfnOpenBrandListPopup('fnSetBrandInfo', 'M');
  198. });
  199. // 브랜드 조회 팝업에서 호출
  200. var fnSetBrandInfo = function(result) {
  201. var arrbrandCd = [];
  202. var brandText = "";
  203. var bIndex = 0;
  204. var brandNm = "";
  205. $('#searchForm').find('#brandText').html('');
  206. $('#searchForm input[name=searchTxt]').val('');
  207. result.forEach(function(brand){
  208. bIndex++;
  209. arrbrandCd.push(brand.brandCd);
  210. brandNm = brand.brandKnm;
  211. });
  212. // 조회값이 하나일 경우 화면에 코드 노출 그외는 갯수 처리
  213. if (bIndex == 1) {
  214. $('#searchForm input[name=searchTxt]').val(brandNm);
  215. }else{
  216. brandText = bIndex + " 개";
  217. $('#searchForm').find('#brandText').html(brandText);
  218. }
  219. var jsonData = JSON.stringify(arrbrandCd);
  220. $("#searchForm input[name=brandList]").val(jsonData);
  221. }
  222. /**************** 검색 ********************************************************/
  223. $('#btnSearch').on('click', function() {
  224. $("#searchForm input[name=pageNo]").val('1');
  225. fnGoodsListSearch();
  226. });
  227. // 조회
  228. var fnGoodsListSearch = function() {
  229. if(!fnConditionCheck()) return;
  230. gagaPaging.init('searchForm', fnSearchCallBack, 'goodsListPagination', $('#searchForm').find('#pageSize').val());
  231. gagaPaging.load($("#searchForm input[name=pageNo]").val());
  232. }
  233. //검색 조건 확인
  234. var fnConditionCheck = function(){
  235. var formId = '#searchForm';
  236. var form = document.searchForm;
  237. if (event.keyCode === 13) return false;
  238. var searchFlag = false;
  239. var cnt = 0;
  240. if( !gagajf.isNull($("#searchForm textarea[name=condition]").val())
  241. || (!gagajf.isNull($("#searchForm input[name=stDate]").val()) && !gagajf.isNull($("#searchForm input[name=edDate]").val()))
  242. ){
  243. searchFlag = true;
  244. }else{
  245. /* for (i = 0; i < form.elements.length; i++ ) {
  246. var el = form.elements[i];
  247. if ($(el).prop("type") == "text" || ($(el).prop("type") == "select-one" && el.name != "search" && el.name != "pageSize")) {
  248. if (!(el.value == null || el.value == "")) {
  249. cnt++;
  250. }
  251. }
  252. }
  253. if(cnt > 0) searchFlag = true; */
  254. }
  255. if(searchFlag == false){
  256. mcxDialog.alert("검색조건을 입력하세요.");
  257. return false;
  258. }
  259. var fromDate = $('#searchForm input[name=stDate]').val();
  260. var toDate = $('#searchForm input[name=edDate]').val();
  261. if (!gagajf.isNull(fromDate) || !gagajf.isNull(toDate)) {
  262. if (gagajf.isNull(fromDate) || gagajf.isNull(toDate)) {
  263. mcxDialog.alertC("등록일 조회시 시작일자와 종료일자를 입력하세요.", {
  264. sureBtnText: "확인",
  265. sureBtnClick: function() {
  266. $('#searchForm input[name=stDate]').focus();
  267. }
  268. });
  269. return false;
  270. }
  271. if (fromDate > toDate) {
  272. mcxDialog.alertC("등록 시작일자는 종료일자 보다 클 수 없습니다.", {
  273. sureBtnText: "확인",
  274. sureBtnClick: function() {
  275. $('#searchForm input[name=stDate]').focus();
  276. }
  277. });
  278. return false;
  279. }
  280. }
  281. return true;
  282. }
  283. var fnSearchCallBack = function(result){
  284. $('#searchForm').find('#gridRowTotalCount').html(result.pageing.pageable.totalCount.addComma());
  285. $('#searchForm').find('#pageNo').val(result.pageing.pageable.pageNo.addComma());
  286. $('#searchForm').find('#pgNo').html(result.pageing.pageable.pageNo.addComma());
  287. $('#searchForm').find('#endPgNo').html(result.pageing.pageable.totalPage.addComma());
  288. gridOptions.api.setRowData(result.goodsList);
  289. gagaPaging.createPagination(result.pageing.pageable);
  290. }
  291. /**************** 검색 // *****************************************************/
  292. /**************** 초기화 클릭시 *****************************************************/
  293. $('#btnInit').on('click', function() {
  294. $('#searchForm')[0].reset();
  295. $("#multiBrand").empty();
  296. $('#searchForm input[name=brandList]').val('');
  297. $('#searchForm').find('#brandText').html('');
  298. });
  299. /**************** 초기화 클릭시 // *****************************************************/
  300. /**************** 엑셀업로드 ********************************************************/
  301. $('#btnGoodsUpload').on('click', function() {
  302. var jsonData = JSON.stringify({apiType : "GOODS"});
  303. gagajf.ajaxJsonSubmit('/shoplinker/check/api_runable', jsonData, function(result) {
  304. // 현재실행중인건 없음.
  305. if( 0 == result.runCnt){
  306. cfnExcelUploadPopup('shoplinkerUploadGoods', 'shoplinkerUploadGoods');
  307. }else{
  308. mcxDialog.alert(result.runStdt+"에 호출한 건이 현재 실행중입니다.");
  309. }
  310. });
  311. });
  312. var shoplinkerUploadGoods = function(result){
  313. var dateStr = new Date().format("YYYYMMDDHHmmss");
  314. var actionUrl = "/shoplinker/goods/send/excelupload/register";
  315. let params = {};
  316. params.procJob = result.procJob;
  317. params.excelFileNm = result.excelFileNm;
  318. params.sid = dateStr;
  319. // 수량체크 로직 추가(500개 초과시 알림창 표시위함)
  320. var jsonData = JSON.stringify(params);
  321. gagajf.ajaxJsonSubmit(actionUrl+'/chk', jsonData, function(result2) {
  322. // post 전송
  323. $.post(actionUrl, $.param(params));
  324. });
  325. }
  326. /**************** 엑셀업로드 // *****************************************************/
  327. /**************** 엑셀다운로드 *****************************************************/
  328. var fnExcelDownLoad = function(){
  329. var formId = '#searchForm';
  330. if (gridOptions.api.getDisplayedRowCount() <= 0){
  331. mcxDialog.alert("조회된 데이터가 없습니다.<br/>다시 조회 후 다운로드 받으세요.");
  332. return;
  333. }
  334. var params = $(formId).serialize();
  335. $('#ExcelList').attr({ href : '/shoplinker/goods/excel/list?' + params }).get(0).click();
  336. }
  337. /**************** 엑셀다운로드 // *****************************************************/
  338. /**************** 샵링커기획전생성엑셀 *****************************************************/
  339. $('#btnGoodsPlanning').on('click', function() {
  340. var formId = '#searchForm';
  341. if (gagajf.isNull($("#searchForm textarea[name=condition]").val()) ){
  342. mcxDialog.alertC("상품 코드를 입력하세요", {
  343. sureBtnText: "확인",
  344. sureBtnClick: function() {
  345. $("#searchForm textarea[name=condition]").focus();
  346. }
  347. });
  348. return false;
  349. }
  350. var params = $(formId).serialize();
  351. $('#ExcelList').attr({ href : '/shoplinker/goods/excel/planning?' + params }).get(0).click();
  352. });
  353. /**************** 샵링커기획전생성엑셀 // *****************************************************/
  354. /**************** 미리보기 *****************************************************/
  355. var fnOpenPreviewPopup = function(logSq) {
  356. var actionUrl = '/shoplinker/goods/preview/form/' + logSq;
  357. cfOpenWindowPopup(actionUrl, 'popupShoplinkerTemplatePreview', 1200, 700);
  358. }
  359. /**************** 미리보기 // *****************************************************/
  360. /**************** 테스트용 *******************************************************/
  361. // 테스트- 실제 샵링커 호출
  362. var fnTest = function(){
  363. var data = {procJob : "1"
  364. ,excelFileNm : "2"
  365. };
  366. var jsonData = JSON.stringify(data);
  367. gagajf.ajaxJsonSubmit('/shoplinker/apiTest2', jsonData, null);
  368. }
  369. /**************** 테스트용 // *****************************************************/
  370. $(document).ready(function() {
  371. cfnCreateCalendar('#sellTerms', 'stDate', 'edDate', true, '등록일', 'X');
  372. $('.btnToday').trigger('click');
  373. // Create a agGrid
  374. gagaAgGrid.createGrid('gridList', gridOptions);
  375. });
  376. /*]]>*/
  377. </script>
  378. </html>