fix: 修复实体搜索切换页码不高亮,以及多个搜索关键字拼接为一个字段时不高亮等问题

This commit is contained in:
刘洪洪
2023-11-10 18:15:33 +08:00
parent 360fffde68
commit 2f919d1774
4 changed files with 32 additions and 18 deletions

View File

@@ -424,19 +424,21 @@ export default {
},
pageSize (val) {
this.pageObj.pageSize = val
const keywordList = this.getKeywordListByMetaList(this.metaList)
if (this.initFlag) {
if (val !== 20) {
this.search({ metaList: this.metaList, q: this.q })
this.search({ metaList: this.metaList, q: this.q, keywordList: keywordList })
}
} else {
this.search({ metaList: this.metaList, q: this.q })
this.search({ metaList: this.metaList, q: this.q, keywordList: keywordList })
}
},
pageNo (val) {
if (!this.initFlag) {
this.pageObj.pageNo = val
this.pageObj.resetPageNo = false
this.search({ metaList: this.metaList, q: this.q })
const keywordList = this.getKeywordListByMetaList(this.metaList)
this.search({ metaList: this.metaList, q: this.q, keywordList: keywordList })
}
},
// 点击上一页箭头
@@ -683,14 +685,7 @@ export default {
}
const parser = new Parser(columnList)
const metaList = parser.parseStr(_.cloneDeep(str)).metaList
const keywordList = []
metaList.forEach(item => {
if (item.column && item.column.type === columnType.fullText) {
keywordList.push({ type: item.column.type, value: item.column.label })
} else if (item.column && item.column.type === columnType.string) {
keywordList.push({ type: item.column.type, value: item.value.value })
}
})
const keywordList = this.getKeywordListByMetaList(metaList)
const keyInfo = parser.comparedEntityKey(parser.handleEntityTypeByStr(str))
if (keyInfo.isKey) {
const errorList = parser.validateStr(keyInfo.key)
@@ -744,6 +739,19 @@ export default {
}).finally(() => {
})
},
getKeywordListByMetaList (metaList) {
if (metaList) {
const keywordList = []
metaList.forEach(item => {
if (item.column && item.column.type === columnType.fullText) {
keywordList.push({ type: item.column.type, value: item.column.label })
} else if (item.column && item.column.type === columnType.string) {
keywordList.push({ type: item.column.type, value: item.value.value })
}
})
return keywordList
}
},
getKeyword (list) {
if (list) {
const metaList = JSON.parse(JSON.stringify(list))
@@ -773,7 +781,6 @@ export default {
}
},
mounted () {
this.getEntityIndexData()
let { q, listMode } = this.$route.query
// 如果地址栏有listMode即列表页并非首页则开始搜索
@@ -788,6 +795,9 @@ export default {
if (q) {
str1 = q.substring(q.indexOf('%'), q.indexOf('%') + 3)
}
if (q.indexOf('+') > -1) {
q = q.replace('+', '')
}
if (q && q.indexOf('%') > 0 && (str1 !== '%20' || str1 === '%25')) {
q = decodeURI(q)
}
@@ -797,6 +807,10 @@ export default {
this.$store.commit('resetScoreBase')
this.queryScoreBase()
}
if (!this.showList) {
this.getEntityIndexData()
}
},
watch: {
timeFilter () {

View File

@@ -35,7 +35,7 @@
<div class="basic-info__item">
<i class="cn-icon cn-icon-position"></i>
<span class="row-item-label">{{ $t('overall.city') }}&nbsp;:&nbsp;&nbsp;</span>
<span class="row-item-value" v-high-light="keywordList">{{ entityData.location ? ipLocationRegion(entityData.location) : '-' }}</span>
<span class="row-item-value high-location" v-high-light="keywordList">{{ entityData.location ? ipLocationRegion(entityData.location) : '-' }}</span>
</div>
<div class="basic-info__item">
<i class="cn-icon cn-icon-cloud"></i>
@@ -176,7 +176,7 @@
<el-collapse-transition>
<div class="cn-entity__detail-overview" v-if="!isCollapse">
<el-divider></el-divider>
<detail-overview :entity="entityData" :time-filter="timeFilter" :key-word-list="keywordList" @reloadEntity="getEntity" />
<detail-overview :entity="entityData" :time-filter="timeFilter" :keywordList="keywordList" @reloadEntity="getEntity" />
</div>
</el-collapse-transition>
</div>

View File

@@ -10,7 +10,7 @@
<img v-if="entity.location.country===countryNameIdMapping.Unknown || !countryNameIdMapping[entity.location.country]" src="../../../../../public/images/flag/Unknown.svg" class="filter-country-flag">
<img v-else :src="require(`../../../../../public/images/flag/${countryNameIdMapping[entity.location.country]}.png`)" class="filter-country-flag" >
</div>
<span v-high-light="keywordList">{{ ipLocationRegion(entity.location) }}</span>
<span v-high-light="keywordList" class="high-location">{{ ipLocationRegion(entity.location) }}</span>
</div>
<div v-else>-</div>
</div>
@@ -21,7 +21,7 @@
</div>
<div class="overview__row">
<div class="row__label row__label--width130">{{$t('entities.openPort')}}</div>
<div class="row__content" style="word-break: break-word;" v-high-light="keywordList">{{ openPort }}</div>
<div class="row__content high-location" style="word-break: break-word;" v-high-light="keywordList">{{ openPort }}</div>
</div>
</div>
</div>