require(['config'], function() { require([ ], function($) { pageObj.init(); }); }); //화면변수 const COLLMNG03010_GRID_ID = '#ITP_COLLMNG03010_jqGrid'; const COLLMNG03010_GRID_LIST = '#ITP_COLLMNG03010_jqGrid_list'; const COLLMNG03010_GRID_PAGER = '#ITP_COLLMNG03010_jqGridPager'; const COLLMNG03010_GRID_EMPTY = '#ITP_COLLMNG03010_jqGridEmpty'; //API URL let API_RTNMNG_INOUTMNG_SPPLY_PICK_GRID_LIST ='/api/rtnmng/inoutmng/spply-pick-grid-list'; //화면 grid ColModel const gridColModel = { list:[ { index: 'VIEW_CD', name: 'viewCd', label: ITP_MSG_LOCALE.label.viewCd, width: '10', fixed: false, align: 'center', sortable: false, hidden: true }, { index: 'BRAND_ID', name: 'brandId', label: ITP_MSG_LOCALE.label.brandId, width: '10', fixed: false, align: 'center', sortable: false, hidden: true }, { index: 'BRAND_NM', name: 'brandNm', label: ITP_MSG_LOCALE.label.brandNm, // 브랜드명 width: '10', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'COL_PICK_UNQ_NO', name: 'colPickUnqNo', label: ITP_MSG_LOCALE.label.colPickUnqNo, // 수거서번호 width: '10', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'PICK_ST_NM', name: 'pickStNm', label: ITP_MSG_LOCALE.label.pickStNm, // 수거서상태 width: '8', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'COL_REQ_DT', name: 'colRegDt', label: ITP_MSG_LOCALE.label.colRegDt, // 수거일자 width: '10', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'COL_REQ_DT', name: 'colReqDt', label: ITP_MSG_LOCALE.label.colReqDt, // 수거요청일 width: '10', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'COL_SCH_DT', name: 'colSchDt', label: ITP_MSG_LOCALE.label.colSchDt, // 수거예정일 width: '10', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'ITEM_ID', name: 'itemId', label: ITP_MSG_LOCALE.label.itemId, // 품목번호 width: '10', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'ITEM_NM', name: 'itemNm', label: ITP_MSG_LOCALE.label.itemNm, // 품목명 width: '8', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'COL_REQ_QTY', name: 'colReqQty', label: ITP_MSG_LOCALE.label.colReqQty, // 수거수량 width: '6', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'RTN_RSN_DVSN_NM', name: 'rtnRsnDvsnNm', label: ITP_MSG_LOCALE.label.rtnRsnDvsnNm, // 반품사유구분 width: '9', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'UNIT_AMT', name: 'unitAmt', label: ITP_MSG_LOCALE.label.unitAmt, // 단가 width: '7', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'COL_REQ_AMT', name: 'colReqAmt', label: ITP_MSG_LOCALE.label.colReqAmt, // 수거금액 width: '9', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'WHS_NM', name: 'whsNm', label: ITP_MSG_LOCALE.label.whsNm, // 납품장소 width: '10', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'PICK_MGR_NM', name: 'pickMgrNm', label: ITP_MSG_LOCALE.label.pickMgrNm, // 수거담당자 width: '10', fixed: false, align: 'center', sortable: false, hidden: false }, { index: 'PICK_MGR_TEL_NO', name: 'pickMgrTelNo', label: ITP_MSG_LOCALE.label.pickMgrTelNo, // 수거담당자연락처 width: '10', fixed: false, align: 'center', sortable: false, hidden: false } ], view: [], detail: [] }; /*화면공통 Object*/ let pageObj = { init: function() { this.ui.init(); this.event.init(); this.action(); }, ui: { init: function() { this.view(); this.grid(); this.ready(); }, view: function() { // 버튼 권한설정 fn_proc_btn_auth('COLLMNG03010'); // 공통코드 표시 $('select').each(function() { if($(this).data('select-code')) { fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id')); } }); // 조회일자 지정 var now = new Date(); var defaultToDate = new Date(now); defaultToDate.setDate(now.getDate() + 7); $('#ITP_TAB_COLLMNG03010 .input-group.date').datepicker(ITP_DATE_LANGUAGE); $('#ITP_FORM_COLLMNG03010_SEARCH_FROM_DT').datepicker('setDate', now); $('#ITP_FORM_COLLMNG03010_SEARCH_TO_DT').datepicker('setDate', defaultToDate); }, grid: function() { itp_fn_jqgrid_resize(COLLMNG03010_GRID_ID, COLLMNG03010_GRID_LIST, 'lg'); listObj.empty.init(); itp_fn_fire_window_resize(); }, ready: function() { listObj.init(); } }, event: { init: function() { this.button(); }, button: function() { // 버튼 클릭 이벤트 $('button').each(function() { var id = $(this).attr('id'); $(this).on('click', function() { switch (id) { case 'ITP_BTN_COLLMNG03010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭 case 'ITP_BTN_COLLMNG03010_NEWREG' : listObj.button.create(); break; // 신규등록 버튼 case 'ITP_BTN_COLLMNG03010_MODIFY' : modifyObj.button.modify(); break; // 수정 버튼 case 'ITP_BTN_COLLMNG03010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼 case 'ITP_BTN_COLLMNG03010_DELETE' : modifyObj.button.del(); break; // 발주 취소 버튼(예정) } }); }); } }, switchScreen: function(mode) { $('.itp_det_head').find('button[id^="ITP_BTN_COLLMNG03010_"]').each(function(i) { $(this).hide(); }); $('#ITP_TAB_COLLMNG03010').find('div[id$="_CONTAINER"]').each(function(i) { $(this).hide(); }); if(mode == 'LIST') { // 목록 fn_show_btn_auth_array(['#ITP_BTN_COLLMNG03010_SRH', '#ITP_BTN_COLLMNG03010_NEWREG']); $('#ITP_AJAX_COLLMNG03010_LIST_CONTAINER').show(); $('#ITP_FORM_COLLMNG03010_SEARCH #ITP_FORM_COLLMNG03010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId')); if(fn_make_user_info.get('spplyId').length != 0){ $('#ITP_FORM_COLLMNG03010_SEARCH #ITP_FORM_COLLMNG03010_SEARCH_SPPLY_ID').val(fn_make_user_info.get('spplyId')); } else { $('#ITP_FORM_COLLMNG03010_SEARCH #ITP_FORM_COLLMNG03010_SEARCH_SPPLY_ID').val(fn_make_user_info.get('userId')); } $('#ITP_BTN_COLLMNG03010_SRH').show(); $('#ITP_BTN_COLLMNG03010_PRINT').show(); $('#ITP_BTN_COLLMNG03010_SEARCH_WHS_ID').show(); $('#ITP_BTN_COLLMNG03010_DELETE_WHS_ID').show(); } }, action: function() { var _this = this; $('#ITP_BTN_COLLMNG03010_PRINT').on('click', function() { _this.popup(); }); }, popup: function() { var selectedIds = $(COLLMNG03010_GRID_ID).getGridParam('selarrrow'); if(selectedIds.length > 1) { // 1이상 선택시 alert("납품서 하나만 선택해주세요 (대표 납품서번호)") ;//출력 return; //리턴 } var selRowData ; //변수선언 for (var i=selectedIds.length-1; i>=0; i--) { //1개만 선택시 selRowData = $(COLLMNG03010_GRID_ID).jqGrid('getRowData', selectedIds[i]); //cell 선택 } const key = {brandId: selRowData.brandId, colPickUnqNo: selRowData.colPickUnqNo}; // popup key 값 설정 console.log(key); fn_call_popup('biz', 'BIZPOP_COL_STTMT_PRN', '#ITP_ASIDE', null, key, 'S'); } }; /*목록화면 Object*/ let listObj = { init: function() { this.grid.init(); this.action(); }, itp_COLLMNG03010_param: {}, itp_COLLMNG03010_search: false, button: { search: function() { listObj.itp_COLLMNG03010_search = true; let param = $('#ITP_FORM_COLLMNG03010_SEARCH').serializeObject(); param.gridSize = $.jgrid.defaults.rowNum; param.gridPage = $.jgrid.defaults.page; console.log(1234); console.log(JSON.stringify(param)); $(COLLMNG03010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid'); } }, empty: { init: function() { var _this = this; this.push(); $(COLLMNG03010_GRID_EMPTY).on('click', function() { _this.back(); listObj.itp_COLLMNG03010_param.gridSize = $.jgrid.defaults.rowNum; $(COLLMNG03010_GRID_ID).setGridParam({'postData': JSON.stringify(listObj.itp_COLLMNG03010_param)}).trigger('reloadGrid'); }); }, push: function() { let param = $('#ITP_FORM_COLLMNG03010_SEARCH').serializeObject(); listObj.itp_COLLMNG03010_param = param; }, back: function() { $('#ITP_FORM_COLLMNG03010_SERVICE_BRAND_TYPE').val(listObj.itp_COLLMNG03010_param.brandType); $('#ITP_FORM_COLLMNG03010_SERVICE_ST_CD').val(listObj.itp_COLLMNG03010_param.stCd); $('#ITP_FORM_COLLMNG03010_SEARCH_BRAND_NM').val(listObj.itp_COLLMNG03010_param.brandNm); } }, grid: { init: function() { // 데이터 없을때 listObj.empty.push(); this.search(); }, colModel: gridColModel.list, search: function() { pageObj.switchScreen('LIST'); this.unload(); this.load(); }, load: function() { let param = $('#ITP_FORM_COLLMNG03010_SEARCH').serializeObject(); param.gridSize = $.jgrid.defaults.rowNum; console.log(JSON.stringify(param)); var option = { gridId: COLLMNG03010_GRID_ID, colModel: gridColModel.list, param: param, url: DOMAIN + API_RTNMNG_INOUTMNG_SPPLY_PICK_GRID_LIST, pager: COLLMNG03010_GRID_PAGER, multiselect: true, multiboxonly : false, rownumbers: false,/* onCellSelect: function(rowId, cellIdx, cellValue) { var cm = $(this).jqGrid('getGridParam', 'colModel'); var colNm = cm[cellIdx].name; if (colNm === 'pchPodrUnqNo') { const pchPodrUnqNoVal = $(this).jqGrid('getCell', rowId, 'pchPodrUnqNo'); const brandIdVal = $(this).jqGrid('getCell', rowId, 'brandId'); const key = {pchPodrUnqNo: pchPodrUnqNoVal, brandId: brandIdVal}; var param = $.param(key); modifyObj.init(param); } },*/ loadComplete: function(data) { console.log(data); itp_fn_grid_load_complete(data, COLLMNG03010_GRID_ID, true, 'number', 'COLLMNG03010', listObj.itp_COLLMNG03010_search, listObj.empty, true, data.gridRecords, true); }, onPaging: function(action) { itp_fn_grid_paging(COLLMNG03010_GRID_ID, action, param); } }; itp_fn_grid_make_remote(option); }, clearData: function() { $(COLLMNG03010_GRID_ID).jqGrid('clearGridData', true); $(COLLMNG03010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px'); $(COLLMNG03010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData); $(COLLMNG03010_GRID_EMPTY).show(); }, unload: function() { $.jgrid.gridUnload(COLLMNG03010_GRID_ID); } }, action: function() { var _this = this; // 출하창고 조회 버튼 클릭 $('#ITP_BTN_COLLMNG03010_SEARCH_WHS_ID').on('click', function() { _this.popup(); }); // 출하창고 텍스트 삭제 버튼 클릭 $('#ITP_BTN_COLLMNG03010_DELETE_WHS_ID').on('click', function() { $('#ITP_FORM_COLLMNG03010_SEARCH_WHS_NM').val(''); $('#ITP_FORM_COLLMNG03010_SEARCH_WHS_ID').val(''); }); }, popup: function() { var popFn = this.callback.create; const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'),whsDvsn: ''}; fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S'); }, callback: { create: function(rowDataPop) { console.log(rowDataPop); $('#ITP_FORM_COLLMNG03010_SEARCH_WHS_ID').val(rowDataPop.whsId); $('#ITP_FORM_COLLMNG03010_SEARCH_WHS_NM').val(rowDataPop.whsNm); } } };