123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- require(['config'], function() {
- require([
- ], function($) {
- mobPageObj.init();
- });
- });
- /*API URL*/
- const API_MOBILE_GRID_LIST = 'api/rtnmng/inoutmng/retstock-result-grid-list'; // 목록
- const API_MOBILE_INFO = '/api/rtnmng/po/info-pchOdr'; // 상세
- const API_POP_SEARCH_LIST = '/api/whs/mng/pop-whs-search';
- const API_POP_SPPLY_LIST = '/api/spply/pop-grid-list';
- const PAGE_MODE_LIST = "LIST";
- const PAGE_MODE_VIEW = "VIEW";
- let mobPageObj = {
- viewMode: PAGE_MODE_LIST,
- init: function () {
- this.ui.init();
- this.event.init();
- this.ready();
- },
- ui: {
- init: function () {
- this.view();
- this.info();
- },
- view: function() {
- // 공통코드 표시
- $('select').each(function() {
- if($(this).data('select-code')) {
- fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
- }
- });
- // 조회일자 지정
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH_FROM_DT').val(itp_fn_date_add('M', -1));
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH_TO_DT').val(itp_fn_date_add('M', 0));
- },
- 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'));
- }
- },
- event: {
- init: function() {
- this.button();
- },
- button: function() {
- $('button[id^="ITP_BTN_MRTNMNG06010_LIST"]').on('click', function() {
- var id = $(this).attr('id');
- switch (id) {
- case 'ITP_BTN_MRTNMNG06010_LIST_SEARCH_WHS_NM' : mobPopObj.popWhsNm.init('WHS'); break;
- case 'ITP_BTN_MRTNMNG06010_LIST_DELETE_WHS_NM' : mobPopObj.popWhsNm.delete('WHS'); break;
- case 'ITP_BTN_MRTNMNG06010_LIST_SEARCH_RTN_WHS_NM' : mobPopObj.popWhsNm.init('RTN_WHS'); break;
- case 'ITP_BTN_MRTNMNG06010_LIST_DELETE_RTN_WHS_NM' : mobPopObj.popWhsNm.delete('RTN_WHS'); break;
- case 'ITP_BTN_MRTNMNG06010_LIST_SEARCH' : mobContentObj.list.search(); break;
- }
- return false;
- });
- $(document).on('click', '#ITP_LIST_MRTNMNG06010_LIST_ITEM_ROWS li', function() {
- var item = mobContentObj.list.rows[$(this).index()];
- mobContentObj.view.init(item);
- });
- $(document).on('click', '#ITP_POP_MRTNMNG06010_LIST_SPPLY_ROWS li button', function() {
- mobPopObj.popSpply.choice($(this));
- });
- $(document).on('click', '#ITP_LIST_MRTNMNG06010_POP_WHS_ROWS li button', function() {
- mobPopObj.popWhsNm.choice($(this));
- });
- }
- },
- switchScreen: function(mode) {
- $('#ITP_MOBILE_MRTNMNG06010').find('div[id$="_CONTAINER"]').each(function(i) {
- $(this).hide();
- });
- if(mode === PAGE_MODE_LIST) {
- $('#ITP_AJAX_MRTNMNG06010_LIST_CONTAINER').show();
- this.moreView(true);
- }
- this.viewMode = mode;
- },
- moreView: function(isScroll) {
- var _this = this;
- if(isScroll) {
- $('#ITP_LIST_MRTNMNG06010_LIST_ITEM_AREA').on('scroll', function () {
- if($(this).scrollTop() + $(this).innerHeight() + 1 >= $(this)[0].scrollHeight) {
- if(mobContentObj.list.totPage > mobContentObj.list.listPage) {
- if(!mobContentObj.list.isSearch) {
- mobContentObj.list.load();
- }
- }
- }
- });
- } else {
- $('#ITP_LIST_MRTNMNG06010_LIST_AREA').off('scroll');
- }
- },
- ready: function() {
- mobContentObj.list.init();
- }
- };
- let mobContentObj = {
- list: {
- listSize: 10,
- listPage: 0,
- totPage: 0,
- isSearch: false,
- rows: [],
- init: function() {
- mobPageObj.switchScreen(PAGE_MODE_LIST);
- // this.search();
- },
- search: function() {
- if($('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_RTN_WHS_NM').val().length < 1) {
- alert('수거창고를 지정해주세요!');
- return;
- }
- var formId = '#ITP_FORM_MRTNMNG05010_LIST_SEARCH';
- itp_fn_form_clear_validate(null, formId);
- if (itp_fn_form_event.isValid(formId)) {
- this.listPage = 0;
- this.totPage = 0;
- this.rows.length = 0;
- $('#ITP_LIST_MRTNMNG06010_LIST_ITEM_ROWS').empty();
- this.load();
- }
- },
- load: function() {
- var _this = this;
- this.isSearch = true;
- var callbackFn = function(result) {
- console.log(result);
- _this.isSearch = false;
- _this.totPage = result.gridTotal;
- $.each(result.gridRows, function (i, item) {
- $('#ITP_LIST_MRTNMNG06010_LIST_ITEM_AREA .panel-group').append($('#ITP_LIST_MRTNMNG06010_LIST_ITEM_ROWCOPY').html());
- var $li = $('#ITP_LIST_MRTNMNG06010_LIST_ITEM_AREA .panel-group > .list-row:last');
- $li.find('.fnPchPodrUnqNo').text(item.pchPodrUnqNo);
- $li.find('.fnDlvCmpltDt').text(item.dlvCmpltDt);
- $li.find('.fnDlvSchDt').text(item.dlvSchDt);
- $li.find('.fnSpplyNm').text(item.spplyNm);
- $li.find('.fnWhsNm').text(item.whsNm);
- $li.find('.fnItemNm').text(item.itemNm);
- $li.find('.fnPodrQty').text(CommonObj.comma.set(item.podrQty));
- $li.find('.fnDlvQty').text(CommonObj.comma.set(item.dlvQty));
- _this.rows.push(item);
- });
- };
- var errFn = function() { _this.isSearch = false;};
- const param = $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH').serializeObject();
- param.gridPage = ++this.listPage;
- param.gridSize = this.listSize;
- param.fromDt = CommonObj.onlyNumber(param.fromDt);
- param.toDt = CommonObj.onlyNumber(param.toDt);
- console.log(JSON.stringify(param));
- fn_ajax_call(API_MOBILE_GRID_LIST, JSON.stringify(param), callbackFn, 'POST', errFn);
- }
- }
- };
- let mobPopObj = {
- popSpply: {
- popId: 'ITP_POP_MRTNMNG06010_SPPLY_AREA',
- rows: [],
- init: function() {
- this.rows.length = 0;
- mobPopObj.show(this.popId);
- this.search();
- this.action();
- },
- search: function() {
- var _this = this;
- $('#ITP_POP_MRTNMNG06010_LIST_SPPLY_AREA .panel-group').empty();
- var callbackFn = function(result) {
- console.log(result);
- _this.view(result.gridRows);
- };
- let param = $('#ITP_FORM_MRTNMNG06010_POP_SPPLY_SEARCH').serializeObject();
- fn_ajax_call(API_POP_SPPLY_LIST, JSON.stringify(param), callbackFn, 'POST');
- },
- view: function(gridRows) {
- this.rows = gridRows;
- $.each(gridRows, function (i, item) {
- $('#ITP_POP_MRTNMNG06010_LIST_SPPLY_AREA .panel-group').append($('#ITP_POP_MRTNMNG06010_LIST_SPPLY_ROWCOPY').html());
- var $li = $('#ITP_POP_MRTNMNG06010_LIST_SPPLY_AREA .panel-group > .list-row:last');
- $li.find('.fnSpplyNm').text(item.spplyNm);
- $li.find('.fnStNm').text($li.find('.fnStNm').text().replace('$', item.stNm));
- $li.find('.fnSpplyId').data('item-key', item.spplyId);
- });
- },
- choice: function(elem) {
- var _this = this;
- var spplyId = $(elem).data('item-key');
- $.each(this.rows, function (i, item) {
- if(spplyId === item.spplyId) {
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_SPPLY_ID').val(item.spplyId);
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_SPPLY_NM').val(item.spplyNm);
- _this.close();
- return false;
- }
- });
- },
- action: function() {
- var _this = this;
- $('button[id^="ITP_BTN_MRTNMNG06010_POP_SPPLY"]').off('click').on('click', function() {
- var id = $(this).attr('id');
- switch (id) {
- case 'ITP_BTN_MRTNMNG06010_POP_SPPLY_SEARCH' : _this.search(); break;
- case 'ITP_BTN_MRTNMNG06010_POP_SPPLY_CHOICE' : _this.choice($(this)); break;
- case 'ITP_BTN_MRTNMNG06010_POP_SPPLY_CLOSE' : _this.close(); break;
- }
- return false;
- });
- },
- delete: function() {
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_SPPLY_ID').val('');
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_SPPLY_NM').val('');
- },
- close: function() {
- this.rows.length = 0;
- $('#ITP_POP_MRTNMNG06010_LIST_SPPLY_AREA .panel-group').empty();
- $('#ITP_FORM_MRTNMNG06010_POP_SPPLY_SEARCH #ITP_FORM_MRTNMNG06010_POP_SPPLY_KEYWORD').val('');
- mobPopObj.hide(this.popId);
- }
- },
- popWhsNm: {
- popId: 'ITP_POP_MRTNMNG06010_WHS_AREA',
- rows: [],
- init: function (mode) {
- this.popMode = mode;
- this.rows.length = 0;
- mobPopObj.show(this.popId);
- this.search();
- this.action();
- },
- search: function () {
- var _this = this;
- $('#ITP_LIST_MRTNMNG06010_POP_WHS_AREA .panel-group').empty();
- var callbackFn = function(result) {
- console.log(result);
- _this.view(result.gridRows);
- };
- const param = $('#ITP_FORM_MRTNMNG06010_POP_WHS').serializeObject();
- fn_ajax_call(API_POP_SEARCH_LIST, JSON.stringify(param), callbackFn, 'POST');
- },
- view: function(gridRows) {
- this.rows = gridRows;
- $.each(gridRows, function (i, item) {
- $('#ITP_LIST_MRTNMNG06010_POP_WHS_AREA .panel-group').append($('#ITP_LIST_MRTNMNG06010_POP_WHS_ROWCOPY').html());
- var $li = $('#ITP_LIST_MRTNMNG06010_POP_WHS_AREA .panel-group > .list-row:last');
- $li.find('.fnWhsNm').text(item.whsNm);
- $li.find('.fnLocationNm').text(item.locationNm);
- $li.find('.fnWhsId').data('whs-id', item.whsId);
- });
- },
- choice: function(elem) {
- var _this = this;
- var whsId = $(elem).data('whs-id');
- $.each(this.rows, function (i, item) {
- if(whsId === item.whsId) {
- if(_this.popMode === 'RTN_WHS') {
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_RTN_WHS_ID').val(item.whsId);
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_RTN_WHS_NM').val(item.whsNm);
- } else {
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_WHS_ID').val(item.whsId);
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_WHS_NM').val(item.whsNm);
- }
- _this.close();
- return false;
- }
- });
- },
- action: function() {
- var _this = this;
- $('button[id^="ITP_BTN_MRTNMNG06010_POP_WHS"]').off('click').on('click', function() {
- var id = $(this).attr('id');
- switch (id) {
- case 'ITP_BTN_MRTNMNG06010_POP_WHS_SEARCH' : _this.search(); break;
- case 'ITP_BTN_MRTNMNG06010_POP_WHS_CHOICE' : _this.choice($(this)); break;
- case 'ITP_BTN_MRTNMNG06010_POP_WHS_CLOSE' : _this.close(); break;
- }
- return false;
- });
- },
- delete: function() {
- if(this.popMode === 'RTN_WHS') {
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_RTN_WHS_ID').val('');
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_RTN_WHS_NM').val('');
- } else {
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_WHS_ID').val('');
- $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_WHS_NM').val('');
- }
- },
- close: function() {
- this.rows.length = 0;
- $('#ITP_POP_MRTNMNG06010_LIST_WHS_AREA .panel-group').empty();
- $('#ITP_FORM_MRTNMNG06010_POP_WHS #ITP_FORM_MRTNMNG06010_POP_WHS_KEYWORD').val('');
- mobPopObj.hide(this.popId);
- }
- },
- show: function(popId) {
- $('button[id$="_CLOSE"]').off('click').on('click', function() {
- console.log($(this).attr('id'));
- if($(this).hasClass('btn-pop-close')) {
- mobPopObj.hide(popId);
- }
- });
- $('#' + popId).show();
- },
- hide: function(popId) {
- $('#' + popId).closest('.mobile-pop-close').hide();
- }
- };
|