|
@@ -7,6 +7,7 @@ const ProductType = {
|
|
|
:value="defaultVal"
|
|
|
expand-trigger="hover"
|
|
|
:options="productTypeList"
|
|
|
+ :show-search="{ filter }"
|
|
|
:fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
|
|
|
:id="id"
|
|
|
placeholder="请选择产品分类"
|
|
@@ -22,7 +23,11 @@ const ProductType = {
|
|
|
id: {
|
|
|
type: String,
|
|
|
default: ''
|
|
|
- }
|
|
|
+ },
|
|
|
+ level: {
|
|
|
+ type: [String,Number],
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
@@ -39,6 +44,10 @@ const ProductType = {
|
|
|
this.getProductType()
|
|
|
},
|
|
|
methods: {
|
|
|
+ filter(inputValue, path) {
|
|
|
+ console.log(inputValue, path)
|
|
|
+ return path.some(option => option.productTypeName.indexOf(inputValue) > -1);
|
|
|
+ },
|
|
|
setDefValue(defaultVal){
|
|
|
this.handleChange(defaultVal)
|
|
|
},
|
|
@@ -51,11 +60,39 @@ const ProductType = {
|
|
|
getProductType () {
|
|
|
productTypeQuery({}).then(res => {
|
|
|
if (res.status == 200) {
|
|
|
- this.productTypeList = res.data
|
|
|
+ if(this.level){
|
|
|
+ this.productTypeList = this.getBylevel(res.data)
|
|
|
+ }else{
|
|
|
+ this.productTypeList = res.data
|
|
|
+ }
|
|
|
} else {
|
|
|
this.productTypeList = []
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+ getBylevel(data){
|
|
|
+ const ret = []
|
|
|
+ // 显示一级分类
|
|
|
+ if(this.level == 1){
|
|
|
+ data.map(item => {
|
|
|
+ if(item.children){
|
|
|
+ delete item.children
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 显示二级分类
|
|
|
+ if(this.level == 2){
|
|
|
+ data.map(item => {
|
|
|
+ if(item.children){
|
|
|
+ item.children.map(cd => {
|
|
|
+ if(cd.children){
|
|
|
+ delete cd.children
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return data
|
|
|
}
|
|
|
}
|
|
|
}
|