Selaa lähdekoodia

재고기준정보 관리

marseyes 2 vuotta sitten
vanhempi
commit
f234f80f0d

+ 45 - 37
src/main/webapp/app/stockmng/STOCKMNG03010.html

@@ -13,44 +13,52 @@
13 13
 					<div class="itp_lg_form itp_type1 fix">
14 14
 						<div class="itp_srh_border fix">
15 15
 							<div class="col-xs-12">
16
+								<form id="ITP_FORM_STOCKMNG03010" class="form-horizontal">
17
+								<input type="hidden" id="ITP_FORM_STOCKMNG03010_BRAND_ID" name="brandId" value="">
18
+								<input type="hidden" id="ITP_FORM_STOCKMNG03010_WHS_ID" name="whsId" value="">
19
+								<input type="hidden" id="ITP_FORM_STOCKMNG03010_LOCATION" name="location" value="">								
20
+								</form>
16 21
 								<form id="ITP_FORM_STOCKMNG03010_SEARCH" class="form-horizontal">
17
-								    <div class="form-group">
18
-							            <div class="col-xs-2 itp_in" style="padding:0px;">
19
-							                <select id="ITP_FORM_STOCKMNG03010_SERVICE_WHS_MGNT_BASE_INFO" class="form-control itp_input" name="sWhsMgntBaseInfo">
20
-							                    <option value="">창고</option>											
21
-							                </select>	
22
-							            </div>
23
-							            <div class="col-xs-2 itp_in" style="padding:0px;">
24
-							                <select id="ITP_FORM_STOCKMNG03010_SEARCH_WHS_MGNT_BASE_LOC" class="form-control itp_input" name="sWhsMgntBaseLoc">
25
-							                    <option value="">판매용/B품/폐기품</option>											
26
-							                </select>										
27
-							            </div>
28
-							             <div class="col-xs-4 itp_in">
29
-							            	<input type="text" id="ITP_FORM_STOCKMNG03010_SEARCH_ITEM_NM" class="form-control itp_input" name="sItemNm" placeholder="품목번호 or 품목명" />
30
-								        </div>
31
-								    </div>
32
-								    <div class="form-group" style="padding-top: 10px; border-top: 1px dotted #ccc;">
33
-								        <div class="col-xs-1 itp_in" style="width:14%; padding:0px;">
34
-								            <select id="ITP_FORM_STOCKMNG03010_SEARCH_ITEM_CLASS1" class="form-control itp_input" name="sItemClass1">
35
-								                <option value="">품목분류Level1</option>											
36
-								            </select>										
37
-								        </div>
38
-								        <div class="col-xs-1 itp_in" style="width:14%; padding:0px;">
39
-								            <select id="ITP_FORM_STOCKMNG03010_SEARCH_ITEM_CLASS2" class="form-control itp_input" name="sItemClass2">
40
-								                <option value="">품목분류Level2</option>											
41
-								            </select>										
42
-								        </div>
43
-								        <div class="col-xs-1 itp_in" style="width:14%; padding:0px;">
44
-								            <select id="ITP_FORM_STOCKMNG03010_SEARCH_ITEM_CLASS3" class="form-control itp_input" name="sItemClass3">
45
-								                <option value="">품목분류Level3</option>											
46
-								            </select>										
47
-								        </div>
48
-								        <div class="col-xs-1 itp_in" style="width:14%; padding:0px;">
49
-								            <select id="ITP_FORM_STOCKMNG03010_SEARCH_ITEM_CLASS4" class="form-control itp_input" name="sItemClass4">
50
-								                <option value="">품목분류Level4</option>											
51
-								            </select>										
52
-								        </div>
53
-								    </div>
22
+									<input type="hidden" id="ITP_FORM_STOCKMNG03010_SEARCH_BRAND_ID" name="sbrandId" value="">
23
+									<input type="hidden" id="ITP_FORM_STOCKMNG03010_SEARCH_STORE_ID" name="sstoreId" value="">
24
+								
25
+									<div class="form-group">
26
+										<div class="col-xs-10">
27
+											<div class="col-xs-2 itp_ip itp_noMar">
28
+												<select id="ITP_FORM_STOCKMNG03010_SEARCH_WHS_ID" class="form-control itp_input" name="swhsId"></select>	
29
+											</div>
30
+											<div class="col-xs-3 itp_ip itp_noMar">
31
+												<select id="ITP_FORM_STOCKMNG03010_SEARCH_LOCATION" class="form-control itp_input" name="slocation"></select>										
32
+											</div>
33
+										</div>
34
+									</div>
35
+									<div class="form-group" style="padding-top: 10px; border-top: 1px dotted #ccc;">
36
+										<div class="col-xs-10">
37
+											<div class="col-xs-2 itp_ip itp_noMar">
38
+												<select id="ITP_FORM_STOCKMNG03010_SEARCH_ITEM_CLASS1" class="form-control itp_input" name="sitemClass1">
39
+													<option value="">품목분류Level1</option>											
40
+												</select>										
41
+											</div>
42
+											<div class="col-xs-2 itp_ip itp_noMar">
43
+												<select id="ITP_FORM_STOCKMNG03010_SEARCH_ITEM_CLASS2" class="form-control itp_input" name="sitemClass2">
44
+													<option value="">품목분류Level2</option>											
45
+												</select>										
46
+											</div>
47
+											<div class="col-xs-2 itp_ip itp_noMar">
48
+												<select id="ITP_FORM_STOCKMNG03010_SEARCH_ITEM_CLASS3" class="form-control itp_input" name="sitemClass3">
49
+													<option value="">품목분류Level3</option>											
50
+												</select>										
51
+											</div>
52
+											<div class="col-xs-2 itp_ip itp_noMar">
53
+												<select id="ITP_FORM_STOCKMNG03010_SEARCH_ITEM_CLASS4" class="form-control itp_input" name="sitemClass4">
54
+													<option value="">품목분류Level4</option>											
55
+												</select>										
56
+											</div>
57
+											<div class="col-xs-4 itp_in itp_noMar">
58
+												<input type="text" id="ITP_FORM_STOCKMNG03010_SEARCH_ITEM_NM" class="form-control itp_input" name="sitemNm" placeholder="품목번호 or 품목명" />
59
+											</div>
60
+										</div>							
61
+									</div>
54 62
 								</form>
