ProductVip.js
5.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/**
* Created by wangqianjun on 16/2/23.
*/
var $ = require('jquery'),
common=require('../../common/common');
// 初始化筛选框
new common.dropDown({el: "#shop-name", ajax: "shopsRest"});
new common.dropDown({el: "#brandId", ajax: "brand"});
/**
* 列表
* @type {common.grid}
*/
var g = new common.grid({
el: '#basicTable',
parms: function () {
return {
productSkn: common.util.__input('productSkn'),
shopId: common.util.__input('shop-name'),
brandId: common.util.__input('brandId'),
productVipStatus: common.util.__input('productVipStatus')
};
},
columns: [
// {
// display: "复选框",
// render: function (item) {
// var HtmArr = [];
// HtmArr.push('<label><input name="choose" type="checkbox" value="'+item.productSKN+'"/></label>');
// return HtmArr.join('');
// }
// },
{
display: "SKN",
name: "productSKN"
}, {
display: "店铺",
name: "shopName"
}, {
display: "品牌",
name: "brandName"
}, {
display: "状态",
render: function (item) {
var HtmArr = [];
if(item.productVipStatus == 0){
HtmArr.push('<label>跟随店铺</label>');
}else if(item.productVipStatus == 1){
HtmArr.push('<label>开启</label>');
}else{
HtmArr.push('<label>关闭</label>');
}
return HtmArr.join('');
}
}, {
display: '操作',
render: function (item) {
var HtmArr = [];
if(item.productVipStatus == 0){
HtmArr.push('<label><input name="'+item.productSKN+'" type="radio" value="1" onclick="changeStatus('+item.productSKN+',1)"/>开启</label>');
HtmArr.push('<label><input name="'+item.productSKN+'" type="radio" value="2" onclick="changeStatus('+item.productSKN+',2)"/>关闭</label>');
}else if(item.productVipStatus == 1){
HtmArr.push('<label><input name="'+item.productSKN+'" type="radio" value="0" onclick="changeStatus('+item.productSKN+',0)"/>跟随店铺</label>');
HtmArr.push('<label><input name="'+item.productSKN+'" type="radio" value="2" onclick="changeStatus('+item.productSKN+',2)"/>关闭</label>');
}else{
HtmArr.push('<label><input name="'+item.productSKN+'" type="radio" value="0" onclick="changeStatus('+item.productSKN+',0)"/>跟随店铺</label>');
HtmArr.push('<label><input name="'+item.productSKN+'" type="radio" value="1" onclick="changeStatus('+item.productSKN+',1)"/>开启</label>');
}
return HtmArr.join('');
}
}]
});
g.init('/vip/queryProductVipList');
$("#flowShop").click(function() {
if(!$('#all').is(':checked')) {
alert("请勾选复选框!");
return;
}
var params= {
productSkn: common.util.__input('productSkn'),
shopId: common.util.__input('shop-name'),
brandId: common.util.__input('brandId'),
productVipStatus: common.util.__input('productVipStatus'),
changeStatus: 0
};
common.dialog.confirm("警告",
"确认批量修改商品VIP状态为跟随店铺?",
function () {
common.util.__ajax({
url: '/vip/batchChangeStatus',
data: params
}, function(res) {
g.reload();
});
});
});
$("#open").click(function() {
if(!$('#all').is(':checked')) {
alert("请勾选复选框!");
return;
}
var params= {
productSkn: common.util.__input('productSkn'),
shopId: common.util.__input('shop-name'),
brandId: common.util.__input('brandId'),
productVipStatus: common.util.__input('productVipStatus'),
changeStatus: 1
};
common.dialog.confirm("警告",
"确认批量修改商品VIP状态为开启?",
function () {
common.util.__ajax({
url: '/vip/batchChangeStatus',
data: params
}, function(res) {
g.reload();
});
});
});
$("#close").click(function() {
if(!$('#all').is(':checked')) {
alert("请勾选复选框!");
return;
}
var params= {
productSkn: common.util.__input('productSkn'),
shopId: common.util.__input('shop-name'),
brandId: common.util.__input('brandId'),
productVipStatus: common.util.__input('productVipStatus'),
changeStatus: 2
};
common.dialog.confirm("警告",
"确认批量修改商品VIP状态为关闭?",
function () {
common.util.__ajax({
url: '/vip/batchChangeStatus',
data: params
}, function(res) {
g.reload();
});
});
});
$("#filter-btn").click(function() {
g.reload(1);
});
function changeStatus(productSkn,status) {
var param = {
productSkn: productSkn,
productVipStatus: status
};
common.dialog.confirm("警告",
"确认修改状态?",
function () {
common.util.__ajax({
url: '/vip/changeStatus',
data: param
}, function(res) {
g.reload();
});
});
};
// function DoCheck()
// {
// var ch=document.getElementsByName("choose");
// if(document.getElementsByName("all")[0].checked==true)
// {
// for(var i=0;i<ch.length;i++)
// {
// ch[i].checked=true;
// }
// }else{
// for(var i=0;i<ch.length;i++)
// {
// ch[i].checked=false;
// }
// }
// }
// window.DoCheck = DoCheck;
window.changeStatus = changeStatus;