marseyes 2 år sedan
förälder
incheckning
d6841975bd

+ 59 - 0
src/main/webapp/app/salesmng/SALESMNG01010.html

@@ -0,0 +1,59 @@
1
+<section id="ITP_TAB_SALESMNG01010" class="tab-pane active itp_sec">
2
+	<div class="itp_cont">
3
+		<article class="itp_detail">
4
+			<div class="itp_det_head fix">
5
+				<h2 class="pull-left itp_det_tit"><i class="glyphicon glyphicon-chevron-right"></i><strong>매장별 매출현황</strong></h2>
6
+				<div class="pull-right itp_cicon">
7
+					<button type="button" id="ITP_BTN_SALESMNG01010_SRH" class="btn btn-success btn-sm SEB" style="display: inline-block;"><i class="glyphicon"></i>&nbsp;&nbsp;조회&nbsp;&nbsp;</button>
8
+				</div>
9
+			</div>
10
+			<div class="itp_det_in">
11
+				<div id="ITP_AJAX_SALESMNG01010_LIST_CONTAINER">
12
+					<div class="itp_lg_form itp_type1 fix">
13
+						<div class="itp_srh_border fix">
14
+							<div class="col-xs-12">
15
+								<form id="ITP_FORM_SALESMNG01010_SEARCH" class="form-horizontal">
16
+								<input type="hidden" id="ITP_FORM_SALESMNG01010_SEARCH_BRAND_ID" name="sbrandId" value="">
17
+								<input type="hidden" id="ITP_FORM_SALESMNG01010_SEARCH_STORE_ID" name="sstoreId" value="">
18
+								
19
+									<div class="form-group">
20
+										<div class="col-xs-3 itp_ip itp_noMar">
21
+											<div class="input-group">
22
+											<input type="text" id="ITP_FORM_SALESMNG01010_SEARCH_STORE_SPPLY_NM" class="form-control itp_input" placeholder="매장명" readonly="readonly" />
23
+												<span class="input-group-btn">
24
+													<button id="ITP_BTN_SALESMNG01010_SEARCH_ERASE" class="btn btn-default btn-sm itp_btn UPB" type="button"><i class="glyphicon glyphicon-remove"></i></button>
25
+													<button type="button" id="ITP_BTN_SALESMNG01010_SEARCH_STORE_POP" class="btn btn-success btn-sm SEB" style="display: inline-block;"><i class="glyphicon glyphicon-search"></i></button>
26
+												</span>
27
+											</div>
28
+										</div>
29
+										<div class="col-xs-1 itp_ip itp_noMar" style="width:70px; padding-top: 5px; padding-right: 5px;">
30
+											<label>조회기간</label>
31
+										</div>
32
+										<div class="col-xs-3 itp_ip itp_noMar">
33
+											<div class="input-daterange input-group date">
34
+												<input type="text" id="ITP_FORM_SALESMNG01010_SEARCH_FROM_DT" class="form-control itp_input" name="fromDt" value="" readonly>
35
+												<span class="input-group-addon itp_date_to">~</span>
36
+												<input type="text" id="ITP_FORM_SALESMNG01010_SEARCH_TO_DT" class="form-control itp_input" name="toDt" value="" readonly> 
37
+											</div>
38
+										</div>
39
+									</div>
40
+								</form>
41
+							</div>
42
+						</div>
43
+					</div>
44
+					<div class="itp_table fix">
45
+						<div id="ITP_SALESMNG01010_jqGrid_list" class="itp_tb_list itp_gType1" data-total-cnt="${totalCnt}">
46
+							<div id="ITP_SALESMNG01010_jqGridView" class="itp_views fix"></div>
47
+							<button type="button" id="ITP_BTN_SALESMNG01010_EXCEL" class="btn btn-success btn-sm Excel" style="float:right;"><i class="glyphicon "></i>Excel</button>
48
+							<table id="ITP_SALESMNG01010_jqGrid"></table>
49
+							<div id="ITP_SALESMNG01010_jqGridPager"></div>
50
+							<div id="ITP_SALESMNG01010_jqGridEmpty" class="itp_no_data"></div>
51
+						</div>
52
+					</div>
53
+				</div>
54
+				
55
+			</div>
56
+		</article>
57
+	</div>
58
+	<div id="ITP_TAP_JS"></div>
59
+</section>

+ 63 - 0
src/main/webapp/app/salesmng/SALESMNG02010.html

