|
@@ -5,13 +5,13 @@ const ProductType = {
|
|
|
@change="handleChange"
|
|
|
:change-on-select="changeOnSelect"
|
|
|
:value="defaultVal"
|
|
|
- expand-trigger="hover"
|
|
|
+ :expand-trigger="expandType"
|
|
|
:options="productTypeList"
|
|
|
:show-search="{ filter }"
|
|
|
:fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
|
|
|
:id="id"
|
|
|
placeholder="请选择产品分类"
|
|
|
- allowClear />
|
|
|
+ :allowClear="true"/>
|
|
|
`,
|
|
|
props: {
|
|
|
value: {
|
|
@@ -20,15 +20,19 @@ const ProductType = {
|
|
|
return []
|
|
|
}
|
|
|
},
|
|
|
+ expandType: {
|
|
|
+ type: String,
|
|
|
+ default: 'hover'
|
|
|
+ },
|
|
|
id: {
|
|
|
type: String,
|
|
|
default: ''
|
|
|
},
|
|
|
level: {
|
|
|
- type: [String,Number],
|
|
|
+ type: [String, Number],
|
|
|
default: ''
|
|
|
},
|
|
|
- changeOnSelect:{
|
|
|
+ changeOnSelect: {
|
|
|
type: Boolean,
|
|
|
default: true
|
|
|
}
|
|
@@ -48,25 +52,25 @@ const ProductType = {
|
|
|
this.getProductType()
|
|
|
},
|
|
|
methods: {
|
|
|
- filter(inputValue, path) {
|
|
|
+ filter (inputValue, path) {
|
|
|
console.log(inputValue, path)
|
|
|
- return path.some(option => option.productTypeName.indexOf(inputValue) > -1);
|
|
|
+ return path.some(option => option.productTypeName.indexOf(inputValue) > -1)
|
|
|
},
|
|
|
- setDefValue(defaultVal){
|
|
|
+ setDefValue (defaultVal) {
|
|
|
this.handleChange(defaultVal)
|
|
|
},
|
|
|
- handleChange (value,row) {
|
|
|
+ handleChange (value, row) {
|
|
|
this.defaultVal = value
|
|
|
- this.$emit('change', this.defaultVal, this.id,row)
|
|
|
+ this.$emit('change', this.defaultVal, this.id, row)
|
|
|
this.$emit('input', this.defaultVal)
|
|
|
},
|
|
|
// 产品分类列表
|
|
|
getProductType () {
|
|
|
productTypeQuery({}).then(res => {
|
|
|
if (res.status == 200) {
|
|
|
- if(this.level){
|
|
|
+ if (this.level) {
|
|
|
this.productTypeList = this.getBylevel(res.data)
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.productTypeList = res.data
|
|
|
}
|
|
|
} else {
|
|
@@ -74,23 +78,23 @@ const ProductType = {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- getBylevel(data){
|
|
|
+ getBylevel (data) {
|
|
|
const ret = []
|
|
|
// 显示一级分类
|
|
|
- if(this.level == 1){
|
|
|
+ if (this.level == 1) {
|
|
|
data.map(item => {
|
|
|
- if(item.children){
|
|
|
+ if (item.children) {
|
|
|
delete item.children
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
// 显示二级分类
|
|
|
- if(this.level == 2){
|
|
|
+ if (this.level == 2) {
|
|
|
data.map(item => {
|
|
|
- if(item.children){
|
|
|
+ if (item.children) {
|
|
|
item.children.map(cd => {
|
|
|
- if(cd.children){
|
|
|
- delete cd.children
|
|
|
+ if (cd.children) {
|
|
|
+ delete cd.children
|
|
|
}
|
|
|
})
|
|
|
}
|