GoodsSetForm.html 18 KB

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