Explorar el Código

모바일 공통 작업

juney hace 2 años
padre
commit
9529634f83
Se han modificado 1 ficheros con 394 adiciones y 0 borrados
  1. 394 0
      src/main/webapp/mobile/js/app/mpomng/ITP_MPOMNG01010.js

+ 394 - 0
src/main/webapp/mobile/js/app/mpomng/ITP_MPOMNG01010.js

@@ -0,0 +1,394 @@
1
+require(['config'], function() {
2
+	require([
3
+	], function($) {
4
+		pageObj.init();
5
+	});
6
+});
7
+
8
+/********************************************************
9
+ --------------------------------------------------------
10
+ - Object 목록								            -
11
+ --------------------------------------------------------
12
+ * const gridColModel = {}	: 화면 Grid Object			*
13
+ * let pageObj = {}			: 화면공통 Object			*
14
+ * let listObj = {}			: 목록화면 Object			*
15
+ * let viewObj = {}			: 상세화면 Object			*
16
+ * let modifyObj = {}		: 수정화면 Object			*
17
+ * let createObj = {}		: 신규화면 Object			*
18
+ *******************************************************/
19
+
20
+/*화면 변수*/
21
+/*
22
+const POMNG01010_GRID_ID = '#ITP_POMNG01010_jqGrid';
23
+const POMNG01010_GRID_LIST = '#ITP_POMNG01010_jqGrid_list';
24
+const POMNG01010_GRID_PAGER = '#ITP_POMNG01010_jqGridPager';
25
+const POMNG01010_GRID_EMPTY = '#ITP_POMNG01010_jqGridEmpty';
26
+
27
+const POMNG01010_VIEW_GRID_ID = '#ITP_POMNG01010_VIEW_jqGrid';
28
+const POMNG01010_VIEW_GRID_LIST = '#ITP_POMNG01010_VIEW_jqGrid_list';
29
+const POMNG01010_VIEW_GRID_PAGER = '#ITP_POMNG01010_VIEW_jqGridPager';
30
+const POMNG01010_VIEW_GRID_EMPTY = '#ITP_POMNG01010_VIEW_jqGridEmpty';
31
+*/
32
+const POMNG01010_DETAIL_GRID_ID = '#ITP_POMNG01010_DETAIL_jqGrid';
33
+const POMNG01010_DETAIL_GRID_LIST = '#ITP_POMNG01010_DETAIL_jqGrid_list';
34
+const POMNG01010_DETAIL_GRID_PAGER = '#ITP_POMNG01010_DETAIL_jqGridPager';
35
+const POMNG01010_DETAIL_GRID_EMPTY = '#ITP_POMNG01010_DETAIL_jqGridEmpty';  // ==>dwkim html확인필요
36
+
37
+/*
38
+let ITP_FORM_POMNG01010_DETAIL_IS_DUPLICATE = false;
39
+let ITP_FORM_POMNG01010_DETAIL_IS_WRITING = false;
40
+*/
41
+
42
+/*API URL*/
43
+let API_DETAIL_INIT_INFO = '/api/pomng/init-pchReq'
44
+//let API_DETAIL_GRID_LIST = '/api/affl/detail-grid-list';
45
+//let API_DETAIL_INFO = '/api/affl/info-affl';
46
+//let COMPANY_INFO_COMPANY = '/api/affl/info-affl';
47
+let API_DETAIL_SAVE = '/api/pomng/save-pchReq';
48
+//let API_CHECK_DUPLICATE = '/api/affl/check-duplicate';
49
+//let API_INTI_USERPW = '/api/user/inti-userpw';
50
+
51
+/*화면 Grid ColModel   ==>선택박스 항목 추가 부분  */
52
+const gridColModel = {
53
+	detail: [
54
+		{
55
+			index: 'VIEW_CD', name: 'viewCd',
56
+			label: ITP_MSG_LOCALE.label.viewCd,
57
+			width: '10', fixed: false, align: 'center',
58
+			sortable: false, hidden: true
59
+		},
60
+		{
61
+			index: 'ITEM_ID', name: 'itemId',
62
+			label: ITP_MSG_LOCALE.label.itemId,
63
+			width: '20', fixed: false, align: 'center',
64
+			sortable: false, editable: false, edittype: 'text',
65
+			editrules: { required: true }
66
+		},
67
+		{
68
+			index: 'ITEM_NM', name: 'itemNm',
69
+			label: ITP_MSG_LOCALE.label.itemNm,
70
+			width: '30', fixed: false, align: 'center',
71
+			sortable: true, editable: false, edittype: 'text',
72
+			editrules: { required: true }
73
+		},
74
+		{
75
+			index: 'UNIT', name: 'unit',
76
+			label: ITP_MSG_LOCALE.label.unit,
77
+			width: '10', fixed: false, align: 'center',
78
+			sortable: false, editable: false, edittype: 'text'
79
+		},
80
+		{
81
+			index: 'UNIT_AMT', name: 'unitAmt',
82
+			label: ITP_MSG_LOCALE.label.unitAmt,
83
+			width: '10', fixed: false, align: 'center',
84
+			sortable: false, editable: false, edittype: 'text', hidden: false
85
+		},
86
+		{
87
+			index: 'PCH_REQ_QTY', name: 'pchReqQty',
88
+			label: ITP_MSG_LOCALE.label.pchReqQty, //단가
89
+			width: '10', fixed: false, align: 'right',
90
+			sortable: true, editable: true, edittype: 'text',
91
+			editrules: { number:true}
92
+		},
93
+		{
94
+			index: 'PCH_REQ_AMT', name: 'pchReqAmt',
95
+			label: ITP_MSG_LOCALE.label.pchReqAmt,
96
+			width: '10', fixed: false, align: 'right',
97
+			sortable: false, editable: false, edittype: 'text', hidden: false
98
+		},
99
+
100
+		{
101
+			index: 'BRAND_UNIT_UNQ_NO', name: 'brandUnitUnqNo',
102
+			label: ITP_MSG_LOCALE.label.brandUnitUnqNo,
103
+			width: '10', fixed: false, align: 'center',
104
+			sortable: false, editable: false, edittype: 'text', hidden: true
105
+		},
106
+		{
107
+			index: 'STORE_UNIT_UNQ_NO', name: 'storeUnitUnqNo',
108
+			label: ITP_MSG_LOCALE.label.storeUnitUnqNo,
109
+			width: '10', fixed: false, align: 'center',
110
+			sortable: false, editable: false, edittype: 'text', hidden: true
111
+		},
112
+		{
113
+			index: 'UNIT_GUBUN', name: 'unitGubun',
114
+			label: ITP_MSG_LOCALE.label.unitGubun,
115
+			width: '10', fixed: false, align: 'center',
116
+			sortable: false, editable: false, edittype: 'text', hidden: true
117
+		}
118
+	]
119
+};
120
+
121
+/*화면공통 Object*/
122
+let pageObj = {
123
+	init: function() {
124
+		this.ui.init();
125
+		this.event.init();
126
+		this.action();
127
+	},
128
+	action: function () {
129
+		var _this = this;
130
+		// 납품장소 조회 버튼 클릭
131
+		$('#ITP_FORM_POMNG01010_SEARCH_WHS_NM').on('click', function() {
132
+			_this.popup();
133
+		});
134
+		// 납품장소 텍스트 삭제 버튼 클릭
135
+		$('#ITP_FORM_POMNG01010_DELETE_WHS_NM').on('click', function() {
136
+			$('#ITP_FORM_POMNG01010_DETAIL_WHS_NM').val('');
137
+			$('#ITP_FORM_POMNG01010_DETAIL_WHS_ID').val('');
138
+			$('#ITP_FORM_POMNG01010_DETAIL_LOCATION_NM').val('');
139
+			$('#ITP_FORM_POMNG01010_DETAIL_LOCATION').val('');
140
+			
141
+		});
142
+	},
143
+	popup: function () {
144
+		// 팝업
145
+		var popFn = this.callback.create;
146
+		const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
147
+		fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S');
148
+		
149
+	},
150
+	callback: {
151
+		create: function(rowDataPop) {
152
+			console.log(rowDataPop);
153
+			if(rowDataPop) {
154
+				$('#ITP_FORM_POMNG01010_DETAIL_WHS_NM').val(rowDataPop.whsNm);
155
+				$('#ITP_FORM_POMNG01010_DETAIL_WHS_ID').val(rowDataPop.whsId);
156
+				$('#ITP_FORM_POMNG01010_DETAIL_LOCATION_NM').val(rowDataPop.locationNm);
157
+				$('#ITP_FORM_POMNG01010_DETAIL_LOCATION').val(rowDataPop.location);
158
+			}
159
+		}
160
+	},
161
+	itp_POMNG01010_param: {},  // ==>dwkim 
162
+	itp_POMNG01010_search: false,  // ==>dwkim 
163
+	ui: {
164
+		init: function() {
165
+			this.view();
166
+			this.grid();
167
+			this.ready();
168
+		},
169
+		view: function() {
170
+			// 버튼 권한설정
171
+			fn_proc_btn_auth('POMNG01010');
172
+			
173
+			// 공통코드 표시
174
+			$('select').each(function() {
175
+				if ($(this).data('select-code')) {
176
+					fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
177
+				}
178
+			});
179
+
180
+			// 조회일자 지정
181
+			var now = new Date();
182
+			$('#ITP_FORM_POMNG01010_DETAIL_DLV_REQ_DT').datepicker('dlvReqDt', new Date(now.setDate(now.getDate() + 5)));
183
+			
184
+			//납품장소 필드 readonly
185
+			$('#ITP_FORM_POMNG01010_DETAIL_WHS_NM').attr('readonly', true);
186
+			$('#ITP_FORM_POMNG01010_DETAIL_LOCATION_NM').attr('readonly', true);
187
+			// form alert message 주입
188
+			/*
189
+			$('input[data-alert-required="ONLYCHK"]').each(function() {
190
+				if($(this).data('alert-msg') === 'address') {
191
+					$(this).data('alert-msg', ITP_MSG_LOCALE.message.form.emptyAddr);
192
+				}
193
+			});
194
+			*/
195
+		},
196
+		grid: function() {
197
+			itp_fn_jqgrid_resize(POMNG01010_DETAIL_GRID_ID, POMNG01010_DETAIL_GRID_LIST, 'lg');
198
+			//listObj.empty.init();
199
+			itp_fn_fire_window_resize();
200
+		},
201
+		ready: function() {
202
+			createObj.init();
203
+		}
204
+	},
205
+	event: {
206
+		init: function() {
207
+			this.button();
208
+		},
209
+		button: function() {
210
+			// 버튼 클릭 이벤트
211
+			$('button').each(function() {
212
+				var id = $(this).attr('id');
213
+				$(this).on('click', function() {
214
+					switch (id) {
215
+						case 'ITP_BTN_POMNG01010_SRH': modifyObj.button.save(); break;	// 구매요청
216
+						case 'ITP_BTN_POMNG01010_NEWREG': modifyObj.button.newReg(); break;	// 임시저장
217
+						case 'ITP_BTN_POMNG01010_DETAIL_ADDROW': pageObj.grid.button.addRow(); break;	// 품목추가
218
+						case 'ITP_BTN_POMNG01010_DETAIL_DELROW': pageObj.grid.button.delRow(); break;	// 품목삭제
219
+					}
220
+				});
221
+			});
222
+
223
+			$('body').on('click', function(e) {
224
+				// afflUserObj.grid.resetGrid(e);
225
+			});
226
+
227
+		}
228
+	},
229
+	grid: {
230
+		init: function(mode, gridData) {
231
+			this.mode = mode;
232
+			this.gridId = POMNG01010_DETAIL_GRID_ID;
233
+			this.unload();  // ==>dwkim 
234
+			this.load(gridData);
235
+		},
236
+		mode: 'DETAIL',
237
+		gridId: '',
238
+		button: {
239
+			addRow: function() {
240
+				// 팝업
241
+				var popFn = function(rowDataPop) {
242
+					console.log(rowDataPop);
243
+					// 기존등록 데이터
244
+					var exists = '';
245
+					const rowData = $(POMNG01010_DETAIL_GRID_ID).getRowData();
246
+					$.each(rowData, function(key, value) {
247
+						//exists = exists + value.itemId + ';';
248
+						exists = exists + value.brandUnitUnqNo + ';';
249
+					});
250
+
251
+					$.each(rowDataPop, function(key, value) {
252
+						// if (exists.indexOf(value.itemId) < 0 && value.podrPssblDvsn == 'PO01') {
253
+						if (exists.indexOf(value.brandUnitUnqNo) < 0 && value.podrPssblDvsn == 'PO01') {
254
+							value['viewCd'] = "C";
255
+							$(POMNG01010_DETAIL_GRID_ID).jqGrid('addRowData', value.brandUnitUnqNo, value, 'last');
256
+						}
257
+					});
258
+					$(POMNG01010_DETAIL_GRID_EMPTY).hide();
259
+				};
260
+				const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
261
+				fn_call_popup('biz', 'BIZPOP_ITEM', '#ITP_ASIDE', popFn, key, 'S');  // ==>dwkim 추후 작업 진행  파라메타 설명필요
262
+			},
263
+			delRow: function() {
264
+				itp_fn_grid_del_row(POMNG01010_DETAIL_GRID_ID);
265
+				// 그리드 포문으로 금액 재계산후 구매요청금액에 넣어줌
266
+				this.load.recal();  //==>dwkim 왜 호출이 안될까요
267
+			}
268
+		},
269
+		load: function(gridData) {  // ==>dwkim  오픈시 데이타 가져오는 부분 넣으면 되는건지 여부 gird가 아님
270
+			var _this = this;
271
+			var option = {
272
+				gridId: this.gridId,
273
+				colModel: gridColModel.detail,
274
+				data: gridData,
275
+				multiselect: true,
276
+				cellEdit: true,
277
+				loadComplete: function(data) {
278
+					_this.clearData();
279
+				},
280
+				afterSaveCell: function(rowid,name,val,iRow,iCol) {
281
+					// 구매요청금액 계산 (기존금액과 )
282
+					var unitAmt = jQuery(POMNG01010_DETAIL_GRID_ID).jqGrid('getCell',rowid,iCol-1);
283
+					jQuery(POMNG01010_DETAIL_GRID_ID).jqGrid('setRowData',rowid,{pchReqAmt: parseInt(val)*parseInt(unitAmt)});
284
+					// 그리드 포문으로 금액 재계산후 구매요청금액에 넣어줌
285
+					_this.recal();
286
+				}
287
+			};
288
+			itp_fn_grid_make_local(option);
289
+		},
290
+		clearData: function() {
291
+			console.log(this.gridId);
292
+			$(POMNG01010_DETAIL_GRID_ID).jqGrid('clearGridData', true);
293
+			$(POMNG01010_DETAIL_GRID_LIST).find('.ui-jqgrid .ui-jqgrid-bdiv').css('overflow-x', 'hidden');
294
+			$(POMNG01010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
295
+			$(POMNG01010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
296
+			$(POMNG01010_DETAIL_GRID_EMPTY).show();
297
+		},
298
+		recal: function() {
299
+			//PCH_REQ_AMT
300
+			const rowData = $(POMNG01010_DETAIL_GRID_ID).getRowData();
301
+			var pchReqAmt = 0 ;
302
+			$.each(rowData, function(key, value) {
303
+				if (value.pchReqAmt != null && value.pchReqAmt != "") {
304
+					pchReqAmt = pchReqAmt + parseInt(value.pchReqAmt) ;
305
+				}
306
+				
307
+			});
308
+			$('#ITP_FORM_POMNG01010_DETAIL .fnPchReqAmt').text(pchReqAmt);
309
+		},
310
+		unload: function() {
311
+			$.jgrid.gridUnload(this.gridId);
312
+		}
313
+	}
314
+};
315
+
316
+/*신규화면 Object*/
317
+let createObj = {
318
+	init: function() {
319
+		$('#ITP_FORM_POMNG01010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
320
+		$('#ITP_FORM_POMNG01010_DETAIL_STORE_ID').val(fn_make_user_info.get('storeId'));
321
+		//let param = 'brandId=' + LOGIN_USER_INFO.brandId + "&spplyId=" + LOGIN_USER_INFO.spplyId;
322
+		this.load();
323
+	},
324
+	button: {
325
+		save: function() {
326
+			const formId = '#ITP_FORM_POMNG01010_DETAIL';
327
+			itp_fn_form_clear_validate(null, formId);
328
+
329
+			// if (vali_cmpyCd && vali_cmpyStatCd && vali_cmpyTypeCd && vali_cmpyNm && vali_bossNm && vali_mainTel && vali_mainEmail) {
330
+			if (itp_fn_form_event.isValid(formId)) {
331
+
332
+				// if($('#ITP_FORM_POMNG01010_DETAIL_CMPY_ZIPNO').val() === '' || $('#ITP_FORM_POMNG01010_DETAIL_CMPY_ADRES').val() === '') {
333
+				// 	itp_fn_modal_alert('주소 검색을 통해 회사 주소를 입력하세요.');
334
+				// 	return;
335
+				// }
336
+
337
+				if (ITP_FORM_POMNG01010_DETAIL_IS_DUPLICATE) {
338
+					itp_fn_modal_duplicate('회사코드 중복체크를 해주세요.', formId + '_AFFL_SHOP_ID');
339
+				} else {
340
+					let gridInsertData = [];
341
+					let gridUpdateData = [];
342
+					let gridDeleteData = [];
343
+					const rowData = $(POMNG01010_DETAIL_GRID_ID).getRowData();
344
+					const keyValue = $(formId + '_AFFL_SHOP_ID').val();
345
+					$.each(rowData, function(key, value) {
346
+						if (value.viewCd !== 'R') {
347
+							value.afflShopId = keyValue;
348
+							if (value.viewCd === 'C') {
349
+								gridInsertData.push(value);
350
+							} else if (value.viewCd === 'U') {
351
+								gridUpdateData.push(value);
352
+							} else if (value.viewCd === 'D') {
353
+								gridDeleteData.push(value);
354
+							}
355
+						}
356
+					});
357
+
358
+					let param = $(formId).serializeObject();
359
+					param.gridInsertData = gridInsertData;
360
+					param.gridUpdateData = gridUpdateData;
361
+					param.gridDeleteData = gridDeleteData;
362
+					console.log(JSON.stringify(param));
363
+					var searhFn = function() {
364
+						ITP_FORM_POMNG01010_DETAIL_IS_WRITING = false;
365
+						viewObj.init();
366
+					};
367
+					fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
368
+				}
369
+			}
370
+		}
371
+	},
372
+	load: function() {
373
+		fn_ajax_call(API_DETAIL_INIT_INFO, '', this.callback, 'GET');
374
+	},
375
+	callback: function(result) {
376
+		console.log(result);
377
+
378
+		$('#ITP_FORM_POMNG01010_DETAIL #ITP_FORM_POMNG01010_DETAIL_VIEW_CD').val('C');
379
+
380
+		$('#ITP_FORM_POMNG01010_DETAIL #ITP_FORM_POMNG01010_DETAIL_BRAND_ID').val(result.brandId);
381
+		$('#ITP_FORM_POMNG01010_DETAIL #ITP_FORM_POMNG01010_DETAIL_STORE_ID').val(result.storeId);
382
+		$('#ITP_FORM_POMNG01010_DETAIL #ITP_FORM_POMNG01010_DETAIL_LOAN_DVSN').val(result.loanDvsn);
383
+		$('#ITP_FORM_POMNG01010_DETAIL #ITP_FORM_POMNG01010_DETAIL_LOAN_MGNT_UNQ_NO').val(result.loanMgntUnqNo);
384
+		$('#ITP_FORM_POMNG01010_DETAIL #ITP_FORM_POMNG01010_DETAIL_PCH_REQ_DVSN').val(result.pchReqDvsn);
385
+		$('#ITP_FORM_POMNG01010_DETAIL .fnBrandNm').text(result.brandNm);
386
+		$('#ITP_FORM_POMNG01010_DETAIL .fnPchReqDept').text(result.reqDept);
387
+		$('#ITP_FORM_POMNG01010_DETAIL .fnPchReqMgrNm').text(result.userNm);
388
+		$('#ITP_FORM_POMNG01010_DETAIL .fnPchReqAmt').text("0");
389
+		$('#ITP_FORM_POMNG01010_DETAIL .fnLoanDvsnNm').text(result.loanDvsnNm);
390
+		$('#ITP_FORM_POMNG01010_DETAIL .fnPchActAmt').text(result.ordUseAmt);
391
+
392
+		pageObj.grid.init();
393
+	}
394
+};