|
@@ -0,0 +1,355 @@
|
|
1
|
+/********************************************************
|
|
2
|
+ --------------------------------------------------------
|
|
3
|
+ - Object 목록 -
|
|
4
|
+ --------------------------------------------------------
|
|
5
|
+ * const gridColModel = {} : 화면 Grid Object *
|
|
6
|
+ * let pageObj = {} : 화면공통 Object *
|
|
7
|
+ * let listObj = {} : 목록화면 Object *
|
|
8
|
+ * let modifyObj = {} : 상세화면 Object *
|
|
9
|
+ *******************************************************/
|
|
10
|
+
|
|
11
|
+/*화면 변수*/
|
|
12
|
+const SALESMNG02010_GRID_ID = '#ITP_SALESMNG02010_jqGrid';
|
|
13
|
+const SALESMNG02010_GRID_LIST = '#ITP_SALESMNG02010_jqGrid_list';
|
|
14
|
+const SALESMNG02010_GRID_PAGER = '#ITP_SALESMNG02010_jqGridPager';
|
|
15
|
+const SALESMNG02010_GRID_EMPTY = '#ITP_SALESMNG02010_jqGridEmpty';
|
|
16
|
+
|
|
17
|
+let ITP_FORM_SALESMNG02010_DETAIL_IS_DUPLICATE = false;
|
|
18
|
+let ITP_FORM_SALESMNG02010_DETAIL_IS_WRITING = false;
|
|
19
|
+let SALESMNG02010_DETAIL_GRID_LAST_ROW_ID;
|
|
20
|
+
|
|
21
|
+/*API URL*/
|
|
22
|
+let API_GRID_LIST = '/api/sale/mng/item-grid-list';
|
|
23
|
+
|
|
24
|
+let LOGIN_AUTH_TYPE_CD;
|
|
25
|
+
|
|
26
|
+/*화면 Grid ColModel*/
|
|
27
|
+const gridColModel = {
|
|
28
|
+ list: [
|
|
29
|
+ {
|
|
30
|
+ index: 'VIEW_CD', name: 'viewCd',
|
|
31
|
+ label: ITP_MSG_LOCALE.label.viewCd,
|
|
32
|
+ width: '10', fixed: false, align: 'center',
|
|
33
|
+ sortable: false, hidden: true
|
|
34
|
+ },
|
|
35
|
+ {
|
|
36
|
+ index: 'BRAND_NM', name: 'brandNm',
|
|
37
|
+ label: "브랜드",
|
|
38
|
+ width: '10', fixed: false, align: 'center',
|
|
39
|
+ sortable: false, hidden: true
|
|
40
|
+ },
|
|
41
|
+ {
|
|
42
|
+ index: 'ITEM_ID', name: 'itemId',
|
|
43
|
+ label: "품목번호",
|
|
44
|
+ width: '10', fixed: false, align: 'center',
|
|
45
|
+ sortable: false, hidden: false, classes: 'ui-ellipsis'
|
|
46
|
+ },
|
|
47
|
+ {
|
|
48
|
+ index: 'ITEM_NM', name: 'itemNm',
|
|
49
|
+ label: "품목명",
|
|
50
|
+ width: '15', fixed: false, align: 'left',
|
|
51
|
+ sortable: false, hidden: false, classes: 'ui-ellipsis'
|
|
52
|
+ },
|
|
53
|
+ {
|
|
54
|
+ index: 'WHS_QTY', name: 'whsQty',
|
|
55
|
+ label: "구매수량",
|
|
56
|
+ width: '10', fixed: false, align: 'right',
|
|
57
|
+ sortable: false, editable: false, edittype: 'text',
|
|
58
|
+ formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
|
|
59
|
+ },
|
|
60
|
+ {
|
|
61
|
+ index: 'SUPPLY_AMT', name: 'supplyAmt',
|
|
62
|
+ label: "공급가액",
|
|
63
|
+ width: '10', fixed: false, align: 'right',
|
|
64
|
+ sortable: false, editable: false, edittype: 'text',
|
|
65
|
+ formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
|
|
66
|
+ },
|
|
67
|
+ {
|
|
68
|
+ index: 'STORE_AMT', name: 'storeAmt',
|
|
69
|
+ label: "판매금액",
|
|
70
|
+ width: '10', fixed: false, align: 'right',
|
|
71
|
+ sortable: false, editable: false, edittype: 'text',
|
|
72
|
+ formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
|
|
73
|
+ },
|
|
74
|
+ {
|
|
75
|
+ index: 'INCOME_AMT', name: 'incomeAmt',
|
|
76
|
+ label: "수입금액",
|
|
77
|
+ width: '10', fixed: false, align: 'right',
|
|
78
|
+ sortable: false, editable: false, edittype: 'text',
|
|
79
|
+ formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
|
|
80
|
+ },
|
|
81
|
+ {
|
|
82
|
+ index: 'WHS_QTY1', name: 'whsQty1',
|
|
83
|
+ label: "반품수량",
|
|
84
|
+ width: '10', fixed: false, align: 'right',
|
|
85
|
+ sortable: false, editable: false, edittype: 'text',
|
|
86
|
+ formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
|
|
87
|
+ },
|
|
88
|
+ {
|
|
89
|
+ index: 'SUPPLY_AMT1', name: 'supplyAmt1',
|
|
90
|
+ label: "반품공급가액",
|
|
91
|
+ width: '10', fixed: false, align: 'right',
|
|
92
|
+ sortable: false, editable: false, edittype: 'text',
|
|
93
|
+ formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
|
|
94
|
+ },
|
|
95
|
+ {
|
|
96
|
+ index: 'STORE_AMT1', name: 'storeAmt1',
|
|
97
|
+ label: "판품금액",
|
|
98
|
+ width: '10', fixed: false, align: 'right',
|
|
99
|
+ sortable: false, editable: false, edittype: 'text',
|
|
100
|
+ formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
|
|
101
|
+ },
|
|
102
|
+ {
|
|
103
|
+ index: 'INCOME_AMT1', name: 'incomeAmt1',
|
|
104
|
+ label: "판품손실",
|
|
105
|
+ width: '10', fixed: false, align: 'right',
|
|
106
|
+ sortable: false, editable: false, edittype: 'text',
|
|
107
|
+ formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
|
|
108
|
+ },
|
|
109
|
+ {
|
|
110
|
+ index: 'TOT_INCOME_AMT', name: 'totIncomeAmt',
|
|
111
|
+ label: "총매출금액",
|
|
112
|
+ width: '10', fixed: false, align: 'right',
|
|
113
|
+ sortable: false, editable: false, edittype: 'text',
|
|
114
|
+ formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
|
|
115
|
+ }
|
|
116
|
+ ]
|
|
117
|
+};
|
|
118
|
+
|
|
119
|
+require(['config'], function() {
|
|
120
|
+ require([
|
|
121
|
+ 'kakao.map.util'
|
|
122
|
+ ], function($) {
|
|
123
|
+ pageObj.init();
|
|
124
|
+ });
|
|
125
|
+});
|
|
126
|
+
|
|
127
|
+/*화면공통 Object*/
|
|
128
|
+let pageObj = {
|
|
129
|
+ init: function () {
|
|
130
|
+ this.ui.init();
|
|
131
|
+ this.event.init();
|
|
132
|
+ },
|
|
133
|
+ ui: {
|
|
134
|
+ init: function () {
|
|
135
|
+ this.view();
|
|
136
|
+ this.grid();
|
|
137
|
+ this.ready();
|
|
138
|
+ },
|
|
139
|
+ view: function() {
|
|
140
|
+ // 버튼 권한설정
|
|
141
|
+ fn_proc_btn_auth('SALESMNG02010');
|
|
142
|
+
|
|
143
|
+ // 공통코드 표시
|
|
144
|
+ $('select').each(function() {
|
|
145
|
+ if($(this).data('select-code')) {
|
|
146
|
+ fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
|
|
147
|
+ }
|
|
148
|
+ });
|
|
149
|
+
|
|
150
|
+ // 조회일자 지정
|
|
151
|
+ var now = new Date();
|
|
152
|
+ $('#ITP_TAB_SALESMNG02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
|
|
153
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_FROM_DT').datepicker('setDate', new Date(now.setMonth(now.getMonth() - 1)));
|
|
154
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_TO_DT').datepicker('setDate', new Date());
|
|
155
|
+
|
|
156
|
+ // 권한에 따라 매장값 설정
|
|
157
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
|
|
158
|
+ LOGIN_AUTH_TYPE_CD = fn_make_user_info.get('authTpCd'); // 권한타입
|
|
159
|
+ if(LOGIN_AUTH_TYPE_CD == '50') {
|
|
160
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_STORE_ID').val(fn_make_user_info.get('storeId'));
|
|
161
|
+ }
|
|
162
|
+
|
|
163
|
+ },
|
|
164
|
+ grid: function() {
|
|
165
|
+ itp_fn_jqgrid_resize(SALESMNG02010_GRID_ID, SALESMNG02010_GRID_LIST, 'lg');
|
|
166
|
+ listObj.empty.init();
|
|
167
|
+ itp_fn_fire_window_resize();
|
|
168
|
+ },
|
|
169
|
+ ready: function() {
|
|
170
|
+ listObj.init();
|
|
171
|
+ }
|
|
172
|
+ },
|
|
173
|
+ event: {
|
|
174
|
+ init: function () {
|
|
175
|
+ this.button();
|
|
176
|
+ this.change();
|
|
177
|
+ },
|
|
178
|
+ button: function () {
|
|
179
|
+ // 버튼 클릭 이벤트
|
|
180
|
+ $('button').each(function() {
|
|
181
|
+ var id = $(this).attr('id');
|
|
182
|
+ $(this).on('click', function() {
|
|
183
|
+ switch (id) {
|
|
184
|
+ case 'ITP_BTN_SALESMNG02010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
|
|
185
|
+ case 'ITP_BTN_SALESMNG02010_SEARCH_STORE_POP' : listObj.button.storePop(); break; // 매장검색 팝업
|
|
186
|
+ case 'ITP_BTN_SALESMNG02010_SEARCH_ERASE' : listObj.button.storeErase(); break; // 매장 지움
|
|
187
|
+ case 'ITP_BTN_SALESMNG02010_EXCEL' : listObj.excelDown(); break; // 엑셀 다운로드
|
|
188
|
+ }
|
|
189
|
+ });
|
|
190
|
+ });
|
|
191
|
+
|
|
192
|
+ $('body').on('click', function(e) {
|
|
193
|
+
|
|
194
|
+ });
|
|
195
|
+
|
|
196
|
+ },
|
|
197
|
+ change: function() {
|
|
198
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_STORE_SPPLY_GUBUN').on('change', function() {
|
|
199
|
+ var gubunVal = $('#ITP_FORM_SALESMNG02010_SEARCH_STORE_SPPLY_GUBUN').val();
|
|
200
|
+ if(gubunVal == '1') { // 매장
|
|
201
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_STORE_SPPLY_NM').attr('placeholder', '매장명');
|
|
202
|
+
|
|
203
|
+ $(SALESMNG02010_GRID_ID).jqGrid('hideCol', ["spplyNm"]);
|
|
204
|
+ $(SALESMNG02010_GRID_ID).jqGrid('showCol', ["storeNm"]);
|
|
205
|
+ // $(SALESMNG02010_GRID_ID).setColProp('spplyNm', {hidden: true});
|
|
206
|
+ // $(SALESMNG02010_GRID_ID).setColProp('storeNm', {hidden: false});
|
|
207
|
+ }
|
|
208
|
+ listObj.button.search();
|
|
209
|
+ // itp_fn_jqgrid_resize(SALESMNG02010_GRID_ID, SALESMNG02010_GRID_LIST, 'lg');
|
|
210
|
+ });
|
|
211
|
+ }
|
|
212
|
+ },
|
|
213
|
+ switchScreen: function(mode) {
|
|
214
|
+ if(mode == 'LIST') { // 목록
|
|
215
|
+ $('#ITP_BTN_SALESMNG02010_MODIFY').hide();
|
|
216
|
+ $('#ITP_BTN_SALESMNG02010_CANCELLIST').hide();
|
|
217
|
+ $('#ITP_BTN_SALESMNG02010_DELETE').hide();
|
|
218
|
+ $('#ITP_BTN_SALESMNG02010_STTL_END').hide();
|
|
219
|
+
|
|
220
|
+ if(LOGIN_AUTH_TYPE_CD == '50') { // 매장관리자
|
|
221
|
+ $('#ITP_BTN_SALESMNG02010_SEARCH_STORE_POP').hide();
|
|
222
|
+ $('#ITP_BTN_SALESMNG02010_SEARCH_ERASE').hide();
|
|
223
|
+ } else {
|
|
224
|
+ $('#ITP_BTN_SALESMNG02010_SEARCH_STORE_POP').show();
|
|
225
|
+ $('#ITP_BTN_SALESMNG02010_SEARCH_ERASE').show();
|
|
226
|
+ }
|
|
227
|
+
|
|
228
|
+ fn_show_btn_auth('#ITP_BTN_SALESMNG02010_SRH');
|
|
229
|
+
|
|
230
|
+ $('#ITP_AJAX_SALESMNG02010_LIST_CONTAINER').show();
|
|
231
|
+ $('#ITP_BTN_SALESMNG02010_EXCEL').show();
|
|
232
|
+
|
|
233
|
+ }
|
|
234
|
+ }
|
|
235
|
+};
|
|
236
|
+
|
|
237
|
+/*목록화면 Object*/
|
|
238
|
+let listObj = {
|
|
239
|
+ init: function () {
|
|
240
|
+ this.grid.init();
|
|
241
|
+ },
|
|
242
|
+ itp_SALESMNG02010_search: false,
|
|
243
|
+ button: {
|
|
244
|
+ search: function() {
|
|
245
|
+ listObj.itp_SALESMNG02010_search = true;
|
|
246
|
+ let param = $('#ITP_FORM_SALESMNG02010_SEARCH').serializeObject();
|
|
247
|
+ param.gridSize = $.jgrid.defaults.rowNum;
|
|
248
|
+ param.gridPage = $.jgrid.defaults.page;
|
|
249
|
+ $(SALESMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
|
|
250
|
+ },
|
|
251
|
+ storePop: function() {
|
|
252
|
+ fn_call_popup('biz', 'BIZPOP_BRAND_STORE', '#ITP_ASIDE', function(result) {
|
|
253
|
+ // alert(JSON.stringify(result));
|
|
254
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_STORE_ID').val(result[0].storeId);
|
|
255
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_STORE_SPPLY_NM').val(result[0].storeNm);
|
|
256
|
+ listObj.button.search();
|
|
257
|
+ }, null, 'S');
|
|
258
|
+ },
|
|
259
|
+ storeErase: function() {
|
|
260
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_STORE_ID').val('');
|
|
261
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_STORE_SPPLY_NM').val('');
|
|
262
|
+ listObj.button.search();
|
|
263
|
+ }
|
|
264
|
+ },
|
|
265
|
+ empty: {
|
|
266
|
+ init: function() {
|
|
267
|
+ var _this = this;
|
|
268
|
+ this.push();
|
|
269
|
+ $(SALESMNG02010_GRID_EMPTY).on('click', function() {
|
|
270
|
+ _this.back();
|
|
271
|
+ _this.itp_SALESMNG02010_param.gridSize = $.jgrid.defaults.rowNum;
|
|
272
|
+ $(SALESMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_SALESMNG02010_param)}).trigger('reloadGrid');
|
|
273
|
+ });
|
|
274
|
+ },
|
|
275
|
+ itp_SALESMNG02010_param: {},
|
|
276
|
+ push: function() {
|
|
277
|
+ let param = $('#ITP_FORM_SALESMNG02010_SEARCH').serializeObject();
|
|
278
|
+ listObj.itp_SALESMNG02010_param = param;
|
|
279
|
+ },
|
|
280
|
+ back: function() {
|
|
281
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_STORE_ID').val(listObj.itp_SALESMNG02010_param.sstoreId);
|
|
282
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_STORE_NM').val(listObj.itp_SALESMNG02010_param.sstoreNm);
|
|
283
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_FROM_DT').val(listObj.itp_SALESMNG02010_param.fromDt);
|
|
284
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_TO_DT').val(listObj.itp_SALESMNG02010_param.toDt);
|
|
285
|
+ $('#ITP_FORM_SALESMNG02010_SEARCH_ITEM_NM').val(listObj.itp_SALESMNG02010_param.sitemNm);
|
|
286
|
+ }
|
|
287
|
+ },
|
|
288
|
+ grid: {
|
|
289
|
+ init: function () {
|
|
290
|
+ // 데이터 없을때
|
|
291
|
+ listObj.empty.push();
|
|
292
|
+ this.search();
|
|
293
|
+ },
|
|
294
|
+ colModel: gridColModel.list,
|
|
295
|
+ search: function() {
|
|
296
|
+ pageObj.switchScreen('LIST');
|
|
297
|
+ this.unload();
|
|
298
|
+ this.load();
|
|
299
|
+ },
|
|
300
|
+ load: function() {
|
|
301
|
+ let param = $('#ITP_FORM_SALESMNG02010_SEARCH').serializeObject();
|
|
302
|
+ param.gridSize = $.jgrid.defaults.rowNum;
|
|
303
|
+
|
|
304
|
+ var option = {
|
|
305
|
+ gridId: SALESMNG02010_GRID_ID,
|
|
306
|
+ colModel: gridColModel.list,
|
|
307
|
+ param: param,
|
|
308
|
+ url: DOMAIN + API_GRID_LIST,
|
|
309
|
+ pager: SALESMNG02010_GRID_PAGER,
|
|
310
|
+ onCellSelect: function(rowId, cellIdx, cellValue) {
|
|
311
|
+ var cm = $(this).jqGrid('getGridParam', 'colModel');
|
|
312
|
+ var colNm = cm[cellIdx].name;
|
|
313
|
+ if (colNm == 'sttlMgntUnqNo') {
|
|
314
|
+ const sttlMgntUnqNoVal = $(this).jqGrid('getCell', rowId, 'sttlMgntUnqNo');
|
|
315
|
+
|
|
316
|
+ const key = {sttlMgntUnqNo: sttlMgntUnqNoVal, viewCd: 'R'};
|
|
317
|
+ var param = $.param(key);
|
|
318
|
+ modifyObj.init(param);
|
|
319
|
+ }
|
|
320
|
+ },
|
|
321
|
+ loadComplete: function(data) {
|
|
322
|
+ console.log(data);
|
|
323
|
+ itp_fn_grid_load_complete(data, SALESMNG02010_GRID_ID, true, 'number', 'SALESMNG02010', listObj.itp_SALESMNG02010_search, listObj.empty, true, data.gridRecords, true);
|
|
324
|
+ var ids = $(SALESMNG02010_GRID_ID).getDataIDs();
|
|
325
|
+ $.each(ids, function(idx, rowId) {
|
|
326
|
+ $(SALESMNG02010_GRID_ID).jqGrid('setCell', rowId, 'sttlMgntUnqNo', '', ITP_GRID_COL_STYLE.link);
|
|
327
|
+ });
|
|
328
|
+ },
|
|
329
|
+ onPaging: function(action) {
|
|
330
|
+ itp_fn_grid_paging(SALESMNG02010_GRID_ID, action, param);
|
|
331
|
+ }
|
|
332
|
+ };
|
|
333
|
+ itp_fn_grid_make_remote(option);
|
|
334
|
+ },
|
|
335
|
+ clearData : function() {
|
|
336
|
+ $(SALESMNG02010_GRID_ID).jqGrid('clearGridData', true);
|
|
337
|
+ $(SALESMNG02010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
|
|
338
|
+ $(SALESMNG02010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
|
|
339
|
+ $(SALESMNG02010_GRID_EMPTY).show();
|
|
340
|
+ },
|
|
341
|
+ unload : function() {
|
|
342
|
+ $.jgrid.gridUnload(SALESMNG02010_GRID_ID);
|
|
343
|
+ }
|
|
344
|
+ },
|
|
345
|
+ excelDown: function() {
|
|
346
|
+ var param = {
|
|
347
|
+ 'url': API_GRID_LIST,
|
|
348
|
+ 'param': $('#ITP_FORM_SALESMNG02010_SEARCH').serializeObject(),
|
|
349
|
+ 'gridColumns': $(SALESMNG02010_GRID_ID).jqGrid('getGridParam', 'colModel'),
|
|
350
|
+ 'fileName': '품목별_매출현황.xlsx',
|
|
351
|
+ 'sheetName': '품목별매출현황'
|
|
352
|
+ };
|
|
353
|
+ itp_fn_remote_to_excel(param);
|
|
354
|
+ }
|
|
355
|
+};
|