ITP_MPOMNG01010.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. mobPageObj.init();
  5. });
  6. });
  7. /*API URL*/
  8. const API_MOBILE_INIT_INFO = '/api/pomng/init-pchReq';
  9. const API_MOBILE_SAVE = '/api/pomng/save-pchReq';
  10. const API_POP_SEARCH_LIST = '/api/whs/mng/pop-whs-search';
  11. const API_POP_ITEM_LIST = '/api/item/pop-grid-list';
  12. const ID_ITP_POP_MPOMNG01010_REQ_AREA = "ITP_POP_MPOMNG01010_REQ_AREA";
  13. const ID_ITP_POP_MPOMNG01010_WHS_AREA = "ITP_POP_MPOMNG01010_WHS_AREA";
  14. const ID_ITP_POP_MPOMNG01010_ITEM_AREA = "ITP_POP_MPOMNG01010_ITEM_AREA";
  15. const PCH_REQ_ST_CD_TEMP_SAVE ="PR00";
  16. const PCH_REQ_ST_CD_REQUEST_SAVE ="PR20";
  17. let mobPageObj = {
  18. isPrevPage: false,
  19. pageParam: null,
  20. init: function () {
  21. this.ui.init();
  22. this.event.init();
  23. this.ready();
  24. },
  25. ui: {
  26. init: function () {
  27. this.info();
  28. },
  29. info: function() {
  30. $('input:hidden[id$="_BRAND_ID"]').val(fn_make_user_info.get('brandId'));
  31. $('input:hidden[id$="_STORE_ID"]').val(fn_make_user_info.get('storeId'));
  32. $('#ITP_MOBILE_MPOMNG01010 .itp_input.date').datepicker(ITP_DATE_LANGUAGE);
  33. $('#ITP_FORM_MPOMNG01010_DETAIL_DLV_REQ_DT').datepicker('setDate', itp_fn_date_add('M', 0));
  34. if(fn_make_user_info.get('authTpCd') === '50') {
  35. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_NM').attr('readonly', true);
  36. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_BTN_MPOMNG01010_DETAIL_SEARCH_WHS_NM').attr('disabled', true);
  37. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_BTN_MPOMNG01010_DETAIL_DELETE_WHS_NM').attr('disabled', true);
  38. }
  39. }
  40. },
  41. event: {
  42. init: function() {
  43. this.button();
  44. },
  45. button: function() {
  46. $('button[id^="ITP_BTN_MPOMNG01010_DETAIL"]').on('click', function() {
  47. if($(this).is('[data-call-popup]')) {
  48. mobPopObj.show($(this).data('call-popup'), $(this).attr('id'));
  49. } else {
  50. var id = $(this).attr('id');
  51. switch (id) {
  52. case 'ITP_BTN_MPOMNG01010_DETAIL_DELROW' : mobContObj.list.delRow(); break;
  53. case 'ITP_BTN_MPOMNG01010_DETAIL_SEARCH_WHS_NM' : mobPopObj.popWhsNm.init(); break;
  54. case 'ITP_BTN_MPOMNG01010_DETAIL_DELETE_WHS_NM' : mobPopObj.popWhsNm.delete(); break;
  55. case 'ITP_BTN_MPOMNG01010_DETAIL_CANCEL' : mobContObj.cancel(); break;
  56. }
  57. }
  58. return false;
  59. });
  60. }
  61. },
  62. ready: function() {
  63. mobContObj.init();
  64. }
  65. };
  66. let mobContObj = {
  67. init: function() {
  68. this.list.empty();
  69. this.data.load();
  70. },
  71. data: {
  72. initPchReq: null,
  73. load: function() {
  74. var _this = this;
  75. var callbackFn = function(result) {
  76. console.log(result);
  77. _this.initPchReq = result;
  78. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_BRAND_ID').val(result.brandId);
  79. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_STORE_ID').val(result.storeId);
  80. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_LOAN_DVSN').val(result.loanDvsn);
  81. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_LOAN_MGNT_UNQ_NO').val(result.loanMgntUnqNo);
  82. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_PCH_REQ_DVSN').val(result.pchReqDvsn);
  83. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_PCH_REQ_UNQ_NO').val(result.pchReqUnqNo);
  84. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_MALL_ID').val(result.mallId);
  85. $('#ITP_FORM_MPOMNG01010_DETAIL .fnPchReqAmtTot').text(CommonObj.currency.add('0'));
  86. $('#ITP_FORM_MPOMNG01010_DETAIL .fnOrdUseAmt').text(CommonObj.currency.add(result.ordUseAmt));
  87. if(result.whsId !== '' && result.location !== '') {
  88. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_ID').val(result.whsId);
  89. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_NM').val(result.whsNm);
  90. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_LOCATION').val(result.location);
  91. }
  92. };
  93. const param = {brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId')};
  94. fn_ajax_call(API_MOBILE_INIT_INFO, param, callbackFn, 'GET');
  95. }
  96. },
  97. list: {
  98. rows: [],
  99. addRow: function() {
  100. },
  101. delRow: function() {
  102. this.detachRow();
  103. },
  104. attachRow: function (item) {
  105. var _this = this;
  106. var fnIsExist = function(rows) {
  107. var isExist = false;
  108. $.each(rows, function(i, row) {
  109. if(row.brandUnitUnqNo === item.brandUnitUnqNo) {
  110. isExist = true;
  111. return false;
  112. }
  113. });
  114. return isExist;
  115. };
  116. if(!fnIsExist(this.rows)) {
  117. $('#ITP_LIST_MPOMNG01010_ITEM_AREA .panel-group').append($('#ITP_LIST_MPOMNG01010_DETAIL_ROWCOPY').html());
  118. var $li = $('#ITP_LIST_MPOMNG01010_ITEM_AREA .panel-group > .list-row:last');
  119. $li.find('.fnBrandUnitUnqNo').val(item.brandUnitUnqNo);
  120. $li.find('.fnItemNm').text(item.itemNm);
  121. $li.find('.fnPchReqQty').text(item.pchReqQty);
  122. $li.find('.fnUnitAmt').text(CommonObj.currency.add(item.unitAmt));
  123. $li.find('.fnOrdAmt').text(CommonObj.currency.add(Number(item.unitAmt) * Number(item.pchReqQty)));
  124. $('.list-row #ITP_BTN_MPOMNG01010_DETAIL_PLUS')[$li.index()].addEventListener('click', function() { _this.actPlus(this); });
  125. $('.list-row #ITP_BTN_MPOMNG01010_DETAIL_MINUS')[$li.index()].addEventListener('click', function() { _this.actMinus(this); });
  126. this.rows.push(item);
  127. this.pchReqAmtTot();
  128. }
  129. this.empty();
  130. },
  131. detachRow: function () {
  132. if($('#ITP_LIST_MPOMNG01010_ITEM_AREA input:checkbox[name=brandUnitUnqNo]:checked').length > 0) {
  133. var _this = this;
  134. $('#ITP_LIST_MPOMNG01010_DETAIL_ROWS li').each(function(index, elem) {
  135. var __this = this;
  136. var isChecked = $(this).find('input[type="checkbox"]').is(':checked');
  137. if(isChecked) {
  138. $.each(_this.rows, function(i, row){
  139. if(row.brandUnitUnqNo === $(__this).find('input[type="checkbox"]').val()) {
  140. _this.rows.splice(i, 1);
  141. return false;
  142. }
  143. });
  144. $(this).remove();
  145. }
  146. });
  147. this.pchReqAmtTot();
  148. }
  149. this.empty();
  150. },
  151. actPlus: function(elem) {
  152. var $li = $(elem).closest('li');
  153. var num = Number($li.find('.fnPchReqQty').text());
  154. var calcNum = num + 1;
  155. $($li).find('.fnPchReqQty').text(calcNum.toString());
  156. this.rows[$li.index()]['pchReqQty'] = calcNum;
  157. this.pchReqAmtUnit(elem, calcNum);
  158. this.pchReqAmtTot();
  159. },
  160. actMinus: function(elem) {
  161. var $div = $(elem).siblings('div');
  162. var num = Number($div.text());
  163. if(num <= 1) {
  164. itp_fn_modal_alert_ajax('주문수량을 확인하세요.');
  165. } else {
  166. $($div).text((num - 1).toString());
  167. this.rows[$div.parents('li').index()]['pchReqQty'] = $($div).text();
  168. this.pchReqAmtUnit(elem, $($div).text());
  169. this.pchReqAmtTot();
  170. }
  171. },
  172. pchReqAmtUnit: function(elem, qty) {
  173. var $div = $(elem).parent().prev();
  174. var unitAmt = CommonObj.onlyNumber($div.find('.fnUnitAmt').text());
  175. $div.find('.fnOrdAmt').text(CommonObj.currency.add(Number(unitAmt ? unitAmt : 0) * Number(qty)));
  176. },
  177. pchReqAmtTot: function() {
  178. var reqAmt = 0;
  179. $.each(this.rows, function(index, item) {
  180. var qty = item.pchReqQty;
  181. var amt = item.unitAmt;
  182. reqAmt += Number(qty) * amt;
  183. });
  184. $('#ITP_AJAX_MPOMNG01010_VIEW_CONTAINER').find('.fnPchReqAmtTot').text(CommonObj.currency.add(reqAmt));
  185. },
  186. empty: function() {
  187. ($('#ITP_LIST_MPOMNG01010_DETAIL_ROWS li').length > 0) ? $('.itp_non_data').hide() : $('.itp_non_data').show();
  188. }
  189. },
  190. reset: function() {
  191. $('#ITP_LIST_MPOMNG01010_DETAIL_ROWS').children().remove();
  192. this.data.load();
  193. },
  194. cancel: function () {
  195. $(location).attr('href', MOBILE_CONTEXTPATH + '/app/main.html');
  196. }
  197. };
  198. let mobPopObj = {
  199. init: function(popId, parentId) {
  200. switch (popId) {
  201. case 'ITP_POP_MPOMNG01010_REQ_AREA' : this.popReqConfirm.init(parentId); break;
  202. case 'ITP_POP_MPOMNG01010_WHS_AREA' : this.popWhsNm.init(); break;
  203. case 'ITP_POP_MPOMNG01010_ITEM_AREA' : this.popItem.init(); break;
  204. }
  205. },
  206. popItem: {
  207. // rows: null,
  208. init: function() {
  209. this.search();
  210. },
  211. search: function() {
  212. $('#ITP_LIST_MPOMNG01010_POP_ITEM_AREA .panel-group').empty();
  213. var callbackFn = function(result) {
  214. console.log(result);
  215. mobPopObj.popItem.rows = result.gridRows;
  216. $.each(mobPopObj.popItem.rows, function (i, item) {
  217. $('#ITP_LIST_MPOMNG01010_POP_ITEM_AREA .panel-group').append($('#ITP_LIST_MPOMNG01010_POP_ITEM_ROWCOPY').html());
  218. var $li = $('#ITP_LIST_MPOMNG01010_POP_ITEM_AREA .panel-group > .row_2:last');
  219. $li.find('#ITP_FORM_MPOMNG01010_POP_ITEM_CHECKBOX').val(item.itemId);
  220. $li.find('.fnItemNm').text(item.itemNm);
  221. $li.find('.fnUnitAmt').text(CommonObj.currency.add(item.unitAmt));
  222. $li.find('.fnOrdAmt').text(CommonObj.currency.add(item.unitAmt));
  223. });
  224. mobPopObj.popItem.addRow.init();
  225. };
  226. let param = $('#ITP_FORM_MPOMNG01010_POPUP_ITEM').serializeObject();
  227. fn_ajax_call(API_POP_ITEM_LIST, JSON.stringify(param), callbackFn, 'POST');
  228. },
  229. addRow: {
  230. init: function() {
  231. this.button.init();
  232. },
  233. button: {
  234. init: function() {
  235. var _this = this;
  236. $('button[id^="ITP_BTN_MPOMNG01010_POP_ITEM_"]').off('click').on('click', function() {
  237. var id = $(this).attr('id');
  238. switch (id) {
  239. case 'ITP_BTN_MPOMNG01010_POP_ITEM_PLUS' : _this.actPlus($(this)); break;
  240. case 'ITP_BTN_MPOMNG01010_POP_ITEM_MINUS' : _this.actMinus($(this)); break;
  241. case 'ITP_BTN_MPOMNG01010_POP_ITEM_ADD' : _this.actItemAdd($(this)); break;
  242. case 'ITP_BTN_MPOMNG01010_POP_ITEM_SEARCH' : mobPopObj.popItem.search(); break;
  243. case 'ITP_BTN_MPOMNG01010_POP_ITEM_CLOSE' : mobPopObj.hide(id); break;
  244. }
  245. return false;
  246. });
  247. },
  248. actPlus: function(elem) {
  249. var $div = $(elem).siblings('div');
  250. var num = Number($div.text());
  251. $($div).text((num + 1).toString());
  252. this.reqAmtUnit(elem, $($div).text());
  253. },
  254. actMinus: function(elem) {
  255. var $div = $(elem).siblings('div');
  256. var num = Number($div.text());
  257. if(num <= 1) {
  258. itp_fn_modal_alert_ajax('주문수량을 확인하세요.');
  259. } else {
  260. $($div).text((num - 1).toString());
  261. this.reqAmtUnit(elem, $($div).text());
  262. }
  263. },
  264. reqAmtUnit: function(elem, qty) {
  265. var $li = $(elem).closest('li');
  266. var unitAmt = CommonObj.onlyNumber($li.find('.fnUnitAmt').text());
  267. $li.find('.fnOrdAmt').text(CommonObj.currency.add(Number(unitAmt ? unitAmt : 0) * Number(qty)));
  268. },
  269. actItemAdd: function(elem) {
  270. var $li = $(elem).closest('li');
  271. // var index = $(elem).closest('li').index();
  272. var item = mobPopObj.popItem.rows[$li.index()];
  273. // var item = mobPopObj.popItem.rows[index];
  274. item['pchReqQty'] = $(elem).closest('li').find('.fnPchReqQty').html();
  275. mobContObj.list.attachRow(item);
  276. }
  277. }
  278. },
  279. delRow: function() {
  280. }
  281. },
  282. popWhsNm: {
  283. init: function () {
  284. this.rows.length = 0;
  285. this.search();
  286. this.action();
  287. },
  288. rows: [],
  289. search: function () {
  290. var _this = this;
  291. $('#ITP_LIST_MPOMNG01010_POP_WHS_AREA .panel-group').empty();
  292. var callbackFn = function(result) {
  293. console.log(result);
  294. _this.view(result.gridRows);
  295. };
  296. const param = $('#ITP_FORM_MPOMNG01010_POP_WHS').serializeObject();
  297. fn_ajax_call(API_POP_SEARCH_LIST, JSON.stringify(param), callbackFn, 'POST');
  298. },
  299. view: function(gridRows) {
  300. this.rows = gridRows;
  301. $.each(gridRows, function (i, item) {
  302. $('#ITP_LIST_MPOMNG01010_POP_WHS_AREA .panel-group').append($('#ITP_LIST_MPOMNG01010_POP_WHS_ROWCOPY').html());
  303. var $li = $('#ITP_LIST_MPOMNG01010_POP_WHS_AREA .panel-group > .row_2:last');
  304. $li.find('.fnWhsNm').text(item.whsNm);
  305. $li.find('.fnLocationNm').text(item.locationNm);
  306. $li.find('.fnWhsId').data('whs-id', item.whsId);
  307. });
  308. },
  309. action: function() {
  310. var _this = this;
  311. $('#ITP_LIST_MPOMNG01010_POP_WHS_AREA button[id$="POP_WHS_CHOICE"]').off('click').on('click', function() {
  312. var whsId = $(this).data('whs-id');
  313. $.each(_this.rows, function (i, item) {
  314. if(whsId === item.whsId) {
  315. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_ID').val(item.whsId);
  316. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_NM').val(item.whsNm);
  317. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_LOCATION').val(item.location);
  318. mobPopObj.hide(ID_ITP_POP_MPOMNG01010_WHS_AREA);
  319. itp_fn_form_clear_validate(null, '#ITP_FORM_MPOMNG01010_DETAIL');
  320. return false;
  321. }
  322. });
  323. });
  324. $('#ITP_FORM_MPOMNG01010_POP_WHS button[id="ITP_BTN_MPOMNG01010_POP_WHS_SEARCH"]').off('click').on('click', function() {
  325. _this.search();
  326. });
  327. },
  328. delete: function() {
  329. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_ID').val('');
  330. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_NM').val('');
  331. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_LOCATION').val('');
  332. }
  333. },
  334. popReqConfirm: {
  335. saveMode: 1, // 1 : 임시저장, 2 : 구매요청, 요청금액이 가능금액보다 클 경우 (3 : PG 정보 없음, 4 : 선불매장, 5 : 후불매장)
  336. init: function (parentId) {
  337. this.formId = '#ITP_FORM_MPOMNG01010_DETAIL';
  338. this.pchReqStCd = (parentId === 'ITP_BTN_MPOMNG01010_DETAIL_REQ_ORDER') ? PCH_REQ_ST_CD_REQUEST_SAVE : PCH_REQ_ST_CD_TEMP_SAVE;
  339. this.view();
  340. this.action();
  341. },
  342. view: function() {
  343. var popMsg = '';
  344. var loanDvsn = $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_LOAN_DVSN').val();
  345. var ordUseAmt = CommonObj.onlyNumber($('#ITP_FORM_MPOMNG01010_DETAIL .fnOrdUseAmt').text());
  346. var pchReqAmtTot = CommonObj.onlyNumber($('#ITP_FORM_MPOMNG01010_DETAIL .fnPchReqAmtTot').text());
  347. if(this.pchReqStCd === PCH_REQ_ST_CD_REQUEST_SAVE) { // 구매요청
  348. if(loanDvsn === 'LD03') { // 무정산
  349. this.saveMode = 2;
  350. popMsg = '구매요청 하시겠습니까?';
  351. $('#ITP_POP_MPOMNG01010_REQ_AREA #ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM').text('확인');
  352. } else {
  353. if (Number(ordUseAmt) < Number(pchReqAmtTot)) { // 요청금액이 가능금액보다 클 경우
  354. if($('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_MALL_ID').val() === '') { // PG 정보 없음
  355. this.saveMode = 3;
  356. if(loanDvsn === 'LD01') { // 선불매장
  357. popMsg = '선불매장이므로 입금을 하시고, 입금등록 후 브랜드에서 승인이 되어야 구매요청을 하실 수 있습니다.';
  358. } else if(loanDvsn === 'LD02') { // 후불매장
  359. popMsg = '구매한도가 부족합니다.<br>' +
  360. '선입금을 하시고, 입금등록 후 브랜드에서 승인이 되어야 구매요청을 하실 수 있습니다.\n';
  361. }
  362. $('#ITP_POP_MPOMNG01010_REQ_AREA #ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM').text('확인');
  363. } else {
  364. if(loanDvsn === 'LD01') { // 선불매장
  365. this.saveMode = 4;
  366. popMsg = '선불매장이므로 결재를 하셔야 구매요청이 진행이 됩니다.<br>' +
  367. '결재를 하시겠습니까?';
  368. $('#ITP_POP_MPOMNG01010_REQ_AREA #ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM').text('결제');
  369. } else if(loanDvsn === 'LD02') { // 후불매장
  370. this.saveMode = 5;
  371. popMsg = '구매한도가 부족합니다.<br>' +
  372. '선결재를 하신 후에 구매요청을 하시기 바랍니다.<br>' +
  373. '결재를 하시겠습니까?';
  374. $('#ITP_POP_MPOMNG01010_REQ_AREA #ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM').text('결제');
  375. }
  376. }
  377. } else {
  378. this.saveMode = 2;
  379. popMsg = '구매요청 하시겠습니까?';
  380. $('#ITP_POP_MPOMNG01010_REQ_AREA #ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM').text('확인');
  381. }
  382. }
  383. } else { // 임시저장
  384. this.saveMode = 1;
  385. popMsg = '임시저장 하시겠습니까?';
  386. $('#ITP_POP_MPOMNG01010_REQ_AREA #ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM').text('확인');
  387. }
  388. $('#ITP_POP_MPOMNG01010_REQ_AREA .fnPopDlvReqDt').text($('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_DLV_REQ_DT').val());
  389. $('#ITP_POP_MPOMNG01010_REQ_AREA .fnItemQty').text(CommonObj.currency.add(mobContObj.list.rows.length, '개'));
  390. $('#ITP_POP_MPOMNG01010_REQ_AREA .fnOrdReqAmt').text($('#ITP_AJAX_MPOMNG01010_VIEW_CONTAINER .fnPchReqAmtTot').text());
  391. $('#ITP_POP_MPOMNG01010_REQ_AREA .fnOrdPssblAmt').text($('#ITP_AJAX_MPOMNG01010_VIEW_CONTAINER .fnOrdUseAmt').text());
  392. $('#ITP_POP_MPOMNG01010_REQ_AREA .fnOrdAmt').text(CommonObj.currency.add(pchReqAmtTot));
  393. $('#ITP_POP_MPOMNG01010_REQ_AREA .pop_msg').html(popMsg);
  394. },
  395. action: function() {
  396. var _this = this;
  397. $('#ITP_POP_MPOMNG01010_REQ_AREA button[id="ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM"]').off('click').on('click', function() {
  398. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_PCH_REQ_ST_CD').val(_this.pchReqStCd);
  399. _this.save();
  400. });
  401. },
  402. save: function() {
  403. var procSave = function (rtnFn) {
  404. let param = $('#ITP_FORM_MPOMNG01010_DETAIL').serializeObject();
  405. $.each(mobContObj.list.rows, function(index, item) {
  406. item['viewCd'] = 'C';
  407. });
  408. param.gridInsertData = mobContObj.list.rows;
  409. var saveFn = function (result) {
  410. console.log(result);
  411. mobPopObj.hide('ITP_POP_MPOMNG01010_REQ_AREA');
  412. console.log(typeof rtnFn === 'function');
  413. // if(typeof rtnFn === 'function') rtnFn();
  414. mobContObj.reset();
  415. };
  416. console.log(param);
  417. fn_ajax_call(API_MOBILE_SAVE, JSON.stringify(param), saveFn, 'POST');
  418. };
  419. if (this.saveMode === 1 || this.saveMode === 2 || this.saveMode === 3) {
  420. if(this.saveMode === 3)
  421. $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_PCH_REQ_ST_CD').val(PCH_REQ_ST_CD_TEMP_SAVE);
  422. procSave();
  423. } else if (this.saveMode === 4 || this.saveMode === 5) {
  424. // 결제 팝업 결과
  425. var popFn = function(rowDataPop) {
  426. console.log(JSON.stringify(rowDataPop));
  427. procSave(function(result) { mobContObj.reset(); });
  428. };
  429. // 결제 팝업
  430. var ordUseAmt = CommonObj.onlyNumber($('#ITP_FORM_MPOMNG01010_DETAIL .fnOrdUseAmt').text());
  431. var pchReqAmtTot = CommonObj.onlyNumber($('#ITP_FORM_MPOMNG01010_DETAIL .fnPchReqAmtTot').text());
  432. var args = {
  433. 'payTpCd' : '40',
  434. 'brandId' : $('#ITP_FORM_MPOMNG01010_DETAIL_BRAND_ID').val(),
  435. 'storeId' : $('#ITP_FORM_MPOMNG01010_DETAIL_STORE_ID').val(),
  436. 'goodsAmt' : Number(pchReqAmtTot - ordUseAmt)
  437. };
  438. fn_call_popup('biz', 'BIZPOP_PO_PAYMENT', '#ITP_ASIDE', popFn, args, 'M');
  439. }
  440. }
  441. },
  442. show: function(popId, parentId) {
  443. var _this = this;
  444. $('button[id$="CLOSE"]').off('click').on('click', function() {
  445. var id = $(this).attr('id');
  446. if($(this).hasClass('btn-pop-close')) {
  447. _this.hide(id);
  448. }
  449. });
  450. if(parentId === 'ITP_BTN_MPOMNG01010_DETAIL_REQ_ORDER' || parentId === 'ITP_BTN_MPOMNG01010_DETAIL_TEMP_SAVE') {
  451. var formId = '#ITP_FORM_MPOMNG01010_DETAIL';
  452. itp_fn_form_clear_validate(null, formId);
  453. if (itp_fn_form_event.isValid(formId)) {
  454. if($('#ITP_LIST_MPOMNG01010_DETAIL_ROWS > li').size() < 1) {
  455. alert('품목추가 버튼을 이용하여 품목을 추가해 주세요.');
  456. return false;
  457. } else {
  458. $('#' + popId).show();
  459. mobPopObj.init(popId, parentId);
  460. }
  461. }
  462. } else {
  463. $('#' + popId).show();
  464. mobPopObj.init(popId, parentId);
  465. }
  466. },
  467. hide: function(id) {
  468. $('#' + id).closest('.mobile-pop-close').hide();
  469. }
  470. };