55 63
 							</div>
56 64
 						</div>

+ 356 - 0
src/main/webapp/js/app/stockmng/ITP_STOCKMNG03010.js

@@ -0,0 +1,356 @@
1
+/********************************************************
2
+ --------------------------------------------------------
3
+ - Object 목록								            -
4
+ --------------------------------------------------------
5
+ * const gridColModel = {}	: 화면 Grid Object			*
6
+ * let pageObj = {}			: 화면공통 Object			*
7
+ * let listObj = {}			: 목록화면 Object			*
8
+ *******************************************************/
9
+
10
+/*화면 변수*/
11
+const STOCKMNG03010_GRID_ID = '#ITP_STOCKMNG03010_jqGrid';
12
+const STOCKMNG03010_GRID_LIST = '#ITP_STOCKMNG03010_jqGrid_list';
13
+const STOCKMNG03010_GRID_PAGER = '#ITP_STOCKMNG03010_jqGridPager';
14
+const STOCKMNG03010_GRID_EMPTY = '#ITP_STOCKMNG03010_jqGridEmpty';
15
+
16
+let ITP_FORM_STOCKMNG03010_IS_DUPLICATE = false;
17
+let ITP_FORM_STOCKMNG03010_IS_WRITING = false;
18
+let STOCKMNG03010_GRID_LAST_ROW_ID;
19
+
20
+/*API URL*/
21
+let STOCK_BASE_MNG_DETAIL_GRID_LIST = '/api/stock/base/mng/detail-grid-list';
22
+let WHS_MNG_DETAIL_GRID_LIST = '/api/whs/mng/detail-grid-list';
23
+let WHS_MNG_LOCATION_GRID_LIST = '/api/whs/mng/location-grid-list';
24
+let STOCK_BASE_MNG_SAVE = '/api/stock/base/mng/save';
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_ID', name: 'brandId',
37
+			label: "브랜드ID", 
38
+			width: '0', fixed: false, align: 'center',
39
+			sortable: false, hidden: true
40
+		},
41
+		{
42
+			index: 'LOCATION', name: 'location',
43
+			label: "로케이션", 
44
+			width: '0', fixed: false, align: 'center',
45
+			sortable: false, hidden: true
46
+		},
47
+		{
48
+			index: 'BRAND_NM', name: 'brandNm',
49
+			label: ITP_MSG_LOCALE.label.brandNm, //브랜드
50
+			width: '10', fixed: false, align: 'center',
51
+			sortable: false, hidden: false
52
+		},
53
+		{
54
+			index: 'STORE_NM', name: 'storeNm',
55
+			label: "매장명", 
56
+			width: '10', fixed: false, align: 'center',
57
+			sortable: false, hidden: false
58
+		},
59
+		{
60
+			index: 'WHS_ID', name: 'whsId',
61
+			label: "창고번호", 
62
+			width: '8', fixed: false, align: 'center',
63
+			sortable: false, hidden: false
64
+		},
65
+		{
66
+			index: 'WHS_NM', name: 'whsNm',
67
+			label: "창고명", 
68
+			width: '13', fixed: false, align: 'center',
69
+			sortable: false, hidden: false
70
+		},
71
+		{
72
+			index: 'LOCATION_NM', name: 'locationNm',
73
+			label: "Location명", 
74
+			width: '10', fixed: false, align: 'center',
75
+			sortable: false, hidden: false
76
+		},
77
+		{
78
+			index: 'ITEM_ID', name: 'itemId',
79
+			label: "품목번호", 
80
+			width: '11', fixed: false, align: 'center',
81
+			sortable: false, hidden: false
82
+		},
83
+		{
84
+			index: 'ITEM_NM', name: 'itemNm',
85
+			label: "품목명", 
86
+			width: '10', fixed: false, align: 'center',
87
+			sortable: false, hidden: false
88
+		},
89
+		{
90
+			index: 'UNIT', name: 'unit',
91
+			label: "단위", 
92
+			width: '7', fixed: false, align: 'center',
93
+			sortable: false, hidden: false
94
+		},
95
+		{
96
+			index: 'PRP_STCK_QTY', name: 'prpStckQty',
97
+			label: "적정재고수량", 
98
+			width: '8', fixed: false, align: 'center',
99
+			sortable: false, editable: true, edittype: 'text',
100
+			editrules: {required: false}
101
+		},
102
+		{
103
+			index: 'SFT_STCK_RT', name: 'sftStckRt',
104
+			label: "안전재고비율(%)", 
105
+			width: '10', fixed: false, align: 'center',
106
+			sortable: false, editable: true, edittype: 'text',
107
+			editrules: {required: false}
108
+		}		
109
+	]
110
+};
111
+
112
+require(['config'], function() {
113
+	require([
114
+	], function($) {
115
+		pageObj.init();
116
+	});
117
+});
118
+
119
+/*화면공통 Object*/
120
+let pageObj = {
121
+	init: function () {
122
+		this.ui.init();
123
+		this.event.init();
124
+	},
125
+	ui: {
126
+		init: function () {
127
+			this.view();
128
+			this.grid();
129
+			this.ready();
130
+		},
131
+		view: function() {
132
+			// 버튼 권한설정
133
+			fn_proc_btn_auth('STOCKMNG03010');
134
+			
135
+			// 브랜드ID 지정
136
+			var data = JSON.parse(sessionStorage.getItem('itp_manage_brand_info'));
137
+			$('#ITP_FORM_STOCKMNG03010_SEARCH_BRAND_ID').val(data.brandId);
138
+			
139
+			pageObj.fnWhsList(function() {
140
+				pageObj.fnLocationList();
141
+			}); // 창고리스트
142
+			
143
+			// 공통코드 표시
144
+			// fn_make_select(CODE_LIST, 'WHS_DVSN', 'ITP_FORM_STOCKMNG03010_WHS_DVSN');			
145
+
146
+			// 조회일자 지정
147
+			$('#ITP_TAB_STOCKMNG03010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);			
148
+		},
149
+		grid: function() {
150
+			itp_fn_jqgrid_resize(STOCKMNG03010_GRID_ID, STOCKMNG03010_GRID_LIST, 'lg');
151
+			listObj.empty.init();
152
+			itp_fn_fire_window_resize();
153
+		},
154
+		ready: function() {
155
+			listObj.init();
156
+		}
157
+	},
158
+	event: {
159
+		init: function () {
160
+			this.button();
161
+			this.change();
162
+		},
163
+		button: function () {
164
+			// 버튼 클릭 이벤트
165
+			$('button').each(function() {
166
+				var id = $(this).attr('id');
167
+				$(this).on('click', function() {
168
+					switch (id) {
169
+						case 'ITP_BTN_STOCKMNG03010_SRH'		: listObj.button.search();		break;	// 조회 버튼
170
+						case 'ITP_BTN_STOCKMNG03010_SAVE'		: listObj.button.save();		break;	// 저장 버튼
171
+					}
172
+				});
173
+			});
174
+
175
+			$('body').on('click', function(e) {
176
+				var gridId = STOCKMNG03010_GRID_ID.replace('#', '');
177
+				var rids = $(STOCKMNG03010_GRID_ID).jqGrid('getDataIDs');
178
+				var last_row_id = rids[rids.length - 1];
179
+				itp_fn_grid_reset_selection(e, last_row_id, gridId, 'STOCKMNG03010');
180
+			});
181
+		}, 
182
+		change: function () {
183
+			// 창고 변경
184
+			$('#ITP_FORM_STOCKMNG03010_SEARCH_WHS_ID').on('change', function() {
185
+				pageObj.fnLocationList(function() {
186
+					listObj.button.search(); // 조회	
187
+				}); // 로케이션 리스트
188
+			});
189
+			$('#ITP_FORM_STOCKMNG03010_SEARCH_LOCATION').on('change', function() {
190
+				listObj.button.search(); // 조회
191
+			});
192
+			
193
+		}
194
+	},
195
+	switchScreen: function(mode) {
196
+		if(mode == 'LIST') { // 목록			
197
+			fn_show_btn_auth('#ITP_BTN_STOCKMNG03010_SRH');
198
+
199
+			$('#ITP_AJAX_STOCKMNG03010_LIST_CONTAINER').show();
200
+		}
201
+	}, 
202
+	fnWhsList: function(fnCall) {
203
+		const brandIdVal = $('#ITP_FORM_STOCKMNG03010_SEARCH_BRAND_ID').val();	
204
+		const param = {sbrandId: brandIdVal, pagingYn: false};
205
+		
206
+		fn_ajax_call(WHS_MNG_DETAIL_GRID_LIST, JSON.stringify(param), function(result) {
207
+			
208
+			fn_make_select_whs(result.gridRows, 'ITP_FORM_STOCKMNG03010_SEARCH_WHS_ID');
209
+			
210
+			if (fnCall !== undefined || typeof fnCall !== 'undefined') fnCall();
211
+					
212
+		}, 'POST');
213
+	}, 
214
+	fnLocationList: function(fnCall) {
215
+		const brandIdVal = $('#ITP_FORM_STOCKMNG03010_SEARCH_BRAND_ID').val();	
216
+		const whsIdVal = $('#ITP_FORM_STOCKMNG03010_SEARCH_WHS_ID').val();	
217
+		const param = {brandId: brandIdVal, whsId: whsIdVal, pagingYn: false};
218
+		
219
+		fn_ajax_call(WHS_MNG_LOCATION_GRID_LIST, JSON.stringify(param), function(result) {
220
+			
221
+			fn_make_select_location(result.gridRows, 'ITP_FORM_STOCKMNG03010_SEARCH_LOCATION');
222
+			
223
+			if (fnCall !== undefined || typeof fnCall !== 'undefined') fnCall();
224
+					
225
+		}, 'POST');
226
+	}
227
+};
228
+
229
+/*목록화면 Object*/
230
+let listObj = {
231
+	init: function () {
232
+		this.grid.init();
233
+	},
234
+	itp_STOCKMNG03010_search: false,
235
+	button: {
236
+		search: function() {
237
+			listObj.itp_STOCKMNG03010_search = true;
238
+			let param = $('#ITP_FORM_STOCKMNG03010_SEARCH').serializeObject();
239
+			param.gridSize = $.jgrid.defaults.rowNum;
240
+			param.gridPage = $.jgrid.defaults.page;
241
+			$(STOCKMNG03010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
242
+		}, 
243
+		save: function() {
244
+			$('#ITP_FORM_STOCKMNG03010_WHS_ID').val($('#ITP_FORM_STOCKMNG03010_SEARCH_WHS_ID').val());
245
+			$('#ITP_FORM_STOCKMNG03010_LOCATION').val($('#ITP_FORM_STOCKMNG03010_SEARCH_LOCATION').val());
246
+			
247
+			const formId = '#ITP_FORM_STOCKMNG03010';
248
+			itp_fn_form_clear_validate(null, formId);
249
+			
250
+			let gridUpdateData = [];
251
+			const rowData = $(STOCKMNG03010_GRID_ID).getRowData();			
252
+			if(rowData.length < 1) {
253
+				itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.grid.noData);
254
+				return;
255
+			}	
256
+			$.each(rowData, function(key, value) {
257
+				if (value.viewCd != 'R') {
258
+					if (value.viewCd == 'U') {
259
+						gridUpdateData.push(value);
260
+					} 
261
+				}
262
+			});
263
+			if(gridUpdateData.length < 1) {
264
+				itp_fn_modal_alert_ajax('변경된 데이터가 없습니다.');
265
+				return;
266
+			}
267
+			let param = $(formId).serializeObject();			
268
+			param.gridUpdateData = gridUpdateData;
269
+			//console.log(JSON.stringify(param));
270
+			var searhFn = function() {
271
+				ITP_FORM_STOCKMNG03010_DETAIL_IS_WRITING = false;
272
+				listObj.grid.search();
273
+			};
274
+			fn_ajax_call(STOCK_BASE_MNG_SAVE, JSON.stringify(param), searhFn, 'POST');
275
+		}
276
+	},
277
+	empty: {
278
+		init: function() {
279
+			var _this = this;
280
+			this.push();
281
+			$(STOCKMNG03010_GRID_EMPTY).on('click', function() {
282
+				_this.back();
283
+				_this.itp_STOCKMNG03010_param.gridSize = $.jgrid.defaults.rowNum;
284
+				$(STOCKMNG03010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_STOCKMNG03010_param)}).trigger('reloadGrid');
285
+			});
286
+		},
287
+		itp_STOCKMNG03010_param: {},
288
+		push: function() {
289
+			let param = $('#ITP_FORM_STOCKMNG03010_SEARCH').serializeObject();
290
+			listObj.itp_STOCKMNG03010_param = param;
291
+		},
292
+		back: function() {
293
+			$('#ITP_FORM_STOCKMNG03010_DEVI_TP_CD').val(this.itp_STOCKMNG03010_param.deviTpCd);
294
+			$('#ITP_FORM_STOCKMNG03010_ORDER_YN').val(this.itp_STOCKMNG03010_param.orderYn);
295
+			$('#ITP_FORM_STOCKMNG03010_ADT_AUTH_CD').val(this.itp_STOCKMNG03010_param.adtAuthCd);
296
+			$('#ITP_FORM_STOCKMNG03010_EMAIL_RCV_YN').val(this.itp_STOCKMNG03010_param.emailRcvYn);
297
+			$('#ITP_FORM_STOCKMNG03010_MEMB_EXIT_DT').val(this.itp_STOCKMNG03010_param.membExitDt);
298
+			$('#ITP_FORM_STOCKMNG03010_FROM_DT').val(this.itp_STOCKMNG03010_param.fromDt);
299
+			$('#ITP_FORM_STOCKMNG03010_TO_DT').val(this.itp_STOCKMNG03010_param.toDt);
300
+			$('#ITP_FORM_STOCKMNG03010_KEYWORD').val(this.itp_STOCKMNG03010_param.keyword);
301
+		}
302
+	},
303
+	grid: {
304
+		init: function () {
305
+			// 데이터 없을때
306
+			listObj.empty.push();
307
+			this.search();
308
+		},
309
+		colModel: gridColModel.list,
310
+		search: function() {
311
+			pageObj.switchScreen('LIST');
312
+			this.unload();
313
+			this.load();
314
+		},
315
+		load: function() {
316
+			var data = JSON.parse(sessionStorage.getItem('itp_manage_brand_info'));
317
+			$('#ITP_FORM_STOCKMNG03010_BRAND_ID').val(data.brandId);
318
+			$('#ITP_FORM_STOCKMNG03010_SEARCH_BRAND_ID').val(data.brandId);
319
+			
320
+			let param = $('#ITP_FORM_STOCKMNG03010_SEARCH').serializeObject();
321
+			param.gridSize = $.jgrid.defaults.rowNum;
322
+
323
+			var option = {
324
+				gridId: STOCKMNG03010_GRID_ID,
325
+				colModel: gridColModel.list,
326
+				param: JSON.stringify(param),
327
+				url: DOMAIN + STOCK_BASE_MNG_DETAIL_GRID_LIST,
328
+				pager: STOCKMNG03010_GRID_PAGER,
329
+				onCellSelect: function(rowId, cellIdx, cellValue) {
330
+					STOCKMNG03010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowId, cellIdx, STOCKMNG03010_GRID_LAST_ROW_ID, STOCKMNG03010_GRID_ID); 
331
+		   		},
332
+				loadComplete: function(data) {
333
+					console.log(data);
334
+					itp_fn_grid_load_complete(data, STOCKMNG03010_GRID_ID, true, 'number', 'STOCKMNG03010', listObj.itp_STOCKMNG03010_search, listObj.empty, true, data.gridRecords, true);
335
+					var ids = $(STOCKMNG03010_GRID_ID).getDataIDs();
336
+					$.each(ids, function(idx, rowId) {
337
+						// $(STOCKMNG03010_GRID_ID).jqGrid('setCell', rowId, 'whsNm', '', ITP_GRID_COL_STYLE.link);
338
+					});
339
+				},
340
+				onPaging: function(action) {
341
+					itp_fn_grid_paging(STOCKMNG03010_GRID_ID, action, param);
342
+				}
343
+			};
344
+			itp_fn_grid_make_remote(option);
345
+		},
346
+		clearData : function() {
347
+			$(STOCKMNG03010_GRID_ID).jqGrid('clearGridData', true);
348
+			$(STOCKMNG03010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
349
+			$(STOCKMNG03010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
350
+			$(STOCKMNG03010_GRID_EMPTY).show();
351
+		},
352
+		unload : function() {
353
+			$.jgrid.gridUnload(STOCKMNG03010_GRID_ID);
354
+		}
355
+	}
356
+};