|
@@ -38,11 +38,19 @@ module.exports = { |
|
@@ -38,11 +38,19 @@ module.exports = { |
38
|
return {
|
38
|
return {
|
39
|
chosenVal: '',
|
39
|
chosenVal: '',
|
40
|
show: false,
|
40
|
show: false,
|
41
|
- chosen: {},
|
41
|
+ chosen: [],
|
42
|
choiceName: '品牌',
|
42
|
choiceName: '品牌',
|
43
|
showMore: false,
|
43
|
showMore: false,
|
44
|
allChoices: [],
|
44
|
allChoices: [],
|
45
|
- initialChoices: []
|
45
|
+ initialChoices: [],
|
|
|
46
|
+ isGs: '',
|
|
|
47
|
+ gsFilter: null,
|
|
|
48
|
+ secondSort: []
|
|
|
49
|
+ }
|
|
|
50
|
+ },
|
|
|
51
|
+ computed: {
|
|
|
52
|
+ isGs() {
|
|
|
53
|
+ return typeMap[this.name] === 'group_sort';
|
46
|
}
|
54
|
}
|
47
|
},
|
55
|
},
|
48
|
methods: {
|
56
|
methods: {
|
|
@@ -55,21 +63,53 @@ module.exports = { |
|
@@ -55,21 +63,53 @@ module.exports = { |
55
|
bus.$emit('expand.choice.only', this.name);
|
63
|
bus.$emit('expand.choice.only', this.name);
|
56
|
},
|
64
|
},
|
57
|
toggleChoice(index, choice) {
|
65
|
toggleChoice(index, choice) {
|
58
|
- const newChoice = {
|
|
|
59
|
- id: choice.id,
|
|
|
60
|
- name: choice.name,
|
|
|
61
|
- isChosen: !choice.isChosen,
|
|
|
62
|
- category_name: choice.category_name,
|
|
|
63
|
- relation_parameter: choice.relation_parameter
|
|
|
64
|
- };
|
|
|
65
|
-
|
|
|
66
|
- this.allChoices.$set(index, newChoice);
|
|
|
67
|
- !newChoice.isChosen && (delete this.chosen[index]);
|
|
|
68
|
- newChoice.isChosen && (this.chosen[index] = newChoice);
|
66
|
+ let change;
|
|
|
67
|
+
|
|
|
68
|
+ this.isGs && this.delSecondSort(choice);
|
|
|
69
|
+ if (this.isGs) {
|
|
|
70
|
+ change = {
|
|
|
71
|
+ isChosen: !choice.isChosen,
|
|
|
72
|
+ category_name: choice.category_name,
|
|
|
73
|
+ relation_parameter: choice.relation_parameter
|
|
|
74
|
+ };
|
|
|
75
|
+ } else {
|
|
|
76
|
+ change = {
|
|
|
77
|
+ id: choice.id,
|
|
|
78
|
+ name: choice.name,
|
|
|
79
|
+ isChosen: !choice.isChosen
|
|
|
80
|
+ };
|
|
|
81
|
+ }
|
|
|
82
|
+
|
|
|
83
|
+ this.allChoices.$set(index, change);
|
|
|
84
|
+
|
|
|
85
|
+ if (!change.isChosen) {
|
|
|
86
|
+ let id1, id2;
|
|
|
87
|
+
|
|
|
88
|
+ _.each(this.chosen, (ch, idx) => {
|
|
|
89
|
+ id1 = this.isGs ? ch.relation_parameter.sort : ch.id;
|
|
|
90
|
+ id2 = this.isGs ? choice.relation_parameter.sort : choice.id;
|
|
|
91
|
+
|
|
|
92
|
+ if (id1 === id2) {
|
|
|
93
|
+ this.chosen.splice(idx, 1);
|
|
|
94
|
+ return false;
|
|
|
95
|
+ }
|
|
|
96
|
+ });
|
|
|
97
|
+ } else {
|
|
|
98
|
+ this.chosen.push(change);
|
|
|
99
|
+ }
|
69
|
|
100
|
|
70
|
this.calcChosenStr();
|
101
|
this.calcChosenStr();
|
71
|
bus.$emit('subChosen.change', typeMap[this.name], this.chosen);
|
102
|
bus.$emit('subChosen.change', typeMap[this.name], this.chosen);
|
72
|
},
|
103
|
},
|
|
|
104
|
+ delSecondSort(){
|
|
|
105
|
+ if (this.chosen.length && this.secondSort.length) { // 选择三级分类时排除所有二级分类
|
|
|
106
|
+ _.each(this.chosen, (item, index) => {
|
|
|
107
|
+ if (this.secondSort.indexOf(item.relation_parameter.sort) > -1) {
|
|
|
108
|
+ this.chosen = this.chosen.splice(index, 1);
|
|
|
109
|
+ }
|
|
|
110
|
+ });
|
|
|
111
|
+ }
|
|
|
112
|
+ },
|
73
|
calcChosenStr(){
|
113
|
calcChosenStr(){
|
74
|
let name;
|
114
|
let name;
|
75
|
let names = [];
|
115
|
let names = [];
|
|
@@ -113,7 +153,7 @@ module.exports = { |
|
@@ -113,7 +153,7 @@ module.exports = { |
113
|
foldExcept(name) {
|
153
|
foldExcept(name) {
|
114
|
this.show = this.name === name;
|
154
|
this.show = this.name === name;
|
115
|
},
|
155
|
},
|
116
|
- subFilterChange(sub){
|
156
|
+ subFilterChange(sub, filter){
|
117
|
if (typeMap[this.name] === sub.subType) {
|
157
|
if (typeMap[this.name] === sub.subType) {
|
118
|
let names = [];
|
158
|
let names = [];
|
119
|
const len = sub.value.length;
|
159
|
const len = sub.value.length;
|
|
@@ -124,6 +164,12 @@ module.exports = { |
|
@@ -124,6 +164,12 @@ module.exports = { |
124
|
} else {
|
164
|
} else {
|
125
|
const gs = sub.subType === 'group_sort';
|
165
|
const gs = sub.subType === 'group_sort';
|
126
|
|
166
|
|
|
|
167
|
+ // 所有品类信息
|
|
|
168
|
+ // 用于选择三级分类的时候清除非三级分类
|
|
|
169
|
+ if (gs && !this.gsFilter) {
|
|
|
170
|
+ this.calcSecondSort(filter);
|
|
|
171
|
+ }
|
|
|
172
|
+
|
127
|
this.chosen = [];
|
173
|
this.chosen = [];
|
128
|
this.allChoices = this.initialChoices.slice();
|
174
|
this.allChoices = this.initialChoices.slice();
|
129
|
_.each(sub.value, (item, index) => {
|
175
|
_.each(sub.value, (item, index) => {
|
|
@@ -162,7 +208,7 @@ module.exports = { |
|
@@ -162,7 +208,7 @@ module.exports = { |
162
|
item.category_name = item.name;
|
208
|
item.category_name = item.name;
|
163
|
}
|
209
|
}
|
164
|
|
210
|
|
165
|
- this.chosen[index] = item;
|
211
|
+ this.chosen.push(item);
|
166
|
});
|
212
|
});
|
167
|
this.chosenVal = names.join(',');
|
213
|
this.chosenVal = names.join(',');
|
168
|
}
|
214
|
}
|
|
@@ -170,6 +216,15 @@ module.exports = { |
|
@@ -170,6 +216,15 @@ module.exports = { |
170
|
this.show = false;
|
216
|
this.show = false;
|
171
|
bus.$emit('subChosen.change', typeMap[this.name], this.chosen);
|
217
|
bus.$emit('subChosen.change', typeMap[this.name], this.chosen);
|
172
|
}
|
218
|
}
|
|
|
219
|
+ },
|
|
|
220
|
+ calcSecondSort(filter){
|
|
|
221
|
+ _.each(filter, item => {
|
|
|
222
|
+ let idArr = [];
|
|
|
223
|
+ _.each(item.sub, subItm => {
|
|
|
224
|
+ idArr.push(subItm.relation_parameter.sort);
|
|
|
225
|
+ });
|
|
|
226
|
+ this.secondSort.push(idArr.join(','));
|
|
|
227
|
+ });
|
173
|
}
|
228
|
}
|
174
|
},
|
229
|
},
|
175
|
created(){
|
230
|
created(){
|