全局搜索

This commit is contained in:
a0049873 2022-08-15 14:48:53 +08:00
parent 91d3622d77
commit 5f3c8d3556
4 changed files with 244 additions and 87 deletions

View File

@ -2,7 +2,7 @@
* @Author: hisense.wuhongjian * @Author: hisense.wuhongjian
* @Date: 2022-04-01 19:19:40 * @Date: 2022-04-01 19:19:40
* @LastEditors: hisense.liangjunhua * @LastEditors: hisense.liangjunhua
* @LastEditTime: 2022-08-09 10:37:31 * @LastEditTime: 2022-08-13 14:54:04
* @Description: 告诉大家这是什么 * @Description: 告诉大家这是什么
*/ */
import request from '@/utils/request' import request from '@/utils/request'
@ -353,6 +353,14 @@ export function getIntegrationServicesList(params) {
params, params,
}) })
} }
//
export function getCountByFuzzyQuery(params) {
return request({
url: '/resource/getCountByFuzzyQuery?keyWorld=' + params,
method: 'get',
params,
})
}
// -- // --
export function getIntegrationDetail(id) { export function getIntegrationDetail(id) {

View File

@ -9,6 +9,37 @@
<detailsPageInfrastructureTree v-show="flag != '6'" /> <detailsPageInfrastructureTree v-show="flag != '6'" />
</div> </div>
<div class="top" v-if="Cardsname != '知识库' && Cardsname != '基础设施'"> <div class="top" v-if="Cardsname != '知识库' && Cardsname != '基础设施'">
<div class="resultListSearchInput-father">
<div class="resultListSearchInput-son">
模糊搜索
<a-input-search
v-model:value="searchValue"
placeholder="请输入关键词"
enter-button="搜索"
size="large"
@search="getAppResources2"
@change="onSearch"
class="resultListSearchInput"
/>
<button class="button-reset" @click="chongzhi()">重置</button>
<button
class="button-reset"
style="margin-left: 0.1rem"
@click="globalSearch()"
>
全局搜索
</button>
<button
v-if="Cardsname == '应用资源'"
class="button-reset"
@click="applyAll()"
style="margin-left: 0.1rem"
>
全部申请
</button>
<div class="hengxian" style="background: transparent"></div>
</div>
</div>
<div class="top-title"> <div class="top-title">
<div <div
v-for="item in titleName" v-for="item in titleName"
@ -23,31 +54,18 @@
backgroundSize: 'cover', backgroundSize: 'cover',
}" }"
></span> ></span>
<span>{{ item.name }}</span> <span v-if="globalData.data.length > 0">
</div> {{
</div> item.name +
<div class="resultListSearchInput-father"> '(' +
<div class="resultListSearchInput-son"> (globalData.data.filter((val) => val.type === item.name)[0]
模糊搜索 .count || '0') +
<a-input-search ')'
v-model:value="searchValue" }}
placeholder="请输入关键词" </span>
enter-button="搜索" <span v-else>
size="large" {{ item.name }}
@search="getAppResources" </span>
@change="onSearch"
class="resultListSearchInput"
/>
<button class="button-reset" @click="chongzhi()">重置</button>
<button
v-if="Cardsname == '应用资源'"
class="button-reset"
@click="applyAll()"
style="margin-left: 0.1rem"
>
全部申请
</button>
<div class="hengxian"></div>
</div> </div>
</div> </div>
<div class="top-content-father" :key="listKey"> <div class="top-content-father" :key="listKey">
@ -160,46 +178,7 @@
</div> </div>
</div> </div>
<div class="top" v-else-if="Cardsname === '基础设施'"> <div class="top" v-else-if="Cardsname === '基础设施'">
<div class="top-title"> <div class="resultListSearchInput-father">
<div
v-for="item in titleName"
:key="item.name"
:class="item.name === Cardsname ? 'sel' : ''"
@click="changeCards(item.name)"
>
<span
class="photo"
:style="{
backgroundImage: `url(${item.photo}) `,
backgroundSize: 'cover',
}"
></span>
<span>{{ item.name }}</span>
</div>
</div>
<div class="top-content-father">
<infrastructurePage @add="handleAdd" />
</div>
</div>
<div class="top" v-else>
<div class="top-title">
<div
v-for="item in titleName"
:key="item.name"
:class="item.name === Cardsname ? 'sel' : ''"
@click="changeCards(item.name)"
>
<span
class="photo"
:style="{
backgroundImage: `url(${item.photo}) `,
backgroundSize: 'cover',
}"
></span>
<span>{{ item.name }}</span>
</div>
</div>
<div class="resultListSearchInput-father" style="background: unset">
<div class="resultListSearchInput-son"> <div class="resultListSearchInput-son">
模糊搜索 模糊搜索
<a-input-search <a-input-search
@ -207,11 +186,107 @@
placeholder="请输入关键词" placeholder="请输入关键词"
enter-button="搜索" enter-button="搜索"
size="large" size="large"
@search="getAppResources" @search="getAppResources2"
@change="onSearch" @change="onSearch"
class="resultListSearchInput" class="resultListSearchInput"
/> />
<button class="button-reset" @click="chongzhi()">重置</button> <button class="button-reset" @click="chongzhi()">重置</button>
<button
class="button-reset"
style="margin-left: 0.1rem"
@click="globalSearch()"
>
全局搜索
</button>
<div class="hengxian" style="background: transparent"></div>
</div>
</div>
<div class="top-title">
<div
v-for="item in titleName"
:key="item.name"
:class="item.name === Cardsname ? 'sel' : ''"
@click="changeCards(item.name)"
>
<span
class="photo"
:style="{
backgroundImage: `url(${item.photo}) `,
backgroundSize: 'cover',
}"
></span>
<span v-if="globalData.data.length > 0">
{{
item.name +
'(' +
(globalData.data.filter((val) => val.type === item.name)[0]
.count || '0') +
')'
}}
</span>
<span v-else>
{{ item.name }}
</span>
</div>
</div>
<div class="top-content-father">
<infrastructurePage
ref="camera"
@add="handleAdd"
:searchValue="searchValue"
/>
</div>
</div>
<div class="top" v-else>
<div class="resultListSearchInput-father">
<div class="resultListSearchInput-son">
模糊搜索
<a-input-search
v-model:value="searchValue"
placeholder="请输入关键词"
enter-button="搜索"
size="large"
@search="getAppResources2"
@change="onSearch"
class="resultListSearchInput"
/>
<button class="button-reset" @click="chongzhi()">重置</button>
<button
class="button-reset"
style="margin-left: 0.1rem"
@click="globalSearch()"
>
全局搜索
</button>
<div class="hengxian" style="background: transparent"></div>
</div>
</div>
<div class="top-title">
<div
v-for="item in titleName"
:key="item.name"
:class="item.name === Cardsname ? 'sel' : ''"
@click="changeCards(item.name)"
>
<span
class="photo"
:style="{
backgroundImage: `url(${item.photo}) `,
backgroundSize: 'cover',
}"
></span>
<span v-if="globalData.data.length > 0">
{{
item.name +
'(' +
(globalData.data.filter((val) => val.type === item.name)[0]
.count || '0') +
')'
}}
</span>
<span v-else>
{{ item.name }}
</span>
</div> </div>
</div> </div>
<KnowledgeBase <KnowledgeBase
@ -421,7 +496,7 @@
</div> </div>
</div> </div>
<div class="top-content-father"> <div class="top-content-father">
<infrastructurePage /> <infrastructurePage ref="camera" :searchValue="searchValue" />
</div> </div>
</div> </div>
<div class="top" v-else> <div class="top" v-else>
@ -721,6 +796,7 @@
pageWithAttrs, pageWithAttrs,
getDataResource, getDataResource,
getIntegrationServicesList, getIntegrationServicesList,
getCountByFuzzyQuery,
} from '@/api/home.js' } from '@/api/home.js'
import { getSgcList } from '@/api/personalCenter' import { getSgcList } from '@/api/personalCenter'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
@ -866,10 +942,14 @@
} }
// //
const chongzhi = () => { const chongzhi = (flag) => {
loading.value = true loading.value = true
// //
if (!flag) {
searchValue.value = '' searchValue.value = ''
globalFlag.value = false
globalData.data = []
}
paramsGetResources.name = searchValue.value paramsGetResources.name = searchValue.value
// //
ListContent.records.forEach((val) => { ListContent.records.forEach((val) => {
@ -1009,9 +1089,45 @@
const resourceList = reactive({ data: [] }) const resourceList = reactive({ data: [] })
const videoList = reactive({ data: [] }) const videoList = reactive({ data: [] })
const resourceTotal = ref('') const resourceTotal = ref('')
//
const camera = ref(null)
const globalData = reactive({ data: [] })
const globalFlag = ref(false)
const globalSearch = () => {
if (searchValue.value) {
globalFlag.value = true
getCountByFuzzyQuery(searchValue.value || '').then((res) => {
console.log('全局搜索==========》', res.data.data)
globalData.data = res.data.data
if (paramsGetResources.type == '基础设施') {
console.log('camera1', camera.value)
camera.value.getCamera(true, searchValue.value)
} else {
getAppResources()
}
})
} else {
message.warning('全局搜索必须输入关键词!')
}
}
// //
const re = /^[0-9\u4E00-\u9FA5]*$/ const re = /^[0-9\u4E00-\u9FA5]*$/
const getAppResources2 = () => {
globalFlag.value = false
if (
whoShow1.value.itShowQingDao &&
paramsGetResources.type == '基础设施'
) {
console.log('camera2', camera)
camera.value.getCamera(true, searchValue.value)
} else {
getAppResources()
}
}
const getAppResources = (switchIndex) => { const getAppResources = (switchIndex) => {
if (!globalFlag.value) {
globalData.data = []
}
if (searchValue.value) { if (searchValue.value) {
let str = '' let str = ''
let r = null let r = null
@ -1308,7 +1424,11 @@
getNewList() getNewList()
if (!tecHnosphere && !appLiCation) { if (!tecHnosphere && !appLiCation) {
getAppResources() if (searchValue.value) {
globalSearch()
} else {
getAppResources2()
}
} }
}) })
// //
@ -1369,7 +1489,7 @@
) )
// router.currentRoute.value.query.select // router.currentRoute.value.query.select
tagFlag.value = false tagFlag.value = false
chongzhi() chongzhi(true)
getNewList() getNewList()
}) })
} }
@ -1428,6 +1548,7 @@
Cardsname, Cardsname,
getNewList, getNewList,
getAppResources, getAppResources,
getAppResources2,
chongzhi, chongzhi,
onSearch, onSearch,
onShowSizeChange, onShowSizeChange,
@ -1460,6 +1581,9 @@
abilitySquareFunction, abilitySquareFunction,
abilitySquareFunctionData, abilitySquareFunctionData,
showAbilitySquareNum, showAbilitySquareNum,
globalData,
globalSearch,
camera,
} }
}, },
components: { components: {
@ -1761,13 +1885,13 @@
.top-title { .top-title {
display: flex; display: flex;
justify-content: space-between; justify-content: space-around;
align-items: center; align-items: center;
font-size: 0.2rem; font-size: 0.2rem;
font-family: 'Alibaba PuHuiTi'; font-family: 'Alibaba PuHuiTi';
color: #000000; color: #000000;
line-height: 0.34rem; line-height: 0.34rem;
margin-bottom: 0.2rem;
.photo { .photo {
display: inline-block; display: inline-block;
height: 0.44rem; height: 0.44rem;
@ -1776,7 +1900,7 @@
} }
div { div {
margin: 0 0.2rem; // margin: 0 0.2rem;
padding: 0 0.1rem; padding: 0 0.1rem;
cursor: pointer; cursor: pointer;
display: flex; display: flex;

View File

@ -408,7 +408,7 @@
<!-- 右侧 --> <!-- 右侧 -->
<div class="contentRight"> <div class="contentRight">
<!-- 搜索@search="onSearch" --> <!-- 搜索@search="onSearch" -->
<div class="searchInput"> <div class="searchInput" v-if="isXiHaiAn">
<a-input-search <a-input-search
v-model:value="mapSearchParam.cameraName" v-model:value="mapSearchParam.cameraName"
placeholder="请输入关键词" placeholder="请输入关键词"
@ -619,9 +619,11 @@
ref, ref,
reactive, reactive,
onMounted, onMounted,
defineProps,
watch, watch,
defineComponent, defineComponent,
nextTick, nextTick,
defineExpose,
} from 'vue' } from 'vue'
import { import {
getCameraByParentId, getCameraByParentId,
@ -639,6 +641,10 @@
import mybus from '@/myplugins/mybus' import mybus from '@/myplugins/mybus'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { Form } from 'ant-design-vue' import { Form } from 'ant-design-vue'
const props = defineProps({
//
searchValue: { type: String, default: '' },
})
const current = ref(1) const current = ref(1)
const videoTotal = ref(0) const videoTotal = ref(0)
const router = useRouter() const router = useRouter()
@ -789,6 +795,13 @@
const roomModalCreateTime = ref('') const roomModalCreateTime = ref('')
const roomModalEndTime = ref('') const roomModalEndTime = ref('')
const lookData = ref({}) const lookData = ref({})
// console.log('', props.searchValue)
if (props.searchValue) {
// console.log('')
// eslint-disable-next-line vue/no-setup-props-destructure
mapSearchParam.value.cameraName = props.searchValue
}
//=========================== //===========================
onMounted(() => { onMounted(() => {
if (jcssType.value) { if (jcssType.value) {
@ -1369,7 +1382,11 @@
// console.log('') // console.log('')
// } // }
const wrjFlag = ref(false) const wrjFlag = ref(false)
const getCamera = () => { const getCamera = (flag, str) => {
if (flag) {
mapSearchParam.value.cameraName = str
console.log('赋值===============》', str, mapSearchParam.value)
}
console.log('初始化调用') console.log('初始化调用')
console.log('不选左侧树的时候不调用接口', mapSearchParam.value) console.log('不选左侧树的时候不调用接口', mapSearchParam.value)
if (!whoShow1.value.itShowXiHaiAn) { if (!whoShow1.value.itShowXiHaiAn) {
@ -1419,6 +1436,9 @@
}) })
} }
} }
defineExpose({
getCamera,
})
// //
const addShoppingCart = () => { const addShoppingCart = () => {
if (selectedList.value.length > 0) { if (selectedList.value.length > 0) {

View File

@ -2,14 +2,14 @@
<div class="navigation"> <div class="navigation">
<div class="main" v-if="qeihuan"> <div class="main" v-if="qeihuan">
<div class="top"> <div class="top">
<span <!-- <span
v-for="name in topList" v-for="name in topList"
:key="name" :key="name"
:class="name == select ? 'select' : ''" :class="name == select ? 'select' : ''"
@click="changeCard(name)" @click="changeCard(name)"
> >
{{ name }} {{ name }}
</span> </span> -->
</div> </div>
<div class="bottom"> <div class="bottom">
<a-input-search <a-input-search
@ -154,6 +154,7 @@
import { ref } from 'vue' import { ref } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useStore } from 'vuex' import { useStore } from 'vuex'
import { message } from 'ant-design-vue'
const store = useStore() const store = useStore()
const router = useRouter() const router = useRouter()
const topList = ref([ const topList = ref([
@ -279,6 +280,7 @@
} }
const mohuchaxun = ref('组件服务') const mohuchaxun = ref('组件服务')
function onSearch() { function onSearch() {
if (text.value) {
snum.value.str = text.value snum.value.str = text.value
console.log('===================>', text.value) console.log('===================>', text.value)
store.commit('home/selectCardsData', snum.value) store.commit('home/selectCardsData', snum.value)
@ -286,6 +288,9 @@
path: '/DetailsPageconetent', path: '/DetailsPageconetent',
query: snum.value, query: snum.value,
}) })
} else {
message.warning('请输入查询内容!')
}
// router.push({ path: '/DetailsPageconetent' }) // router.push({ path: '/DetailsPageconetent' })
} }
</script> </script>
@ -303,7 +308,7 @@
.main { .main {
width: 8.8rem; width: 8.8rem;
height: 1.48rem; height: 1.48rem;
background: rgba(255, 255, 255, 0.18); // background: rgba(255, 255, 255, 0.18);
padding: 0.2rem 0.4rem; padding: 0.2rem 0.4rem;
border-radius: 0.02rem; border-radius: 0.02rem;
.top { .top {