@@ -0,0 +1,63 @@
1
+<section id="ITP_TAB_SALESMNG02010" class="tab-pane active itp_sec">
2
+	<div class="itp_cont">
3
+		<article class="itp_detail">
4
+			<div class="itp_det_head fix">
5
+				<h2 class="pull-left itp_det_tit"><i class="glyphicon glyphicon-chevron-right"></i><strong>품별별 매출현황</strong></h2>
6
+				<div class="pull-right itp_cicon">
7
+					<button type="button" id="ITP_BTN_SALESMNG02010_SRH" class="btn btn-success btn-sm SEB" style="display: inline-block;"><i class="glyphicon"></i>&nbsp;&nbsp;조회&nbsp;&nbsp;</button>
8
+				</div>
9
+			</div>
10
+			<div class="itp_det_in">
11
+				<div id="ITP_AJAX_SALESMNG02010_LIST_CONTAINER">
12
+					<div class="itp_lg_form itp_type1 fix">
13
+						<div class="itp_srh_border fix">
14
+							<div class="col-xs-12">
15
+								<form id="ITP_FORM_SALESMNG02010_SEARCH" class="form-horizontal">
16
+								<input type="hidden" id="ITP_FORM_SALESMNG02010_SEARCH_BRAND_ID" name="sbrandId" value="">
17
+								<input type="hidden" id="ITP_FORM_SALESMNG02010_SEARCH_STORE_ID" name="sstoreId" value="">
18
+								
19
+									<div class="form-group">
20
+										<div class="col-xs-3 itp_ip itp_noMar">
21
+											<div class="input-group">
22
+											<input type="text" id="ITP_FORM_SALESMNG02010_SEARCH_STORE_SPPLY_NM" class="form-control itp_input" placeholder="매장명" readonly="readonly" />
23
+												<span class="input-group-btn">
24
+													<button id="ITP_BTN_SALESMNG02010_SEARCH_ERASE" class="btn btn-default btn-sm itp_btn UPB" type="button"><i class="glyphicon glyphicon-remove"></i></button>
25
+													<button type="button" id="ITP_BTN_SALESMNG02010_SEARCH_STORE_POP" class="btn btn-success btn-sm SEB" style="display: inline-block;"><i class="glyphicon glyphicon-search"></i></button>
26
+												</span>
27
+											</div>
28
+										</div>
29
+										<div class="col-xs-1 itp_ip itp_noMar" style="width:70px; padding-top: 5px; padding-right: 5px;">
30
+											<label>조회기간</label>
31
+										</div>
32
+										<div class="col-xs-3 itp_ip itp_noMar">
33
+											<div class="input-daterange input-group date">
34
+												<input type="text" id="ITP_FORM_SALESMNG02010_SEARCH_FROM_DT" class="form-control itp_input" name="fromDt" value="" readonly>
35
+												<span class="input-group-addon itp_date_to">~</span>
36
+												<input type="text" id="ITP_FORM_SALESMNG02010_SEARCH_TO_DT" class="form-control itp_input" name="toDt" value="" readonly> 
37
+											</div>
38
+										</div>
39
+										<div class="col-xs-3 itp_in itp_noMar">
40
+											<input type="text" id="ITP_FORM_SALESMNG02010_SEARCH_ITEM_NM" class="form-control itp_input" name="sitemNm" placeholder="품목명">
41
+										</div>
42
+										
43
+									</div>
44
+								</form>
45
+							</div>
46
+						</div>
47
+					</div>
48
+					<div class="itp_table fix">
49
+						<div id="ITP_SALESMNG02010_jqGrid_list" class="itp_tb_list itp_gType1" data-total-cnt="${totalCnt}">
50
+							<div id="ITP_SALESMNG02010_jqGridView" class="itp_views fix"></div>
51
+							<button type="button" id="ITP_BTN_SALESMNG02010_EXCEL" class="btn btn-success btn-sm Excel" style="float:right;"><i class="glyphicon "></i>Excel</button>
52
+							<table id="ITP_SALESMNG02010_jqGrid"></table>
53
+							<div id="ITP_SALESMNG02010_jqGridPager"></div>
54
+							<div id="ITP_SALESMNG02010_jqGridEmpty" class="itp_no_data"></div>
55
+						</div>
56
+					</div>
57
+				</div>
58
+				
59
+			</div>
60
+		</article>
61
+	</div>
62
+	<div id="ITP_TAP_JS"></div>
63
+</section>

+ 349 - 0
src/main/webapp/js/app/salesmng/ITP_SALESMNG01010.js

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

+ 355 - 0
src/main/webapp/js/app/salesmng/ITP_SALESMNG02010.js

@@ -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
+};