Browse Source

모바일 메인 챠트 출력 처리

isna 2 years ago
parent
commit
d84c6c2f67
1 changed files with 242 additions and 134 deletions
  1. 242 134
      src/main/webapp/mobile/js/app/main.js

+ 242 - 134
src/main/webapp/mobile/js/app/main.js

@@ -122,165 +122,273 @@ var mobMainObj = {
122 122
 		view:function() {
123 123
 			$('div[id^="ITP_MAIN_DRAW"]').hide();
124 124
 			var authTpCd = fn_make_user_info.get('authTpCd');
125
-			if(authTpCd === '40' || authTpCd === '10') {
125
+			console.log("chart init authTpCd=="+authTpCd)
126
+			if(authTpCd === '40' ) {
126 127
 				this.brand.init();
127 128
 			} else if(authTpCd === '50') {
128 129
 				this.store.init();
129 130
 			} else if(authTpCd === '60') {
130 131
 				this.spply.init();
131 132
 			}
133
+			const me=this;
134
+			$('#ITP_FORM_MAIN_SEARCH_PR_TYPE').on('change', function() {
135
+				me.drawChartReq();
136
+			});
137
+			
138
+			$('#ITP_FORM_MAIN_SEARCH_PO_TYPE').on('change', function() {
139
+				me.drawChartPodr();
140
+			});
141
+			
142
+			$('#ITP_FORM_MAIN_SEARCH_ITEM_CNT_TYPE').on('change', function() {
143
+				me.drawChartReqUp();
144
+			});
145
+			
146
+			$('#ITP_FORM_MAIN_SEARCH_DELI_TYPE').on('change', function() {
147
+				this.drawChartDeli();
148
+			});
149
+			
150
+			$('#ITP_FORM_MAIN_SEARCH_RELEASE_TYPE').on('change', function() {
151
+				this.drawChartRelease();
152
+			});
153
+			
154
+			$('#ITP_FORM_MAIN_SEARCH_ORDERS_TYPE').on('change', function() {
155
+				this.drawChartOrders();
156
+			});
157
+		},
158
+		store: {
159
+			init: function() {
160
+				const chart=mobMainObj.chart;
161
+				$('#ITP_MAIN_HEADER_STORE').show();			
162
+				$('#ITP_MAIN_DRAW_CHART_REQ').show();  
163
+				google.charts.setOnLoadCallback(chart.drawChartReq); // 구매요청
164
+				
165
+				$('#ITP_MAIN_DRAW_DELI_CHART').show();  
166
+				google.charts.setOnLoadCallback(chart.drawChartDeli); // 입고
167
+				
168
+				$('#ITP_MAIN_DRAW_CHART_REQ_UP').show();
169
+				google.charts.setOnLoadCallback(chart.drawChartReqUp); // 매출순위
170
+				
171
+				$('#ITP_MAIN_DRAW_CHART_CORE').show();
172
+				google.charts.setOnLoadCallback(chart.drawChartcore); // 정산
173
+				chartCnt=4;
174
+				
175
+			}
176
+		},
177
+		spply: {
178
+			init: function() {
179
+				const chart=mobMainObj.chart;
180
+				$('#ITP_MAIN_HEADER_SPPLY').show();
181
+			
182
+				$('#ITP_MAIN_DRAW_ORDERS_CHART').show();  
183
+				google.charts.setOnLoadCallback(chart.drawChartOrders); // 수주내역
184
+				
185
+				$('#ITP_MAIN_DRAW_RELEASE_CHART').show();  
186
+				google.charts.setOnLoadCallback(chart.drawChartRelease); // 출고
187
+				
188
+				$('#ITP_MAIN_DRAW_CHART_REQ_UP').show();
189
+				google.charts.setOnLoadCallback(chart.drawChartReqUp); // 매출순위
190
+				
191
+				$('#ITP_MAIN_DRAW_CHART_CORE').show();
192
+				google.charts.setOnLoadCallback(chart.drawChartcore); // 정산
193
+				chartCnt=4; 
194
+			}
132 195
 		},
133 196
 		brand: {
134 197
 			init: function() {
198
+				const chart=mobMainObj.chart;
135 199
 				$('#ITP_MAIN_DRAW_CHART_REQ').show();
136
-				google.charts.setOnLoadCallback(this.drawChartReq); // 구매요청
200
+				google.charts.setOnLoadCallback(chart.drawChartReq); // 구매요청
137 201
 
138 202
 				$('#ITP_MAIN_DRAW_CHART_PODR').show();
139
-				google.charts.setOnLoadCallback(this.drawChartPodr); // 구매발주
203
+				google.charts.setOnLoadCallback(chart.drawChartPodr); // 구매발주
140 204
 
141 205
 				$('#ITP_MAIN_DRAW_CHART_REQ_UP').show();
142
-				google.charts.setOnLoadCallback(this.drawChartReqUp); // 매출순위
206
+				google.charts.setOnLoadCallback(chart.drawChartReqUp); // 매출순위
143 207
 
144 208
 				if(fn_make_user_info.get('brandId')) {
145 209
 					$('#ITP_MAIN_DRAW_CHART_CORE').show();
146
-					google.charts.setOnLoadCallback(this.drawChartcore); // 정산
147
-					chartCnt=4;
148
-				} else {
149
-					chartCnt=3;
210
+					google.charts.setOnLoadCallback(chart.drawChartcore); // 정산
150 211
 				}
151
-				const me=this;
152
-				$('#ITP_FORM_MAIN_SEARCH_PR_TYPE').on('change', function() {
153
-					me.drawChartReq();
154
-				});
155
-				
156
-				$('#ITP_FORM_MAIN_SEARCH_PO_TYPE').on('change', function() {
157
-					me.drawChartPodr();
158
-				});
159
-				
160
-				$('#ITP_FORM_MAIN_SEARCH_ITEM_CNT_TYPE').on('change', function() {
161
-					me.drawChartReqUp();
162
-				});
163
-				
164
-				$('#ITP_FORM_MAIN_SEARCH_DELI_TYPE').on('change', function() {
165
-					// this.drawChartDeli();
166
-				});
167
-				
168
-				$('#ITP_FORM_MAIN_SEARCH_RELEASE_TYPE').on('change', function() {
169
-					// this.drawChartRelease();
170
-				});
171
-				
172
-				$('#ITP_FORM_MAIN_SEARCH_ORDERS_TYPE').on('change', function() {
173
-					// this.drawChartOrders();
174
-				});
175
-
176 212
 				$('#ITP_MAIN_DRAW_LINE').show();
177 213
 				$('#ITP_MAIN_DRAW_LINE .itp_main_draw_line').show();
178
-				google.charts.setOnLoadCallback(this.drawLine); // 안전재고
179
-			},
180
-			drawChartReq: function() {
181
-				const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), prType: $('#ITP_FORM_MAIN_SEARCH_PR_TYPE').val() };
182
-				var param = $.param(key);
183
-				fn_ajax_call(MAIN_CHART_PCH_REQ_CHART, param, function(result) {
184
-
185
-					var data = google.visualization.arrayToDataTable( eval(result.chartData) );
186
-					var options = {
187
-						legend: { position: 'left' },
188
-						bar: { groupWidth: "50%" },
189
-						width: chartWidth,
190
-					};
191
-					var chart = new google.charts.Bar(document.getElementById('ITP_PCH_REQ_GRAPH'));
192
-					// chart.draw(data, options);
193
-					console.log("xx draw char req xx", param, data, chart)
194
-					chart.draw(data, google.charts.Bar.convertOptions(options));
195
-
196
-				}, 'GET');
197
-			},
198
-			drawChartPodr: function() {
199
-				const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), poType: $('#ITP_FORM_MAIN_SEARCH_PO_TYPE').val() };
200
-				var param = $.param(key);
201
-				fn_ajax_call(MAIN_CHART_PCH_ODR_CHART, param, function(result) {
202
-
203
-					var data = google.visualization.arrayToDataTable( eval(result.chartData) );
204
-
205
-					var options = {
206
-						legend: { position: 'left' },
207
-						bar: { groupWidth: "50%" },
208
-						width: chartWidth,
209
-					};
210
-					var chart = new google.charts.Bar(document.getElementById('ITP_PCH_PODR_GRAPH'));
211
-					// chart.draw(data, options);
212
-					chart.draw(data, google.charts.Bar.convertOptions(options));
213
-
214
-				}, 'GET');
215
-			},
216
-			drawChartReqUp: function() {
217
-				const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), spplyId:fn_make_user_info.get('spplyId'), prType: $('#ITP_FORM_MAIN_SEARCH_ITEM_CNT_TYPE').val() };
218
-				var param = $.param(key);
219
-				fn_ajax_call(MAIN_CHART_PR_RANK_CHART, param, function(result) {
220
-
221
-					var data = google.visualization.arrayToDataTable( eval(result.chartData) );
222
-
223
-					var options = {
224
-						title: '구매요청 상위 품목',
225
-						legend: { position: 'left' },
226
-						bars: 'horizontal',
227
-						width: chartWidth,
228
-					};
229
-					console.log("xxxxxxxxxxx drawChartReqUp xxxxxxxxxxx")
230
-
231
-					var chart = new google.charts.Bar(document.getElementById('ITP_PCH_REQ_UP_ITEM_GRAPH'));
232
-					chart.draw(data, options);
233
-
234
-				}, 'GET');
235
-			},
236
-			drawChartcore: function() {
237
-				const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), spplyId:fn_make_user_info.get('spplyId') };
238
-				var param = $.param(key);
239
-				fn_ajax_call(MAIN_CHART_STL_CHART, param, function(result) {
240
-
241
-					// var data = google.visualization.arrayToDataTable([ [' ', ' '], ['요청', 25], ['확인', 65], ['반려', 10] ]);
242
-					var data = google.visualization.arrayToDataTable( eval(result.chartData) );
243
-
244
-					var options = {
245
-						// title: '정산',
246
-						legend: { position: 'left' },
247
-						width: chartWidth,
248
-					};
249
-					var chart = new google.visualization.PieChart(document.getElementById('ITP_STTL_GRAPH'));
250
-					console.log("xxxxxxxxxxx drawChartcore xxxxxxxxxxx", data, options )
251
-					chart.draw(data, options);
252
-
253
-				}, 'GET');
254
-			},
255
-			drawLine: function() {
256
-				const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId') };
257
-				var param = $.param(key);
258
-				fn_ajax_call(MAIN_CHART_SFT_STCK_CHART, param, function(result) {
259
-
260
-					var data = google.visualization.arrayToDataTable( eval(result.chartData) );
261
-
262
-					var options = {
263
-						title: '',
264
-						width: chartWidth + 100,
265
-						legend: { position: 'top' }
266
-					};
267
-
268
-					var chart = new google.visualization.LineChart(document.getElementById('ITP_SAFE_STCK_GRAPH'));
269
-					chart.draw(data, options);
270
-
271
-				}, 'GET');
272
-			}
214
+				google.charts.setOnLoadCallback(chart.drawLine); // 안전재고
215
+			},			
273 216
 		},
