|
@@ -0,0 +1,262 @@
|
|
1
|
+require(['config'], function() {
|
|
2
|
+ require([
|
|
3
|
+ ], function($) {
|
|
4
|
+ mobPageObj.init();
|
|
5
|
+ });
|
|
6
|
+});
|
|
7
|
+
|
|
8
|
+/*API URL*/
|
|
9
|
+const API_MOBILE_GRID_LIST = '/api/stock/cdd/detail-grid-list'; // 목록
|
|
10
|
+const API_MOBILE_SAVE = '/api/stock/cdd/save-stock-cdd'; // 저장
|
|
11
|
+const API_MOBILE_LOCATION = '/api/whs/mng/location-grid-list'; // 이력
|
|
12
|
+const API_POP_SEARCH_LIST = '/api/whs/mng/detail-grid-list';
|
|
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_MSTOCKMNG02010_LIST_SEARCH_STCK_DT').val(itp_fn_date_add('M', 0));
|
|
39
|
+ },
|
|
40
|
+ info: function() {
|
|
41
|
+ $('input:hidden[id$="_BRAND_ID"]').val(fn_make_user_info.get('brandId'));
|
|
42
|
+ $('input:hidden[id$="_STORE_ID"]').val(fn_make_user_info.get('storeId'));
|
|
43
|
+ }
|
|
44
|
+ },
|
|
45
|
+ event: {
|
|
46
|
+ init: function() {
|
|
47
|
+ this.button();
|
|
48
|
+ },
|
|
49
|
+ button: function() {
|
|
50
|
+ $('button[id^="ITP_BTN_MSTOCKMNG02010_LIST"]').on('click', function() {
|
|
51
|
+ var id = $(this).attr('id');
|
|
52
|
+ switch (id) {
|
|
53
|
+ case 'ITP_BTN_MSTOCKMNG02010_LIST_SEARCH_WHS_NM' : mobPopObj.popWhsNm.init(); break;
|
|
54
|
+ case 'ITP_BTN_MSTOCKMNG02010_LIST_DELETE_WHS_NM' : mobPopObj.popWhsNm.delete(); break;
|
|
55
|
+ case 'ITP_BTN_MSTOCKMNG02010_LIST_SEARCH' : mobContentObj.list.search(); break;
|
|
56
|
+ case 'ITP_BTN_MSTOCKMNG02010_LIST_BARCODE' : mobContentObj.list.barcode(); break;
|
|
57
|
+ }
|
|
58
|
+ return false;
|
|
59
|
+ });
|
|
60
|
+
|
|
61
|
+ $('button[id^="ITP_BTN_MSTOCKMNG02010_VIEW"]').on('click', function() {
|
|
62
|
+ var id = $(this).attr('id');
|
|
63
|
+ switch (id) {
|
|
64
|
+ case 'ITP_BTN_MSTOCKMNG02010_VIEW_SEARCH' : mobContentObj.view.history.search(); break;
|
|
65
|
+ case 'ITP_BTN_MSTOCKMNG02010_VIEW_CANCEL_LIST' : mobContentObj.view.cancel(); break;
|
|
66
|
+ }
|
|
67
|
+ return false;
|
|
68
|
+ });
|
|
69
|
+
|
|
70
|
+ $(document).on('click', '#ITP_LIST_MSTOCKMNG02010_LIST_ITEM_ROWS li', function() {
|
|
71
|
+ var item = mobContentObj.list.rows[$(this).index()];
|
|
72
|
+ mobContentObj.view.init(item);
|
|
73
|
+ });
|
|
74
|
+
|
|
75
|
+ $(document).on('click', '#ITP_LIST_MSTOCKMNG02010_POP_STORE_ROWS li button', function() {
|
|
76
|
+ mobPopObj.popWhsNm.choice($(this));
|
|
77
|
+ });
|
|
78
|
+ }
|
|
79
|
+ },
|
|
80
|
+ switchScreen: function(mode) {
|
|
81
|
+ $('#ITP_MOBILE_MSTOCKMNG02010').find('div[id$="_CONTAINER"]').each(function(i) {
|
|
82
|
+ $(this).hide();
|
|
83
|
+ });
|
|
84
|
+ if(mode === PAGE_MODE_LIST) {
|
|
85
|
+ $('#ITP_AJAX_MSTOCKMNG02010_LIST_CONTAINER').show();
|
|
86
|
+ this.moreView(true);
|
|
87
|
+ } else if(mode === PAGE_MODE_VIEW) {
|
|
88
|
+ $('#ITP_AJAX_MSTOCKMNG02010_VIEW_CONTAINER').show();
|
|
89
|
+ this.moreView(false);
|
|
90
|
+ }
|
|
91
|
+ this.viewMode = mode;
|
|
92
|
+ },
|
|
93
|
+ moreView: function(isScroll) {
|
|
94
|
+ var _this = this;
|
|
95
|
+ if(isScroll) {
|
|
96
|
+ $('#ITP_LIST_MSTOCKMNG02010_LIST_ITEM_AREA').on('scroll', function () {
|
|
97
|
+ if($(this).scrollTop() + $(this).innerHeight() + 1 >= $(this)[0].scrollHeight) {
|
|
98
|
+ if(mobContentObj.list.totPage > mobContentObj.list.listPage) {
|
|
99
|
+ if(!mobContentObj.list.isSearch) {
|
|
100
|
+ mobContentObj.list.load();
|
|
101
|
+ }
|
|
102
|
+ }
|
|
103
|
+ }
|
|
104
|
+ });
|
|
105
|
+ } else {
|
|
106
|
+ $('#ITP_LIST_MSTOCKMNG02010_LIST_AREA').off('scroll');
|
|
107
|
+ }
|
|
108
|
+ },
|
|
109
|
+ ready: function() {
|
|
110
|
+ mobContentObj.list.init();
|
|
111
|
+ }
|
|
112
|
+};
|
|
113
|
+
|
|
114
|
+let mobContentObj = {
|
|
115
|
+ list: {
|
|
116
|
+ listSize: 10,
|
|
117
|
+ listPage: 0,
|
|
118
|
+ totPage: 0,
|
|
119
|
+ isSearch: false,
|
|
120
|
+ rows: [],
|
|
121
|
+ init: function() {
|
|
122
|
+ mobPageObj.switchScreen(PAGE_MODE_LIST);
|
|
123
|
+ this.search();
|
|
124
|
+ },
|
|
125
|
+ search: function() {
|
|
126
|
+ this.listPage = 0;
|
|
127
|
+ this.totPage = 0;
|
|
128
|
+ this.rows.length = 0;
|
|
129
|
+ $('#ITP_LIST_MSTOCKMNG02010_LIST_ITEM_ROWS').empty();
|
|
130
|
+ this.load();
|
|
131
|
+ },
|
|
132
|
+ load: function() {
|
|
133
|
+ var _this = this;
|
|
134
|
+ this.isSearch = true;
|
|
135
|
+ var callbackFn = function(result) {
|
|
136
|
+ console.log(result);
|
|
137
|
+ _this.isSearch = false;
|
|
138
|
+ _this.totPage = result.gridTotal;
|
|
139
|
+ $.each(result.gridRows, function (i, item) {
|
|
140
|
+ $('#ITP_LIST_MSTOCKMNG02010_LIST_ITEM_AREA .panel-group').append($('#ITP_LIST_MSTOCKMNG02010_LIST_ITEM_ROWCOPY').html());
|
|
141
|
+ var $li = $('#ITP_LIST_MSTOCKMNG02010_LIST_ITEM_AREA .panel-group > .list-row:last');
|
|
142
|
+ $li.find('.fnStoreNm').text(item.storeNm);
|
|
143
|
+ $li.find('.fnLoanDvsnNm').text(item.loanDvsnNm);
|
|
144
|
+ var limitAmt;
|
|
145
|
+ if(item.loanDvsn == 'LD01') { // 선불(충전)
|
|
146
|
+ limitAmt = item.chrgeLimitAmt;
|
|
147
|
+ } else if(item.loanDvsn == 'LD02') { // 후불(신용)
|
|
148
|
+ limitAmt = item.credtLimitAmt;
|
|
149
|
+ }
|
|
150
|
+ $li.find('.fnLimitAmt').text(CommonObj.currency.add(limitAmt));
|
|
151
|
+ $li.find('.fnPosbLimitAmt').text(CommonObj.currency.add(limitAmt - item.useAmtTotal));
|
|
152
|
+ $li.find('.fnTmpRcvAcctTotal').text(CommonObj.currency.add(item.tmpRcvAcctTotal));
|
|
153
|
+ $li.find('.fnUseAmtTotal').text(CommonObj.currency.add(item.useAmtTotal));
|
|
154
|
+ $li.find('.fnUseYnNm').text(item.useYnNm);
|
|
155
|
+ _this.rows.push(item);
|
|
156
|
+ });
|
|
157
|
+ };
|
|
158
|
+ var errFn = function() { _this.isSearch = false;};
|
|
159
|
+ const param = $('#ITP_FORM_MSTOCKMNG02010_LIST_SEARCH').serializeObject();
|
|
160
|
+ param.gridPage = ++this.listPage;
|
|
161
|
+ param.gridSize = this.listSize
|
|
162
|
+ // console.log(JSON.stringify(param));
|
|
163
|
+ fn_ajax_call(API_MOBILE_GRID_LIST, JSON.stringify(param), callbackFn, 'POST', errFn);
|
|
164
|
+ },
|
|
165
|
+ barcode: function() {
|
|
166
|
+ location.replace('app:barcode');
|
|
167
|
+ // location.href = 'app:barcode';
|
|
168
|
+ }
|
|
169
|
+ }
|
|
170
|
+};
|
|
171
|
+
|
|
172
|
+let mobPopObj = {
|
|
173
|
+ popWhsNm: {
|
|
174
|
+ popId: 'ITP_POP_MSTOCKMNG02010_WHS_AREA',
|
|
175
|
+ rows: [],
|
|
176
|
+ init: function () {
|
|
177
|
+ this.rows.length = 0;
|
|
178
|
+ mobPopObj.show(this.popId);
|
|
179
|
+ this.search();
|
|
180
|
+ this.action();
|
|
181
|
+ },
|
|
182
|
+ search: function () {
|
|
183
|
+ var _this = this;
|
|
184
|
+ $('#ITP_LIST_MSTOCKMNG02010_POP_WHS_AREA .panel-group').empty();
|
|
185
|
+ var callbackFn = function(result) {
|
|
186
|
+ console.log(result);
|
|
187
|
+ _this.view(result.gridRows);
|
|
188
|
+ };
|
|
189
|
+ const param = $('#ITP_FORM_MSTOCKMNG02010_POP_WHS').serializeObject();
|
|
190
|
+ console.log(JSON.stringify(param));
|
|
191
|
+ fn_ajax_call(API_POP_SEARCH_LIST, JSON.stringify(param), callbackFn, 'POST');
|
|
192
|
+ },
|
|
193
|
+ view: function(gridRows) {
|
|
194
|
+ this.rows = gridRows;
|
|
195
|
+ $.each(gridRows, function (i, item) {
|
|
196
|
+ $('#ITP_LIST_MSTOCKMNG02010_POP_WHS_AREA .panel-group').append($('#ITP_LIST_MSTOCKMNG02010_POP_WHS_ROWCOPY').html());
|
|
197
|
+ var $li = $('#ITP_LIST_MSTOCKMNG02010_POP_WHS_AREA .panel-group > .list-row:last');
|
|
198
|
+ $li.find('.fnWhsNm').text(item.whsNm);
|
|
199
|
+ $li.find('.fnLocationNm').text(item.locationNm);
|
|
200
|
+ $li.find('.fnWhsId').data('whs-id', item.whsId);
|
|
201
|
+ });
|
|
202
|
+ },
|
|
203
|
+ choice: function(elem) {
|
|
204
|
+ var _this = this;
|
|
205
|
+ var whsId = $(elem).data('whs-id');
|
|
206
|
+ $.each(this.rows, function (i, item) {
|
|
207
|
+ if(whsId === item.whsId) {
|
|
208
|
+ $('#ITP_FORM_MSTOCKMNG02010_LIST_SEARCH #ITP_FORM_MSTOCKMNG02010_LIST_SEARCH_WHS_ID').val(item.whsId);
|
|
209
|
+ $('#ITP_FORM_MSTOCKMNG02010_LIST_SEARCH #ITP_FORM_MSTOCKMNG02010_LIST_SEARCH_WHS_NM').val(item.whsNm);
|
|
210
|
+ _this.close();
|
|
211
|
+ _this.location(item.whsId);
|
|
212
|
+ return false;
|
|
213
|
+ }
|
|
214
|
+ });
|
|
215
|
+ },
|
|
216
|
+ location: function(whsId) {
|
|
217
|
+ var callbackFn = function(result) {
|
|
218
|
+ fn_make_select_location(result.gridRows, 'ITP_FORM_MSTOCKMNG02010_LIST_SEARCH_LOCATION');
|
|
219
|
+ };
|
|
220
|
+ var param = {
|
|
221
|
+ 'brandId': fn_make_user_info.get('brandId'),
|
|
222
|
+ 'storeId': fn_make_user_info.get('storeId'),
|
|
223
|
+ 'whsId': whsId
|
|
224
|
+ };
|
|
225
|
+ fn_ajax_call(API_MOBILE_LOCATION, JSON.stringify(param), callbackFn, 'POST');
|
|
226
|
+ },
|
|
227
|
+ action: function() {
|
|
228
|
+ var _this = this;
|
|
229
|
+ $('button[id^="ITP_BTN_MSTOCKMNG02010_POP_WHS"]').off('click').on('click', function() {
|
|
230
|
+ var id = $(this).attr('id');
|
|
231
|
+ switch (id) {
|
|
232
|
+ case 'ITP_BTN_MSTOCKMNG02010_POP_WHS_SEARCH' : _this.search(); break;
|
|
233
|
+ case 'ITP_BTN_MSTOCKMNG02010_POP_WHS_CHOICE' : _this.choice($(this)); break;
|
|
234
|
+ case 'ITP_BTN_MSTOCKMNG02010_POP_WHS_CLOSE' : _this.close(); break;
|
|
235
|
+ }
|
|
236
|
+ return false;
|
|
237
|
+ });
|
|
238
|
+ },
|
|
239
|
+ delete: function() {
|
|
240
|
+ $('#ITP_FORM_MSTOCKMNG02010_LIST_SEARCH #ITP_FORM_MSTOCKMNG02010_LIST_SEARCH_WHS_ID').val('');
|
|
241
|
+ $('#ITP_FORM_MSTOCKMNG02010_LIST_SEARCH #ITP_FORM_MSTOCKMNG02010_LIST_SEARCH_WHS_NM').val('');
|
|
242
|
+ },
|
|
243
|
+ close: function() {
|
|
244
|
+ this.rows.length = 0;
|
|
245
|
+ $('#ITP_POP_MSTOCKMNG02010_LIST_WHS_AREA .panel-group').empty();
|
|
246
|
+ $('#ITP_FORM_MSTOCKMNG02010_POP_WHS #ITP_FORM_MSTOCKMNG02010_POP_WHS_KEYWORD').val('');
|
|
247
|
+ mobPopObj.hide(this.popId);
|
|
248
|
+ }
|
|
249
|
+ },
|
|
250
|
+ show: function(popId) {
|
|
251
|
+ $('button[id$="_CLOSE"]').off('click').on('click', function() {
|
|
252
|
+ console.log($(this).attr('id'));
|
|
253
|
+ if($(this).hasClass('btn-pop-close')) {
|
|
254
|
+ mobPopObj.hide(popId);
|
|
255
|
+ }
|
|
256
|
+ });
|
|
257
|
+ $('#' + popId).show();
|
|
258
|
+ },
|
|
259
|
+ hide: function(popId) {
|
|
260
|
+ $('#' + popId).closest('.mobile-pop-close').hide();
|
|
261
|
+ }
|
|
262
|
+};
|