require(['config'], function() { require([ ], function($) { mobPageObj.init(); }); }); /*API URL*/ const API_MOBILE_INIT_INFO = '/api/pomng/init-pchReq'; const API_MOBILE_SAVE = '/api/pomng/save-pchReq'; const API_POP_SEARCH_LIST = '/api/whs/mng/pop-whs-search'; const API_POP_ITEM_LIST = '/api/item/pop-grid-list'; const API_MOBILE_BARCODE = '/api/item/info-barcode-item'; // 바코드 const ID_ITP_POP_MPOMNG01010_REQ_AREA = "ITP_POP_MPOMNG01010_REQ_AREA"; const ID_ITP_POP_MPOMNG01010_WHS_AREA = "ITP_POP_MPOMNG01010_WHS_AREA"; const ID_ITP_POP_MPOMNG01010_ITEM_AREA = "ITP_POP_MPOMNG01010_ITEM_AREA"; const PCH_REQ_ST_CD_TEMP_SAVE ="PR00"; const PCH_REQ_ST_CD_REQUEST_SAVE ="PR20"; let mobPageObj = { isPrevPage: false, pageParam: null, init: function () { this.ui.init(); this.event.init(); this.ready(); }, ui: { init: function () { this.info(); }, info: function() { $('input:hidden[id$="_BRAND_ID"]').val(fn_make_user_info.get('brandId')); $('input:hidden[id$="_STORE_ID"]').val(fn_make_user_info.get('storeId')); $('#ITP_MOBILE_MPOMNG01010 .itp_input.date').datepicker(ITP_DATE_LANGUAGE); $('#ITP_FORM_MPOMNG01010_DETAIL_DLV_REQ_DT').datepicker('setDate', itp_fn_date_add('D', 5)); // if(fn_make_user_info.get('authTpCd') === '50') { // $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_NM').attr('readonly', true); // $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_BTN_MPOMNG01010_DETAIL_SEARCH_WHS_NM').attr('disabled', true); // $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_BTN_MPOMNG01010_DETAIL_DELETE_WHS_NM').attr('disabled', true); // } } }, event: { init: function() { this.button(); }, button: function() { $('button[id^="ITP_BTN_MPOMNG01010_DETAIL"]').on('click', function() { if($(this).is('[data-call-popup]')) { mobPopObj.show($(this).data('call-popup'), $(this).attr('id')); } else { var id = $(this).attr('id'); switch (id) { case 'ITP_BTN_MPOMNG01010_DETAIL_DELROW' : mobContObj.list.delRow(); break; case 'ITP_BTN_MPOMNG01010_DETAIL_SEARCH_WHS_NM' : mobPopObj.popWhsNm.init(); break; case 'ITP_BTN_MPOMNG01010_DETAIL_DELETE_WHS_NM' : mobPopObj.popWhsNm.delete(); break; case 'ITP_BTN_MPOMNG01010_DETAIL_SCAN' : mobContObj.barcode.callApp(); break; case 'ITP_BTN_MPOMNG01010_DETAIL_WISH' : mobContObj.wishList.init(); break; case 'ITP_BTN_MPOMNG01010_DETAIL_CANCEL' : mobContObj.cancel(); break; } } return false; }); } }, ready: function() { mobContObj.init(); } }; let mobContObj = { init: function() { this.list.empty(); this.data.load(); }, data: { initPchReq: null, load: function() { var _this = this; var callbackFn = function(result) { console.log(result); _this.initPchReq = result; $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_BRAND_ID').val(result.brandId); $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_STORE_ID').val(result.storeId); $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_LOAN_DVSN').val(result.loanDvsn); $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_LOAN_MGNT_UNQ_NO').val(result.loanMgntUnqNo); $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_PCH_REQ_DVSN').val(result.pchReqDvsn); $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_PCH_REQ_UNQ_NO').val(result.pchReqUnqNo); $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_MALL_ID').val(result.mallId); $('#ITP_FORM_MPOMNG01010_DETAIL .fnPchReqAmtTot').text(CommonObj.currency.add('0')); $('#ITP_FORM_MPOMNG01010_DETAIL .fnOrdUseAmt').text(CommonObj.currency.add(result.ordUseAmt)); if(result.whsId !== '' && result.location !== '') { $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_ID').val(result.whsId); $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_NM').val(result.whsNm); $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_LOCATION').val(result.location); } }; const param = {brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId')}; fn_ajax_call(API_MOBILE_INIT_INFO, param, callbackFn, 'GET'); } }, list: { rows: [], addRow: function() { }, delRow: function() { this.detachRow(); }, attachRow: function (items) { var _this = this; var fnIsExist = function(rows, item) { var isExist = false; $.each(rows, function(i, row) { if(row.brandUnitUnqNo === item.brandUnitUnqNo) { isExist = true; return false; } }); return isExist; }; $.each(items, function(i, item) { if(!fnIsExist(_this.rows, item)) { _this.rows.push(item); $('#ITP_LIST_MPOMNG01010_ITEM_AREA .panel-group').append($('#ITP_LIST_MPOMNG01010_DETAIL_ROWCOPY').html()); var $li = $('#ITP_LIST_MPOMNG01010_ITEM_AREA .panel-group > .list-row:last'); $li.find('.fnBrandUnitUnqNo').val(item.brandUnitUnqNo); $li.find('.fnItemNm').text(item.itemNm); $li.find('#ITP_MPOMNG01010_DETAIL_NUM').val(item.pchReqQty ? item.pchReqQty : '1'); $li.find('.fnUnitAmt').text(CommonObj.currency.add(item.unitAmt)); $li.find('.fnOrdAmt').text(CommonObj.currency.add(Number(item.unitAmt) * Number(item.pchReqQty ? item.pchReqQty : '1'))); $('.list-row #ITP_BTN_MPOMNG01010_DETAIL_PLUS')[$li.index()].addEventListener('click', function() { _this.actPlus(this); }); $('.list-row #ITP_BTN_MPOMNG01010_DETAIL_MINUS')[$li.index()].addEventListener('click', function() { _this.actMinus(this); }); $('.item-row #ITP_MPOMNG01010_DETAIL_NUM')[$li.index()].addEventListener('input', function() { _this.actInput(this); }); _this.pchReqAmtTot(); } }); this.empty(); }, detachRow: function () { if($('#ITP_LIST_MPOMNG01010_ITEM_AREA input:checkbox[name=brandUnitUnqNo]:checked').length > 0) { var _this = this; $('#ITP_LIST_MPOMNG01010_DETAIL_ROWS li').each(function(index, elem) { var __this = this; var isChecked = $(this).find('input[type="checkbox"]').is(':checked'); if(isChecked) { $.each(_this.rows, function(i, row){ if(row.brandUnitUnqNo === $(__this).find('input[type="checkbox"]').val()) { _this.rows.splice(i, 1); return false; } }); $(this).remove(); } }); this.pchReqAmtTot(); } this.empty(); }, actPlus: function(elem) { var elQty = $(elem).prev(); var num = Number($(elQty).val()); if(num < 100000) { var calcNum = num + 1; $(elQty).val(calcNum.toString()); this.rows[elQty.parents('li').index()]['pchReqQty'] = calcNum; this.pchReqAmtUnit(elem, calcNum); this.pchReqAmtTot(); } }, actMinus: function(elem) { var elQty = $(elem).next(); var num = Number($(elQty).val()); if(num > 1) { var calcNum = num - 1; $(elQty).val(calcNum.toString()); this.rows[elQty.parents('li').index()]['pchReqQty'] = calcNum; this.pchReqAmtUnit(elem, calcNum); this.pchReqAmtTot(); } }, actInput: function(elem) { var _this = this; var index = $(elem).parents('li').index(); CommonObj.chkMaxLength(elem, function(qty) { mobContObj.list.rows[index]['pchReqQty'] = qty; mobContObj.list.pchReqAmtUnit(elem, qty); mobContObj.list.pchReqAmtTot(); }); }, pchReqAmtUnit: function(elem, qty) { var $div = $(elem).parent().prev(); var unitAmt = CommonObj.onlyNumber($div.find('.fnUnitAmt').text()); $div.find('.fnOrdAmt').text(CommonObj.currency.add(Number(unitAmt ? unitAmt : 0) * Number(qty))); }, pchReqAmtTot: function() { var reqAmt = 0; $.each(this.rows, function(index, item) { var qty = item.pchReqQty; var amt = item.unitAmt; reqAmt += Number(qty) * amt; }); $('#ITP_AJAX_MPOMNG01010_VIEW_CONTAINER').find('.fnPchReqAmtTot').text(CommonObj.currency.add(reqAmt)); }, empty: function() { ($('#ITP_LIST_MPOMNG01010_DETAIL_ROWS li').length > 0) ? $('.itp_non_data').hide() : $('.itp_non_data').show(); } }, reset: function() { $('#ITP_LIST_MPOMNG01010_DETAIL_ROWS').children().remove(); this.list.rows.length = 0; this.data.load(); }, cancel: function () { $(location).attr('href', MOBILE_CONTEXTPATH + '/app/main.html'); }, barcode: { callApp: function() { location.replace('app:scan'); // appCallFnBarcode('ITEM221217000006BRD221200038'); } }, wishList: { init: function () { console.log('wishList'); } } }; function appCallFnBarcode(barcode) { var infoFn = function(result) { // console.log(JSON.stringify(result)); if(result) { mobContObj.list.attachRow([result]); } }; const param = { 'sBrandId': fn_make_user_info.get('brandId'), 'sStoreId': fn_make_user_info.get('storeId'), 'sBarcode': barcode }; fn_ajax_call(API_MOBILE_BARCODE, param, infoFn, 'GET'); } let mobPopObj = { init: function(popId, parentId) { switch (popId) { case 'ITP_POP_MPOMNG01010_REQ_AREA' : this.popReqConfirm.init(parentId); break; case 'ITP_POP_MPOMNG01010_WHS_AREA' : this.popWhsNm.init(); break; case 'ITP_POP_MPOMNG01010_ITEM_AREA' : this.popItem.init(); break; case 'ITP_POP_MPOMNG01010_WISH_LIST_AREA' : this.popWishList.init(); break; } }, popItem: { // rows: null, init: function() { $('#ITP_POP_MPOMNG01010_ITEM_AREA #ITP_FORM_MPOMNG01010_POP_ITEM_KEYWORD').val(''); this.search(); }, search: function() { $('#ITP_LIST_MPOMNG01010_POP_ITEM_AREA .panel-group').empty(); var callbackFn = function(result) { console.log(result); mobPopObj.popItem.rows = result.gridRows; $.each(mobPopObj.popItem.rows, function (i, item) { $('#ITP_LIST_MPOMNG01010_POP_ITEM_AREA .panel-group').append($('#ITP_LIST_MPOMNG01010_POP_ITEM_ROWCOPY').html()); var $li = $('#ITP_LIST_MPOMNG01010_POP_ITEM_AREA .panel-group > .row_2:last'); $li.find('#ITP_FORM_MPOMNG01010_POP_ITEM_CHECKBOX').val(item.itemId); $li.find('.fnItemNm').text(item.itemNm); $li.find('.fnUnitAmt').text(CommonObj.currency.add(item.unitAmt)); $li.find('.fnOrdAmt').text(CommonObj.currency.add(item.unitAmt)); }); mobPopObj.popItem.addRow.init(); }; let param = $('#ITP_FORM_MPOMNG01010_POPUP_ITEM').serializeObject(); fn_ajax_call(API_POP_ITEM_LIST, JSON.stringify(param), callbackFn, 'POST'); }, addRow: { init: function() { this.button.init(); }, button: { init: function() { var _this = this; $('button[id^="ITP_BTN_MPOMNG01010_POP_ITEM_"]').off('click').on('click', function() { var id = $(this).attr('id'); switch (id) { case 'ITP_BTN_MPOMNG01010_POP_ITEM_PLUS' : _this.actPlus($(this)); break; case 'ITP_BTN_MPOMNG01010_POP_ITEM_MINUS' : _this.actMinus($(this)); break; case 'ITP_BTN_MPOMNG01010_POP_ITEM_ADD' : _this.addItems(); break; // case 'ITP_BTN_MPOMNG01010_POP_ITEM_ADD' : _this.actItemAdd($(this)); break; case 'ITP_BTN_MPOMNG01010_POP_ITEM_SEARCH' : mobPopObj.popItem.search(); break; case 'ITP_BTN_MPOMNG01010_POP_ITEM_CLOSE' : mobPopObj.hide(id); break; } return false; }); $('input[id="ITP_MPOMNG01010_POP_NUM"]').off('input').on('input', function() { var _this = this; CommonObj.chkMaxLength(this, function(qty) { mobPopObj.popItem.addRow.button.reqAmtUnit(_this, qty) }); }); }, actPlus: function(elem) { var elQty = $(elem).prev(); var num = Number($(elQty).val()); if(num < 100000) { var calcNum = num + 1; $(elQty).val(calcNum.toString()); this.reqAmtUnit(elem, calcNum); } }, actMinus: function(elem) { var elQty = $(elem).next(); var num = Number($(elQty).val()); if(num > 1) { var calcNum = num - 1; $(elQty).val(calcNum.toString()); this.reqAmtUnit(elem, calcNum); } }, reqAmtUnit: function(elem, qty) { var $li = $(elem).closest('li'); var unitAmt = CommonObj.onlyNumber($li.find('.fnUnitAmt').text()); $li.find('.fnOrdAmt').text(CommonObj.currency.add(Number(unitAmt ? unitAmt : 0) * Number(qty))); }, actItemAdd: function(elem) { var $li = $(elem).closest('li'); var item = mobPopObj.popItem.rows[$li.index()]; item['pchReqQty'] = $li.find('.fnPchReqQty').html(); // var index = $(elem).closest('li').index(); // var item = mobPopObj.popItem.rows[index]; // item['pchReqQty'] = $(elem).closest('li').find('.fnPchReqQty').html(); mobContObj.list.attachRow(item); }, addItems: function() { var items = []; var chkMsg = ''; $('#ITP_LIST_MPOMNG01010_POP_ITEM_ROWS').find('input:checkbox').each(function() { if($(this).is(':checked')) { var val = $(this).closest('li').find('#ITP_MPOMNG01010_POP_NUM').val(); if(val === '') { chkMsg = '수량을 입력하세요.'; return false; } var index = $(this).closest('li').index(); var item = mobPopObj.popItem.rows[index]; item['pchReqQty'] = val; items.push(item); } }); if(chkMsg !== '') { itp_fn_modal_alert(chkMsg); return; } if(items.length < 1) { itp_fn_modal_alert('품목을 선택하세요.'); return; } mobContObj.list.attachRow(items); mobPopObj.popItem.close(); } } }, delRow: function() { }, close: function() { this.rows.length = 0; $('#ITP_LIST_MPOMNG01010_POP_ITEM_ROWS').children().remove(); mobPopObj.hide('ITP_POP_MPOMNG01010_ITEM_AREA'); } }, popWishList: { rows: [], init: function () { this.clear(); this.load(); }, load: function() { }, search: function() { }, clear: function() { this.rows.length = 0; } }, popWhsNm: { init: function () { $('#ITP_LIST_MPOMNG01010_POP_WHS_AREA .mb_0').children().remove(); this.rows.length = 0; this.search(); this.action(); }, rows: [], search: function () { var _this = this; $('#ITP_LIST_MPOMNG01010_POP_WHS_AREA .mb_0').empty(); var callbackFn = function(result) { console.log(result); $.each(result.gridRows, function (i, item) { $('#ITP_LIST_MPOMNG01010_POP_WHS_AREA .mb_0').append($('#ITP_LIST_MPOMNG01010_POP_WHS_ROWCOPY').html()); var $li = $('#ITP_LIST_MPOMNG01010_POP_WHS_AREA .mb_0 > .row_2:last'); $li.find('.fnWhsNm').text(item.whsNm); $li.find('.fnLocationNm').text(item.locationNm); $li.find('.fnWhsId').data('whs-id', item.whsId); $li.find('.fnWhsId').data('location', item.location); $('#ITP_LIST_MPOMNG01010_POP_WHS_ROWS li button')[$li.index()].addEventListener('click', function() { _this.choice(this); }); }); }; const param = $('#ITP_FORM_MPOMNG01010_POP_WHS').serializeObject(); (fn_make_user_info.get('authTpCd') === '50') ? param.swhsDvsn = 'W02' : param.swhsDvsn = 'W01'; fn_ajax_call(API_POP_SEARCH_LIST, JSON.stringify(param), callbackFn, 'POST'); }, action: function() { var _this = this; $('#ITP_FORM_MPOMNG01010_POP_WHS button[id="ITP_BTN_MPOMNG01010_POP_WHS_SEARCH"]').off('click').on('click', function() { _this.search(); }); }, choice: function(elem) { var whsId = $(elem).data('whs-id'); var whsNm = $(elem).parent().prev().find('.fnWhsNm').text(); var location = $(elem).data('location'); $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_ID').val(whsId); $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_NM').val(whsNm); $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_LOCATION').val(location); mobPopObj.hide(ID_ITP_POP_MPOMNG01010_WHS_AREA); itp_fn_form_clear_validate(null, '#ITP_FORM_MPOMNG01010_DETAIL'); }, delete: function() { $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_ID').val(''); $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_WHS_NM').val(''); $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_LOCATION').val(''); } }, popReqConfirm: { saveMode: 1, // 1 : 임시저장, 2 : 구매요청, 요청금액이 가능금액보다 클 경우 (3 : PG 정보 없음, 4 : 선불매장, 5 : 후불매장) init: function (parentId) { this.formId = '#ITP_FORM_MPOMNG01010_DETAIL'; this.pchReqStCd = (parentId === 'ITP_BTN_MPOMNG01010_DETAIL_REQ_ORDER') ? PCH_REQ_ST_CD_REQUEST_SAVE : PCH_REQ_ST_CD_TEMP_SAVE; this.view(); this.action(); }, view: function() { var popMsg = ''; var loanDvsn = $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_LOAN_DVSN').val(); var ordUseAmt = CommonObj.onlyNumber($('#ITP_FORM_MPOMNG01010_DETAIL .fnOrdUseAmt').text()); var pchReqAmtTot = CommonObj.onlyNumber($('#ITP_FORM_MPOMNG01010_DETAIL .fnPchReqAmtTot').text()); if(this.pchReqStCd === PCH_REQ_ST_CD_REQUEST_SAVE) { // 구매요청 if(loanDvsn === 'LD03') { // 무정산 this.saveMode = 2; popMsg = '구매요청 하시겠습니까?'; $('#ITP_POP_MPOMNG01010_REQ_AREA .divOrdPssblAmt').hide(); $('#ITP_POP_MPOMNG01010_REQ_AREA .divOrdAmt').hide(); $('#ITP_POP_MPOMNG01010_REQ_AREA .divOrdReqAmt').addClass('border'); $('#ITP_POP_MPOMNG01010_REQ_AREA #ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM').text('확인'); } else { $('#ITP_POP_MPOMNG01010_REQ_AREA .divOrdPssblAmt').show(); $('#ITP_POP_MPOMNG01010_REQ_AREA .divOrdAmt').show(); $('#ITP_POP_MPOMNG01010_REQ_AREA .divOrdReqAmt').removeClass('border'); if (Number(ordUseAmt) < Number(pchReqAmtTot)) { // 요청금액이 가능금액보다 클 경우 if(CommonObj.isPayPossible()) { // PG 정보 여부 if(loanDvsn === 'LD01') { // 선불매장 this.saveMode = 4; popMsg = '선불매장이므로 결재를 하셔야 구매요청이 진행이 됩니다.
' + '결재를 하시겠습니까?'; $('#ITP_POP_MPOMNG01010_REQ_AREA #ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM').text('결제'); } else if(loanDvsn === 'LD02') { // 후불매장 this.saveMode = 5; popMsg = '구매한도가 부족합니다.
' + '선결재를 하신 후에 구매요청을 하시기 바랍니다.
' + '결재를 하시겠습니까?'; $('#ITP_POP_MPOMNG01010_REQ_AREA #ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM').text('결제'); } } else { this.saveMode = 3; if(loanDvsn === 'LD01') { // 선불매장 popMsg = '선불매장이므로 입금을 하시고, 입금등록 후 브랜드에서 승인이 되어야 구매요청을 하실 수 있습니다.'; } else if(loanDvsn === 'LD02') { // 후불매장 popMsg = '구매한도가 부족합니다.
' + '선입금을 하시고, 입금등록 후 브랜드에서 승인이 되어야 구매요청을 하실 수 있습니다.\n'; } $('#ITP_POP_MPOMNG01010_REQ_AREA #ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM').text('확인'); } } else { this.saveMode = 2; popMsg = '구매요청 하시겠습니까?'; $('#ITP_POP_MPOMNG01010_REQ_AREA #ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM').text('확인'); } } } else { // 임시저장 this.saveMode = 1; popMsg = '임시저장 하시겠습니까?'; $('#ITP_POP_MPOMNG01010_REQ_AREA #ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM').text('확인'); } $('#ITP_POP_MPOMNG01010_REQ_AREA .fnPopDlvReqDt').text($('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_DLV_REQ_DT').val()); $('#ITP_POP_MPOMNG01010_REQ_AREA .fnItemQty').text(CommonObj.currency.add(mobContObj.list.rows.length, '개')); $('#ITP_POP_MPOMNG01010_REQ_AREA .fnOrdReqAmt').text($('#ITP_AJAX_MPOMNG01010_VIEW_CONTAINER .fnPchReqAmtTot').text()); $('#ITP_POP_MPOMNG01010_REQ_AREA .fnOrdPssblAmt').text($('#ITP_AJAX_MPOMNG01010_VIEW_CONTAINER .fnOrdUseAmt').text()); var ordAmt = Number(pchReqAmtTot) - Number(ordUseAmt); $('#ITP_POP_MPOMNG01010_REQ_AREA .fnOrdAmt').text(CommonObj.currency.add(ordAmt > 0 ? ordAmt : 0)); $('#ITP_POP_MPOMNG01010_REQ_AREA .pop_msg').html(popMsg); }, action: function() { var _this = this; $('#ITP_POP_MPOMNG01010_REQ_AREA button[id="ITP_BTN_MPOMNG01010_POP_REQ_CONFIRM"]').off('click').on('click', function() { $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_PCH_REQ_ST_CD').val(_this.pchReqStCd); _this.save(); }); }, save: function() { var procSave = function () { let param = $('#ITP_FORM_MPOMNG01010_DETAIL').serializeObject(); $.each(mobContObj.list.rows, function(index, item) { item['viewCd'] = 'C'; item['pchReqAmt'] = Number(item.unitAmt) * Number(item.pchReqQty); }); param.gridInsertData = mobContObj.list.rows; var saveFn = function (result) { console.log(result); mobPopObj.hide('ITP_POP_MPOMNG01010_REQ_AREA'); mobContObj.reset(); }; // console.log(JSON.stringify(param)); fn_ajax_call(API_MOBILE_SAVE, JSON.stringify(param), saveFn, 'POST'); }; if (this.saveMode === 1 || this.saveMode === 2 || this.saveMode === 3) { if(this.saveMode === 3) $('#ITP_FORM_MPOMNG01010_DETAIL #ITP_FORM_MPOMNG01010_DETAIL_PCH_REQ_ST_CD').val(PCH_REQ_ST_CD_TEMP_SAVE); procSave(); } else if (this.saveMode === 4 || this.saveMode === 5) { // 결제 팝업 var ordUseAmt = CommonObj.onlyNumber($('#ITP_FORM_MPOMNG01010_DETAIL .fnOrdUseAmt').text()); var pchReqAmtTot = CommonObj.onlyNumber($('#ITP_FORM_MPOMNG01010_DETAIL .fnPchReqAmtTot').text()); var args = { 'payTpCd' : '40', 'brandId' : $('#ITP_FORM_MPOMNG01010_DETAIL_BRAND_ID').val(), 'storeId' : $('#ITP_FORM_MPOMNG01010_DETAIL_STORE_ID').val(), 'goodsAmt' : Number(pchReqAmtTot - ordUseAmt) }; fn_call_popup('biz', 'BIZPOP_PO_PAYMENT', '#ITP_ASIDE', procSave, args, 'M'); } } }, show: function(popId, parentId) { var _this = this; $('button[id$="CLOSE"]').off('click').on('click', function() { var id = $(this).attr('id'); if($(this).hasClass('btn-pop-close')) { _this.hide(id); } }); if(parentId === 'ITP_BTN_MPOMNG01010_DETAIL_REQ_ORDER' || parentId === 'ITP_BTN_MPOMNG01010_DETAIL_TEMP_SAVE') { var formId = '#ITP_FORM_MPOMNG01010_DETAIL'; itp_fn_form_clear_validate(null, formId); if (itp_fn_form_event.isValid(formId)) { if($('#ITP_LIST_MPOMNG01010_DETAIL_ROWS > li').size() < 1) { itp_fn_modal_alert('품목추가 버튼을 이용하여 품목을 추가해 주세요.'); return false; } else { var chkMsg = ''; $.each(mobContObj.list.rows, function(index, item) { if(item.pchReqQty === '') { chkMsg = '수량을 입력하세요.'; return false; } }); if(chkMsg !== '') { itp_fn_modal_alert(chkMsg); return; } $('#' + popId).show(); mobPopObj.init(popId, parentId); } } } else { $('#' + popId).show(); mobPopObj.init(popId, parentId); } }, hide: function(id) { $('#' + id).closest('.mobile-pop-close').hide(); } };