|
@@ -2,21 +2,7 @@ |
|
@@ -2,21 +2,7 @@ |
2
|
var $ = require('jquery'),
|
2
|
var $ = require('jquery'),
|
3
|
common = require('../../common/common');
|
3
|
common = require('../../common/common');
|
4
|
|
4
|
|
5
|
-var ENUM = {
|
|
|
6
|
- vipType: {
|
|
|
7
|
- 1: '正常折扣',
|
|
|
8
|
- 2: '统一折扣',
|
|
|
9
|
- 3: '无折扣',
|
|
|
10
|
- 4: '固定折扣',
|
|
|
11
|
- 5: '自定义折扣'
|
|
|
12
|
- },
|
|
|
13
|
- gender: {
|
|
|
14
|
- 1: '男',
|
|
|
15
|
- 2: '女',
|
|
|
16
|
- 3: '通用'
|
|
|
17
|
- }
|
|
|
18
|
-}
|
|
|
19
|
-
|
5
|
+/***********************变价列表***********************/
|
20
|
|
6
|
|
21
|
new common.dropDown({
|
7
|
new common.dropDown({
|
22
|
el: '#shop',
|
8
|
el: '#shop',
|
|
@@ -47,6 +33,21 @@ new common.dropDown({ |
|
@@ -47,6 +33,21 @@ new common.dropDown({ |
47
|
el: "#sex"
|
33
|
el: "#sex"
|
48
|
});
|
34
|
});
|
49
|
|
35
|
|
|
|
36
|
+var ENUM = {
|
|
|
37
|
+ vipType: {
|
|
|
38
|
+ 1: '正常折扣',
|
|
|
39
|
+ 2: '统一折扣',
|
|
|
40
|
+ 3: '无折扣',
|
|
|
41
|
+ 4: '固定折扣',
|
|
|
42
|
+ 5: '自定义折扣'
|
|
|
43
|
+ },
|
|
|
44
|
+ gender: {
|
|
|
45
|
+ 1: '男',
|
|
|
46
|
+ 2: '女',
|
|
|
47
|
+ 3: '通用'
|
|
|
48
|
+ }
|
|
|
49
|
+};
|
|
|
50
|
+
|
50
|
//多级菜单
|
51
|
//多级菜单
|
51
|
var tabTree = new common.tabTree("#sortTree");
|
52
|
var tabTree = new common.tabTree("#sortTree");
|
52
|
tabTree.init();
|
53
|
tabTree.init();
|
|
@@ -56,8 +57,8 @@ var g = new common.grid({ |
|
@@ -56,8 +57,8 @@ var g = new common.grid({ |
56
|
parms: function() {
|
57
|
parms: function() {
|
57
|
var select = tabTree.getAddress();
|
58
|
var select = tabTree.getAddress();
|
58
|
return {
|
59
|
return {
|
59
|
- shop_id: common.util.__input("shopId"),
|
|
|
60
|
product_skn: common.util.__input("skn"),
|
60
|
product_skn: common.util.__input("skn"),
|
|
|
61
|
+ shop_id: common.util.__input("shop"),
|
61
|
brand_id: common.util.__input("brand"),
|
62
|
brand_id: common.util.__input("brand"),
|
62
|
supplier_id: common.util.__input("supplier"),
|
63
|
supplier_id: common.util.__input("supplier"),
|
63
|
is_jit: common.util.__input("jit"),
|
64
|
is_jit: common.util.__input("jit"),
|
|
@@ -67,391 +68,432 @@ var g = new common.grid({ |
|
@@ -67,391 +68,432 @@ var g = new common.grid({ |
67
|
max_sort_id: select[0] ? select[0].id : "",
|
68
|
max_sort_id: select[0] ? select[0].id : "",
|
68
|
middle_sort_id: select[1] ? select[1].id : "",
|
69
|
middle_sort_id: select[1] ? select[1].id : "",
|
69
|
small_sort_id: select[2] ? select[2].id : ""
|
70
|
small_sort_id: select[2] ? select[2].id : ""
|
70
|
- };
|
|
|
71
|
- },
|
|
|
72
|
- columns: [{
|
|
|
73
|
- display: 'SKN',
|
|
|
74
|
- name: 'product_skn'
|
|
|
75
|
- }, {
|
|
|
76
|
- display: '商品信息',
|
|
|
77
|
- name: 'info',
|
|
|
78
|
- render: function(item) {
|
|
|
79
|
- return '<p>名称:' + item.product_name + '</p><p>品牌:' + item.brand_name + '</p><p>类目:' + item.middle_sort_name + '/' + item.small_sort_name + '</p>';
|
|
|
80
|
}
|
71
|
}
|
81
|
- }, {
|
|
|
82
|
- display: '供应商/店铺',
|
|
|
83
|
- name: 'supplier_name'
|
|
|
84
|
- }, {
|
|
|
85
|
- display: '性别',
|
|
|
86
|
- name: 'gender',
|
|
|
87
|
- render: function(item) {
|
72
|
+ },
|
|
|
73
|
+ columns: [
|
|
|
74
|
+ {display: 'SKN', name: 'product_skn'},
|
|
|
75
|
+ {display: '商品信息', render: function(item) {
|
|
|
76
|
+ var html = '<p>名称:' + item.product_name + '</p><p>品牌:' + item.brand_name + '</p>' +
|
|
|
77
|
+ '<div>类目:'+ item.middle_sort_name;
|
|
|
78
|
+ if(item.middle_sort_name) {html += ' > ' + item.middle_sort_name;}
|
|
|
79
|
+ if(item.small_sort_name) {html += ' > ' + item.small_sort_name;}
|
|
|
80
|
+ return html + "</div>";
|
|
|
81
|
+ }},
|
|
|
82
|
+ {display: '供应商/店铺', render: function(item) {
|
|
|
83
|
+ var html = '';
|
|
|
84
|
+ if (item.supplier_name) {
|
|
|
85
|
+ html += item.supplier_name;
|
|
|
86
|
+ if (item.shop_name) {html += '/';}
|
|
|
87
|
+ }
|
|
|
88
|
+ if (item.shop_name) {html += item.shop_name;}
|
|
|
89
|
+ return html;
|
|
|
90
|
+ }},
|
|
|
91
|
+ {display: '性别', render: function(item) {
|
88
|
return ENUM.gender[item.gender];
|
92
|
return ENUM.gender[item.gender];
|
89
|
- }
|
|
|
90
|
- }, {
|
|
|
91
|
- display: '吊牌价',
|
|
|
92
|
- name: 'retail_price'
|
|
|
93
|
- }, {
|
|
|
94
|
- display: '销售价',
|
|
|
95
|
- name: 'sales_price'
|
|
|
96
|
- }, {
|
|
|
97
|
- display: 'VIP折扣类型',
|
|
|
98
|
- name: 'vip_discount_type',
|
|
|
99
|
- render: function(item) {
|
93
|
+ }},
|
|
|
94
|
+ {display: '吊牌价', name: 'retail_price'},
|
|
|
95
|
+ {display: '销售价', name: 'sales_price'},
|
|
|
96
|
+ {display: 'VIP折扣类型', render: function(item) {
|
100
|
return ENUM.vipType[item.vip_discount_type];
|
97
|
return ENUM.vipType[item.vip_discount_type];
|
101
|
- }
|
|
|
102
|
- }, {
|
|
|
103
|
- display: 'VIP价',
|
|
|
104
|
- name: 'vip_price'
|
|
|
105
|
- }, {
|
|
|
106
|
- display: '白金',
|
|
|
107
|
- name: 'vip3_price'
|
|
|
108
|
- }, {
|
|
|
109
|
- display: '金卡',
|
|
|
110
|
- name: 'vip2_price'
|
|
|
111
|
- }, {
|
|
|
112
|
- display: '银卡',
|
|
|
113
|
- name: 'vip1_price'
|
|
|
114
|
- }, {
|
|
|
115
|
- display: '操作信息',
|
|
|
116
|
- name: 'operateInfo',
|
|
|
117
|
- render: function(item) {
|
98
|
+ }},
|
|
|
99
|
+ {display: 'VIP价', name: 'vip_price'},
|
|
|
100
|
+ {display: '白金', name: 'vip3_price'},
|
|
|
101
|
+ {display: '金卡', name: 'vip2_price'},
|
|
|
102
|
+ {display: '银卡', name: 'vip1_price'},
|
|
|
103
|
+ {display: '生效时间', name: 'effectiveTime'},
|
|
|
104
|
+ {display: '操作信息', render: function(item) {
|
118
|
var html = '';
|
105
|
var html = '';
|
119
|
- if (item.founder_name) {
|
|
|
120
|
- html += '<p>' + item.founder_name + '</p>';
|
|
|
121
|
- }
|
|
|
122
|
-
|
|
|
123
|
- if (item.updateTime) {
|
|
|
124
|
- html += '<p>' + item.updateTime + '</p>';
|
|
|
125
|
- }
|
106
|
+ if (item.founder_name) {html += '<p>' + item.founder_name + '</p>';}
|
|
|
107
|
+ if (item.updateTime) {html += '<div style="color: #999;font-size: 12px">' + item.updateTime + '</div>';}
|
126
|
return html;
|
108
|
return html;
|
|
|
109
|
+ }},
|
|
|
110
|
+ {display: '操作', render: function(item) {
|
|
|
111
|
+ return '<a href="javascript:;" class="btn btn-info btn-xs modify-btn" data-skn="' + item.product_skn + '">修改</a><br>' +
|
|
|
112
|
+ '<a href="javascript:;" class="btn btn-primary btn-xs history-btn" data-skn="' + item.product_skn + '" style="margin-top: 10px">变价记录</a>'
|
127
|
}
|
113
|
}
|
128
|
- }, {
|
|
|
129
|
- display: '操作',
|
|
|
130
|
- render: function(item) {
|
|
|
131
|
- return '<a href="javascript:;" class="btn btn-info btn-xs modify-btn" data-skn="' + item.product_skn + '">修改</a>'
|
|
|
132
|
- }
|
|
|
133
|
- }]
|
114
|
+ }]
|
134
|
});
|
115
|
});
|
|
|
116
|
+g.init('/product/queryProductPriceList');
|
135
|
|
117
|
|
136
|
-g.init($("#gridurl").val());
|
|
|
137
|
-
|
|
|
138
|
-//单个变价
|
|
|
139
|
-$('#basicTable').on('click', '.modify-btn', function() {
|
118
|
+//单个变价修改
|
|
|
119
|
+$(document).on('click', '.modify-btn', function() {
|
140
|
var skn = $(this).data('skn'),
|
120
|
var skn = $(this).data('skn'),
|
141
|
- that = this;
|
|
|
142
|
-
|
|
|
143
|
- if ($(that).data('detail')) {
|
|
|
144
|
- $(that).parents('tr').next('.product-detail').toggle();
|
|
|
145
|
- return;
|
121
|
+ parentTr = $(this).parent().parent(),
|
|
|
122
|
+ sknTd = parentTr.find('td').eq(0);
|
|
|
123
|
+
|
|
|
124
|
+ if($(this).hasClass('open')){
|
|
|
125
|
+ $(this).removeClass('open');
|
|
|
126
|
+ $(this).text('修改');
|
|
|
127
|
+ sknTd.removeAttr('rowspan','2');
|
|
|
128
|
+ parentTr.next('.product-detail').remove();
|
|
|
129
|
+ parentTr.next('.extraTr').remove();
|
|
|
130
|
+ }else{
|
|
|
131
|
+ $(this).addClass('open');
|
|
|
132
|
+ $(this).text('收起');
|
|
|
133
|
+ sknTd.attr('rowspan','2');
|
|
|
134
|
+ parentTr.after('<tr class="product-detail"><td colspan="15">加载中...若长时间加载不出来,请重新刷新页面!</td>' +
|
|
|
135
|
+ '</tr><tr class="extraTr"></tr>');
|
|
|
136
|
+
|
|
|
137
|
+ common.util.__ajax({
|
|
|
138
|
+ url:'/product/getProductPrice',
|
|
|
139
|
+ data: {param: skn}
|
|
|
140
|
+ },function(rs){
|
|
|
141
|
+ var data = rs.data;
|
|
|
142
|
+ parentTr.next('.product-detail').html($(common.util.__template($("#template").html(), data)));
|
|
|
143
|
+ new common.edit(".product-detail").init();
|
|
|
144
|
+
|
|
|
145
|
+ var $wrap = parentTr.next('.product-detail'),
|
|
|
146
|
+ $price = $wrap.find('.sale-price'),
|
|
|
147
|
+ $select = $wrap.find('.discount-select'),
|
|
|
148
|
+ $vipPrice = $wrap.find('.vip-price'),
|
|
|
149
|
+ $vip3Price = $wrap.find('.vip3-price'),
|
|
|
150
|
+ $vip2Price = $wrap.find('.vip2-price'),
|
|
|
151
|
+ $vip1Price = $wrap.find('.vip1-price'),
|
|
|
152
|
+ $startDate = $wrap.find('.startDate'),
|
|
|
153
|
+ $endDate = $wrap.find('.endDate'),
|
|
|
154
|
+ $submitBtn = $wrap.find('.sure-modify');
|
|
|
155
|
+ $select.val(data.vip_discount_type);
|
|
|
156
|
+
|
|
|
157
|
+ vipPrice($wrap);
|
|
|
158
|
+ $select.on('change', function() {
|
|
|
159
|
+ vipPrice($wrap);
|
|
|
160
|
+ });
|
|
|
161
|
+ $vipPrice.on('blur', function() {
|
|
|
162
|
+ vipPrice($wrap);
|
|
|
163
|
+ });
|
|
|
164
|
+ $price.on('blur', function() {
|
|
|
165
|
+ vipPrice($wrap);
|
|
|
166
|
+ });
|
|
|
167
|
+ $submitBtn.on('click', function() {
|
|
|
168
|
+ common.util.__ajax({
|
|
|
169
|
+ url: '/product/updateProductPrice',
|
|
|
170
|
+ data: {
|
|
|
171
|
+ product_skn: skn,
|
|
|
172
|
+ sales_price: $price.val(),
|
|
|
173
|
+ vip_discount_type: $select.val(),
|
|
|
174
|
+ vip_price: $vipPrice.val(),
|
|
|
175
|
+ vip1_price: $vip1Price.val(),
|
|
|
176
|
+ vip2_price: $vip2Price.val(),
|
|
|
177
|
+ vip3_price: $vip3Price.val(),
|
|
|
178
|
+ cgpriceStartTime:$startDate.val(),
|
|
|
179
|
+ cgpriceEndTime:$endDate.val()
|
|
|
180
|
+ }
|
|
|
181
|
+ }, function(res) {
|
|
|
182
|
+ if (res.code == 200) {g.reload()}
|
|
|
183
|
+ })
|
|
|
184
|
+ });
|
|
|
185
|
+ },true);
|
146
|
}
|
186
|
}
|
147
|
|
187
|
|
148
|
- $.ajax({
|
|
|
149
|
- type: 'POST',
|
|
|
150
|
- url: '/product/getProductPrice',
|
|
|
151
|
- dataType: 'json',
|
|
|
152
|
- data: {
|
|
|
153
|
- param: skn
|
|
|
154
|
- }
|
|
|
155
|
- }).then(function(res) {
|
|
|
156
|
- var data = res.data;
|
|
|
157
|
-
|
|
|
158
|
- $(that).data('detail', true).parents('tr')
|
|
|
159
|
- .after($(common.util.__template($("#template").html(), data)))
|
|
|
160
|
- .next('.product-detail').find('.skn-value').text(skn);
|
|
|
161
|
-
|
|
|
162
|
- var $wrap = $(that).parents('tr').next('.product-detail'),
|
|
|
163
|
- $price = $wrap.find('.sale-price'),
|
188
|
+ function vipPrice($wrap) {
|
|
|
189
|
+ var $price = $wrap.find('.sale-price'),
|
164
|
$select = $wrap.find('.discount-select'),
|
190
|
$select = $wrap.find('.discount-select'),
|
165
|
$vipPrice = $wrap.find('.vip-price'),
|
191
|
$vipPrice = $wrap.find('.vip-price'),
|
166
|
$vip3Price = $wrap.find('.vip3-price'),
|
192
|
$vip3Price = $wrap.find('.vip3-price'),
|
167
|
$vip2Price = $wrap.find('.vip2-price'),
|
193
|
$vip2Price = $wrap.find('.vip2-price'),
|
168
|
- $vip1Price = $wrap.find('.vip1-price'),
|
|
|
169
|
- $submitBtn = $wrap.find('.sure-modify');
|
|
|
170
|
-
|
|
|
171
|
- $select.val(data.vip_discount_type);
|
|
|
172
|
-
|
|
|
173
|
- function vipPrice() {
|
|
|
174
|
- var price = $price.val(),
|
|
|
175
|
- vipPrice = $vipPrice.val(),
|
|
|
176
|
- selectVal = $select.val() - 1,
|
|
|
177
|
- priceArr = [];
|
|
|
178
|
-
|
|
|
179
|
- priceArr.push([price * 0.95, price * 0.9, price * 0.88]);
|
|
|
180
|
- priceArr.push([price * 0.95, price * 0.95, price * 0.95]);
|
|
|
181
|
- priceArr.push([price, price, price]);
|
|
|
182
|
- priceArr.push([$vipPrice.val(), $vipPrice.val(), $vipPrice.val()]);
|
|
|
183
|
-
|
|
|
184
|
- if (selectVal == 4) {
|
|
|
185
|
- $vip1Price.removeAttr('disabled');
|
|
|
186
|
- $vip2Price.removeAttr('disabled');
|
|
|
187
|
- $vip3Price.removeAttr('disabled');
|
|
|
188
|
- } else {
|
|
|
189
|
- $vip1Price.attr('disabled', true).val(Number(priceArr[selectVal][0]).toFixed(2));
|
|
|
190
|
- $vip2Price.attr('disabled', true).val(Number(priceArr[selectVal][1]).toFixed(2));
|
|
|
191
|
- $vip3Price.attr('disabled', true).val(Number(priceArr[selectVal][2]).toFixed(2));
|
194
|
+ $vip1Price = $wrap.find('.vip1-price');
|
|
|
195
|
+
|
|
|
196
|
+ var price = $price.val(),
|
|
|
197
|
+ vipPrice = $vipPrice.val(),
|
|
|
198
|
+ selectVal = $select.val() - 1,
|
|
|
199
|
+ priceArr = [];
|
|
|
200
|
+
|
|
|
201
|
+ priceArr.push([price * 0.95, price * 0.9, price * 0.88]);
|
|
|
202
|
+ priceArr.push([price * 0.95, price * 0.95, price * 0.95]);
|
|
|
203
|
+ priceArr.push([price, price, price]);
|
|
|
204
|
+ priceArr.push([vipPrice, vipPrice, vipPrice]);
|
|
|
205
|
+
|
|
|
206
|
+ if (selectVal == 4) {
|
|
|
207
|
+ $vip1Price.removeAttr('disabled');
|
|
|
208
|
+ $vip2Price.removeAttr('disabled');
|
|
|
209
|
+ $vip3Price.removeAttr('disabled');
|
|
|
210
|
+ } else {
|
|
|
211
|
+ $vip1Price.attr('disabled', true).val(Number(priceArr[selectVal][0]).toFixed(2));
|
|
|
212
|
+ $vip2Price.attr('disabled', true).val(Number(priceArr[selectVal][1]).toFixed(2));
|
|
|
213
|
+ $vip3Price.attr('disabled', true).val(Number(priceArr[selectVal][2]).toFixed(2));
|
|
|
214
|
+ }
|
|
|
215
|
+ }
|
|
|
216
|
+});
|
|
|
217
|
+//变价记录
|
|
|
218
|
+$(document).on('click', '.history-btn', function () {
|
|
|
219
|
+ var skn = $(this).data('skn');
|
|
|
220
|
+ var option = {
|
|
|
221
|
+ title:'变价记录详情',
|
|
|
222
|
+ content:"<div class='historyDetail'>加载变价记录...</div>",
|
|
|
223
|
+ width:'70%',
|
|
|
224
|
+ button:[{value:"关闭", css:"btn-primary"}]
|
|
|
225
|
+ };
|
|
|
226
|
+ new common.dialog(option);
|
|
|
227
|
+ $.ajax({
|
|
|
228
|
+ type: 'POST',
|
|
|
229
|
+ dataType: 'json',
|
|
|
230
|
+ url: '/product/queryProductPriceListBySkn',
|
|
|
231
|
+ data: {param: skn},
|
|
|
232
|
+ success: function (rs) {
|
|
|
233
|
+ var data = rs;
|
|
|
234
|
+ $('.historyDetail').html($(common.util.__template2($("#template2").html(), data.data)));
|
|
|
235
|
+ if(data.code != 200){
|
|
|
236
|
+ common.util.__tip(data.message);
|
192
|
}
|
237
|
}
|
|
|
238
|
+ },
|
|
|
239
|
+ error: function (rs) {
|
|
|
240
|
+ $('.historyDetail').html($(common.util.__template2($("#template2").html(), {})));
|
|
|
241
|
+ common.util.__tip(rs.data.message);
|
193
|
}
|
242
|
}
|
194
|
-
|
|
|
195
|
- vipPrice();
|
|
|
196
|
- $select.on('change', function() {
|
|
|
197
|
- vipPrice();
|
|
|
198
|
- });
|
|
|
199
|
-
|
|
|
200
|
- $vipPrice.on('blur', function() {
|
|
|
201
|
- vipPrice();
|
|
|
202
|
- });
|
|
|
203
|
-
|
|
|
204
|
- $price.on('blur', function() {
|
|
|
205
|
- vipPrice();
|
|
|
206
|
- });
|
|
|
207
|
-
|
|
|
208
|
- $submitBtn.on('click', function() {
|
|
|
209
|
- common.util.__ajax({
|
|
|
210
|
- url: '/product/updateProductPrice',
|
|
|
211
|
- data: {
|
|
|
212
|
- product_skn: skn,
|
|
|
213
|
- sales_price: $price.val(),
|
|
|
214
|
- vip_discount_type: $select.val(),
|
|
|
215
|
- return_coin: $wrap.find('.return-coin').val(),
|
|
|
216
|
- vip_price: $vipPrice.val(),
|
|
|
217
|
- vip1_price: $vip1Price.val(),
|
|
|
218
|
- vip2_price: $vip2Price.val(),
|
|
|
219
|
- vip3_price: $vip3Price.val()
|
|
|
220
|
- }
|
|
|
221
|
- }, function(res) {
|
|
|
222
|
- if (res.code == 200) {
|
|
|
223
|
- g.reload();
|
|
|
224
|
- }
|
|
|
225
|
- })
|
|
|
226
|
- });
|
|
|
227
|
-
|
|
|
228
|
});
|
243
|
});
|
229
|
});
|
244
|
});
|
230
|
-
|
|
|
231
|
//筛选
|
245
|
//筛选
|
232
|
-$("#filter-btn").click(function() {
|
246
|
+$(document).on('click', '#filter-btn', function () {
|
233
|
g.reload(1);
|
247
|
g.reload(1);
|
234
|
});
|
248
|
});
|
235
|
-
|
|
|
236
|
//回车筛选
|
249
|
//回车筛选
|
237
|
-$('#skn').on('keyup', function(event) {
|
250
|
+$(document).on('keyup', 'body', function (event) {
|
238
|
if (event.keyCode == 13) {
|
251
|
if (event.keyCode == 13) {
|
239
|
$("#filter-btn").trigger('click');
|
252
|
$("#filter-btn").trigger('click');
|
240
|
}
|
253
|
}
|
241
|
});
|
254
|
});
|
242
|
-
|
|
|
243
|
//全部
|
255
|
//全部
|
244
|
-$("#all-btn").click(function() {
|
256
|
+$(document).on('click', '#all-btn', function () {
|
245
|
location.href = '';
|
257
|
location.href = '';
|
246
|
});
|
258
|
});
|
247
|
-
|
|
|
248
|
//批量导入按钮点击事件
|
259
|
//批量导入按钮点击事件
|
249
|
-$('#import-btn').on('click', function() {
|
260
|
+$(document).on('click', '#import-btn', function () {
|
250
|
$('#basicTable').hide();
|
261
|
$('#basicTable').hide();
|
251
|
$('#priceChangeSearch').hide();
|
262
|
$('#priceChangeSearch').hide();
|
252
|
$('.bulk-import').show();
|
263
|
$('.bulk-import').show();
|
253
|
});
|
264
|
});
|
254
|
|
265
|
|
255
|
-//返回列表
|
|
|
256
|
-$('#return-btn').on('click', function() {
|
|
|
257
|
- $('.bulk-import').hide();
|
|
|
258
|
- $('#basicTable').show();
|
|
|
259
|
- $('#priceChangeSearch').show();
|
|
|
260
|
-});
|
|
|
261
|
-
|
|
|
262
|
-//批量导入
|
|
|
263
|
-var successList = null,
|
|
|
264
|
- $error = $('#error-msg'),
|
|
|
265
|
- loadModal = null;
|
|
|
266
|
-$('#upload-input').after('<div class="file-name btn btn-default">请选择文件</div>');
|
|
|
267
|
-common.edit.ajaxfileupload("#upload-input", {
|
|
|
268
|
- params: {
|
|
|
269
|
- type: "price",
|
|
|
270
|
- __type: "batch-import",
|
|
|
271
|
- shop: common.util.__input("shopId")
|
|
|
272
|
- },
|
|
|
273
|
- onStart: function() {
|
|
|
274
|
- loadModal = common.dialog.load();
|
|
|
275
|
- $('.file-name').text($('#upload-input').val().replace("C:\\fakepath\\", ""));
|
|
|
276
|
- },
|
|
|
277
|
- onComplete: function(response) {
|
|
|
278
|
- console.log(response);
|
|
|
279
|
- if (loadModal) {
|
|
|
280
|
- loadModal.close();
|
|
|
281
|
- }
|
|
|
282
|
- if (response.code == 200) {
|
|
|
283
|
- var data = response.data,
|
|
|
284
|
- li = '';
|
|
|
285
|
-
|
|
|
286
|
- $('#priceTable').show();
|
|
|
287
|
- $('.success-wrap').hide();
|
|
|
288
|
- successList = data.successList;
|
|
|
289
|
- $.each(data.failFileReason, function(i, value) {
|
|
|
290
|
- li += '<li>' + value + '</li>';
|
|
|
291
|
- });
|
|
|
292
|
- $error.empty().html(li);
|
|
|
293
|
- p.init(successList);
|
|
|
294
|
- } else {
|
|
|
295
|
- common.util.__tip(response.message, 'warning');
|
|
|
296
|
- }
|
|
|
297
|
-
|
|
|
298
|
-
|
|
|
299
|
- }
|
|
|
300
|
-});
|
|
|
301
|
-
|
266
|
+/***********************批量导入***********************/
|
302
|
|
267
|
|
303
|
-
|
|
|
304
|
-var isFirst = false,
|
|
|
305
|
- tableHtml = '';
|
268
|
+var loadModal = null;
|
|
|
269
|
+var importPriceChangeData;
|
|
|
270
|
+var path = ''; //确定变价后返回的excel名
|
306
|
var p = new common.grid({
|
271
|
var p = new common.grid({
|
307
|
- el: "#priceTable",
|
|
|
308
|
- columns: [{
|
|
|
309
|
- display: 'SKN',
|
|
|
310
|
- render: function(item) {
|
272
|
+ el: "#importResultTable",
|
|
|
273
|
+ columns: [
|
|
|
274
|
+ {display: 'SKN', render: function(item) {
|
311
|
return item.newProductPriceBo.product_skn;
|
275
|
return item.newProductPriceBo.product_skn;
|
312
|
- }
|
|
|
313
|
- }, {
|
|
|
314
|
- display: '吊牌价',
|
|
|
315
|
- render: function(item) {
|
|
|
316
|
- return item.newProductPriceBo.retail_price + '<p style="color: #ccc;">' + item.oldProductPriceBo.retail_price + '</p>';
|
|
|
317
|
- }
|
|
|
318
|
- }, {
|
|
|
319
|
- display: '销售价',
|
|
|
320
|
- render: function(item) {
|
276
|
+ }},
|
|
|
277
|
+ {display: '吊牌价', render: function(item) {
|
|
|
278
|
+ return '<p>'+item.newProductPriceBo.retail_price + '</p><div style="color: #999;">' + item.oldProductPriceBo.retail_price + '</div>';
|
|
|
279
|
+ }},
|
|
|
280
|
+ {display: '销售价', render: function(item) {
|
321
|
var newPrice = item.newProductPriceBo,
|
281
|
var newPrice = item.newProductPriceBo,
|
322
|
- newPriceHtml = newPrice.sales_price;
|
|
|
323
|
-
|
282
|
+ newPriceHtml = '<p>'+newPrice.sales_price+'</p>';
|
324
|
if (newPrice.sales_price < (newPrice.retail_price / 2)) {
|
283
|
if (newPrice.sales_price < (newPrice.retail_price / 2)) {
|
325
|
newPriceHtml = '<p style="color: red">' + newPrice.sales_price + '</p>';
|
284
|
newPriceHtml = '<p style="color: red">' + newPrice.sales_price + '</p>';
|
326
|
}
|
285
|
}
|
327
|
-
|
|
|
328
|
- return newPriceHtml + '<p style="color: #ccc;">' + item.oldProductPriceBo.sales_price + '</p>';
|
|
|
329
|
- }
|
|
|
330
|
- }, {
|
|
|
331
|
- display: 'VIP折扣类型',
|
|
|
332
|
- render: function(item) {
|
|
|
333
|
- return ENUM.vipType[item.newProductPriceBo.vip_discount_type] +
|
|
|
334
|
- '<p style="color: #ccc;">' + ENUM.vipType[item.oldProductPriceBo.vip_discount_type] + '</p>';
|
|
|
335
|
- }
|
|
|
336
|
- }, {
|
|
|
337
|
- display: 'VIP价',
|
|
|
338
|
- render: function(item) {
|
286
|
+ return newPriceHtml + '<div style="color: #999;">' + item.oldProductPriceBo.sales_price + '</div>';
|
|
|
287
|
+ }},
|
|
|
288
|
+ {display: 'VIP折扣类型', render: function(item) {
|
|
|
289
|
+ return '<p>'+ENUM.vipType[item.newProductPriceBo.vip_discount_type] + '</p>'+
|
|
|
290
|
+ '<div style="color: #999;">' + ENUM.vipType[item.oldProductPriceBo.vip_discount_type] + '</div>';
|
|
|
291
|
+ }},
|
|
|
292
|
+ {display: 'VIP价', render: function(item) {
|
339
|
var newPrice = item.newProductPriceBo,
|
293
|
var newPrice = item.newProductPriceBo,
|
340
|
newPriceHtml = '';
|
294
|
newPriceHtml = '';
|
341
|
-
|
|
|
342
|
if (newPrice.vip_price) {
|
295
|
if (newPrice.vip_price) {
|
343
|
- newPriceHtml = newPrice.vip_price;
|
|
|
344
|
-
|
|
|
345
|
if (newPrice.vip_price < (newPrice.retail_price / 2)) {
|
296
|
if (newPrice.vip_price < (newPrice.retail_price / 2)) {
|
346
|
newPriceHtml = '<p style="color: red">' + newPrice.vip_price + '</p>';
|
297
|
newPriceHtml = '<p style="color: red">' + newPrice.vip_price + '</p>';
|
|
|
298
|
+ }else{
|
|
|
299
|
+ newPriceHtml = '<p>'+newPrice.vip_price+'</p>';
|
347
|
}
|
300
|
}
|
348
|
} else {
|
301
|
} else {
|
349
|
- newPriceHtml = '-'
|
302
|
+ newPriceHtml = '<p>-</p>'
|
350
|
}
|
303
|
}
|
351
|
- return newPriceHtml + '<p style="color: #ccc;">' + item.oldProductPriceBo.vip_price + '</p>';
|
|
|
352
|
- }
|
|
|
353
|
- }, {
|
|
|
354
|
- display: '白金价',
|
|
|
355
|
- render: function(item) {
|
304
|
+ if(item.oldProductPriceBo.vip_price){
|
|
|
305
|
+ newPriceHtml += '<div style="color: #999;">' + item.oldProductPriceBo.vip_price + '</div>';
|
|
|
306
|
+ }else{
|
|
|
307
|
+ newPriceHtml += '<div>-</div>';
|
|
|
308
|
+ }
|
|
|
309
|
+ return newPriceHtml;
|
|
|
310
|
+ }},
|
|
|
311
|
+ {display: '白金价', render: function(item) {
|
356
|
var newPrice = item.newProductPriceBo,
|
312
|
var newPrice = item.newProductPriceBo,
|
357
|
- newPriceHtml = newPrice.vip3_price;
|
|
|
358
|
-
|
|
|
359
|
- if (newPrice.vip3_price < (newPrice.retail_price / 2)) {
|
|
|
360
|
- newPriceHtml = '<p style="color: red">' + newPrice.vip3_price + '</p>';
|
313
|
+ newPriceHtml = '';
|
|
|
314
|
+ if (newPrice.vip3_price){
|
|
|
315
|
+ if (newPrice.vip3_price < (newPrice.retail_price / 2)) {
|
|
|
316
|
+ newPriceHtml = '<p style="color: red">' + newPrice.vip3_price + '</p>';
|
|
|
317
|
+ }else{
|
|
|
318
|
+ newPriceHtml = '<p>'+newPrice.vip3_price+'</p>';
|
|
|
319
|
+ }
|
|
|
320
|
+ }else{
|
|
|
321
|
+ newPriceHtml = '<p>-</p>'
|
361
|
}
|
322
|
}
|
362
|
-
|
|
|
363
|
- return newPriceHtml + '<p style="color: #ccc;">' + item.oldProductPriceBo.vip3_price + '</p>';
|
|
|
364
|
- }
|
|
|
365
|
- }, {
|
|
|
366
|
- display: '金卡价',
|
|
|
367
|
- render: function(item) {
|
323
|
+ if(item.oldProductPriceBo.vip3_price){
|
|
|
324
|
+ newPriceHtml += '<div style="color: #999;">' + item.oldProductPriceBo.vip3_price + '</div>';
|
|
|
325
|
+ }else{
|
|
|
326
|
+ newPriceHtml += '<div>-</div>';
|
|
|
327
|
+ }
|
|
|
328
|
+ return newPriceHtml;
|
|
|
329
|
+ }},
|
|
|
330
|
+ {display: '金卡价', render: function(item) {
|
368
|
var newPrice = item.newProductPriceBo,
|
331
|
var newPrice = item.newProductPriceBo,
|
369
|
- newPriceHtml = newPrice.vip2_price;
|
|
|
370
|
-
|
|
|
371
|
- if (newPrice.vip2_price < (newPrice.retail_price / 2)) {
|
|
|
372
|
- newPriceHtml = '<p style="color: red">' + newPrice.vip2_price + '</p>';
|
332
|
+ newPriceHtml = '';
|
|
|
333
|
+ if (newPrice.vip2_price){
|
|
|
334
|
+ if (newPrice.vip2_price < (newPrice.retail_price / 2)) {
|
|
|
335
|
+ newPriceHtml = '<p style="color: red">' + newPrice.vip2_price + '</p>';
|
|
|
336
|
+ }else {
|
|
|
337
|
+ newPriceHtml = '<p>'+newPrice.vip2_price+'</p>';
|
|
|
338
|
+ }
|
|
|
339
|
+ }else{
|
|
|
340
|
+ newPriceHtml = '<p>-</p>'
|
373
|
}
|
341
|
}
|
374
|
-
|
|
|
375
|
- return newPriceHtml + '<p style="color: #ccc;">' + item.oldProductPriceBo.vip2_price + '</p>';
|
|
|
376
|
- }
|
|
|
377
|
- }, {
|
|
|
378
|
- display: '银卡价',
|
|
|
379
|
- render: function(item) {
|
342
|
+ if(item.oldProductPriceBo.vip2_price){
|
|
|
343
|
+ newPriceHtml += '<div style="color: #999;">' + item.oldProductPriceBo.vip2_price + '</div>';
|
|
|
344
|
+ }else{
|
|
|
345
|
+ newPriceHtml += '<div>-</div>';
|
|
|
346
|
+ }
|
|
|
347
|
+ return newPriceHtml;
|
|
|
348
|
+ }},
|
|
|
349
|
+ {display: '银卡价', render: function(item) {
|
380
|
var newPrice = item.newProductPriceBo,
|
350
|
var newPrice = item.newProductPriceBo,
|
381
|
- newPriceHtml = newPrice.vip1_price;
|
|
|
382
|
-
|
|
|
383
|
- if (newPrice.vip1_price < (newPrice.retail_price / 2)) {
|
|
|
384
|
- newPriceHtml = '<p style="color: red">' + newPrice.vip1_price + '</p>';
|
351
|
+ newPriceHtml = '';
|
|
|
352
|
+ if (newPrice.vip1_price){
|
|
|
353
|
+ if (newPrice.vip1_price < (newPrice.retail_price / 2)) {
|
|
|
354
|
+ newPriceHtml = '<p style="color: red">' + newPrice.vip1_price + '</p>';
|
|
|
355
|
+ }else{
|
|
|
356
|
+ newPriceHtml = '<p>'+newPrice.vip1_price+'</p>';
|
|
|
357
|
+ }
|
|
|
358
|
+ }else{
|
|
|
359
|
+ newPriceHtml = '<p>-</p>'
|
|
|
360
|
+ }
|
|
|
361
|
+ if(item.oldProductPriceBo.vip1_price){
|
|
|
362
|
+ newPriceHtml += '<div style="color: #999;">' + item.oldProductPriceBo.vip1_price + '</div>';
|
|
|
363
|
+ }else{
|
|
|
364
|
+ newPriceHtml += '<div>-</div>';
|
385
|
}
|
365
|
}
|
|
|
366
|
+ return newPriceHtml;
|
|
|
367
|
+ }},
|
|
|
368
|
+ {display: '操作', render: function(item) {
|
|
|
369
|
+ return '<a class="btn btn-danger btn-xs deleteImport" data-index="' + item.__index + '" href="javascript:;">删除</a>';
|
|
|
370
|
+ }}
|
|
|
371
|
+ ]
|
|
|
372
|
+});
|
386
|
|
373
|
|
387
|
- return newPriceHtml + '<p style="color: #ccc;">' + item.oldProductPriceBo.vip2_price + '</p>';
|
|
|
388
|
- }
|
|
|
389
|
- }, {
|
|
|
390
|
- display: '操作',
|
|
|
391
|
- render: function(item) {
|
|
|
392
|
- return '<a class="btn btn-info delete-btn" data-index="' + item.__index + '" href="javascript:;">删除</a>';
|
374
|
+common.edit.ajaxfileupload("#priceChangeUpload", {
|
|
|
375
|
+ params: {
|
|
|
376
|
+ type: "price",
|
|
|
377
|
+ __type: "batch-import"
|
|
|
378
|
+ },
|
|
|
379
|
+ onStart: function() {
|
|
|
380
|
+ loadModal = common.dialog.load();
|
|
|
381
|
+ clearImportResult()
|
|
|
382
|
+ },
|
|
|
383
|
+ onComplete: function(response) {
|
|
|
384
|
+ console.log("批量接口返回数据",response);
|
|
|
385
|
+ if (loadModal) loadModal.close();
|
|
|
386
|
+
|
|
|
387
|
+ if(response.code == 200){
|
|
|
388
|
+ if(response.data.failFileReason && response.data.failFileReason.length > 0){
|
|
|
389
|
+ showImportMessage(response.data.failFileReason.join('<br/>'), "error");
|
|
|
390
|
+ }else {
|
|
|
391
|
+ showImportMessage("批量导入全部成功!", "success");
|
|
|
392
|
+ }
|
|
|
393
|
+ if(response.data.successList && response.data.successList.length > 0){
|
|
|
394
|
+ showImportTable(response.data);
|
|
|
395
|
+ }
|
|
|
396
|
+ }else{
|
|
|
397
|
+ showImportMessage(response.message, "error");
|
|
|
398
|
+ common.util.__tip(response.message);
|
393
|
}
|
399
|
}
|
394
|
- }]
|
400
|
+ }
|
395
|
});
|
401
|
});
|
396
|
|
402
|
|
397
|
-//全部删除按钮
|
|
|
398
|
-$('#delete-all').on('click', function() {
|
|
|
399
|
- $('#priceTable').empty();
|
|
|
400
|
- $error.empty();
|
|
|
401
|
- successList.length = 0;
|
|
|
402
|
-})
|
|
|
403
|
-
|
|
|
404
|
-
|
|
|
405
|
-//批量变价列表单个删除
|
|
|
406
|
-$('#priceTable').on('click', '.delete-btn', function() {
|
|
|
407
|
- //var index = p.rows[$(this).data('index')];
|
|
|
408
|
- successList.splice($(this).data('index'), 1);
|
|
|
409
|
- p.reload();
|
|
|
410
|
- // console.log(p.rows);
|
403
|
+//显示批量导入结果
|
|
|
404
|
+function showImportMessage(message, statue){
|
|
|
405
|
+ $("#priceChangeImportMessage").removeAttr("class").addClass(statue).show();
|
|
|
406
|
+ $("#detailMassage").html(message);
|
|
|
407
|
+}
|
|
|
408
|
+//显示批量导入数据表
|
|
|
409
|
+function showImportTable(data){
|
|
|
410
|
+ importPriceChangeData = data.successList;
|
|
|
411
|
+
|
|
|
412
|
+ p.init(importPriceChangeData);
|
|
|
413
|
+ $("#priceChangeImportResultSet").show();
|
|
|
414
|
+ $("#priceChangeImportResult").show();
|
|
|
415
|
+ new common.edit("#priceChangeImportResultSet").init();
|
|
|
416
|
+}
|
|
|
417
|
+//清除批量导入结果及列表
|
|
|
418
|
+function clearImportResult(){
|
|
|
419
|
+ $("#detailMassage").empty();
|
|
|
420
|
+ $("#importResultTable").empty();
|
|
|
421
|
+ $("#priceChangeImportResultSet input").val('');
|
|
|
422
|
+
|
|
|
423
|
+ $('#download-btn').hide();
|
|
|
424
|
+ $("#priceChangeImportMessage").hide();
|
|
|
425
|
+ $("#priceChangeImportResultSet").hide();
|
|
|
426
|
+ $("#priceChangeImportResult").hide();
|
|
|
427
|
+}
|
411
|
|
428
|
|
|
|
429
|
+//全部删除
|
|
|
430
|
+$(document).on('click', '#deleteAllImport', function () {
|
|
|
431
|
+ common.dialog.confirm(
|
|
|
432
|
+ '删除确认提示',
|
|
|
433
|
+ '你确定<b><font color="#ff0000">全部删除</font></b>已成功导入的变价么?',
|
|
|
434
|
+ function () {
|
|
|
435
|
+ importPriceChangeData.length = 0;
|
|
|
436
|
+ p.reload();
|
|
|
437
|
+ }
|
|
|
438
|
+ );
|
412
|
});
|
439
|
});
|
413
|
-
|
|
|
414
|
-
|
|
|
415
|
-//确定变价
|
|
|
416
|
-var path = ''; //确定变价后返回的excel名
|
|
|
417
|
-$('#sure-change').on('click', function() {
|
|
|
418
|
- var arr = [],
|
|
|
419
|
- data = '';
|
|
|
420
|
-
|
|
|
421
|
- if (!successList || successList.length == 0) {
|
|
|
422
|
- alert('请上传批量变价文件');
|
|
|
423
|
- return;
|
440
|
+//单个删除
|
|
|
441
|
+$(document).on('click', '.deleteImport', function () {
|
|
|
442
|
+ common.dialog.confirm(
|
|
|
443
|
+ '删除确认提示',
|
|
|
444
|
+ '你确定<b><font color="#ff0000">删除</font></b>该变价么?',
|
|
|
445
|
+ function () {
|
|
|
446
|
+ var index = $(this).data("index");
|
|
|
447
|
+ if(importPriceChangeData){
|
|
|
448
|
+ [].splice.call(importPriceChangeData,index,1);
|
|
|
449
|
+ p.reload();
|
|
|
450
|
+ }
|
|
|
451
|
+ }
|
|
|
452
|
+ );
|
|
|
453
|
+});
|
|
|
454
|
+//确定提交批量
|
|
|
455
|
+$(document).on('click', '.btn-submit-priceChange', function () {
|
|
|
456
|
+ if(importPriceChangeData.length < 1){
|
|
|
457
|
+ common.util.__tip("没有可提交的变价,请重新导入!");
|
|
|
458
|
+ return false;
|
424
|
}
|
459
|
}
|
425
|
- console.log(successList);
|
|
|
426
|
- $.each(successList, function(i, value) {
|
|
|
427
|
- arr.push(value.newProductPriceBo);
|
|
|
428
|
- });
|
|
|
429
|
-
|
|
|
430
|
- // var count=Math.ceil(arr.length/200);
|
|
|
431
|
- // for(var i=0;i<count;i++){
|
|
|
432
|
- // item=arr.slice(i*200,(i+1)*200);
|
|
|
433
|
- // }
|
|
|
434
|
- // while(item=arr.slice(2,4)){
|
|
|
435
|
-
|
|
|
436
|
- // }
|
|
|
437
|
-
|
|
|
438
|
- data = JSON.stringify(arr);
|
|
|
439
|
- console.log(data);
|
|
|
440
|
- common.util.__ajax({
|
|
|
441
|
- url: '/product/batchUpdateProductPrice',
|
|
|
442
|
- data: {
|
|
|
443
|
- batchList: data,
|
|
|
444
|
- shop_id: common.util.__input("shopId")
|
460
|
+ common.dialog.confirm(
|
|
|
461
|
+ '提交确认提示',
|
|
|
462
|
+ '你确定<b><font color="#449d44">提交并保存</font></b>成功导入的变价么?',
|
|
|
463
|
+ function () {
|
|
|
464
|
+ var arr = [];
|
|
|
465
|
+ $.each(importPriceChangeData, function(i, value) {
|
|
|
466
|
+ arr.push(value.newProductPriceBo);
|
|
|
467
|
+ });
|
|
|
468
|
+ common.util.__ajax({
|
|
|
469
|
+ url: '/product/batchUpdateProductPrice',
|
|
|
470
|
+ data: {
|
|
|
471
|
+ batchList: JSON.stringify(arr),
|
|
|
472
|
+ cgpriceStartTime:$('#importStartDate').val(),
|
|
|
473
|
+ cgpriceEndTime:$('#importEndDate').val()
|
|
|
474
|
+ }
|
|
|
475
|
+ }, function(res) {
|
|
|
476
|
+ path = res.data;
|
|
|
477
|
+ importPriceChangeData.length = 0;
|
|
|
478
|
+ clearImportResult();
|
|
|
479
|
+ if(path && path != ''){
|
|
|
480
|
+ $('#download-btn').show();
|
|
|
481
|
+ }
|
|
|
482
|
+ });
|
445
|
}
|
483
|
}
|
446
|
- }, function(res) {
|
|
|
447
|
- $('#priceTable').hide();
|
|
|
448
|
- $('.success-wrap').show();
|
|
|
449
|
- path = res.data;
|
|
|
450
|
- successList.length = 0;
|
|
|
451
|
- });
|
|
|
452
|
-
|
484
|
+ );
|
453
|
});
|
485
|
});
|
454
|
-
|
|
|
455
|
-$('#download-btn').on('click', function() {
|
486
|
+//下载导入结果
|
|
|
487
|
+$(document).on('click', '#download-btn', function() {
|
456
|
location.href = '/ajax/download?path=' + path;
|
488
|
location.href = '/ajax/download?path=' + path;
|
|
|
489
|
+});
|
|
|
490
|
+//返回列表
|
|
|
491
|
+$(document).on('click', '#return-btn', function () {
|
|
|
492
|
+ if(path == ''){
|
|
|
493
|
+ $('.bulk-import').hide();
|
|
|
494
|
+ $('#basicTable').show();
|
|
|
495
|
+ $('#priceChangeSearch').show();
|
|
|
496
|
+ }else{
|
|
|
497
|
+ location.href = '';
|
|
|
498
|
+ }
|
457
|
}); |
499
|
}); |