GoodsSetForm.html 17 KB

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