|
@@ -0,0 +1,186 @@
|
|
1
|
+require(['config'], function() {
|
|
2
|
+ require([
|
|
3
|
+ ], function($) {
|
|
4
|
+ mobPageObj.init();
|
|
5
|
+ });
|
|
6
|
+});
|
|
7
|
+
|
|
8
|
+/*API URL*/
|
|
9
|
+const API_MOBILE_GRID_LIST = '/api/sale/mng/item-grid-list'; // 목록
|
|
10
|
+
|
|
11
|
+const PAGE_MODE_LIST = "LIST";
|
|
12
|
+
|
|
13
|
+let mobPageObj = {
|
|
14
|
+ viewMode: PAGE_MODE_LIST,
|
|
15
|
+ init: function () {
|
|
16
|
+ // 조회일자 지정
|
|
17
|
+ $('#ITP_MOBILE_MSALESMNG02010 .itp_input.date').datepicker(ITP_DATE_LANGUAGE);
|
|
18
|
+ $('#ITP_FORM_MSALESMNG02010_LIST_SEARCH_FROM_DT').datepicker('setDate', itp_fn_date_add('D', -7));
|
|
19
|
+ $('#ITP_FORM_MSALESMNG02010_LIST_SEARCH_TO_DT').datepicker('setDate', itp_fn_date_add('M', 0));
|
|
20
|
+ $('#ITP_FORM_MSALESMNG02010_LIST_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
|
|
21
|
+
|
|
22
|
+ $('button[id^="ITP_BTN_MSALESMNG02010_LIST"]').on('click', function() {
|
|
23
|
+ switch ($(this).attr('id') ) {
|
|
24
|
+ case 'ITP_BTN_MSALESMNG02010_LIST_SEARCH_STORE_NN' :
|
|
25
|
+ mobContObj.popStoreNm.search();
|
|
26
|
+ break;
|
|
27
|
+ case 'ITP_BTN_MSALESMNG02010_LIST_DELETE_STORE_NN' :
|
|
28
|
+ $('#ITP_FORM_MSALESMNG02010_LIST_SEARCH_STORE_ID').val('');
|
|
29
|
+ $('#ITP_FORM_MSALESMNG02010_LIST_SEARCH_STORE_NM').val('');
|
|
30
|
+ break;
|
|
31
|
+ case 'ITP_BTN_MSALESMNG02010_LIST_SEARCH':
|
|
32
|
+ mobContObj.list.search();
|
|
33
|
+ break;
|
|
34
|
+ default: break;
|
|
35
|
+ }
|
|
36
|
+ return false;
|
|
37
|
+ });
|
|
38
|
+ $('#ITP_BTN_MSALESMNG02010_DETAIL_CANCEL').on('click', ()=>$(location).attr('href', MOBILE_CONTEXTPATH + '/app/main.html') );
|
|
39
|
+ // 리스트 조회
|
|
40
|
+ mobContObj.list.init();
|
|
41
|
+ },
|
|
42
|
+ switchScreen: function(mode) {
|
|
43
|
+ $('#ITP_MOBILE_MSALESMNG02010').find('div[id$="_CONTAINER"]').each(function(i) {
|
|
44
|
+ $(this).hide();
|
|
45
|
+ });
|
|
46
|
+ if(mode === PAGE_MODE_LIST) {
|
|
47
|
+ $('#ITP_AJAX_MSALESMNG02010_LIST_CONTAINER').show();
|
|
48
|
+ }
|
|
49
|
+ this.viewMode = mode;
|
|
50
|
+ },
|
|
51
|
+};
|
|
52
|
+
|
|
53
|
+let mobContObj = {
|
|
54
|
+
|
|
55
|
+ list: {
|
|
56
|
+ rows: [],
|
|
57
|
+ listPage: 0,
|
|
58
|
+ init: function() {
|
|
59
|
+ mobPageObj.switchScreen(PAGE_MODE_LIST);
|
|
60
|
+ this.search();
|
|
61
|
+ },
|
|
62
|
+ search: function() {
|
|
63
|
+ this.listPage = 1;
|
|
64
|
+ this.rows.length = 0;
|
|
65
|
+ $('#ITP_LIST_MSALESMNG02010_LIST_ITEM_ROWS').empty();
|
|
66
|
+ setTimeout(function() {
|
|
67
|
+ mobContObj.list.load();
|
|
68
|
+ }, 100);
|
|
69
|
+ },
|
|
70
|
+ pager: function(totPage) {
|
|
71
|
+ (this.listPage < totPage) ?
|
|
72
|
+ CommonObj.moreView('#ITP_LIST_MSALESMNG02010_LIST_ITEM_AREA', true, mobContObj.list.load) :
|
|
73
|
+ CommonObj.moreView('#ITP_LIST_MSALESMNG02010_LIST_ITEM_AREA', false);
|
|
74
|
+ this.listPage += 1;
|
|
75
|
+ },
|
|
76
|
+ load: function() {
|
|
77
|
+ var _this = this;
|
|
78
|
+ var callbackFn = function(result) {
|
|
79
|
+ mobContObj.list.pager(result.gridTotal);
|
|
80
|
+ const label=function(li, item, id, txt, color) {
|
|
81
|
+ if(!txt) txt=item[id];
|
|
82
|
+ var val=color? '<span style="color:'+color+'; font-weight:bold;">'+txt+'</span>': txt;
|
|
83
|
+ li.find('.fn-'+id).html(val);
|
|
84
|
+ };
|
|
85
|
+ const blueLabel=function(li, item, id, txt) {
|
|
86
|
+ label(li, item, id, txt, '#32e');
|
|
87
|
+ };
|
|
88
|
+ const redLabel=function(li, item, id, txt) {
|
|
89
|
+ label(li, item, id, txt, '#e32');
|
|
90
|
+ };
|
|
91
|
+ $.each(result.gridRows, function (i, item) {
|
|
92
|
+ if(item.whsQty!='0') {
|
|
93
|
+ $('#ITP_LIST_MSALESMNG02010_LIST_ITEM_AREA .panel-group').append($('#ITP_LIST_MSALESMNG02010_LIST_ITEM_ROWCOPY').html());
|
|
94
|
+ var $li = $('#ITP_LIST_MSALESMNG02010_LIST_ITEM_AREA .panel-group > .item-row:last');
|
|
95
|
+ label($li,item,'itemId'); blueLabel($li,item,'saleType',"구매");
|
|
96
|
+ label($li,item,'itemNm');
|
|
97
|
+ blueLabel($li,item,'whsQty', item.whsQty);
|
|
98
|
+ blueLabel($li,item,'supplyAmt', CommonObj.currency.add(item.supplyAmt)); // 공급
|
|
99
|
+ blueLabel($li,item,'storeAmt', CommonObj.currency.add(item.storeAmt)); // 판매
|
|
100
|
+ blueLabel($li,item,'incomeAmt', CommonObj.currency.add(item.incomeAmt)); // 수익
|
|
101
|
+ }
|
|
102
|
+ if(item.whsQty1!='0') {
|
|
103
|
+ $('#ITP_LIST_MSALESMNG02010_LIST_ITEM_AREA .panel-group').append($('#ITP_LIST_MSALESMNG02010_LIST_ITEM_ROWCOPY').html());
|
|
104
|
+ var $li = $('#ITP_LIST_MSALESMNG02010_LIST_ITEM_AREA .panel-group > .item-row:last');
|
|
105
|
+ label($li,item,'itemId'); redLabel($li,item,'saleType',"반품");
|
|
106
|
+ label($li,item,'itemNm');
|
|
107
|
+ redLabel($li,item,'whsQty', item.whsQty1);
|
|
108
|
+ redLabel($li,item,'supplyAmt', CommonObj.currency.add(item.supplyAmt1)); // 공급
|
|
109
|
+ redLabel($li,item,'storeAmt', CommonObj.currency.add(item.storeAmt1)); // 판매
|
|
110
|
+ redLabel($li,item,'incomeAmt', CommonObj.currency.add(item.incomeAmt1)); // 수익
|
|
111
|
+ }
|
|
112
|
+ mobContObj.list.rows.push(item);
|
|
113
|
+
|
|
114
|
+ });
|
|
115
|
+ };
|
|
116
|
+ const param = $('#ITP_FORM_MSALESMNG02010_LIST_SEARCH').serializeObject();
|
|
117
|
+ param.gridPage = mobContObj.list.listPage;
|
|
118
|
+ param.gridSize = mobile_list_size;
|
|
119
|
+ console.log(JSON.stringify(param));
|
|
120
|
+ fn_ajax_call(API_MOBILE_GRID_LIST, JSON.stringify(param), callbackFn, 'POST');
|
|
121
|
+ },
|
|
122
|
+ },
|
|
123
|
+ /* 팝업 */
|
|
124
|
+ show: function(popId) {
|
|
125
|
+ $('button[id$="_CLOSE"]').off('click').on('click', function() {
|
|
126
|
+ console.log($(this).attr('id'));
|
|
127
|
+ if($(this).hasClass('btn-pop-close')) {
|
|
128
|
+ mobContObj.hide(popId);
|
|
129
|
+ }
|
|
130
|
+ });
|
|
131
|
+ $('#' + popId).show();
|
|
132
|
+ },
|
|
133
|
+ hide: function(popId) {
|
|
134
|
+ $('#' + popId).closest('.mobile-pop-close').hide();
|
|
135
|
+ },
|
|
136
|
+ popStoreNm: {
|
|
137
|
+ popId: 'ITP_POP_MSALESMNG02010_STORE_AREA',
|
|
138
|
+ rows: [],
|
|
139
|
+ search: function () {
|
|
140
|
+ var self = this;
|
|
141
|
+ mobContObj.show(this.popId);
|
|
142
|
+ $('#ITP_LIST_MSALESMNG02010_POP_STORE_AREA .panel-group').empty();
|
|
143
|
+ $('#ITP_FORM_MSALESMNG02010_STORE_ITEM_BRAND_ID').val(fn_make_user_info.get('brandId'));
|
|
144
|
+ const callbackFn = function(result) {
|
|
145
|
+ self.rows = result.gridRows;
|
|
146
|
+ for(var item of self.rows) {
|
|
147
|
+ $('#ITP_LIST_MSALESMNG02010_POP_STORE_AREA .panel-group').append($('#ITP_LIST_MSALESMNG02010_POP_STORE_ROWCOPY').html());
|
|
148
|
+ var $li = $('#ITP_LIST_MSALESMNG02010_POP_STORE_AREA .panel-group > .row_2:last');
|
|
149
|
+ $li.find('.fnStoreNm').text(item.storeNm);
|
|
150
|
+ $li.find('.fnStoreStNm').text(item.storeStNm);
|
|
151
|
+ $li.find('.fnStoreId').data('store-id', item.storeId);
|
|
152
|
+ }
|
|
153
|
+ $('button[id^="ITP_BTN_MSALESMNG02010_POP_STORE"]').off('click').on('click', function() {
|
|
154
|
+ var id = $(this).attr('id');
|
|
155
|
+ switch (id) {
|
|
156
|
+ case 'ITP_BTN_MSALESMNG02010_POP_STORE_SEARCH' : self.search(); break;
|
|
157
|
+ case 'ITP_BTN_MSALESMNG02010_POP_STORE_CHOICE' : self.choice($(this)); break;
|
|
158
|
+ case 'ITP_BTN_MSALESMNG02010_POP_STORE_CLOSE' : self.close(); break;
|
|
159
|
+ }
|
|
160
|
+ return false;
|
|
161
|
+ });
|
|
162
|
+ };
|
|
163
|
+ const param = $('#ITP_FORM_MSALESMNG02010_POP_STORE').serializeObject();
|
|
164
|
+ fn_ajax_call('/api/store/pop-grid-list', JSON.stringify(param), callbackFn, 'POST');
|
|
165
|
+ },
|
|
166
|
+ choice: function(elem) {
|
|
167
|
+ var _this = this;
|
|
168
|
+ var storeId = $(elem).data('store-id');
|
|
169
|
+ console.log("xxxxx choice xxxxx", storeId, this.rows)
|
|
170
|
+ $.each(this.rows, function (i, item) {
|
|
171
|
+ if(storeId === item.storeId) {
|
|
172
|
+ $('#ITP_FORM_MSALESMNG02010_LIST_SEARCH_STORE_ID').val(item.storeId);
|
|
173
|
+ $('#ITP_FORM_MSALESMNG02010_LIST_SEARCH_STORE_NM').val(item.storeNm);
|
|
174
|
+ _this.close();
|
|
175
|
+ return false;
|
|
176
|
+ }
|
|
177
|
+ });
|
|
178
|
+ },
|
|
179
|
+ close: function() {
|
|
180
|
+ $('#ITP_FORM_MSALESMNG02010_POP_STORE #ITP_FORM_MSALESMNG02010_POP_STORE_KEYWORD').val('');
|
|
181
|
+ mobContObj.hide(this.popId);
|
|
182
|
+ }
|
|
183
|
+ },
|
|
184
|
+
|
|
185
|
+};
|
|
186
|
+
|