|
|
@@ -19,15 +19,15 @@
|
|
|
</ul>
|
|
|
<ul v-if="emptyStatus && type == 'default' && keyword && keyword !== '' && showSimilarWord">
|
|
|
<template v-if="similarList.brand && similarList.brand.length && (similarType == 'all' || similarType == 'brand')">
|
|
|
- <li class="title text-ellipse">品牌</li>
|
|
|
+ <li class="title text-ellipse" v-if="similarType == 'all'">品牌</li>
|
|
|
<li class="text-ellipse" v-for="brand in similarList.brand.slice(0, 4)" @click="onSearch(brand.nameEn, 'brand', $event)">{{brand.nameEn}}</li>
|
|
|
</template>
|
|
|
<template v-if="similarList.kind && similarList.kind.length && (similarType == 'all' || similarType == 'kind')">
|
|
|
- <li class="title text-ellipse">类目(产品名称)</li>
|
|
|
+ <li class="title text-ellipse" v-if="similarType == 'all'">类目(产品名称)</li>
|
|
|
<li class="text-ellipse" v-for="kind in similarList.kind.slice(0, 4)" @click="onSearch(kind.nameCn, 'kind', $event)">{{kind.nameCn}}</li>
|
|
|
</template>
|
|
|
<template v-if="similarList.component && similarList.component.length && (similarType == 'all' || similarType == 'code')">
|
|
|
- <li class="title text-ellipse">型号</li>
|
|
|
+ <li class="title text-ellipse" v-if="similarType == 'all'">型号</li>
|
|
|
<li class="text-ellipse" v-for="code in similarList.component.slice(0, 4)" @click="onSearch(code.code, 'code', $event)">{{code.code}}</li>
|
|
|
</template>
|
|
|
</ul>
|
|
|
@@ -53,13 +53,17 @@
|
|
|
type: Boolean,
|
|
|
default: true
|
|
|
},
|
|
|
- outerKeyword: {
|
|
|
+ outerKeyword: { // 提示keyword
|
|
|
type: String,
|
|
|
default: ''
|
|
|
},
|
|
|
- similarType: {
|
|
|
+ similarType: { // 选择出现的联想词类型
|
|
|
type: String,
|
|
|
default: 'all'
|
|
|
+ },
|
|
|
+ useMatchRule: {
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
}
|
|
|
},
|
|
|
data () {
|
|
|
@@ -108,55 +112,55 @@
|
|
|
// if (key === this.searchKeyword || this.keyword === this.searchKeyword) {
|
|
|
// return
|
|
|
// }
|
|
|
- if (key) {
|
|
|
- this.keyword = key
|
|
|
+ if (key || !this.useMatchRule) {
|
|
|
+ this.keyword = key || this.keyword
|
|
|
this.$emit('searchAction', {
|
|
|
keyword: this.keyword,
|
|
|
type: type
|
|
|
})
|
|
|
} else {
|
|
|
let sType = null
|
|
|
- if (this.type === 'default' && this.keyword && this.keyword !== '' && this.similarList.component) {
|
|
|
- if (this.similarList.component[0] && this.keyword === this.similarList.component[0].code) {
|
|
|
- sType = 'code'
|
|
|
- } else if (this.similarList.brand[0] && this.keyword === this.similarList.brand[0].nameEn) {
|
|
|
+ if (this.type === 'default' && this.keyword && this.keyword !== '' && this.similarList.brand) { // 防止接口报错无法搜索
|
|
|
+ if (this.similarList.brand[0] && this.keyword === this.similarList.brand[0].nameEn) {
|
|
|
sType = 'brand'
|
|
|
} else if (this.similarList.kind[0] && this.keyword === this.similarList.kind[0].nameCn) {
|
|
|
sType = 'kind'
|
|
|
+ } else if (this.similarList.component[0] && this.keyword === this.similarList.component[0].code) {
|
|
|
+ sType = 'code'
|
|
|
} else {
|
|
|
- let arr = [...this.similarList.component, ...this.similarList.brand, ...this.similarList.kind]
|
|
|
+ let arr = [...this.similarList.brand, ...this.similarList.kind, ...this.similarList.component]
|
|
|
if (arr[0]) {
|
|
|
- if (arr[0].code) {
|
|
|
- this.keyword = arr[0].code
|
|
|
- sType = 'code'
|
|
|
- } else if (arr[0].nameEn) {
|
|
|
+ if (arr[0].nameEn) {
|
|
|
this.keyword = arr[0].nameEn
|
|
|
sType = 'brand'
|
|
|
} else if (arr[0].nameCn) {
|
|
|
this.keyword = arr[0].nameCn
|
|
|
sType = 'kind'
|
|
|
+ } else if (arr[0].code) {
|
|
|
+ this.keyword = arr[0].code
|
|
|
+ sType = 'code'
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- } else if (this.type === 'supplier' && this.keyword && this.keyword !== '' && this.similarList.pCmpCode) {
|
|
|
- if (this.similarList.pCmpCode[0] && this.keyword === this.similarList.pCmpCode[0].pCmpCode) {
|
|
|
- sType = 'pCmpCode'
|
|
|
- } else if (this.similarList.pBrandEn[0] && this.keyword === this.similarList.pBrandEn[0].nameEn) {
|
|
|
+ } else if (this.type === 'supplier' && this.keyword && this.keyword !== '' && this.similarList.pBrandEn) { // 防止接口报错无法搜索
|
|
|
+ if (this.similarList.pBrandEn[0] && this.keyword === this.similarList.pBrandEn[0].nameEn) {
|
|
|
sType = 'pBrandEn'
|
|
|
} else if (this.similarList.kind[0] && this.keyword === this.similarList.kind[0].kind) {
|
|
|
sType = 'kind'
|
|
|
+ } else if (this.similarList.pCmpCode[0] && this.keyword === this.similarList.pCmpCode[0].pCmpCode) {
|
|
|
+ sType = 'pCmpCode'
|
|
|
} else {
|
|
|
- let arr = [...this.similarList.pCmpCode, ...this.similarList.pBrandEn, ...this.similarList.kind]
|
|
|
+ let arr = [...this.similarList.pBrandEn, ...this.similarList.kind, ...this.similarList.pCmpCode]
|
|
|
if (arr[0]) {
|
|
|
- if (arr[0].pCmpCode) {
|
|
|
- this.keyword = arr[0].pCmpCode
|
|
|
- sType = 'pCmpCode'
|
|
|
- } else if (arr[0].nameEn) {
|
|
|
+ if (arr[0].nameEn) {
|
|
|
this.keyword = arr[0].nameEn
|
|
|
sType = 'pBrandEn'
|
|
|
} else if (arr[0].kind) {
|
|
|
this.keyword = arr[0].kind
|
|
|
sType = 'kind'
|
|
|
+ } else if (arr[0].pCmpCode) {
|
|
|
+ this.keyword = arr[0].pCmpCode
|
|
|
+ sType = 'pCmpCode'
|
|
|
}
|
|
|
}
|
|
|
}
|