GoodsPriceReservePopupForm.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <!DOCTYPE html>
  2. <html lang="ko"
  3. xmlns:th="http://www.thymeleaf.org">
  4. <!--
  5. *******************************************************************************
  6. * @source : GoodsPriceReservePopupForm.html
  7. * @desc : 상품 가격 예약등록 화면
  8. *============================================================================
  9. * STYLE24
  10. * Copyright(C) 2020 TSIT, All rights reserved.
  11. *============================================================================
  12. * VER DATE AUTHOR DESCRIPTION
  13. * === =========== ========== =============================================
  14. * 1.0 2020.11.13 eskim 최초 작성
  15. *******************************************************************************
  16. -->
  17. <div class="modalPopup" data-width="850" >
  18. <div class="panelStyle">
  19. <div class="panelTitle">
  20. <h2>상품가격예약</h2>
  21. <button type="button" class="close" onclick="uifnPopupClose('popupGoodsPriceReserve')"><i class="fa fa-times"></i></button>
  22. </div>
  23. <form id="goodsPriceRsvtForm" name="goodsPriceRsvtForm" >
  24. <div class="panelContent">
  25. <table class="frmStyle">
  26. <colgroup>
  27. <col style="width:10%;"/>
  28. <col style="width:20%;"/>
  29. <col style="width:10%;"/>
  30. <col/>
  31. </colgroup>
  32. <tr>
  33. <th>상품예약가격<em class="required" title="필수"></em></th>
  34. <td><input type="text" class="w100p aR" id="resGoodsPrice" name="resGoodsPrice" maxlength="10" data-valid-type="numeric" /></td>
  35. <th>예약일시<em class="required" title="필수"></em></th>
  36. <td>
  37. <input name="applyStYMD" id="applyStYMD" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="예약시작일" />
  38. <select name="applyStHH" id="applyStHH" required="required" data-valid-name="예약 시작시간">
  39. <th:block th:each="num, index : ${#numbers.sequence(0,23)}">
  40. <option th:value="${#numbers.formatInteger(num,2)}" th:text="|${#numbers.formatInteger(num,2)}시|" >시간</option>
  41. </th:block>
  42. </select>
  43. <input name="applyStdt" id="applyStdt" type="hidden" />
  44. ~
  45. <input name="applyEdYMD" id="applyEdYMD" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="예약 종료일" />
  46. <select name="applyEdHH" id="applyEdHH" required="required" data-valid-name="예약 종료시간">
  47. <th:block th:each="num: ${#numbers.sequence(0,23)}">
  48. <option th:value="${#numbers.formatInteger(num,2)}" th:text="|${#numbers.formatInteger(num,2)}시|" th:selected="${#numbers.formatInteger(num,2)}==23 ? 'true'">시간</option>
  49. </th:block>
  50. </select>
  51. <input name="applyEddt" id="applyEddt" type="hidden" />
  52. </td>
  53. </tr>
  54. </table>
  55. </div>
  56. <ul class="panelBar">
  57. <li class="left">
  58. <button type="button" class="btn btn-danger btn-lg" id="btnDeleteGoodsPriceRsvt">상품삭제</button>
  59. </li>
  60. <li class="right">
  61. <button type="button" class="btn btn-base btn-lg" id="btnSearchExcel">엑셀조회</button>
  62. <button type="button" class="btn btn-info btn-lg" id="btnSearchGoods">상품조회</button>
  63. </li>
  64. </ul>
  65. <div id="gridGoodsPriceRsvtList" style="width: 100%; height: 400px;" class="ag-theme-balham"></div>
  66. <ul class="panelBar">
  67. <li class="right">
  68. <button type="button" class="btnRight btn btn-base btn-lg" id="btnSaveGoodsPriceRsvt">적용</button>
  69. </li>
  70. </ul>
  71. </form>
  72. </div>
  73. </div>
  74. <script th:inline="javascript">
  75. /*<![CDATA[*/
  76. var rsvtGoodsPriceColumnDefs = [
  77. {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  78. {headerName: 'No', width: 50, cellClass: 'text-center',valueGetter: function(params) { return params.node.rowIndex+1}},
  79. {headerName: "상품코드", field: "goodsCd", width: 140, cellClass: 'text-center'},
  80. {headerName: "상품명", field: "goodsNm", width: 330, cellClass: 'text-left'},
  81. {headerName: "정상가", field: "listPrice" , width: 120, cellClass: 'text-right'
  82. ,valueFormatter: function(params) {return params.value.addComma();}
  83. },
  84. {headerName: "현재판매가", field: "currPrice", width: 120, cellClass: 'text-right'
  85. ,valueFormatter: function(params) {return params.value.addComma();},
  86. }
  87. ];
  88. // Get GridOptions
  89. var rsvtGoodsPriceGridOptions = gagaAgGrid.getGridOptions(rsvtGoodsPriceColumnDefs);
  90. rsvtGoodsPriceGridOptions.enableBrowserTooltips = true;
  91. // 중복 선택 가능
  92. rsvtGoodsPriceGridOptions.rowSelection = 'multiple';
  93. rsvtGoodsPriceGridOptions.suppressRowClickSelection = true;
  94. //rsvtGoodsPriceGridOptions.rowHeight = 60; //이미지가 있을경우 높이 지정해야함.
  95. // 상품 조회 클릭 시
  96. $('#btnSearchGoods').on('click', function() {
  97. cfnOpenGoodsPopup('fnSearchGoods');
  98. });
  99. // 상품 조회 콜백함수
  100. var fnSearchGoods = function(result) {
  101. if (result.length < 1) return;
  102. var oldData = gagaAgGrid.getAllRowData(rsvtGoodsPriceGridOptions);
  103. $.each(result, function(idx, item) {
  104. var isInvalid = false;
  105. if (oldData != null && oldData.length != 0){
  106. oldData.forEach(function(oneData){
  107. if(oneData.goodsCd == item.goodsCd){
  108. isInvalid = true;
  109. return true;
  110. }
  111. });
  112. if(isInvalid){
  113. return isInvalid;
  114. }
  115. }
  116. gagaAgGrid.addRowData(rsvtGoodsPriceGridOptions, {"goodsCd" : item.goodsCd, "goodsNm" : item.goodsNm, "listPrice" : item.listPrice, "currPrice" : item.currPrice});
  117. });
  118. uifnPopupClose('popupGoods');
  119. return false;
  120. };
  121. // 저장 클릭 시
  122. $('#btnSaveGoodsPriceRsvt').on('click', function() {
  123. var allRowData = gagaAgGrid.getAllRowData(rsvtGoodsPriceGridOptions);
  124. if(allRowData.length == 0){
  125. mcxDialog.alertC("상품을 조회한 후 추가해주세요.", {
  126. sureBtnText: "확인",
  127. sureBtnClick: function() {
  128. }
  129. });
  130. return;
  131. }
  132. if(gagajf.isNull($("#goodsPriceRsvtForm input[name=resGoodsPrice]").val())) {
  133. mcxDialog.alertC("상품 예약가격을 입력하세요.",{
  134. sureBtnText: "확인",
  135. sureBtnClick: function() {
  136. $("#goodsPriceRsvtForm input[name=resGoodsPrice]").focus();
  137. }
  138. });
  139. return false;
  140. }
  141. var fromDate = $('#goodsPriceRsvtForm input[name=applyStYMD]').val();
  142. var toDate = $('#goodsPriceRsvtForm input[name=applyEdYMD]').val();
  143. if (gagajf.isNull(fromDate)) {
  144. mcxDialog.alertC("예약 시작일자를 입력하세요.", {
  145. sureBtnText: "확인",
  146. sureBtnClick: function() {
  147. $('#goodsPriceRsvtForm input[name=applyStYMD]').focus();
  148. }
  149. });
  150. return false;
  151. }
  152. if (gagajf.isNull(toDate)) {
  153. mcxDialog.alertC("예약 종료일자를 입력하세요.", {
  154. sureBtnText: "확인",
  155. sureBtnClick: function() {
  156. $('#goodsPriceRsvtForm input[name=applyEdYMD]').focus();
  157. }
  158. });
  159. return false;
  160. }
  161. if (fromDate > toDate) {
  162. mcxDialog.alertC("예약 시작일자는 종료일자 보다 클 수 없습니다.", {
  163. sureBtnText: "확인",
  164. sureBtnClick: function() {
  165. $('#goodsPriceRsvtForm input[name=applyEdYMD]').focus();
  166. }
  167. });
  168. return false;
  169. }
  170. var optCheck = false;
  171. $.each(allRowData, function(index, item) {
  172. if (item.listPrice < $("#goodsPriceRsvtForm input[name=resGoodsPrice]").val()){
  173. optCheck = true;
  174. mcxDialog.alertC("가격예약 상품중 정상가보다 높은 상품이 존재합니다.<br/>확인해 주세요", {
  175. sureBtnText: "확인",
  176. sureBtnClick: function() {
  177. rsvtGoodsPriceGridOptions.api.setFocusedCell(index, "goodsCd", null);
  178. }
  179. });
  180. return false;
  181. }
  182. });
  183. if (optCheck) return false;
  184. var applyStdt = $('#goodsPriceRsvtForm input[name=applyStYMD]').val().replaceAll("-","") +
  185. $('#goodsPriceRsvtForm select[name=applyStHH]').val() + "0000";
  186. var applyEddt = $('#goodsPriceRsvtForm input[name=applyEdYMD]').val().replaceAll("-","") +
  187. $('#goodsPriceRsvtForm select[name=applyEdHH]').val() +"5959";
  188. $('#goodsPriceRsvtForm input[name=applyStdt]').val(applyStdt);
  189. $('#goodsPriceRsvtForm input[name=applyEddt]').val(applyEddt);
  190. if ($('#goodsPriceRsvtForm input[name=applyStdt]').val() > $('#goodsPriceRsvtForm input[name=applyEddt]').val()) {
  191. mcxDialog.alertC("예약 시작일자는 종료일자 보다 클 수 없습니다.", {
  192. sureBtnText: "확인",
  193. sureBtnClick: function() {
  194. $('#goodsPriceRsvtForm input[name=applyEdYMD]').focus();
  195. }
  196. });
  197. return false;
  198. }
  199. var toDateStr = new Date().format("YYYYMMDDHHmmss");
  200. if (toDateStr >= applyStdt){
  201. mcxDialog.alertC("예약 시작일자는 현재일자 보다 작거나 같을 수 없습니다.", {
  202. sureBtnText: "확인",
  203. sureBtnClick: function() {
  204. $('#goodsPriceRsvtForm input[name=applyStYMD]').focus();
  205. }
  206. });
  207. return false;
  208. }
  209. if (toDateStr >= applyEddt){
  210. mcxDialog.alertC("예약 종료일자는 현재일자 보다 작거나 같을 수 없습니다.", {
  211. sureBtnText: "확인",
  212. sureBtnClick: function() {
  213. $('#goodsPriceRsvtForm input[name=applyEdYMD]').focus();
  214. }
  215. });
  216. return false;
  217. }
  218. mcxDialog.confirm('저장하시겠습니까?', {
  219. cancelBtnText: "취소",
  220. sureBtnText: "확인",
  221. sureBtnClick: function(){
  222. var arrGoodsCd = [];
  223. var arrEndGoodsPrice = [];
  224. allRowData.forEach(function(item, index) {
  225. arrGoodsCd.push(item.goodsCd);
  226. arrEndGoodsPrice.push(item.currPrice);
  227. });
  228. var data = {resGoodsPrice : $('#goodsPriceRsvtForm input[name=resGoodsPrice]').val()
  229. , applyStdt : $('#goodsPriceRsvtForm input[name=applyStdt]').val()
  230. , applyEddt : $('#goodsPriceRsvtForm input[name=applyEddt]').val()
  231. , arrGoodsCd : arrGoodsCd
  232. , arrEndGoodsPrice : arrEndGoodsPrice
  233. };
  234. var jsonData = JSON.stringify(data);
  235. gagajf.ajaxJsonSubmit('/goods/price/reserve/save', jsonData, fnGoodsPriceRsvtListFormClose);
  236. }
  237. });
  238. });
  239. // 조회상품 삭제
  240. $('#btnDeleteGoodsPriceRsvt').on('click', function() {
  241. var selectedData = rsvtGoodsPriceGridOptions.api.getSelectedRows();
  242. if (selectedData.length == 0) {
  243. mcxDialog.alert('선택된 행이 없습니다.');
  244. return;
  245. }
  246. //화면에서 삭제
  247. var removedData = gagaAgGrid.removeRowData(rsvtGoodsPriceGridOptions, false);
  248. });
  249. //엑셀 상품 조회
  250. $('#btnSearchExcel').on('click', function() {
  251. cfnExcelUploadPopup('goodsPriceRsvtExcelUpload', 'goodsPriceRsvtExcelUpload');
  252. });
  253. var goodsPriceRsvtExcelUpload = function(result){
  254. var data = {procJob : result.procJob
  255. ,excelFileNm : result.excelFileNm
  256. };
  257. var jsonData = JSON.stringify(data);
  258. gagajf.ajaxJsonSubmit('/goods/search/excelupload/save', jsonData, fnRsvtGoodsPriceExcelUploadCallBack);
  259. }
  260. var fnRsvtGoodsPriceExcelUploadCallBack = function(result){
  261. gagajf.ajaxJsonSubmit('/goods/excel/upload/goods/list', '', fnExcelSearchCallBack);
  262. }
  263. var fnExcelSearchCallBack = function(result){
  264. if (result.goodsExcelList.length < 1) return;
  265. var oldData = gagaAgGrid.getAllRowData(rsvtGoodsPriceGridOptions);
  266. $.each(result.goodsExcelList, function(idx, item) {
  267. var isInvalid = false;
  268. if (oldData != null && oldData.length != 0){
  269. oldData.forEach(function(oneData){
  270. if(oneData.goodsCd == item.goodsCd){
  271. isInvalid = true;
  272. return true;
  273. }
  274. });
  275. if(isInvalid){
  276. return isInvalid;
  277. }
  278. }
  279. gagaAgGrid.addRowData(rsvtGoodsPriceGridOptions, {"goodsCd" : item.goodsCd, "goodsNm" : item.goodsNm, "listPrice" : item.listPrice, "currPrice" : item.currPrice});
  280. });
  281. return;
  282. }
  283. //창종료
  284. var fnGoodsPriceRsvtListFormClose = function(){
  285. uifnPopupClose('popupGoodsPriceReserve');
  286. fnGoodsPriceResDeleteCollBack();
  287. }
  288. $(document).ready(function() {
  289. // Create a agGrid
  290. gagaAgGrid.createGrid('gridGoodsPriceRsvtList', rsvtGoodsPriceGridOptions);
  291. });
  292. /*]]>*/
  293. </script>
  294. </html>