274
-		store: {
275
-			init: function() {
217
+		drawChartReq: function() {
218
+			const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), prType: $('#ITP_FORM_MAIN_SEARCH_PR_TYPE').val() };
219
+			var param = $.param(key);
220
+			fn_ajax_call(MAIN_CHART_PCH_REQ_CHART, param, function(result) {
221
+
222
+				var data = google.visualization.arrayToDataTable( eval(result.chartData) );
223
+				var options = {
224
+					legend: { position: 'left' },
225
+					bar: { groupWidth: "50%" },
226
+					width: chartWidth,
227
+				};
228
+				var chart = new google.charts.Bar(document.getElementById('ITP_PCH_REQ_GRAPH'));
229
+				// chart.draw(data, options);
230
+				console.log("xx draw char req xx", param, data, chart)
231
+				chart.draw(data, google.charts.Bar.convertOptions(options));
276 232
 
277
-			}
233
+			}, 'GET');
278 234
 		},
279
-		spply: {
280
-			init: function() {
235
+		drawChartPodr: function() {
236
+			const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), poType: $('#ITP_FORM_MAIN_SEARCH_PO_TYPE').val() };
237
+			var param = $.param(key);
238
+			fn_ajax_call(MAIN_CHART_PCH_ODR_CHART, param, function(result) {
281 239
 
282
-			}
240
+				var data = google.visualization.arrayToDataTable( eval(result.chartData) );
241
+
242
+				var options = {
243
+					legend: { position: 'left' },
244
+					bar: { groupWidth: "50%" },
245
+					width: chartWidth,
246
+				};
247
+				var chart = new google.charts.Bar(document.getElementById('ITP_PCH_PODR_GRAPH'));
248
+				// chart.draw(data, options);
249
+				chart.draw(data, google.charts.Bar.convertOptions(options));
250
+
251
+			}, 'GET');
252
+		},
253
+		drawChartReqUp: function() {
254
+			const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), spplyId:fn_make_user_info.get('spplyId'), prType: $('#ITP_FORM_MAIN_SEARCH_ITEM_CNT_TYPE').val() };
255
+			var param = $.param(key);
256
+			fn_ajax_call(MAIN_CHART_PR_RANK_CHART, param, function(result) {
257
+
258
+				var data = google.visualization.arrayToDataTable( eval(result.chartData) );
259
+
260
+				var options = {
261
+					title: '구매요청 상위 품목',
262
+					legend: { position: 'left' },
263
+					bars: 'horizontal',
264
+					width: chartWidth,
265
+				};
266
+				console.log("xxxxxxxxxxx drawChartReqUp xxxxxxxxxxx")
267
+
268
+				var chart = new google.charts.Bar(document.getElementById('ITP_PCH_REQ_UP_ITEM_GRAPH'));
269
+				chart.draw(data, options);
270
+
271
+			}, 'GET');
272
+		},
273
+		drawChartcore: function() {
274
+			const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), spplyId:fn_make_user_info.get('spplyId') };
275
+			var param = $.param(key);
276
+			fn_ajax_call(MAIN_CHART_STL_CHART, param, function(result) {
277
+
278
+				// var data = google.visualization.arrayToDataTable([ [' ', ' '], ['요청', 25], ['확인', 65], ['반려', 10] ]);
279
+				var data = google.visualization.arrayToDataTable( eval(result.chartData) );
280
+
281
+				var options = {
282
+					// title: '정산',
283
+					legend: { position: 'left' },
284
+					width: chartWidth,
285
+				};
286
+				var chart = new google.visualization.PieChart(document.getElementById('ITP_STTL_GRAPH'));
287
+				console.log("xxxxxxxxxxx drawChartcore xxxxxxxxxxx", data, options )
288
+				chart.draw(data, options);
289
+
290
+			}, 'GET');
291
+		},
292
+		drawLine: function() {
293
+			const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId') };
294
+			var param = $.param(key);
295
+			fn_ajax_call(MAIN_CHART_SFT_STCK_CHART, param, function(result) {
296
+
297
+				var data = google.visualization.arrayToDataTable( eval(result.chartData) );
298
+
299
+				var options = {
300
+					title: '',
301
+					width: chartWidth + 100,
302
+					legend: { position: 'top' }
303
+				};
304
+
305
+				var chart = new google.visualization.LineChart(document.getElementById('ITP_SAFE_STCK_GRAPH'));
306
+				chart.draw(data, options);
307
+
308
+			}, 'GET');
309
+		},
310
+		//수주내역 그래프
311
+		drawChartOrders() {
312
+			
313
+			const key = { brandId:fn_make_user_info.get('brandId'), 
314
+						spplyId:fn_make_user_info.get('spplyId'), 
315
+						poType: $('#ITP_FORM_MAIN_SEARCH_ORDERS_TYPE').val() };
316
+			var param = $.param(key);
317
+			fn_ajax_call(MAIN_CHART_PCH_ODR_CHART, param, function(result) {
318
+				
319
+				var data = google.visualization.arrayToDataTable( eval(result.chartData) );
320
+				var options = {
321
+					legend: { position: 'left' },
322
+					width: chartWidth,
323
+				};	
324
+				var chart = new google.charts.Bar(document.getElementById('ITP_ORDERS_GRAPH'));
325
+				chart.draw(data, options);
326
+				
327
+			}, 'GET');
328
+			
329
+		},
330
+		//입고 그래프
331
+		drawChartDeli() {
332
+			
333
+			const key = { brandId:fn_make_user_info.get('brandId'), 
334
+						storeId:fn_make_user_info.get('storeId'), 
335
+						deliType: $('#ITP_FORM_MAIN_SEARCH_DELI_TYPE').val() };
336
+			var param = $.param(key);
337
+			fn_ajax_call(MAIN_CHART_DELI_CHART, param, function(result) {
338
+				
339
+				var data = google.visualization.arrayToDataTable( eval(result.chartData) );
340
+				var options = {
341
+					legend: { position: 'left' },
342
+					width: chartWidth,
343
+				};	
344
+				var chart = new google.charts.Bar(document.getElementById('ITP_DELI_GRAPH'));
345
+				chart.draw(data, options);
346
+				
347
+			}, 'GET');
348
+			
349
+		},
350
+		//출고 그래프
351
+		drawChartRelease() {
352
+			
353
+			const key = { brandId:fn_make_user_info.get('brandId'), 
354
+						spplyId:fn_make_user_info.get('spplyId'), 
355
+						deliType: $('#ITP_FORM_MAIN_SEARCH_RELEASE_TYPE').val() };
356
+			var param = $.param(key);
357
+			fn_ajax_call(MAIN_CHART_DELI_CHART, param, function(result) {
358
+				
359
+				var data = google.visualization.arrayToDataTable( eval(result.chartData) );
360
+				var options = {
361
+					legend: { position: 'left' },
362
+					width: chartWidth,
363
+				};	
364
+				var chart = new google.charts.Bar(document.getElementById('ITP_RELEASE_GRAPH'));
365
+				chart.draw(data, options);
366
+				
367
+			}, 'GET');
368
+			
369
+		},
370
+		//구매발주 그래프
371
+		drawChartPodr() {
372
+			
373
+			const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), poType: $('#ITP_FORM_MAIN_SEARCH_PO_TYPE').val() };
374
+			var param = $.param(key);
375
+			fn_ajax_call(MAIN_CHART_PCH_ODR_CHART, param, function(result) {
376
+				
377
+				var data = google.visualization.arrayToDataTable( eval(result.chartData) );
378
+			
379
+				var options = {
380
+					legend: { position: 'left' }, 
381
+					bar: { groupWidth: "50%" },
382
+					width: chartWidth,
383
+				};	
384
+				var chart = new google.charts.Bar(document.getElementById('ITP_PCH_PODR_GRAPH'));	
385
+				// chart.draw(data, options);
386
+				chart.draw(data, google.charts.Bar.convertOptions(options));
387
+				
388
+			}, 'GET');	
389
+			
283 390
 		}
391
+		
284 392
 	}
285 393
 };
286 394