123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483 |
- require(['config'], function() {
- require([
- ], function($) {
- pageObj.init();
- });
- });
- /********************************************************
- --------------------------------------------------------
- - Object 목록 -
- --------------------------------------------------------
- * const gridColModel = {} : 화면 Grid Object *
- * let pageObj = {} : 화면공통 Object *
- * let listObj = {} : 목록화면 Object *
- * let viewObj = {} : 상세화면 Object *
- * let modifyObj = {} : 수정화면 Object *
- * let createObj = {} : 신규화면 Object *
- *******************************************************/
- /*화면 변수*/
- const STINFO06010_GRID_ID = '#ITP_STINFO06010_jqGrid';
- const STINFO06010_GRID_LIST = '#ITP_STINFO06010_jqGrid_list';
- const STINFO06010_GRID_PAGER = '#ITP_STINFO06010_jqGridPager';
- const STINFO06010_GRID_EMPTY = '#ITP_STINFO06010_jqGridEmpty';
- const STINFO06010_DETAIL_GRID_ID = '#ITP_STINFO06010_DETAIL_jqGrid';
- const STINFO06010_DETAIL_GRID_LIST = '#ITP_STINFO06010_DETAIL_jqGrid_list';
- const STINFO06010_DETAIL_GRID_PAGER = '#ITP_STINFO06010_DETAIL_jqGridPager';
- const STINFO06010_DETAIL_GRID_EMPTY = '#ITP_STINFO06010_DETAIL_jqGridEmpty';
- let STINFO06010_GRID_LAST_ROW_ID;
- /* 공통코드 리스트 */
- let ITP_COMMON_CD_DSTRBT_COST_UNIT = fn_make_common_cd_list(CODE_LIST, 'DSTRBT_COST_UNIT', true, '기본단위');
- let ITP_COMMON_CD_CURR = fn_make_common_cd_list(CODE_LIST, 'CURR', true, '통화');
- let ITP_COMMON_CD_UNIT_TARGET_CD = fn_make_common_cd_list(CODE_LIST, 'UNIT_TARGET_CD', true, '대상여부');
- /*API URL*/
- let API_DETAIL_GRID_LIST = '/api/itemunit/store-unit-grid-list'; // 목록
- let API_DETAIL_INFO = '/api/itemunit/info-storeitemunit'; // 상세
- let API_DETAIL_SAVE = '/api/itemunit/save-store-itemunit'; // 저장
- /*화면 Grid ColModel*/
- const gridColModel = {
- list: [
- {
- index: 'BRAND_ID', name: 'brandId',
- label: ITP_MSG_LOCALE.label.brandId, //브랜드ID
- width: '10', fixed: false, align: 'center',
- sortable: false, hidden: true
- },
- {
- index: 'BRAND_NM', name: 'brandNm',
- label: ITP_MSG_LOCALE.label.brandNm, //브랜드명
- width: '13', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'STORE_ID', name: 'storeId',
- label: ITP_MSG_LOCALE.label.storeId, //매장ID
- width: '10', fixed: false, align: 'center',
- sortable: false, hidden: true
- },
- {
- index: 'STORE_NM', name: 'storeNm',
- label: ITP_MSG_LOCALE.label.storeNm, //매장명
- width: '10', fixed: false, align: 'center',
- sortable: false, hidden: true
- },
- {
- index: 'CONT_STT_DT', name: 'contSttDt',
- label: ITP_MSG_LOCALE.label.contSttDt, //계약시작일
- width: '15', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'CONT_END_DT', name: 'contEndDt',
- label: ITP_MSG_LOCALE.label.contEndDt, //계약종료일
- width: '6', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'SYS_REG_DTTM', name: 'sysRegDttm',
- label: ITP_MSG_LOCALE.label.sysRegDt, //계약생성일
- width: '6', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'ITEM_CNT', name: 'itemCnt',
- label: ITP_MSG_LOCALE.label.itemCnt, //계약품목수
- width: '10', fixed: false, align: 'center',
- sortable: false, hidden: false
- }
- ],
- detail: [
- {
- index: 'BRAND_ID', name: 'brandId',
- label: ITP_MSG_LOCALE.label.brandId, //브랜드ID
- width: '10', fixed: false, align: 'center',
- sortable: false, hidden: true
- },
- {
- 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: '13', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'CONT_STT_DT', name: 'contSttDt',
- label: ITP_MSG_LOCALE.label.contSttDt, //계약시작일
- width: '10', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'CONT_END_DT', name: 'contEndDt',
- label: ITP_MSG_LOCALE.label.contEndDt, //계약종료일
- width: '10', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'UNIT', name: 'unit',
- label: ITP_MSG_LOCALE.label.unit, //기본단위
- width: '9', fixed: false, align: 'center',
- sortable: false, editable: true, formatter: 'select', edittype: 'select',
- editoptions: {value: ITP_COMMON_CD_DSTRBT_COST_UNIT},
- editrules: {required: true}
- },
- {
- index: 'STDD_QYT', name: 'stddQty',
- label: ITP_MSG_LOCALE.label.stddQty, //기준수량
- width: '6', fixed: false, align: 'center',
- sortable: true, editable: true, edittype: 'text',
- editrules: {required: true}
- },
- {
- index: 'CURR', name: 'curr',
- label: ITP_MSG_LOCALE.label.curr, //통화
- width: '9', fixed: false, align: 'center',
- sortable: false, editable: true, formatter: 'select', edittype: 'select',
- editoptions: {value: ITP_COMMON_CD_CURR},
- editrules: {required: true}
- },
- {
- index: 'UNIT_AMT', name: 'unitAmt',
- label: ITP_MSG_LOCALE.label.unitAmt, //단가
- width: '10', fixed: false, align: 'center',
- sortable: true, editable: true, edittype: 'text',
- editrules: {required: true}
- },
- {
- index: 'UNIT_TARGET_CD', name: 'unitTargetCd',
- label: ITP_MSG_LOCALE.label.unitTargetCd, //대상여부
- width: '10', fixed: false, align: 'center',
- sortable: false, editable: true, formatter: 'select', edittype: 'select',
- editoptions: {value: ITP_COMMON_CD_UNIT_TARGET_CD},
- editrules: {required: true}
- },
- {
- index: 'SPPLY_UNIT_AMT', name: 'spplyUnitAmt',
- label: ITP_MSG_LOCALE.label.spplyUnitAmt, //공급단가
- width: '6', fixed: false, align: 'center',
- sortable: false, hidden: false
- },
- {
- index: 'EDIT_STATUS', name: 'editStatus',
- label: ITP_MSG_LOCALE.label.spplyUnitAmt, //공급단가
- width: '6', fixed: false, align: 'center',
- sortable: false, hidden: true
- }
- ]
- };
- /*화면공통 Object*/
- let pageObj = {
- init: function () {
- this.ui.init();
- this.event.init();
- },
- screenMode: 'LIST',
- ui: {
- init: function () {
- this.view();
- this.grid();
- this.ready();
- },
- view: function() {
- // 버튼 권한설정
- fn_proc_btn_auth('STINFO06010');
- // 공통코드 표시
- $('select').each(function() {
- if($(this).data('select-code')) {
- fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
- }
- });
- // 조회일자 지정
- $('#ITP_TAB_STINFO06010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
- },
- grid: function() {
- itp_fn_jqgrid_resize(STINFO06010_GRID_ID, STINFO06010_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_STINFO06010_SRH' : (this.screenMode === 'List') ? listObj.button.search() : modifyObj.search(); break; // 조회 버튼 클릭
- case 'ITP_BTN_STINFO06010_NEWREG' : listObj.button.create(); break; // 신규등록 버튼
- case 'ITP_BTN_STINFO06010_CANCELLIST' : listObj.grid.search(); break; // 취소/목록 버튼
- case 'ITP_BTN_STINFO06010_SAVE' : modifyObj.button.save(); break; // 저장 버튼
- }
- });
- });
- }
- },
- switchScreen: function(mode) {
- $('.itp_det_head').find('button[id^="ITP_BTN_STINFO06010_"]').each(function(i) {
- $(this).hide();
- });
- $('#ITP_TAB_STINFO06010').find('div[id$="_CONTAINER"]').each(function(i) {
- $(this).hide();
- });
- if(mode == 'LIST') { // 목록
- $('#ITP_AJAX_STINFO06010_LIST_CONTAINER').show();
- fn_show_btn_auth_array(['#ITP_BTN_STINFO06010_SRH', '#ITP_BTN_STINFO06010_NEWREG']);
- } else if(mode == 'ADD') { // 등록
- $('#ITP_AJAX_STINFO06010_DETAIL_CONTAINER').show();
- fn_show_btn_auth_array(['#ITP_BTN_STINFO06010_CANCELLIST', '#ITP_BTN_STINFO06010_SAVE']);
- $('#ITP_FORM_STINFO06010_DETAIL').find('input, textarea, select, checkbox').each(function(i, elem) {
- $(this).attr('id') === 'ITP_FORM_STINFO06010_DETAIL_VIEW_CD' ? $(this).val('C') : $(this).val('');
- if(elem.type === 'select') {
- $(this).val('').prop('selected', true);
- }
- });
- // 가맹점 정보 설정
- $('#ITP_FORM_STINFO06010_DETAIL_AFFL_SHOP_ID').val(fn_make_user_info.get('afflShopId'));
- $('#ITP_FORM_STINFO06010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
- $('#ITP_FORM_STINFO06010_DETAIL_STORE_ID').removeAttr('readonly');
- $('#ITP_FORM_STINFO06010_DETAIL_DUP').removeAttr('disabled');
- $('#ITP_FORM_STINFO06010_DETAIL .fnStoreNm').text('(자동부여)');
- } else if(mode == 'MODIFY') { // 수정
- $('#ITP_AJAX_STINFO06010_DETAIL_CONTAINER').show();
- fn_show_btn_auth_array(['#ITP_BTN_STINFO06010_CANCELLIST', '#ITP_BTN_STINFO06010_SAVE', '#ITP_BTN_STINFO06010_RESET_PW']);
- // 가맹점 정보 설정
- $('#ITP_FORM_STINFO06010_DETAIL_AFFL_SHOP_ID').val(fn_make_user_info.get('afflShopId'));
- $('#ITP_FORM_STINFO06010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
- } else if(mode == 'VIEW') { // 보기
- $('#ITP_AJAX_STINFO06010_VIEW_CONTAINER').show();
- fn_show_btn_auth_array(['#ITP_BTN_STINFO06010_MODIFY', '#ITP_BTN_STINFO06010_CANCELLIST']);
- }
- this.screenMode = mode;
- }
- };
- /*목록화면 Object*/
- let listObj = {
- init: function () {
- this.grid.init();
- },
- itp_STINFO06010_search: false,
- button: {
- search: function() {
- listObj.itp_STINFO06010_search = true;
- let param = $('#ITP_FORM_STINFO06010_SEARCH').serializeObject();
- param.gridSize = $.jgrid.defaults.rowNum;
- param.gridPage = $.jgrid.defaults.page;
- $(STINFO06010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
- },
- create: function() {
- if(!fn_make_user_info.isEmpty()) {
- let param = $('#ITP_FORM_STINFO06010_DETAIL').serializeObject();
- modifyObj.init($.param(param));
- }
- }
- },
- empty: {
- init: function() {
- var _this = this;
- this.push();
- $(STINFO06010_GRID_EMPTY).on('click', function() {
- _this.back();
- _this.itp_STINFO06010_param.gridSize = $.jgrid.defaults.rowNum;
- $(STINFO06010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_STINFO06010_param)}).trigger('reloadGrid');
- });
- },
- itp_STINFO06010_param: {},
- push: function() {
- let param = $('#ITP_FORM_STINFO06010_SEARCH').serializeObject();
- listObj.itp_STINFO06010_param = param;
- },
- back: function() {
- $('#ITP_FORM_STINFO06010_SERVICE_ST_CD').val(this.itp_STINFO06010_param.sstoreNm);
- }
- },
- grid: {
- init: function () {
- // 데이터 없을때
- listObj.empty.push();
- this.search();
- },
- search: function() {
- pageObj.switchScreen('LIST');
- this.unload();
- this.load();
- },
- load: function() {
- let param = $('#ITP_FORM_STINFO06010_SEARCH').serializeObject();
- param.gridSize = $.jgrid.defaults.rowNum;
- param.sbrandId = fn_make_user_info.get('brandId');
- var option = {
- gridId: STINFO06010_GRID_ID,
- colModel: gridColModel.list,
- param: JSON.stringify(param),
- url: DOMAIN + API_DETAIL_GRID_LIST,
- pager: STINFO06010_GRID_PAGER,
- onCellSelect: function(rowId, cellIdx, cellValue) {
- var cm = $(this).jqGrid('getGridParam', 'colModel');
- var colNm = cm[cellIdx].name;
- if (colNm == 'contSttDt') {
- const storeId = $(this).jqGrid('getCell', rowId, 'storeId');
- const contSttDt = $(this).jqGrid('getCell', rowId, 'contSttDt');
- const contEndDt = $(this).jqGrid('getCell', rowId, 'contEndDt');
- const key = {brandId:fn_make_user_info.get('brandId'), storeId: storeId, contSttDt: contSttDt, contEndDt: contEndDt, viewCd: 'R'};
- var param = $.param(key);
- modifyObj.init(param);
- }
- },
- loadComplete: function(data) {
- console.log(data);
- itp_fn_grid_load_complete(data, STINFO06010_GRID_ID, true, 'number', 'STINFO06010', listObj.itp_STINFO06010_search, listObj.empty, true, data.gridRecords, true);
- var ids = $(STINFO06010_GRID_ID).getDataIDs();
- $.each(ids, function(idx, rowId) {
- $(STINFO06010_GRID_ID).jqGrid('setCell', rowId, 'contSttDt', '', ITP_GRID_COL_STYLE.link);
- });
- },
- onPaging: function(action) {
- itp_fn_grid_paging(STINFO06010_GRID_ID, action, param);
- }
- };
- itp_fn_grid_make_remote(option);
- },
- clearData : function() {
- $(STINFO06010_GRID_ID).jqGrid('clearGridData', true);
- $(STINFO06010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
- $(STINFO06010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
- $(STINFO06010_GRID_EMPTY).show();
- },
- unload : function() {
- $.jgrid.gridUnload(STINFO06010_GRID_ID);
- }
- }
- };
- /*수정화면 Object*/
- let modifyObj = {
- init: function (param) {
- pageObj.switchScreen('MODIFY');
- this.grid.init(param);
- },
- itp_STINFO06010_search: false,
- search: function() {
- listObj.itp_STINFO06010_search = true;
- let param = $('#ITP_FORM_STINFO06010_DETAIL').serializeObject();
- param.gridSize = $.jgrid.defaults.rowNum;
- param.gridPage = $.jgrid.defaults.page;
- $(STINFO06010_DETAIL_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
- },
- button: {
- save: function() {
- itp_fn_grid_save_rows(STINFO06010_DETAIL_GRID_ID);
- var rows = $(STINFO06010_DETAIL_GRID_ID).getRowData();
- let param = {};
- var gridUpdateData = [];
- $.each(rows, function (key, value) {
- if(value.editStatus === 'U') {
- gridUpdateData.push(value);
- }
- });
- param['viewCd'] = 'U';
- param['brandId'] = fn_make_user_info.get('brandId');
- param['storeId'] = fn_make_user_info.get('userId');
- param['gridUpdateData'] = gridUpdateData;
- console.log(JSON.stringify(param));
- var searhFn = function() {
- listObj.grid.search();
- };
- fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
- }
- },
- empty: {
- init: function() {
- var _this = this;
- this.push();
- $(STINFO06010_DETAIL_GRID_EMPTY).on('click', function() {
- _this.back();
- _this.itp_STINFO06010_param.gridSize = $.jgrid.defaults.rowNum;
- $(STINFO06010_DETAIL_GRID_ID).setGridParam($.param(_this.itp_STINFO06010_param)).trigger('reloadGrid');
- });
- },
- itp_STINFO06010_param: {},
- push: function() {
- let param = $('#ITP_FORM_STINFO06010_DETAIL').serializeObject();
- listObj.itp_STINFO06010_param = param;
- },
- back: function() {
- }
- },
- grid: {
- init: function (param) {
- // 데이터 없을때
- listObj.empty.push();
- this.unload();
- this.load(param);
- },
- load: function(param) {
- var option = {
- gridId: STINFO06010_DETAIL_GRID_ID,
- colModel: gridColModel.detail,
- mtype: 'GET',
- param: param,
- url: DOMAIN + API_DETAIL_INFO,
- loadComplete: function(data) {
- console.log(data);
- itp_fn_grid_load_complete(data, STINFO06010_DETAIL_GRID_ID, false, 'number', 'STINFO06010', modifyObj.itp_STINFO06010_search, modifyObj.empty, true, data.gridRecords, true);
- },
- // onCelSelect: function(rowId, cellIdx, cellValue) {
- // STINFO06010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowId, cellIdx, STINFO06010_GRID_LAST_ROW_ID, STINFO06010_DETAIL_GRID_ID, ['itemId']);
- // },
- ondblClickRow : function (rowid, iRow, iCol) {
- console.log('rowId ===> ' + rowid);
- STINFO06010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowid, iRow, STINFO06010_GRID_LAST_ROW_ID, STINFO06010_DETAIL_GRID_ID, ['itemId']);
- $('#' + rowid + "_stddQty").blur(function(){
- console.log('_stddQty ===> ' + '#' + rowid + "_stddQty");
- $(STINFO06010_DETAIL_GRID_ID).jqGrid('saveRow', rowid, true, 'clientArray');
- if($(STINFO06010_DETAIL_GRID_ID).jqGrid('getRowData', rowid, 'editStatus') !== 'U') {
- $(STINFO06010_DETAIL_GRID_ID).jqGrid('setRowData', rowid, {editStatus: 'U'});
- }
- });
- },
- onPaging: function(action) {
- itp_fn_grid_paging(STINFO06010_GRID_ID, action, param);
- }
- };
- itp_fn_grid_make_remote(option);
- },
- clearData : function() {
- $(STINFO06010_DETAIL_GRID_ID).jqGrid('clearGridData', true);
- $(STINFO06010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
- $(STINFO06010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
- $(STINFO06010_DETAIL_GRID_EMPTY).show();
- },
- unload : function() {
- $.jgrid.gridUnload(STINFO06010_DETAIL_GRID_ID);
- }
- }
- };
|