|
@@ -0,0 +1,366 @@
|
|
1
|
+require(['config'], function() {
|
|
2
|
+ require([
|
|
3
|
+ ], function($) {
|
|
4
|
+ mobPageObj.init();
|
|
5
|
+ });
|
|
6
|
+});
|
|
7
|
+
|
|
8
|
+/*API URL*/
|
|
9
|
+const API_MOBILE_GRID_LIST = '/api/pomng/inoutmng/spply-target-grid-list'; // 목록
|
|
10
|
+const API_MOBILE_INFO = '/api/pomng/inoutmng/init-spply-inv'; // 상세
|
|
11
|
+const API_MOBILE_SAVE = '/api/pomng/inoutmng/save-spply-inv'; // 저장
|
|
12
|
+const API_POP_SEARCH_LIST = '/api/whs/mng/pop-whs-search';
|
|
13
|
+
|
|
14
|
+const PAGE_MODE_LIST = "LIST";
|
|
15
|
+const PAGE_MODE_VIEW = "VIEW";
|
|
16
|
+
|
|
17
|
+let mobPageObj = {
|
|
18
|
+ viewMode: PAGE_MODE_LIST,
|
|
19
|
+ init: function () {
|
|
20
|
+ this.ui.init();
|
|
21
|
+ this.event.init();
|
|
22
|
+ this.ready();
|
|
23
|
+ },
|
|
24
|
+ ui: {
|
|
25
|
+ init: function () {
|
|
26
|
+ this.view();
|
|
27
|
+ this.info();
|
|
28
|
+ },
|
|
29
|
+ view: function() {
|
|
30
|
+ // 공통코드 표시
|
|
31
|
+ $('select').each(function() {
|
|
32
|
+ if($(this).data('select-code')) {
|
|
33
|
+ fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
|
|
34
|
+ }
|
|
35
|
+ });
|
|
36
|
+
|
|
37
|
+ // 조회일자 지정
|
|
38
|
+ $('#ITP_FORM_MORDMNG02010_LIST_SEARCH_FROM_DT').val(itp_fn_date_add('M', -1));
|
|
39
|
+ $('#ITP_FORM_MORDMNG02010_LIST_SEARCH_TO_DT').val(itp_fn_date_add('M', 0));
|
|
40
|
+ },
|
|
41
|
+ info: function() {
|
|
42
|
+ $('input:hidden[id$="_BRAND_ID"]').val(fn_make_user_info.get('brandId'));
|
|
43
|
+ $('input:hidden[id$="_STORE_ID"]').val(fn_make_user_info.get('storeId'));
|
|
44
|
+ $('input:hidden[id$="_SPPLY_ID"]').val(fn_make_user_info.get('userId'));
|
|
45
|
+ }
|
|
46
|
+ },
|
|
47
|
+ event: {
|
|
48
|
+ init: function() {
|
|
49
|
+ this.button();
|
|
50
|
+ },
|
|
51
|
+ button: function() {
|
|
52
|
+ $('button[id^="ITP_BTN_MORDMNG02010_LIST"]').on('click', function() {
|
|
53
|
+ var id = $(this).attr('id');
|
|
54
|
+ switch (id) {
|
|
55
|
+ case 'ITP_BTN_MORDMNG02010_LIST_SEARCH_WHS_NM' : mobPopObj.popWhsNm.init(); break;
|
|
56
|
+ case 'ITP_BTN_MORDMNG02010_LIST_DELETE_WHS_NM' : mobPopObj.popWhsNm.delete(); break;
|
|
57
|
+ case 'ITP_BTN_MORDMNG02010_LIST_SEARCH' : mobContentObj.list.search(); break;
|
|
58
|
+ }
|
|
59
|
+ return false;
|
|
60
|
+ });
|
|
61
|
+
|
|
62
|
+ $('button[id^="ITP_BTN_MORDMNG02010_VIEW"]').on('click', function() {
|
|
63
|
+ var id = $(this).attr('id');
|
|
64
|
+ switch (id) {
|
|
65
|
+ case 'ITP_BTN_MORDMNG02010_VIEW_ADD' : mobContentObj.view.add(); break;
|
|
66
|
+ case 'ITP_BTN_MORDMNG02010_VIEW_CANCEL_LIST' : mobContentObj.view.cancel(); break;
|
|
67
|
+ }
|
|
68
|
+ return false;
|
|
69
|
+ });
|
|
70
|
+
|
|
71
|
+ $(document).on('click', '#ITP_LIST_MORDMNG02010_LIST_ITEM_ROWS li', function() {
|
|
72
|
+ var item = mobContentObj.list.rows[$(this).index()];
|
|
73
|
+ mobContentObj.view.init(item);
|
|
74
|
+ });
|
|
75
|
+
|
|
76
|
+ $(document).on('click', '#ITP_LIST_MORDMNG02010_POP_WHS_ROWS li button', function() {
|
|
77
|
+ mobPopObj.popWhsNm.choice($(this));
|
|
78
|
+ });
|
|
79
|
+ }
|
|
80
|
+ },
|
|
81
|
+ switchScreen: function(mode) {
|
|
82
|
+ $('#ITP_MOBILE_MORDMNG02010').find('div[id$="_CONTAINER"]').each(function(i) {
|
|
83
|
+ $(this).hide();
|
|
84
|
+ });
|
|
85
|
+ if(mode === PAGE_MODE_LIST) {
|
|
86
|
+ $('#ITP_AJAX_MORDMNG02010_LIST_CONTAINER').show();
|
|
87
|
+ this.moreView(true);
|
|
88
|
+ } else if(mode === PAGE_MODE_VIEW) {
|
|
89
|
+ $('#ITP_AJAX_MORDMNG02010_VIEW_CONTAINER').show();
|
|
90
|
+ this.moreView(false);
|
|
91
|
+ }
|
|
92
|
+ this.viewMode = mode;
|
|
93
|
+ },
|
|
94
|
+ moreView: function(isScroll) {
|
|
95
|
+ var _this = this;
|
|
96
|
+ if(isScroll) {
|
|
97
|
+ $('#ITP_LIST_MORDMNG02010_LIST_ITEM_AREA').on('scroll', function () {
|
|
98
|
+ if($(this).scrollTop() + $(this).innerHeight() + 1 >= $(this)[0].scrollHeight) {
|
|
99
|
+ if(mobContentObj.list.totPage > mobContentObj.list.listPage) {
|
|
100
|
+ if(!mobContentObj.list.isSearch) {
|
|
101
|
+ mobContentObj.list.load();
|
|
102
|
+ }
|
|
103
|
+ }
|
|
104
|
+ }
|
|
105
|
+ });
|
|
106
|
+ } else {
|
|
107
|
+ $('#ITP_LIST_MORDMNG02010_LIST_AREA').off('scroll');
|
|
108
|
+ }
|
|
109
|
+ },
|
|
110
|
+ ready: function() {
|
|
111
|
+ mobContentObj.list.init();
|
|
112
|
+ }
|
|
113
|
+};
|
|
114
|
+
|
|
115
|
+let mobContentObj = {
|
|
116
|
+ list: {
|
|
117
|
+ listSize: 10,
|
|
118
|
+ listPage: 0,
|
|
119
|
+ totPage: 0,
|
|
120
|
+ isSearch: false,
|
|
121
|
+ rows: [],
|
|
122
|
+ init: function() {
|
|
123
|
+ mobPageObj.switchScreen(PAGE_MODE_LIST);
|
|
124
|
+ this.search();
|
|
125
|
+ },
|
|
126
|
+ search: function() {
|
|
127
|
+ this.listPage = 0;
|
|
128
|
+ this.totPage = 0;
|
|
129
|
+ this.rows.length = 0;
|
|
130
|
+ $('#ITP_LIST_MORDMNG02010_LIST_ITEM_ROWS').empty();
|
|
131
|
+ this.load();
|
|
132
|
+ },
|
|
133
|
+ load: function() {
|
|
134
|
+ var _this = this;
|
|
135
|
+ this.isSearch = true;
|
|
136
|
+ var callbackFn = function(result) {
|
|
137
|
+ console.log(result);
|
|
138
|
+ _this.isSearch = false;
|
|
139
|
+ _this.totPage = result.gridTotal;
|
|
140
|
+ $.each(result.gridRows, function (i, item) {
|
|
141
|
+ $('#ITP_LIST_MORDMNG02010_LIST_ITEM_AREA .panel-group').append($('#ITP_LIST_MORDMNG02010_LIST_ITEM_ROWCOPY').html());
|
|
142
|
+ var $li = $('#ITP_LIST_MORDMNG02010_LIST_ITEM_AREA .panel-group > .list-row:last');
|
|
143
|
+ $li.find('.fnBrandNm').text(item.brandNm);
|
|
144
|
+ $li.find('.fnPchPodrUnqNo').text(item.pchPodrUnqNo);
|
|
145
|
+ $li.find('.fnPchPodrDtlNo').text(item.pchPodrDtlNo);
|
|
146
|
+ $li.find('.fnDlvReqDt').text(item.dlvReqDt);
|
|
147
|
+ $li.find('.fnWhsNm').text(item.whsNm);
|
|
148
|
+ $li.find('.fnPodrDt').text(item.podrDt);
|
|
149
|
+ $li.find('.fnItemId').text(item.itemId);
|
|
150
|
+ $li.find('.fnItemNm').text(item.itemNm);
|
|
151
|
+ $li.find('.fnPodrQty').text(CommonObj.currency.add(item.podrQty, '개'));
|
|
152
|
+ $li.find('.fnUnitAmt').text(CommonObj.comma.set(item.unitAmt));
|
|
153
|
+ $li.find('.fnPodrAmt').text(CommonObj.comma.set(item.podrAmt));
|
|
154
|
+ _this.rows.push(item);
|
|
155
|
+ });
|
|
156
|
+ };
|
|
157
|
+ var errFn = function() { _this.isSearch = false;};
|
|
158
|
+ const param = $('#ITP_FORM_MORDMNG02010_LIST_SEARCH').serializeObject();
|
|
159
|
+ param.gridPage = ++this.listPage;
|
|
160
|
+ param.gridSize = this.listSize;
|
|
161
|
+ param.fromDt = param.fromDt.replace(/-/g, ".");
|
|
162
|
+ param.toDt = param.toDt.replace(/-/g, ".");
|
|
163
|
+ fn_ajax_call(API_MOBILE_GRID_LIST, JSON.stringify(param), callbackFn, 'POST', errFn);
|
|
164
|
+ }
|
|
165
|
+ },
|
|
166
|
+ view: {
|
|
167
|
+ rows: [],
|
|
168
|
+ init: function(item) {
|
|
169
|
+ mobPageObj.switchScreen(PAGE_MODE_VIEW);
|
|
170
|
+ this.search(item);
|
|
171
|
+ },
|
|
172
|
+ search: function(item) {
|
|
173
|
+ var _this = this;
|
|
174
|
+ var callbackFn = function(result) {
|
|
175
|
+ console.log(result);
|
|
176
|
+ _this.view(result);
|
|
177
|
+ };
|
|
178
|
+ const param = {
|
|
179
|
+ 'brandId': fn_make_user_info.get('brandId'),
|
|
180
|
+ 'spplyId': fn_make_user_info.get('userId'),
|
|
181
|
+ 'pchPodrUnqNo': item.pchPodrUnqNo
|
|
182
|
+ };
|
|
183
|
+ fn_ajax_call(API_MOBILE_INFO, param, callbackFn, 'GET');
|
|
184
|
+ },
|
|
185
|
+ view: function(result) {
|
|
186
|
+ var _this = this;
|
|
187
|
+ var id = '#ITP_AJAX_MORDMNG02010_VIEW_CONTAINER';
|
|
188
|
+ $(id).find('.fnBrandNm').text(result.brandNm);
|
|
189
|
+ $(id).find('.fnPchPodrUnqNo').text(result.pchPodrUnqNo);
|
|
190
|
+ $(id).find('.fnDlvRegDt').text(result.dlvReqDt);
|
|
191
|
+ $(id).find('.fnPodrTotalAmt').text(CommonObj.currency.add(result.podrTotalAmt));
|
|
192
|
+ $(id).find('.fnWhsNm').text(result.whsNm);
|
|
193
|
+ $(id).find('.fnDeliTelNo').text(result.deliTelNo);
|
|
194
|
+ $.each(result.invPoInfoList, function (i, item) {
|
|
195
|
+ $('#ITP_LIST_MORDMNG02010_VIEW_ITEM_AREA .panel-group').append($('#ITP_LIST_MORDMNG02010_VIEW_ITEM_ROWCOPY').html());
|
|
196
|
+ var $li = $('#ITP_LIST_MORDMNG02010_VIEW_ITEM_AREA .panel-group > .list-row:last');
|
|
197
|
+ $li.find('.fnPchPodrDtlNo').text(item.pchPodrDtlNo);
|
|
198
|
+ $li.find('.fnItemId').text(item.itemId);
|
|
199
|
+ $li.find('.fnItemNm').text(item.itemNm);
|
|
200
|
+ $li.find('.fnPodrQty').text(CommonObj.comma.set(item.podrQty));
|
|
201
|
+ $li.find('.fnUnitAmt').text(CommonObj.currency.add(item.unitAmt));
|
|
202
|
+ $li.find('.fnUnit').text(item.unit);
|
|
203
|
+ $li.find('.fnPodrAmt').text(CommonObj.currency.add(item.podrAmt));
|
|
204
|
+ $li.find('.fnDlvReqDt').text(item.dlvReqDt);
|
|
205
|
+ _this.rows.push(item);
|
|
206
|
+ });
|
|
207
|
+ },
|
|
208
|
+ add: function() {
|
|
209
|
+ var _this = this;
|
|
210
|
+ var param = {};
|
|
211
|
+ var dlvSchDt = $('#ITP_AJAX_MORDMNG02010_VIEW_CONTAINER #ITP_FORM_MORDMNG02010_VIEW_DLV_SCH_DT').val();
|
|
212
|
+ var dlvMgrNm = $('#ITP_AJAX_MORDMNG02010_VIEW_CONTAINER #ITP_FORM_MORDMNG02010_VIEW_DLV_MGR_NM').val();
|
|
213
|
+ var dlvMgrTelNo = $('#ITP_AJAX_MORDMNG02010_VIEW_CONTAINER #ITP_FORM_MORDMNG02010_VIEW_DLV_MGR_TEL_NO').val();
|
|
214
|
+ if(dlvSchDt.length < 1) {
|
|
215
|
+ alert('납품일자를 입력해 주세요.');
|
|
216
|
+ return false;
|
|
217
|
+ }
|
|
218
|
+ if(dlvMgrNm.length < 1) {
|
|
219
|
+ alert('발주담당자를 입력해 주세요.');
|
|
220
|
+ return false;
|
|
221
|
+ }
|
|
222
|
+ if(dlvMgrTelNo.length < 1) {
|
|
223
|
+ alert('발주담당자 연락처를 입력해 주세요.');
|
|
224
|
+ return false;
|
|
225
|
+ }
|
|
226
|
+ var gridInsertData = [];
|
|
227
|
+ var isValid = false;
|
|
228
|
+ $('#ITP_LIST_MORDMNG02010_VIEW_ITEM_AREA .panel-group > .list-row').each(function(index) {
|
|
229
|
+ var row = _this.rows[index];
|
|
230
|
+ var item = {
|
|
231
|
+ 'pchPodrDtlNo': row.pchPodrDtlNo,
|
|
232
|
+ 'pchPodrUnqNo': row.pchPodrUnqNo,
|
|
233
|
+ 'shmtQty': $(this).find('#ITP_FORM_MORDMNG02010_VIEW_SHMT_QTY').val(),
|
|
234
|
+ 'expryDate': $(this).find('#ITP_FORM_MORDMNG02010_VIEW_EXPRY_DATE').val(),
|
|
235
|
+ 'deliDesc': $(this).find('#ITP_FORM_MORDMNG02010_VIEW_DELI_DESC').val()
|
|
236
|
+ };
|
|
237
|
+ if(row.expryYn === 'Y' && item.expryDate.length < 1) {
|
|
238
|
+ alert('유통기한을 입력해 주세요.');
|
|
239
|
+ return false;
|
|
240
|
+ }
|
|
241
|
+ if(item.shmtQty.length < 1) {
|
|
242
|
+ alert('납품수량을 입력해 주세요.');
|
|
243
|
+ return false;
|
|
244
|
+ }
|
|
245
|
+ if(row.podrQty < item.shmtQty) {
|
|
246
|
+ alert('납품수량은 발주수량을 초과할 수 없습니다.');
|
|
247
|
+ return false;
|
|
248
|
+ }
|
|
249
|
+ item.expryDate = item.expryDate.replace(/-/g, ".");
|
|
250
|
+ gridInsertData.push(item);
|
|
251
|
+ isValid = true;
|
|
252
|
+ });
|
|
253
|
+ if(isValid) {
|
|
254
|
+ param['viewCd'] = 'C';
|
|
255
|
+ param['brandId'] = fn_make_user_info.get('brandId');
|
|
256
|
+ param['spplyId'] = fn_make_user_info.get('userId');
|
|
257
|
+ param['dlvSchDt'] = dlvSchDt.replace(/-/g, ".");
|
|
258
|
+ param['dlvMgrNm'] = dlvMgrNm;
|
|
259
|
+ param['dlvMgrTelNo'] = dlvMgrTelNo;
|
|
260
|
+ param['gridInsertData'] = gridInsertData;
|
|
261
|
+ console.log(JSON.stringify(param));
|
|
262
|
+ var callbackFn = function(result) {
|
|
263
|
+ console.log(result);
|
|
264
|
+ _this.cancel();
|
|
265
|
+ };
|
|
266
|
+ fn_ajax_call(API_MOBILE_SAVE, JSON.stringify(param), callbackFn, 'POST');
|
|
267
|
+ }
|
|
268
|
+ },
|
|
269
|
+ cancel: function () {
|
|
270
|
+ var id = '#ITP_AJAX_MORDMNG02010_VIEW_CONTAINER';
|
|
271
|
+ $(id + ' #ITP_FORM_MORDMNG02010_VIEW_DLV_SCH_DT').val('');
|
|
272
|
+ $(id + ' #ITP_FORM_MORDMNG02010_VIEW_DLV_MGR_NM').val('');
|
|
273
|
+ $(id + ' #ITP_FORM_MORDMNG02010_VIEW_DLV_MGR_TEL_NO').val('');
|
|
274
|
+ $(id).find('.fnPchPodrDtlNo').text('');
|
|
275
|
+ $(id).find('.fnItemid').text('');
|
|
276
|
+ $(id).find('.fnItemNm').text('');
|
|
277
|
+ $(id).find('.fnUPodrQty').text('');
|
|
278
|
+ $(id).find('.fnUnitAmt').text('');
|
|
279
|
+ $(id).find('.fnUnit').text('');
|
|
280
|
+ $(id).find('.fnPodrQty').text('');
|
|
281
|
+ $(id).find('.fnPodrAmt').text('');
|
|
282
|
+ $(id).find('.fnDlvReqDt').text('');
|
|
283
|
+ $('#ITP_LIST_MORDMNG02010_VIEW_ITEM_AREA .panel-group').empty();
|
|
284
|
+ mobPageObj.switchScreen(PAGE_MODE_LIST);
|
|
285
|
+ }
|
|
286
|
+ }
|
|
287
|
+};
|
|
288
|
+
|
|
289
|
+let mobPopObj = {
|
|
290
|
+ popWhsNm: {
|
|
291
|
+ popId: 'ITP_POP_MORDMNG02010_WHS_AREA',
|
|
292
|
+ rows: [],
|
|
293
|
+ init: function () {
|
|
294
|
+ this.rows.length = 0;
|
|
295
|
+ mobPopObj.show(this.popId);
|
|
296
|
+ this.search();
|
|
297
|
+ this.action();
|
|
298
|
+ },
|
|
299
|
+ search: function () {
|
|
300
|
+ var _this = this;
|
|
301
|
+ $('#ITP_LIST_MORDMNG02010_POP_WHS_AREA .panel-group').empty();
|
|
302
|
+ var callbackFn = function(result) {
|
|
303
|
+ console.log(result);
|
|
304
|
+ _this.view(result.gridRows);
|
|
305
|
+ };
|
|
306
|
+ const param = $('#ITP_FORM_MORDMNG02010_POP_WHS').serializeObject();
|
|
307
|
+ fn_ajax_call(API_POP_SEARCH_LIST, JSON.stringify(param), callbackFn, 'POST');
|
|
308
|
+ },
|
|
309
|
+ view: function(gridRows) {
|
|
310
|
+ this.rows = gridRows;
|
|
311
|
+ $.each(gridRows, function (i, item) {
|
|
312
|
+ $('#ITP_LIST_MORDMNG02010_POP_WHS_AREA .panel-group').append($('#ITP_LIST_MORDMNG02010_POP_WHS_ROWCOPY').html());
|
|
313
|
+ var $li = $('#ITP_LIST_MORDMNG02010_POP_WHS_AREA .panel-group > .list-row:last');
|
|
314
|
+ $li.find('.fnWhsNm').text(item.whsNm);
|
|
315
|
+ $li.find('.fnLocationNm').text(item.locationNm);
|
|
316
|
+ $li.find('.fnWhsId').data('whs-id', item.whsId);
|
|
317
|
+ });
|
|
318
|
+ },
|
|
319
|
+ choice: function(elem) {
|
|
320
|
+ var _this = this;
|
|
321
|
+ var whsId = $(elem).data('whs-id');
|
|
322
|
+ $.each(this.rows, function (i, item) {
|
|
323
|
+ if(whsId === item.whsId) {
|
|
324
|
+ $('#ITP_FORM_MORDMNG02010_LIST_SEARCH #ITP_FORM_MORDMNG02010_LIST_SEARCH_WHS_ID').val(item.whsId);
|
|
325
|
+ $('#ITP_FORM_MORDMNG02010_LIST_SEARCH #ITP_FORM_MORDMNG02010_LIST_SEARCH_WHS_NM').val(item.whsNm);
|
|
326
|
+ _this.close();
|
|
327
|
+ return false;
|
|
328
|
+ }
|
|
329
|
+ });
|
|
330
|
+ },
|
|
331
|
+ action: function() {
|
|
332
|
+ var _this = this;
|
|
333
|
+ $('button[id^="ITP_BTN_MORDMNG02010_POP_WHS"]').off('click').on('click', function() {
|
|
334
|
+ var id = $(this).attr('id');
|
|
335
|
+ switch (id) {
|
|
336
|
+ case 'ITP_BTN_MORDMNG02010_POP_WHS_SEARCH' : _this.search(); break;
|
|
337
|
+ case 'ITP_BTN_MORDMNG02010_POP_WHS_CHOICE' : _this.choice($(this)); break;
|
|
338
|
+ case 'ITP_BTN_MORDMNG02010_POP_WHS_CLOSE' : _this.close(); break;
|
|
339
|
+ }
|
|
340
|
+ return false;
|
|
341
|
+ });
|
|
342
|
+ },
|
|
343
|
+ delete: function() {
|
|
344
|
+ $('#ITP_FORM_MORDMNG02010_LIST_SEARCH #ITP_FORM_MORDMNG02010_LIST_SEARCH_WHS_ID').val('');
|
|
345
|
+ $('#ITP_FORM_MORDMNG02010_LIST_SEARCH #ITP_FORM_MORDMNG02010_LIST_SEARCH_WHS_NM').val('');
|
|
346
|
+ },
|
|
347
|
+ close: function() {
|
|
348
|
+ this.rows.length = 0;
|
|
349
|
+ $('#ITP_POP_MORDMNG02010_LIST_WHS_AREA .panel-group').empty();
|
|
350
|
+ $('#ITP_FORM_MORDMNG02010_POP_WHS #ITP_FORM_MORDMNG02010_POP_WHS_KEYWORD').val('');
|
|
351
|
+ mobPopObj.hide(this.popId);
|
|
352
|
+ }
|
|
353
|
+ },
|
|
354
|
+ show: function(popId) {
|
|
355
|
+ $('button[id$="_CLOSE"]').off('click').on('click', function() {
|
|
356
|
+ console.log($(this).attr('id'));
|
|
357
|
+ if($(this).hasClass('btn-pop-close')) {
|
|
358
|
+ mobPopObj.hide(popId);
|
|
359
|
+ }
|
|
360
|
+ });
|
|
361
|
+ $('#' + popId).show();
|
|
362
|
+ },
|
|
363
|
+ hide: function(popId) {
|
|
364
|
+ $('#' + popId).closest('.mobile-pop-close').hide();
|
|
365
|
+ }
|
|
366
|
+};
|