|
@@ -2,7 +2,7 @@
|
|
|
<div>
|
|
|
<el-cascader
|
|
|
size="mini"
|
|
|
- :options="options"
|
|
|
+ :options="selectOption"
|
|
|
v-model="selectedOptions"
|
|
|
:props="{ checkStrictly: true }"
|
|
|
ref="area"
|
|
@@ -460,7 +460,6 @@ export default {
|
|
|
}
|
|
|
],
|
|
|
selectOption: [],
|
|
|
-
|
|
|
}
|
|
|
},
|
|
|
props: ['countyCode'],
|
|
@@ -468,16 +467,25 @@ export default {
|
|
|
handleChange(value) {
|
|
|
this.$emit('getCityCode', value);
|
|
|
},
|
|
|
- getFilter() {
|
|
|
- this.options.filter(product => {
|
|
|
- product.children.some(item => item.value === this.countyCode);
|
|
|
- }).map(product => product);
|
|
|
- console.log(this.options);
|
|
|
+ getFilter(list,target ) {
|
|
|
+ let childrenList = [];
|
|
|
+ const targetList = list.filter((item) => {
|
|
|
+ if (item.value == target) {
|
|
|
+ return true;
|
|
|
+ } else if (item.children && item.children.length) {
|
|
|
+ childrenList = childrenList.concat(this.getFilter(item.children, target));
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return targetList.concat(childrenList);
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
this.selectedOptions = [this.countyCode];
|
|
|
- this.getFilter();
|
|
|
+ this.selectOption = this.getFilter(this.options, this.countyCode);
|
|
|
+ // console.log(arr);
|
|
|
console.log(this.selectedOptions);
|
|
|
}
|
|
|
}
|