123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- /********************************************************
- --------------------------------------------------------
- - Object 목록 -
- --------------------------------------------------------
- * const gridColModel = {} : 화면 Grid Object *
- * let pageObj = {} : 화면공통 Object *
- * let listObj = {} : 목록화면 Object *
- *******************************************************/
- /*화면 변수*/
- const STOCKMNG01010_GRID_ID = '#ITP_STOCKMNG01010_jqGrid';
- const STOCKMNG01010_GRID_LIST = '#ITP_STOCKMNG01010_jqGrid_list';
- const STOCKMNG01010_GRID_PAGER = '#ITP_STOCKMNG01010_jqGridPager';
- const STOCKMNG01010_GRID_EMPTY = '#ITP_STOCKMNG01010_jqGridEmpty';
- let ITP_FORM_STOCKMNG01010_DETAIL_IS_DUPLICATE = false;
- let ITP_FORM_STOCKMNG01010_DETAIL_IS_WRITING = false;
- let STOCKMNG01010_DETAIL_GRID_LAST_ROW_ID;
- /*API URL*/
- let STOCK_MNG_DETAIL_GRID_LIST = '/api/stock/mng/detail-grid-list';
- let WHS_MNG_ADD_WHS = '/api/whs/mng/add-whs';
- let WHS_MNG_DETAIL_GRID_LIST = '/api/whs/mng/detail-grid-list';
- let WHS_MNG_LOCATION_GRID_LIST = '/api/whs/mng/location-grid-list';
- /*화면 Grid ColModel*/
- const gridColModel = {
- list: [
- {
- index: 'BRAND_ID', name: 'brandId',
- label: "브랜드ID",
- width: '0', fixed: false, align: 'center',
- sortable: false, hidden: true
- },
- {
- index: 'LOCATION', name: 'location',
- label: "로케이션",
- width: '0', 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: 'STORE_NM', name: 'storeNm',
- label: "매장명",
- width: '10', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'WHS_ID', name: 'whsId',
- label: "창고번호",
- width: '8', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'WHS_NM', name: 'whsNm',
- label: "창고명",
- width: '13', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'LOCATION_NM', name: 'locationNm',
- label: "Location명",
- width: '10', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'ITEM_ID', name: 'itemId',
- label: "품목번호",
- width: '8', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'ITEM_NM', name: 'itemNm',
- label: "품목명",
- width: '10', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'UNIT', name: 'unit',
- label: "단위",
- width: '8', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'STCK_QTY', name: 'stckQty',
- label: "현재고수량",
- width: '8', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'PRP_STCK_QTY', name: 'prpStckQty',
- label: "적정재고수량",
- width: '8', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'SFT_STCK_RT', name: 'sftStckRt',
- label: "안전재고비율(%)",
- width: '10', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'CUR_STCK_RT', name: 'curStckRt',
- label: "현재고비율(%)",
- width: '10', fixed: false, align: 'center',
- sortable: false, hidden: false
- }
- ]
- };
- require(['config'], function() {
- require([
- ], function($) {
- pageObj.init();
- });
- });
- /*화면공통 Object*/
- let pageObj = {
- init: function () {
- this.ui.init();
- this.event.init();
- },
- ui: {
- init: function () {
- this.view();
- this.grid();
- this.ready();
- },
- view: function() {
- // 버튼 권한설정
- fn_proc_btn_auth('STOCKMNG01010');
-
- // 브랜드ID 지정
- var data = JSON.parse(sessionStorage.getItem('itp_manage_brand_info'));
- $('#ITP_FORM_STOCKMNG01010_SEARCH_BRAND_ID').val(data.brandId);
-
- pageObj.fnWhsList(function() {
- pageObj.fnLocationList();
- }); // 창고리스트
-
- // 공통코드 표시
- // fn_make_select(CODE_LIST, 'WHS_DVSN', 'ITP_FORM_STOCKMNG01010_WHS_DVSN');
- // 조회일자 지정
- $('#ITP_TAB_STOCKMNG01010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
- },
- grid: function() {
- itp_fn_jqgrid_resize(STOCKMNG01010_GRID_ID, STOCKMNG01010_GRID_LIST, 'lg');
- listObj.empty.init();
- itp_fn_fire_window_resize();
- },
- ready: function() {
- listObj.init();
- }
- },
- event: {
- init: function () {
- this.button();
- this.change();
- },
- button: function () {
- // 버튼 클릭 이벤트
- $('button').each(function() {
- var id = $(this).attr('id');
- $(this).on('click', function() {
- switch (id) {
- case 'ITP_BTN_STOCKMNG01010_SRH' : listObj.button.search(); break; // 조회 버튼
- case 'ITP_BTN_STOCKMNG01010_ADDROW' : listObj.button.clickStockProc(); break; // 재고처리 버튼
- case 'ITP_BTN_STOCKMNG01010_DELROW' : listObj.button.clickStockHist(); break; // 재고이력 버튼
- }
- });
- });
- $('body').on('click', function(e) {
-
- });
- },
- change: function () {
- // 창고 변경
- $('#ITP_FORM_STOCKMNG01010_SEARCH_WHS_ID').on('change', function() {
- pageObj.fnLocationList(function() {
- listObj.button.search(); // 조회
- }); // 로케이션 리스트
- });
- $('#ITP_FORM_STOCKMNG01010_SEARCH_LOCATION').on('change', function() {
- listObj.button.search(); // 조회
- });
-
- }
- },
- switchScreen: function(mode) {
- if(mode == 'LIST') { // 목록
- fn_show_btn_auth('#ITP_BTN_STOCKMNG01010_SRH');
- $('#ITP_AJAX_STOCKMNG01010_LIST_CONTAINER').show();
- }
- },
- fnWhsList: function(fnCall) {
- const brandIdVal = $('#ITP_FORM_STOCKMNG01010_SEARCH_BRAND_ID').val();
- const param = {sbrandId: brandIdVal, pagingYn: false};
-
- fn_ajax_call(WHS_MNG_DETAIL_GRID_LIST, JSON.stringify(param), function(result) {
-
- fn_make_select_whs(result.gridRows, 'ITP_FORM_STOCKMNG01010_SEARCH_WHS_ID');
-
- if (fnCall !== undefined || typeof fnCall !== 'undefined') fnCall();
-
- }, 'POST');
- },
- fnLocationList: function(fnCall) {
- const brandIdVal = $('#ITP_FORM_STOCKMNG01010_SEARCH_BRAND_ID').val();
- const whsIdVal = $('#ITP_FORM_STOCKMNG01010_SEARCH_WHS_ID').val();
- const param = {brandId: brandIdVal, whsId: whsIdVal, pagingYn: false};
-
- fn_ajax_call(WHS_MNG_LOCATION_GRID_LIST, JSON.stringify(param), function(result) {
-
- fn_make_select_location(result.gridRows, 'ITP_FORM_STOCKMNG01010_SEARCH_LOCATION');
-
- if (fnCall !== undefined || typeof fnCall !== 'undefined') fnCall();
-
- }, 'POST');
- }
- };
- /*목록화면 Object*/
- let listObj = {
- init: function () {
- this.grid.init();
- },
- itp_STOCKMNG01010_search: false,
- button: {
- search: function() {
- listObj.itp_STOCKMNG01010_search = true;
- let param = $('#ITP_FORM_STOCKMNG01010_SEARCH').serializeObject();
- param.gridSize = $.jgrid.defaults.rowNum;
- param.gridPage = $.jgrid.defaults.page;
- $(STOCKMNG01010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
- },
- clickStockProc: function() {
- // 그리드에서 최소1개는 선택해야 함
- const rowKey = $(STOCKMNG01010_GRID_ID).getGridParam('selrow');
- if (!rowKey) {
- itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.noData);
- return;
- }
- var selectedIds = $(STOCKMNG01010_GRID_ID).getGridParam('selarrrow');
- if (selectedIds.length > 1) {
- itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.noSingleData);
- return;
- }
- var brandId = $(STOCKMNG01010_GRID_ID).jqGrid('getRowData', selectedIds[0]).brandId;
- var whsId = $(STOCKMNG01010_GRID_ID).jqGrid('getRowData', selectedIds[0]).whsId;
- var location = $(STOCKMNG01010_GRID_ID).jqGrid('getRowData', selectedIds[0]).location;
- var itemId = $(STOCKMNG01010_GRID_ID).jqGrid('getRowData', selectedIds[0]).itemId;
-
- var args = {'brandId': brandId, 'whsId': whsId, 'location': location, 'itemId': itemId};
- fn_call_popup('biz', 'BIZPOP_PO_STOCK_PROC', '#ITP_ASIDE', function(rowDataPop) {
-
- }, args, 'S');
- },
- clickStockHist: function() {
-
- }
- },
- empty: {
- init: function() {
- var _this = this;
- this.push();
- $(STOCKMNG01010_GRID_EMPTY).on('click', function() {
- _this.back();
- _this.itp_STOCKMNG01010_param.gridSize = $.jgrid.defaults.rowNum;
- $(STOCKMNG01010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_STOCKMNG01010_param)}).trigger('reloadGrid');
- });
- },
- itp_STOCKMNG01010_param: {},
- push: function() {
- let param = $('#ITP_FORM_STOCKMNG01010_SEARCH').serializeObject();
- listObj.itp_STOCKMNG01010_param = param;
- },
- back: function() {
- $('#ITP_FORM_STOCKMNG01010_DEVI_TP_CD').val(this.itp_STOCKMNG01010_param.deviTpCd);
- $('#ITP_FORM_STOCKMNG01010_ORDER_YN').val(this.itp_STOCKMNG01010_param.orderYn);
- $('#ITP_FORM_STOCKMNG01010_ADT_AUTH_CD').val(this.itp_STOCKMNG01010_param.adtAuthCd);
- $('#ITP_FORM_STOCKMNG01010_EMAIL_RCV_YN').val(this.itp_STOCKMNG01010_param.emailRcvYn);
- $('#ITP_FORM_STOCKMNG01010_MEMB_EXIT_DT').val(this.itp_STOCKMNG01010_param.membExitDt);
- $('#ITP_FORM_STOCKMNG01010_FROM_DT').val(this.itp_STOCKMNG01010_param.fromDt);
- $('#ITP_FORM_STOCKMNG01010_TO_DT').val(this.itp_STOCKMNG01010_param.toDt);
- $('#ITP_FORM_STOCKMNG01010_KEYWORD').val(this.itp_STOCKMNG01010_param.keyword);
- }
- },
- grid: {
- init: function () {
- // 데이터 없을때
- listObj.empty.push();
- this.search();
- },
- colModel: gridColModel.list,
- search: function() {
- pageObj.switchScreen('LIST');
- this.unload();
- this.load();
- },
- load: function() {
- var data = JSON.parse(sessionStorage.getItem('itp_manage_brand_info'));
- $('#ITP_FORM_STOCKMNG01010_SEARCH_BRAND_ID').val(data.brandId);
-
- let param = $('#ITP_FORM_STOCKMNG01010_SEARCH').serializeObject();
- param.gridSize = $.jgrid.defaults.rowNum;
- var option = {
- gridId: STOCKMNG01010_GRID_ID,
- colModel: gridColModel.list,
- param: JSON.stringify(param),
- url: DOMAIN + STOCK_MNG_DETAIL_GRID_LIST,
- pager: STOCKMNG01010_GRID_PAGER,
- multiselect: true,
- onCellSelect: function(rowId, cellIdx, cellValue) {
- var cm = $(this).jqGrid('getGridParam', 'colModel');
- var colNm = cm[cellIdx].name;
- if (colNm == 'whsNm') {
-
- }
- },
- loadComplete: function(data) {
- console.log(data);
- itp_fn_grid_load_complete(data, STOCKMNG01010_GRID_ID, true, 'number', 'STOCKMNG01010', listObj.itp_STOCKMNG01010_search, listObj.empty, true, data.gridRecords, true);
- var ids = $(STOCKMNG01010_GRID_ID).getDataIDs();
- $.each(ids, function(idx, rowId) {
- // $(STOCKMNG01010_GRID_ID).jqGrid('setCell', rowId, 'whsNm', '', ITP_GRID_COL_STYLE.link);
- });
- },
- onPaging: function(action) {
- itp_fn_grid_paging(STOCKMNG01010_GRID_ID, action, param);
- }
- };
- itp_fn_grid_make_remote(option);
- },
- clearData : function() {
- $(STOCKMNG01010_GRID_ID).jqGrid('clearGridData', true);
- $(STOCKMNG01010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
- $(STOCKMNG01010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
- $(STOCKMNG01010_GRID_EMPTY).show();
- },
- unload : function() {
- $.jgrid.gridUnload(STOCKMNG01010_GRID_ID);
- }
- }
- };
|