GoodsDealForm.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. <!DOCTYPE html>
  2. <html lang="ko"
  3. xmlns:th="http://www.thymeleaf.org">
  4. <!--
  5. *******************************************************************************
  6. * @source : goodsDealForm.html
  7. * @desc : 딜상상품 구성 관리
  8. *============================================================================
  9. * STYLE24
  10. * Copyright(C) 2019 TSIT, All rights reserved.
  11. *============================================================================
  12. * VER DATE AUTHOR DESCRIPTION
  13. * === =========== ========== =============================================
  14. * 1.0 2020.10.29 eskim 최초 작성
  15. *******************************************************************************
  16. -->
  17. <div class="modalPopup" data-width="1100" >
  18. <div class="panelStyle">
  19. <div class="panelTitle">
  20. <h2>딜 상품 구성</h2>
  21. <button type="button" class="close" onclick="fngoodsDealFormClose()"><i class="fa fa-times"></i></button>
  22. </div>
  23. <form id="goodsDealForm" name="goodsDealForm" th:method="post">
  24. <input type="hidden" id="goodsComposeList" name="goodsComposeList" />
  25. <div class="panelContent">
  26. <ul class="notice">
  27. <li>구성상품 등록시 기본값&nbsp;
  28. <!-- 아이콘 툴팁 -->
  29. <div class="iconTooltip">
  30. <i class="fa fa-info" aria-hidden="true"></i>
  31. <span class="left" style="width:450px; text-align:left;">
  32. * 딜상품 정보<br/>
  33. &nbsp;&nbsp;- 상품상태 : 정보부족<br/>
  34. &nbsp;&nbsp;- 정상가 : 판매가 입력값<br/>
  35. &nbsp;&nbsp;- 판매가 : 구성상품의 대표여부 'Y' 상품의 판매가<br/>
  36. &nbsp;&nbsp;- 브랜드코드 : 구성상품의 기준여부 'Y'상품의 브랜드코드<br/>
  37. &nbsp;&nbsp;- 품목코드 : 구성상품의 기준여부 'Y'상품의 품목코드<br/>
  38. &nbsp;&nbsp;- 포인트 : 구성상품의 기준여부 'Y'상품의 브랜드 포인트<br/>
  39. &nbsp;&nbsp;- 배송비정책 : 구성상품의 기준여부 'Y'상품의 브랜드 배송비정책<br/>
  40. <br/>
  41. * 구성상품 정보<br/>
  42. &nbsp;&nbsp;- 구상상품의 기준상품 : 수정 불가<br/>
  43. &nbsp;&nbsp;- 구상상품의 대표상품 : 수정 가능<br/>
  44. </span>
  45. </div>
  46. <!-- //아이콘 툴팁 -->
  47. </li>
  48. </ul>
  49. <table class="frmStyle">
  50. <colgroup>
  51. <col width="10%"/>
  52. <col/>
  53. <col width="10%"/>
  54. <col width="20%"/>
  55. <col width="10%"/>
  56. <col width="24%"/>
  57. </colgroup>
  58. <tr>
  59. <th>상품명<em class="required" title="필수"></em></th>
  60. <td><input type="text" id="goodsNm" name="goodsNm" maxlength="60"/></td>
  61. <th>판매가<em class="required" title="필수"></em></th>
  62. <td><input type="text" class="w100" id="currPrice" name="currPrice" maxlength="8" data-valid-type="numeric"/></td>
  63. <th>제조년월일<em class="required" title="필수"></em></th>
  64. <td><input type="text" class="w100" id="makeYmd" name="makeYmd" maxlength="8" data-valid-type="date"/></td>
  65. </tr>
  66. <tr>
  67. <th>년도/시즌<em class="required" title="필수"></em></th>
  68. <td><select name="styleYear" id="styleYear">
  69. <option value="">[전체]</option>
  70. <option th:if="${styleYearList}" th:each="oneData, status : ${styleYearList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  71. </select>
  72. <select name="seasonCd" id="seasonCd">
  73. <option value="">[전체]</option>
  74. <option th:if="${seasonList}" th:each="oneData, status : ${seasonList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  75. </select>
  76. </td>
  77. <th>성별<em class="required" title="필수"></em></th>
  78. <td><select name="sexGb" id="sexGb">
  79. <option value="">[전체]</option>
  80. <option th:if="${sexGbList}" th:each="oneData, status : ${sexGbList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  81. </select>
  82. </td>
  83. <th>원산지<em class="required" title="필수"></em></th>
  84. <td ><select name="makeOriginCd" id="makeOriginCd">
  85. <option value="">[전체]</option>
  86. <option th:if="${makOriginList}" th:each="oneData, status : ${makOriginList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  87. </select>
  88. <input type="hidden" id="makeNm" name="makeNm" />
  89. </td>
  90. </tr>
  91. </table>
  92. </div>
  93. <ul class="panelBar">
  94. <li class="left">
  95. <button type="button" class="btn btn-danger btn-lg" onclick="fnGoodsDealDeleteRow();">행삭제</button>
  96. </li>
  97. <li class="right">
  98. <button type="button" class="btn btnRight btn-default btn-lg" onclick="cfnDownloadSampleFile('SF003');">상품엑셀조회 양식 다운로드</button>
  99. <button type="button" class="btn btnRight btn-success btn-lg" id="btnGoodsDealSearchExcel" >엑셀조회</button>
  100. <button type="button" class="btn btnRight btn-base btn-lg" onclick="fnOpenGoodsDealPopup();">구상상품추가</button>
  101. </li>
  102. </ul>
  103. <div id="gridGoodsDealList" style="height: 450px;" class="ag-theme-balham lh60"></div>
  104. </form>
  105. <ul class="panelBar">
  106. <li class="right">
  107. <th:block th:if="${sessionInfo.roleCd == 'G001_0000' OR sessionInfo.roleCd == 'G001_A000' OR sessionInfo.roleCd == 'G001_A101' OR sessionInfo.roleCd == 'G001_A100' OR sessionInfo.roleCd == 'G001_A001'}">
  108. <button type="button" class="btn btnRight btn-success btn-lg" id="btnGoodsDealSave">저장</button>
  109. </th:block>
  110. </li>
  111. </ul>
  112. </div>
  113. </div>
  114. <script th:inline="javascript">
  115. /*<![CDATA[*/
  116. var useYnList = gagajf.convertToArray([[${useYnList}]]);
  117. var goodsStatList = gagajf.convertToArray([[${goodsStatList}]]);
  118. // specify the columns
  119. var columnGoodsDealDefs = [
  120. {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  121. {headerName: "CRUD", field: "crud", width: 75, minWidth: 75, hide: true},
  122. {headerName: "정렬", field: "dispOrd", width: 70 ,hide: false, cellClass: 'text-center', rowDrag: true },
  123. //{headerName: 'No', width: 60, cellClass: 'text-center', valueGetter: function(params) { return params.node.rowIndex + 1 }},
  124. {headerName: "이미지", field: "sysImgNm", width: 100, height: 60, cellClass: 'text-center'
  125. ,cellRenderer: function(params) {
  126. return '<img width="60" src="'+ _goodsUrl+ "/" + params.value + '" alt="" onerror="this.src=\'/image/no.gif\';"/>';
  127. }
  128. },
  129. {headerName: "구성상품코드", field: "compsGoodsCd" , width: 130, cellClass: 'text-center'},
  130. {headerName: "옵션명", field: "compsGoodsOptNm" , width: 250, cellClass: 'text-left',editable: true, required: true},
  131. {headerName: "판매가", field: "currPrice" , width: 100, cellClass: 'text-right'
  132. ,valueFormatter: function(params) {return params.value.addComma();}
  133. },
  134. {headerName: "기준여부(품목/전시카테)", field: "baseYn" , width: 170, cellClass: 'text-center',editable: true, required: true,
  135. cellEditor: 'agRichSelectCellEditor',
  136. cellEditorParams: { values: gagaAgGrid.extractValues(useYnList) },
  137. valueFormatter: function (params) { return gagaAgGrid.lookupValue(useYnList, params.value); },
  138. valueParser: function (params) { return gagaAgGrid.lookupKey(useYnList, params.newValue); }
  139. },
  140. {headerName: "대표여부(가격)", field: "repYn" , width: 120, cellClass: 'text-center',editable: true, required: true,
  141. cellEditor: 'agRichSelectCellEditor',
  142. cellEditorParams: { values: gagaAgGrid.extractValues(useYnList) },
  143. valueFormatter: function (params) { return gagaAgGrid.lookupValue(useYnList, params.value); },
  144. valueParser: function (params) { return gagaAgGrid.lookupKey(useYnList, params.newValue); }
  145. },
  146. {headerName: "전시여부", field: "useYn" , width: 80, cellClass: 'text-center',editable: true, required: true,
  147. cellEditor: 'agRichSelectCellEditor',
  148. cellEditorParams: { values: gagaAgGrid.extractValues(useYnList) },
  149. valueFormatter: function (params) { return gagaAgGrid.lookupValue(useYnList, params.value); },
  150. valueParser: function (params) { return gagaAgGrid.lookupKey(useYnList, params.newValue); }
  151. },
  152. {headerName: "상품상태", field: "goodsStat" , width: 100, cellClass: 'text-center',
  153. cellEditorParams: { values: gagaAgGrid.extractValues(goodsStatList) },
  154. valueFormatter: function (params) { return gagaAgGrid.lookupValue(goodsStatList, params.value); },
  155. valueParser: function (params) { return gagaAgGrid.lookupKey(goodsStatList, params.newValue); }
  156. },
  157. {headerName: "수량", field: "qty" , width: 80, cellClass: 'text-right',hide:true}
  158. ];
  159. // Get GridOptions
  160. var gridGoodsDealOptions = gagaAgGrid.getGridOptions(columnGoodsDealDefs);
  161. gridGoodsDealOptions.rowSelection = 'multiple';
  162. gridGoodsDealOptions.suppressRowClickSelection = true;
  163. gridGoodsDealOptions.stopEditingWhenGridLosesFocus = true; //그리드 에디터 값 저장가능
  164. // 드래그
  165. gridGoodsDealOptions.rowDragManaged = true;
  166. gridGoodsDealOptions.rowHeight = 60; //이미지가 있을경우 높이 지정해야함.
  167. //기준여부 표시
  168. gridGoodsDealOptions.getRowStyle = function(params) {
  169. if ("Y" == params.data.baseYn) {
  170. return { background: '#1ab394' };
  171. }else{
  172. return { background: '#ffffff' };
  173. }
  174. }
  175. // Row
  176. gridGoodsDealOptions.onCellValueChanged = function(event) {
  177. var rowIdx = null;
  178. var isChangColor = true;
  179. if (event.colDef.field == "baseYn"){
  180. if (event.data.baseYn == "Y"){
  181. rowIdx = event.rowIndex;
  182. //다른 기준여부 'Y'가 존재하는지 확인
  183. gridGoodsDealOptions.api.forEachNode(function(rowNode, index) {
  184. if (rowNode.data.baseYn == "Y" && index != rowIdx){
  185. event.data.baseYn = event.oldValue;
  186. gridGoodsDealOptions.api.updateRowData({update: [event.data]});
  187. isChangColor = false;
  188. return;
  189. }
  190. });
  191. if (!isChangColor){
  192. mcxDialog.alert('다른 구성상품에 기준여부가 선택되어 있습니다.');
  193. return;
  194. }
  195. }
  196. }
  197. isChangColor = true;
  198. if (event.colDef.field == "repYn"){
  199. if (event.data.repYn == "Y"){
  200. rowIdx = event.rowIndex;
  201. //다른 대표여부 'Y'가 존재하는지 확인
  202. gridGoodsDealOptions.api.forEachNode(function(rowNode, index) {
  203. if (rowNode.data.repYn == "Y" && index != rowIdx){
  204. event.data.repYn = event.oldValue;
  205. gridGoodsDealOptions.api.updateRowData({update: [event.data]});
  206. isChangColor = false;
  207. return;
  208. }
  209. });
  210. if (!isChangColor){
  211. mcxDialog.alert('다른 구성상품에 대표여부가 선택되어 있습니다.');
  212. return;
  213. }
  214. }
  215. }
  216. }
  217. //창종료
  218. var fngoodsDealFormClose = function(){
  219. uifnPopupClose('popupGoodsDeal');
  220. }
  221. $(document).ready(function() {
  222. gagaAgGrid.createGrid('gridGoodsDealList', gridGoodsDealOptions);
  223. });
  224. var fnOpenGoodsDealPopup = function() {
  225. cfnOpenGoodsPopup('fnCreateGoodsDeal');
  226. }
  227. // 상품추가
  228. var fnCreateGoodsDeal = function(goodsData) {
  229. if (goodsData.length < 1) return;
  230. // 기존상품
  231. var oldGoodsDealList = gagaAgGrid.getAllRowData(gridGoodsDealOptions);
  232. var idx = oldGoodsDealList.length+1;
  233. var isExist = false;
  234. goodsData.forEach(function(goods){
  235. isExist = false;
  236. gridGoodsDealOptions.api.forEachNode(function(rowNode, index) {
  237. if (goods.goodsCd == rowNode.data.compsGoodsCd){
  238. isExist = true;
  239. }
  240. });
  241. if (goods.goodsType != "G056_N"){
  242. isExist = true;
  243. }
  244. if(!isExist){
  245. var data = {
  246. compsGoodsCd: goods.goodsCd
  247. , goodsType: 'G056_D'
  248. , dispOrd: idx
  249. , qty: 1
  250. , compsCurrPrice: goods.currPrice
  251. , compsStaffCurrPrice: goods.currPrice
  252. , baseYn: 'N'
  253. , repYn: 'N'
  254. , goodsStat : goods.goodsStat
  255. , useYn: 'Y'
  256. , compsGoodsOptNm : goods.goodsNm
  257. , currPrice : goods.currPrice
  258. , selfGoodsYn : goods.selfGoodsYn
  259. , sysImgNm : goods.sysImgNm
  260. };
  261. //그리드 마지막에 추가해야함
  262. gridGoodsDealOptions.api.updateRowData({add: [data], addIndex: idx});
  263. idx++;
  264. }
  265. });
  266. gridGoodsDealOptions.api.refreshCells();
  267. }
  268. //엑셀 상품 조회
  269. $('#btnGoodsDealSearchExcel').on('click', function() {
  270. cfnExcelUploadPopup('goodsDealExcelUpload', 'goodsDealExcelUpload');
  271. });
  272. var goodsDealExcelUpload = function(result){
  273. var data = {procJob : result.procJob
  274. ,excelFileNm : result.excelFileNm
  275. };
  276. var jsonData = JSON.stringify(data);
  277. gagajf.ajaxJsonSubmit('/goods/search/excelupload/save', jsonData, fnGoodsDealExcelUploadCallBack);
  278. }
  279. var fnGoodsDealExcelUploadCallBack = function(result){
  280. gagajf.ajaxJsonSubmit('/goods/excel/upload/goods/list', '', fnExcelSearchCallBack);
  281. }
  282. var fnExcelSearchCallBack = function(result){
  283. fnCreateGoodsDeal(result.goodsExcelList);
  284. }
  285. // 저장클릭시
  286. $('#btnGoodsDealSave').on('click', function() {
  287. if(!fnGoodsDealConditionCheck()) return;
  288. mcxDialog.confirm('딜상품을 등록 하시겠습니까?', {
  289. cancelBtnText: "취소",
  290. sureBtnText: "확인",
  291. sureBtnClick: function(){
  292. var goodsComposeList = gagaAgGrid.getAllRowData(gridGoodsDealOptions);
  293. $("#goodsDealForm input[name=goodsComposeList]").val(JSON.stringify(goodsComposeList));
  294. gagajf.ajaxFormSubmit("/goods/deal/save", "#goodsDealForm", fngoodsDealFormClose);
  295. }
  296. });
  297. });
  298. //저장 조건 확인
  299. var fnGoodsDealConditionCheck = function(){
  300. var optCheck = false;
  301. if(gagajf.isNull($("#goodsDealForm input[name=goodsNm]").val())){
  302. mcxDialog.alertC('상품명을 입력해 주세요.', {
  303. sureBtnText: "확인",
  304. sureBtnClick: function() {
  305. $("#goodsDealForm input[name=goodsNm]").focus();
  306. }
  307. });
  308. return false;
  309. }
  310. if(gagajf.isNull($("#goodsDealForm input[name=currPrice]").val())){
  311. mcxDialog.alertC('판매가를 입력해 주세요.', {
  312. sureBtnText: "확인",
  313. sureBtnClick: function() {
  314. $("#goodsDealForm input[name=currPrice]").focus();
  315. }
  316. });
  317. return false;
  318. }
  319. if(Number($("#goodsDealForm input[name=currPrice]").val()) <= 0){
  320. mcxDialog.alertC('판매가를 바르게 입력해 주세요.', {
  321. sureBtnText: "확인",
  322. sureBtnClick: function() {
  323. $("#goodsDealForm input[name=currPrice]").focus();
  324. }
  325. });
  326. return false;
  327. }
  328. if(gagajf.isNull($("#goodsDealForm select[name=styleYear]").val())){
  329. mcxDialog.alertC('년도을 선택해 주세요.', {
  330. sureBtnText: "확인",
  331. sureBtnClick: function() {
  332. $("#goodsDealForm select[name=styleYear]").focus();
  333. }
  334. });
  335. return false;
  336. }
  337. if(gagajf.isNull($("#goodsDealForm select[name=seasonCd]").val())){
  338. mcxDialog.alertC('시즌을 선택해주세요.', {
  339. sureBtnText: "확인",
  340. sureBtnClick: function() {
  341. $("#goodsDealForm select[name=seasonCd]").focus();
  342. }
  343. });
  344. return false;
  345. }
  346. if(gagajf.isNull($("#goodsDealForm select[name=sexGb]").val())){
  347. mcxDialog.alertC('성별을 선택해주세요.', {
  348. sureBtnText: "확인",
  349. sureBtnClick: function() {
  350. $("#goodsDealForm select[name=sexGb]").focus();
  351. }
  352. });
  353. return false;
  354. }
  355. if(gagajf.isNull($("#goodsDealForm select[name=makeOriginCd]").val())){
  356. mcxDialog.alertC('원산지를 입력해 주세요.', {
  357. sureBtnText: "확인",
  358. sureBtnClick: function() {
  359. $("#goodsDealForm select[name=makeOriginCd]").focus();
  360. }
  361. });
  362. return false;
  363. }
  364. var makeYmd = $("#goodsDealForm input[name=makeYmd]").val();
  365. if(gagajf.isNull(makeYmd)){
  366. mcxDialog.alertC('제조년월일를 입력해 주세요.', {
  367. sureBtnText: "확인",
  368. sureBtnClick: function() {
  369. $("#goodsDealForm input[name=makeYmd]").focus();
  370. }
  371. });
  372. return;
  373. }
  374. if(makeYmd.length < 8){
  375. mcxDialog.alertC('제조년월일를 바르게 주세요.', {
  376. sureBtnText: "확인",
  377. sureBtnClick: function() {
  378. $("#goodsDealForm input[name=makeYmd]").focus();
  379. }
  380. });
  381. return false;
  382. }
  383. if(isNaN(Date.parse(makeYmd.substr(0, 4) +'-'+ makeYmd.substr(4, 2) +'-'+ makeYmd.substr(6, 2)))){
  384. mcxDialog.alertC('날짜형식이 아닙니다.', {
  385. sureBtnText: "확인",
  386. sureBtnClick: function() {
  387. $("#goodsDealForm input[name=makeYmd]").focus();
  388. }
  389. });
  390. return false;
  391. }
  392. var allData = gagaAgGrid.getAllRowData(gridGoodsDealOptions);
  393. // Validation
  394. if (!gagaAgGrid.validation(gridGoodsDealOptions, allData))
  395. return false;
  396. var comSupplyCompCd = '';
  397. var comSelfGoodsYn = '';
  398. //기준여부 Y 존재하는지 확인
  399. var checkBaseYn = false;
  400. //대표여부 Y 존재하는지 확인
  401. var checkRepYn = false;
  402. optCheck = false;
  403. $.each(allData, function(index, item) {
  404. if (index == 0){
  405. comSelfGoodsYn = item.selfGoodsYn;
  406. comSupplyCompCd = item.supplyCompCd;
  407. }
  408. if (item.baseYn == "Y"){
  409. checkBaseYn = true;
  410. }
  411. if (item.repYn == "Y"){
  412. checkRepYn = true;
  413. }
  414. if(item.goodsStat != "G008_90"){
  415. optCheck = true;
  416. mcxDialog.alertC("상품상태를 확인해 주세요.", {
  417. sureBtnText: "확인",
  418. sureBtnClick: function() {
  419. gridGoodsDealOptions.api.setFocusedCell(index, "goodsStat", null);
  420. }
  421. });
  422. return false;
  423. }
  424. if(Number(item.qty) <= 0){
  425. optCheck = true;
  426. mcxDialog.alertC("수량을 입력해 주세요.", {
  427. sureBtnText: "확인",
  428. sureBtnClick: function() {
  429. gridGoodsDealOptions.api.setFocusedCell(index, "qty", null);
  430. }
  431. });
  432. return false;
  433. }
  434. if (comSelfGoodsYn != item.selfGoodsYn){
  435. optCheck = true;
  436. mcxDialog.alertC("구상상품중 자사/입점상품 구분값이 다릅니다.\n확인해 주세요", {
  437. sureBtnText: "확인",
  438. sureBtnClick: function() {
  439. gridGoodsDealOptions.api.setFocusedCell(index, "goodsCd", null);
  440. }
  441. });
  442. return false;
  443. }else{
  444. if (comSelfGoodsYn == "N" && (comSupplyCompCd != item.supplyCompCd)){
  445. optCheck = true;
  446. mcxDialog.alertC("구상상품중 입점은 같은 업체 상품만 가능합니다.\n확인해 주세요", {
  447. sureBtnText: "확인",
  448. sureBtnClick: function() {
  449. gridGoodsDealOptions.api.setFocusedCell(index, "goodsCd", null);
  450. }
  451. });
  452. return false;
  453. }
  454. }
  455. });
  456. if(optCheck) {
  457. return false;
  458. }
  459. if (!checkBaseYn){
  460. mcxDialog.alert('구성상품중 기준여부를 선택해 주세요.');
  461. return false;
  462. }
  463. if (!checkRepYn){
  464. mcxDialog.alert('구성상품중 대표여부를 선택해 주세요.');
  465. return false;
  466. }
  467. return true;
  468. }
  469. //상품삭제
  470. var fnGoodsDealDeleteRow = function() {
  471. var selectedData = gagaAgGrid.selectedRowData(gridGoodsDealOptions);
  472. if (selectedData.length == 0) {
  473. mcxDialog.alert('선택된 행이 없습니다.');
  474. return;
  475. }
  476. //화면에서 삭제
  477. var removedData = gagaAgGrid.removeRowData(gridGoodsDealOptions, false);
  478. }
  479. /*]]>*/
  480. </script>
  481. </html>