...
|
...
|
@@ -20,6 +20,13 @@ |
|
|
const _ = require('lodash');
|
|
|
const bus = require('common/vue-bus');
|
|
|
|
|
|
const typeMap = {
|
|
|
品牌: 'brand',
|
|
|
品类: 'group_sort',
|
|
|
颜色: 'color',
|
|
|
尺寸: 'size'
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
props: {
|
|
|
name: String,
|
...
|
...
|
@@ -75,21 +82,16 @@ module.exports = { |
|
|
this.chosenVal = names.join(',');
|
|
|
},
|
|
|
expandSub(name){
|
|
|
const typeMap = {
|
|
|
品牌: 'brand',
|
|
|
品类: 'group_sort',
|
|
|
颜色: 'color'
|
|
|
};
|
|
|
|
|
|
bus.$emit('expand.subFilter', typeMap[name]);
|
|
|
},
|
|
|
setAllChoices(){
|
|
|
let isLimited = false;
|
|
|
const len = this.choices.length;
|
|
|
const overCut = ['品牌', '品类', '颜色', '尺寸'];
|
|
|
|
|
|
this.allChoices = this.choices.slice();
|
|
|
this.initialChoices = this.choices.slice();
|
|
|
isLimited = ['品牌', '品类', '颜色'].indexOf(this.name) > -1;
|
|
|
isLimited = overCut.indexOf(this.name) > -1;
|
|
|
if (len > 11 && isLimited) {
|
|
|
this.showMore = true;
|
|
|
this.allChoices = this.choices.slice(0, 11);
|
...
|
...
|
@@ -108,6 +110,19 @@ module.exports = { |
|
|
},
|
|
|
foldExcept(name) {
|
|
|
this.show = this.name === name
|
|
|
},
|
|
|
subFilterChange(sub){
|
|
|
if (typeMap[this.name] === sub.subType) {
|
|
|
let names = [];
|
|
|
|
|
|
if (sub.value && sub.value.length) {
|
|
|
_.each(sub.value, item => {
|
|
|
names.push(item.name);
|
|
|
});
|
|
|
this.show = false;
|
|
|
this.chosenVal = names.join(',');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
created(){
|
...
|
...
|
@@ -115,6 +130,7 @@ module.exports = { |
|
|
bus.$on('chosenVal.clear', this.clearChosenVal);
|
|
|
bus.$on('chosenVal.search', this.searchChosenVal);
|
|
|
bus.$on('fold.choice.except', this.foldExcept);
|
|
|
bus.$on('subFilter.change', this.subFilterChange);
|
|
|
},
|
|
|
components: {}
|
|
|
};
|
...
|
...
|
|