全局搜索添加排序

This commit is contained in:
a0049873 2022-11-10 15:12:33 +08:00
parent f45b2c6331
commit 6abc05dcf6
1 changed files with 19 additions and 6 deletions

View File

@ -1179,18 +1179,31 @@
} }
getCountByFuzzyQuery(searchValue.value || '', flag).then((res) => { getCountByFuzzyQuery(searchValue.value || '', flag).then((res) => {
console.log('全局搜索==========》', res.data.data) console.log('全局搜索==========》', res.data.data)
const arr = []
const sortArr = [
'应用资源',
'组件服务',
'基础设施',
'数据资源',
'知识库',
]
globalData.data = res.data.data globalData.data = res.data.data
let mapFlag = true let mapFlag = true
res.data.data.map((val) => { res.data.data.map((val) => {
if (mapFlag && val.count != 0) { if (val.count != 0) {
mapFlag = false mapFlag = false
if (Cardsname.value === val.type) { arr.push(val.type)
getAppResources2()
} else {
changeCards(val.type)
}
} }
}) })
arr.sort((a, b) => {
return sortArr.indexOf(a) - sortArr.indexOf(b)
})
console.log('arr', arr)
if (Cardsname.value === arr[0]) {
getAppResources2()
} else {
changeCards(arr[0])
}
if (!mapFlag) { if (!mapFlag) {
return return
} }