GoodsSetForm.html 18 KB

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