|
@@ -2,6 +2,15 @@ |
|
@@ -2,6 +2,15 @@ |
2
|
var $ = require('jquery'),
|
2
|
var $ = require('jquery'),
|
3
|
common = require('../../../common/common');
|
3
|
common = require('../../../common/common');
|
4
|
|
4
|
|
|
|
5
|
+//存储批量选中的sourceId
|
|
|
6
|
+window.batchChooseSourceIds = [];
|
|
|
7
|
+//存储批量选中的直通车名称
|
|
|
8
|
+window.batchChooseSourceNames = [];
|
|
|
9
|
+//存储批量取消选中的sourceId
|
|
|
10
|
+window.batchUnChooseSourceIds = [];
|
|
|
11
|
+//存储批量取消选中的直通车名称
|
|
|
12
|
+window.batchUnChooseSourceNames = [];
|
|
|
13
|
+
|
5
|
var EMUN = {
|
14
|
var EMUN = {
|
6
|
status: {
|
15
|
status: {
|
7
|
0: '关闭',
|
16
|
0: '关闭',
|
|
@@ -9,6 +18,16 @@ var EMUN = { |
|
@@ -9,6 +18,16 @@ var EMUN = { |
9
|
}
|
18
|
}
|
10
|
}
|
19
|
}
|
11
|
|
20
|
|
|
|
21
|
+//筛选
|
|
|
22
|
+$(document).on('click', '#filter-btn', function () {
|
|
|
23
|
+ g.reload(1);
|
|
|
24
|
+});
|
|
|
25
|
+//全部
|
|
|
26
|
+$(document).on('click', '#all-btn', function () {
|
|
|
27
|
+ location.href = '';
|
|
|
28
|
+});
|
|
|
29
|
+
|
|
|
30
|
+var pageChooseSourceIds = [];
|
12
|
var g = new common.grid({
|
31
|
var g = new common.grid({
|
13
|
el: "#basicTable",
|
32
|
el: "#basicTable",
|
14
|
parms: function() {
|
33
|
parms: function() {
|
|
@@ -20,8 +39,37 @@ var g = new common.grid({ |
|
@@ -20,8 +39,37 @@ var g = new common.grid({ |
20
|
},
|
39
|
},
|
21
|
columns: [
|
40
|
columns: [
|
22
|
{
|
41
|
{
|
|
|
42
|
+ display: '',
|
|
|
43
|
+ type: 'checkbox',
|
|
|
44
|
+ render: function (item) {
|
|
|
45
|
+ var htmlContent = "";
|
|
|
46
|
+ if(item.state == 1){
|
|
|
47
|
+ return htmlContent;
|
|
|
48
|
+ }
|
|
|
49
|
+ if(batchChooseSourceIds.length == 0 ){
|
|
|
50
|
+ htmlContent = "<input type='checkbox' class='wqt_checkbox' data-index='"+item.__index+"'>";
|
|
|
51
|
+ }else{
|
|
|
52
|
+ $.each(batchChooseSourceIds,function(n,value) {
|
|
|
53
|
+ if(item.sourceId == value){
|
|
|
54
|
+ htmlContent = "<input type='checkbox' checked='checked' class='wqt_checkbox' data-index='"+item.__index+"'>";
|
|
|
55
|
+ return false
|
|
|
56
|
+ }else{
|
|
|
57
|
+ htmlContent = "<input type='checkbox' class='wqt_checkbox' data-index='"+item.__index+"'>";
|
|
|
58
|
+ }
|
|
|
59
|
+ })
|
|
|
60
|
+ }
|
|
|
61
|
+ return htmlContent;
|
|
|
62
|
+ }
|
|
|
63
|
+ },
|
|
|
64
|
+ {
|
23
|
display: '资源位直通车id',
|
65
|
display: '资源位直通车id',
|
24
|
- name: 'sourceId'
|
66
|
+ name: 'sourceId',
|
|
|
67
|
+ render: function (item) {
|
|
|
68
|
+ if(item.state != 1) {
|
|
|
69
|
+ pageChooseSourceIds.push(item.sourceId);
|
|
|
70
|
+ }
|
|
|
71
|
+ return item.sourceId;
|
|
|
72
|
+ }
|
25
|
},
|
73
|
},
|
26
|
{
|
74
|
{
|
27
|
display: '资源位直通车名称',
|
75
|
display: '资源位直通车名称',
|
|
@@ -46,21 +94,34 @@ var g = new common.grid({ |
|
@@ -46,21 +94,34 @@ var g = new common.grid({ |
46
|
}
|
94
|
}
|
47
|
|
95
|
|
48
|
}
|
96
|
}
|
49
|
- }]
|
97
|
+ }],
|
|
|
98
|
+ selectedCallback:function(item){
|
|
|
99
|
+ if($.inArray(item.sourceId, batchChooseSourceIds) === -1 ){
|
|
|
100
|
+ batchChooseSourceIds.push(item.sourceId);
|
|
|
101
|
+ batchChooseSourceNames.push(item.sourceName);
|
|
|
102
|
+ }
|
|
|
103
|
+ },
|
|
|
104
|
+ unselectedCallback:function(item){
|
|
|
105
|
+ var _index = $.inArray(item.sourceId, batchChooseSourceIds);
|
|
|
106
|
+ if( _index !== -1 ){
|
|
|
107
|
+ batchChooseSourceIds.splice(_index,1);
|
|
|
108
|
+ batchChooseSourceNames.splice(_index, 1);
|
|
|
109
|
+ }
|
|
|
110
|
+ },
|
|
|
111
|
+ complete:function(){
|
|
|
112
|
+ $.each(pageChooseSourceIds, function (i, pageItem) {
|
|
|
113
|
+ if($.inArray(pageItem, batchChooseSourceIds) == -1 ) {
|
|
|
114
|
+ $(".wqt_all").prop("checked", false);
|
|
|
115
|
+ return false;
|
|
|
116
|
+ }
|
|
|
117
|
+ $(".wqt_all").prop("checked", true);
|
|
|
118
|
+ });
|
|
|
119
|
+ pageChooseSourceIds = [];
|
|
|
120
|
+ }
|
50
|
});
|
121
|
});
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
g.init('/categorySource/queryCategorySourceList');
|
122
|
g.init('/categorySource/queryCategorySourceList');
|
54
|
|
123
|
|
55
|
-//筛选
|
|
|
56
|
-$(document).on('click', '#filter-btn', function () {
|
|
|
57
|
- g.reload(1);
|
|
|
58
|
-});
|
|
|
59
|
-//全部
|
|
|
60
|
-$(document).on('click', '#all-btn', function () {
|
|
|
61
|
- location.href = '';
|
|
|
62
|
-});
|
|
|
63
|
-
|
124
|
+var pageUnChooseSourceIds = [];
|
64
|
var sc = new common.grid({
|
125
|
var sc = new common.grid({
|
65
|
el: "#basicTable",
|
126
|
el: "#basicTable",
|
66
|
parms: function() {
|
127
|
parms: function() {
|
|
@@ -71,8 +132,31 @@ var sc = new common.grid({ |
|
@@ -71,8 +132,31 @@ var sc = new common.grid({ |
71
|
},
|
132
|
},
|
72
|
columns: [
|
133
|
columns: [
|
73
|
{
|
134
|
{
|
|
|
135
|
+ display: '',
|
|
|
136
|
+ type: 'checkbox',
|
|
|
137
|
+ render: function (item) {
|
|
|
138
|
+ var htmlContent = "";
|
|
|
139
|
+ if(batchUnChooseSourceIds.length === 0 ){
|
|
|
140
|
+ htmlContent = "<input type='checkbox' class='wqt_checkbox' data-index='"+item.__index+"'>";
|
|
|
141
|
+ }else{
|
|
|
142
|
+ $.each(batchUnChooseSourceIds,function(n,value) {
|
|
|
143
|
+ if(item.sourceId == value){
|
|
|
144
|
+ htmlContent = "<input type='checkbox' checked='checked' class='wqt_checkbox' data-index='"+item.__index+"'>";
|
|
|
145
|
+ return false
|
|
|
146
|
+ }else{
|
|
|
147
|
+ htmlContent = "<input type='checkbox' class='wqt_checkbox' data-index='"+item.__index+"'>";
|
|
|
148
|
+ }
|
|
|
149
|
+ })
|
|
|
150
|
+ }
|
|
|
151
|
+ return htmlContent;
|
|
|
152
|
+ }
|
|
|
153
|
+ }, {
|
74
|
display: '资源位直通车id',
|
154
|
display: '资源位直通车id',
|
75
|
- name: 'sourceId'
|
155
|
+ name: 'sourceId',
|
|
|
156
|
+ render: function (item) {
|
|
|
157
|
+ pageUnChooseSourceIds.push(item.sourceId);
|
|
|
158
|
+ return item.sourceId;
|
|
|
159
|
+ }
|
76
|
},
|
160
|
},
|
77
|
{
|
161
|
{
|
78
|
display: '资源位直通车名称',
|
162
|
display: '资源位直通车名称',
|
|
@@ -92,24 +176,113 @@ var sc = new common.grid({ |
|
@@ -92,24 +176,113 @@ var sc = new common.grid({ |
92
|
render: function(item) {
|
176
|
render: function(item) {
|
93
|
return '<a class="btn btn-xs btn-warning close-btn" data-title="' + item.sourceName + '" _id="' + item.sourceId + '" href="javascript:;">取消选中</a>';
|
177
|
return '<a class="btn btn-xs btn-warning close-btn" data-title="' + item.sourceName + '" _id="' + item.sourceId + '" href="javascript:;">取消选中</a>';
|
94
|
}
|
178
|
}
|
95
|
- }]
|
179
|
+ }],
|
|
|
180
|
+ selectedCallback:function(item){
|
|
|
181
|
+ if($.inArray(item.sourceId, batchUnChooseSourceIds) === -1 ){
|
|
|
182
|
+ batchUnChooseSourceIds.push(item.sourceId);
|
|
|
183
|
+ batchUnChooseSourceNames.push(item.sourceName);
|
|
|
184
|
+ }
|
|
|
185
|
+ },
|
|
|
186
|
+ unselectedCallback:function(item){
|
|
|
187
|
+ var _index = $.inArray(item.sourceId, batchUnChooseSourceIds);
|
|
|
188
|
+ if(_index !== -1 ){
|
|
|
189
|
+ batchUnChooseSourceIds.splice(_index,1);
|
|
|
190
|
+ batchUnChooseSourceNames.splice(_index, 1);
|
|
|
191
|
+ }
|
|
|
192
|
+ },
|
|
|
193
|
+ complete:function(){
|
|
|
194
|
+ $.each(pageUnChooseSourceIds, function (i, pageItem) {
|
|
|
195
|
+ if($.inArray(pageItem, batchUnChooseSourceIds) == -1 ) {
|
|
|
196
|
+ $(".wqt_all").prop("checked", false);
|
|
|
197
|
+ return false;
|
|
|
198
|
+ }
|
|
|
199
|
+ $(".wqt_all").prop("checked", true);
|
|
|
200
|
+ });
|
|
|
201
|
+ pageUnChooseSourceIds = [];
|
|
|
202
|
+ }
|
96
|
});
|
203
|
});
|
97
|
|
204
|
|
98
|
-
|
|
|
99
|
$('input[name="state"]').on('change', function() {
|
205
|
$('input[name="state"]').on('change', function() {
|
100
|
$(this).parent().addClass('current').siblings().removeClass('current');
|
206
|
$(this).parent().addClass('current').siblings().removeClass('current');
|
101
|
var state = $('.state-select').find('.current').find('input').val();
|
207
|
var state = $('.state-select').find('.current').find('input').val();
|
102
|
if(state == 0){
|
208
|
if(state == 0){
|
|
|
209
|
+ batchChooseSourceIds = [];
|
|
|
210
|
+ batchChooseSourceNames = [];
|
103
|
$("#productSearchLabelSearch").show();
|
211
|
$("#productSearchLabelSearch").show();
|
104
|
- g.init('/categorySource/queryCategorySourceList');
|
212
|
+ $("#batchChoose-btn").show();
|
|
|
213
|
+ $("#batchUnChoose-btn").hide();
|
|
|
214
|
+ g.init('/categorySource/queryCategorySourceList');
|
105
|
}else if(state == 1){
|
215
|
}else if(state == 1){
|
106
|
$('#sourceName').setValue='';
|
216
|
$('#sourceName').setValue='';
|
|
|
217
|
+ batchUnChooseSourceIds = [];
|
|
|
218
|
+ batchUnChooseSourceNames = [];
|
107
|
$("#productSearchLabelSearch").hide();
|
219
|
$("#productSearchLabelSearch").hide();
|
|
|
220
|
+ $("#batchChoose-btn").hide();
|
|
|
221
|
+ $("#batchUnChoose-btn").show();
|
108
|
sc.init('/categorySource/queryCategorySourceList');
|
222
|
sc.init('/categorySource/queryCategorySourceList');
|
109
|
}
|
223
|
}
|
110
|
|
224
|
|
111
|
});
|
225
|
});
|
112
|
|
226
|
|
|
|
227
|
+$(document).on('click', '.batchChoose-btn', function(){
|
|
|
228
|
+ if(batchChooseSourceIds.length === 0){
|
|
|
229
|
+ common.util.__tip("未勾选任何直通车!", 'warning');
|
|
|
230
|
+ return false;
|
|
|
231
|
+ }
|
|
|
232
|
+ var content = "";
|
|
|
233
|
+ $.each(batchChooseSourceNames, function(i, item) {
|
|
|
234
|
+ var chooseName ="【" + item + "】";
|
|
|
235
|
+ content += "</br>";
|
|
|
236
|
+ content += chooseName;
|
|
|
237
|
+ });
|
|
|
238
|
+ common.dialog.confirm("温馨提示", "确定  <b><font color='#449d44'>选中 </font></b>以下直通车吗?<b>"+content+"</b>", function() {
|
|
|
239
|
+ var sourceIdList = batchChooseSourceIds;
|
|
|
240
|
+ common.util.__ajax({
|
|
|
241
|
+ url: '/categorySource/batchInsertCategorySourceLink',
|
|
|
242
|
+ data: {
|
|
|
243
|
+ sourceIdList: sourceIdList,
|
|
|
244
|
+ categoryId: getCategoryId()
|
|
|
245
|
+ }
|
|
|
246
|
+ }, function(res){
|
|
|
247
|
+ if (res.code == 200) {
|
|
|
248
|
+ g.reload();
|
|
|
249
|
+ }
|
|
|
250
|
+ })
|
|
|
251
|
+ });
|
|
|
252
|
+
|
|
|
253
|
+});
|
|
|
254
|
+
|
|
|
255
|
+
|
|
|
256
|
+//批量取消选中
|
|
|
257
|
+$(document).on('click', '.batchUnChoose-btn', function() {
|
|
|
258
|
+ if(batchUnChooseSourceIds.length === 0) {
|
|
|
259
|
+ common.util.__tip("未勾选任何直通车!", 'warning');
|
|
|
260
|
+ return false;
|
|
|
261
|
+ }
|
|
|
262
|
+ var content = "";
|
|
|
263
|
+ $.each(batchUnChooseSourceNames, function(i, item) {
|
|
|
264
|
+ var chooseName ="【" + item + "】";
|
|
|
265
|
+ content += "</br>";
|
|
|
266
|
+ content += chooseName;
|
|
|
267
|
+ });
|
|
|
268
|
+ common.dialog.confirm("温馨提示", "确定  <b><font color='#449d44'>取消选中 </font></b>以下直通车吗?<b>"+content+"</b>", function() {
|
|
|
269
|
+ var sourceIdList = batchUnChooseSourceIds;
|
|
|
270
|
+ common.util.__ajax({
|
|
|
271
|
+ url: '/categorySource/batchDeleteCategorySourceLink',
|
|
|
272
|
+ data: {
|
|
|
273
|
+ sourceIdList: sourceIdList,
|
|
|
274
|
+ categoryId: getCategoryId()
|
|
|
275
|
+ }
|
|
|
276
|
+ }, function(res){
|
|
|
277
|
+ if (res.code == 200) {
|
|
|
278
|
+ g.reload();
|
|
|
279
|
+ }
|
|
|
280
|
+ })
|
|
|
281
|
+ });
|
|
|
282
|
+});
|
|
|
283
|
+
|
|
|
284
|
+
|
|
|
285
|
+
|
113
|
$(document).on('click', '.open-btn', function() {
|
286
|
$(document).on('click', '.open-btn', function() {
|
114
|
var id = $(this).attr('_id');
|
287
|
var id = $(this).attr('_id');
|
115
|
common.dialog.confirm("温馨提示", "确定  <b><font color='#449d44'>选中 </font>【" + $(this).data('title') + "】</b> 吗?", function() {
|
288
|
common.dialog.confirm("温馨提示", "确定  <b><font color='#449d44'>选中 </font>【" + $(this).data('title') + "】</b> 吗?", function() {
|
|
@@ -121,6 +294,12 @@ $(document).on('click', '.open-btn', function() { |
|
@@ -121,6 +294,12 @@ $(document).on('click', '.open-btn', function() { |
121
|
}
|
294
|
}
|
122
|
}, function(res){
|
295
|
}, function(res){
|
123
|
if (res.code == 200) {
|
296
|
if (res.code == 200) {
|
|
|
297
|
+ var chooseId = parseInt(id);
|
|
|
298
|
+ var _index = $.inArray(chooseId, batchChooseSourceIds);
|
|
|
299
|
+ if(_index !== -1 ){
|
|
|
300
|
+ batchChooseSourceIds.splice(_index,1);
|
|
|
301
|
+ batchChooseSourceNames.splice(_index, 1);
|
|
|
302
|
+ }
|
124
|
g.reload();
|
303
|
g.reload();
|
125
|
}
|
304
|
}
|
126
|
})
|
305
|
})
|
|
@@ -139,6 +318,12 @@ $(document).on('click', '.close-btn', function() { |
|
@@ -139,6 +318,12 @@ $(document).on('click', '.close-btn', function() { |
139
|
}
|
318
|
}
|
140
|
}, function(res){
|
319
|
}, function(res){
|
141
|
if (res.code == 200) {
|
320
|
if (res.code == 200) {
|
|
|
321
|
+ var unChooseId = parseInt(id);
|
|
|
322
|
+ var _index = $.inArray(unChooseId, batchUnChooseSourceIds);
|
|
|
323
|
+ if(_index !== -1 ){
|
|
|
324
|
+ batchUnChooseSourceIds.splice(_index,1);
|
|
|
325
|
+ batchUnChooseSourceNames.splice(_index, 1);
|
|
|
326
|
+ }
|
142
|
sc.reload();
|
327
|
sc.reload();
|
143
|
}
|
328
|
}
|
144
|
})
|
329
|
})
|