NEZ-1514 feat:全局搜索功能
This commit is contained in:
@@ -14,14 +14,14 @@
|
|||||||
}
|
}
|
||||||
.global-search-box.search-after{
|
.global-search-box.search-after{
|
||||||
height: 82%;
|
height: 82%;
|
||||||
min-height: 894px;
|
min-height: 600px;
|
||||||
}
|
}
|
||||||
.global-search-box {
|
.global-search-box {
|
||||||
//background: $--background-color-empty;
|
//background: $--background-color-empty;
|
||||||
background: rgba(0,0,0,0);
|
background: rgba(0,0,0,0);
|
||||||
width: 80%;
|
width: 80%;
|
||||||
max-width: 1040px;
|
max-width: 1040px;
|
||||||
min-width: 894px;
|
min-width: 600px;
|
||||||
height: auto;
|
height: auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
height: 40px;
|
height: 40px;
|
||||||
line-height: 72px;
|
line-height: 72px;
|
||||||
color: $--color-text-regular;
|
color: $--color-text-regular;
|
||||||
|
padding-left: 0;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
.global-search-cancel{
|
.global-search-cancel{
|
||||||
@@ -118,7 +119,7 @@
|
|||||||
}
|
}
|
||||||
.is-jump{
|
.is-jump{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 20px;
|
right: 5px;
|
||||||
top: 20px;
|
top: 20px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
width: 24px;
|
width: 24px;
|
||||||
@@ -132,6 +133,10 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
padding-right: 30px;
|
||||||
|
.nz-icon {
|
||||||
|
margin-right: 15px;
|
||||||
|
}
|
||||||
.list-item-highlight{
|
.list-item-highlight{
|
||||||
background: none;
|
background: none;
|
||||||
color: $--color-primary;
|
color: $--color-primary;
|
||||||
@@ -142,7 +147,7 @@
|
|||||||
color: $--color-info;
|
color: $--color-info;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
padding-left: 40px;
|
padding-left: 55px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
@@ -207,3 +212,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.fz12{
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 60px 75px 0 75px;
|
padding: 60px 75px 0 75px;
|
||||||
|
.el-skeleton{
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
.search-item-title-icon{
|
.search-item-title-icon{
|
||||||
.nz-icon{
|
.nz-icon{
|
||||||
font-size: 32px;
|
font-size: 32px;
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ export default {
|
|||||||
immediate: true,
|
immediate: true,
|
||||||
deep: true,
|
deep: true,
|
||||||
handler (n) {
|
handler (n) {
|
||||||
console.log(n.fields)
|
|
||||||
n.fields.map(e => {
|
n.fields.map(e => {
|
||||||
if (e.name === 'time') {
|
if (e.name === 'time') {
|
||||||
e.value[0] = bus.timeFormate(e.value[0], this.timeFormatMain)
|
e.value[0] = bus.timeFormate(e.value[0], this.timeFormatMain)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<div class="global-search-box" :class="firstShow? '' : 'search-after'" @click.self="close">
|
<div class="global-search-box" :class="firstShow? '' : 'search-after'" @click.self="close">
|
||||||
<div class="global-search-input" :class="firstShow? '' : 'search-after'">
|
<div class="global-search-input" :class="firstShow? '' : 'search-after'">
|
||||||
<i class="nz-icon nz-icon-search" v-loading="loading"></i>
|
<i class="nz-icon nz-icon-search" v-loading="loading"></i>
|
||||||
<el-input v-model="searchStr" @input="searchAll" ref="searchStr" :placeholder="$t('globalSearch.placeholder')" clearable></el-input>
|
<el-input v-model="searchStr" @input="searchAll" ref="searchStr" :placeholder="$t('globalSearch.placeholder')" @keydown="inputKeydown" @keyup="inputKeydown" @keypress="inputKeydown" clearable></el-input>
|
||||||
<div @click="close" class="global-search-cancel">
|
<div @click="close" class="global-search-cancel">
|
||||||
Cancel
|
Cancel
|
||||||
</div>
|
</div>
|
||||||
@@ -49,6 +49,7 @@
|
|||||||
:key="index"
|
:key="index"
|
||||||
:ref="'item'+ index"
|
:ref="'item'+ index"
|
||||||
@mouseenter="changeSelectIndex(index)"
|
@mouseenter="changeSelectIndex(index)"
|
||||||
|
@click="jumpTo"
|
||||||
>
|
>
|
||||||
<div class="list-item-content">
|
<div class="list-item-content">
|
||||||
<i class="nz-icon" :class="selectIcon(item)" />
|
<i class="nz-icon" :class="selectIcon(item)" />
|
||||||
@@ -150,7 +151,7 @@ export default {
|
|||||||
// scope: ['asset', 'datacenter', 'project', 'module', 'endpoint', 'alertrule'],
|
// scope: ['asset', 'datacenter', 'project', 'module', 'endpoint', 'alertrule'],
|
||||||
scope: [
|
scope: [
|
||||||
{
|
{
|
||||||
type: 'asseet',
|
type: 'asset',
|
||||||
isSelect: true
|
isSelect: true
|
||||||
}, {
|
}, {
|
||||||
type: 'datacenter',
|
type: 'datacenter',
|
||||||
@@ -207,7 +208,7 @@ export default {
|
|||||||
selectIcon (item) {
|
selectIcon (item) {
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
case 'asset' : return 'nz-icon-overview-project'
|
case 'asset' : return 'nz-icon-overview-project'
|
||||||
case 'datacenter' : return 'nz-icon-model'
|
case 'datacenter' : return 'nz-icon-datacenter1'
|
||||||
case 'project' : return 'nz-icon-project'
|
case 'project' : return 'nz-icon-project'
|
||||||
case 'module' : return 'nz-icon-overview-module'
|
case 'module' : return 'nz-icon-overview-module'
|
||||||
case 'endpoint' : return 'nz-icon-overview-endpoint'
|
case 'endpoint' : return 'nz-icon-overview-endpoint'
|
||||||
@@ -249,6 +250,11 @@ export default {
|
|||||||
this.selectIndex = index
|
this.selectIndex = index
|
||||||
this.getItemInfo()
|
this.getItemInfo()
|
||||||
},
|
},
|
||||||
|
inputKeydown (e) {
|
||||||
|
if (e.keyCode === 40 || e.keyCode === 38) {
|
||||||
|
event.preventDefault()
|
||||||
|
}
|
||||||
|
},
|
||||||
keyDown (e) {
|
keyDown (e) {
|
||||||
if (this.jumpLoading) {
|
if (this.jumpLoading) {
|
||||||
return
|
return
|
||||||
@@ -299,6 +305,7 @@ export default {
|
|||||||
this.$get('/stat/rownum', params).then(res => {
|
this.$get('/stat/rownum', params).then(res => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
this.close()
|
this.close()
|
||||||
|
this.$store.commit('setGlobalSearchId', params.id)
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
path: routerPath.route,
|
path: routerPath.route,
|
||||||
query: {
|
query: {
|
||||||
@@ -307,6 +314,10 @@ export default {
|
|||||||
rownum: res.data.rownum
|
rownum: res.data.rownum
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if (routerPath.route === this.$route.path) {
|
||||||
|
this.$store.commit('setIsRouteLive')
|
||||||
|
// this.routeReload()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(res.msg)
|
this.$message.error(res.msg)
|
||||||
this.jumpLoading = false
|
this.jumpLoading = false
|
||||||
@@ -342,7 +353,7 @@ export default {
|
|||||||
getItemInfo () {
|
getItemInfo () {
|
||||||
this.obj = {}
|
this.obj = {}
|
||||||
},
|
},
|
||||||
searchAll () {
|
searchAll (e) {
|
||||||
// this.getSeverityData()
|
// this.getSeverityData()
|
||||||
if (this.searchTimer) {
|
if (this.searchTimer) {
|
||||||
clearInterval(this.searchTimer)
|
clearInterval(this.searchTimer)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
<span v-if="alertLabelData && alertLabelData.state === 'OFF'">{{ $t('overall.disabled') }}</span>
|
<span v-if="alertLabelData && alertLabelData.state === 'OFF'">{{ $t('overall.disabled') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="search-item-value-box" v-else>
|
<div class="search-item-value-box" v-else>
|
||||||
<i v-if="item.icon" class="nz-icon" :class="searchItemClass(item)" :style="searchItemStyle(item)"/>
|
<i v-if="item.icon&&getPathContent(item.key)!=='--'" class="nz-icon" :class="searchItemClass(item)" :style="searchItemStyle(item)"/>
|
||||||
<span class="search-item-value">
|
<span class="search-item-value">
|
||||||
{{getPathContent(item.key)}}
|
{{getPathContent(item.key)}}
|
||||||
</span>
|
</span>
|
||||||
@@ -122,7 +122,7 @@ export default {
|
|||||||
label: this.$t('overall.state')
|
label: this.$t('overall.state')
|
||||||
}, {
|
}, {
|
||||||
key: 'pingInfo.rtt',
|
key: 'pingInfo.rtt',
|
||||||
icon: 'active-icon',
|
icon: 'nz-icon nz-icon-circle fz12',
|
||||||
label: 'Ping'
|
label: 'Ping'
|
||||||
}, {
|
}, {
|
||||||
key: 'dc.name',
|
key: 'dc.name',
|
||||||
@@ -264,7 +264,7 @@ export default {
|
|||||||
key: 'severityId',
|
key: 'severityId',
|
||||||
label: this.$t('alert.severity'),
|
label: this.$t('alert.severity'),
|
||||||
color: this.severityColor,
|
color: this.severityColor,
|
||||||
icon: 'nz-icon nz-icon-circle'
|
icon: 'nz-icon nz-icon-circle fz12'
|
||||||
}, {
|
}, {
|
||||||
key: 'expr',
|
key: 'expr',
|
||||||
label: this.$t('alert.config.expr')
|
label: this.$t('alert.config.expr')
|
||||||
@@ -279,7 +279,7 @@ export default {
|
|||||||
}, {
|
}, {
|
||||||
key: 'state',
|
key: 'state',
|
||||||
label: this.$t('overall.state'),
|
label: this.$t('overall.state'),
|
||||||
icon: 'nz-icon nz-icon-circle'
|
icon: 'nz-icon nz-icon-circle fz12'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -365,7 +365,7 @@ export default {
|
|||||||
str += this.alertLabelData[item.key] ? 'red' : 'green'
|
str += this.alertLabelData[item.key] ? 'red' : 'green'
|
||||||
}
|
}
|
||||||
if (item.key === 'pingInfo.rtt') {
|
if (item.key === 'pingInfo.rtt') {
|
||||||
str += this.alertLabelData.pingInfo.status ? 'red-bg' : 'green-bg'
|
str += this.alertLabelData.pingInfo && this.alertLabelData.pingInfo.status ? 'red' : 'green'
|
||||||
}
|
}
|
||||||
if (item.key === 'state' && this.obj.type === 'alertrule') {
|
if (item.key === 'state' && this.obj.type === 'alertrule') {
|
||||||
str += !this.alertLabelData.state ? 'red' : 'green'
|
str += !this.alertLabelData.state ? 'red' : 'green'
|
||||||
@@ -391,8 +391,7 @@ export default {
|
|||||||
},
|
},
|
||||||
getPathContent (key) {
|
getPathContent (key) {
|
||||||
let str = lodash.get(this.alertLabelData, key, '--')
|
let str = lodash.get(this.alertLabelData, key, '--')
|
||||||
str += ''
|
if (key === 'pingInfo.rtt' && str && str !== '--') {
|
||||||
if (key === 'pingInfo.rtt' && str) {
|
|
||||||
str += ' ms'
|
str += ' ms'
|
||||||
}
|
}
|
||||||
if (key === 'type' && this.obj.type === 'alertrule') {
|
if (key === 'type' && this.obj.type === 'alertrule') {
|
||||||
|
|||||||
@@ -96,6 +96,23 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
tableData: {
|
||||||
|
immediate: true,
|
||||||
|
handler (n) {
|
||||||
|
if (n && n.length) {
|
||||||
|
const id = this.$store.getters.getGlobalSearchId
|
||||||
|
if (id) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (document.getElementById('globalSearch' + id)) {
|
||||||
|
document.getElementById('globalSearch' + id).scrollIntoView(true)
|
||||||
|
this.$store.commit('setGlobalSearchId', '')
|
||||||
|
}
|
||||||
|
}, 500)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// document.querySelector("#header").scrollIntoView(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -108,6 +108,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</template>
|
</template>
|
||||||
|
<span v-else-if="item.prop === 'id'" :id="'globalSearch' + scope.row.id">{{scope.row[item.prop]}}</span>
|
||||||
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
|
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
|
||||||
<template v-else>-</template>
|
<template v-else>-</template>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -103,6 +103,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<template v-else-if="item.prop === 'brand'">{{scope.row.brand ? scope.row.brand.name : '-'}}</template>
|
<template v-else-if="item.prop === 'brand'">{{scope.row.brand ? scope.row.brand.name : '-'}}</template>
|
||||||
<template v-else-if="item.prop === 'purchaseDate'">{{scope.row.purchaseDate ? scope.row.purchaseDate : '-'}}</template>
|
<template v-else-if="item.prop === 'purchaseDate'">{{scope.row.purchaseDate ? scope.row.purchaseDate : '-'}}</template>
|
||||||
|
<span v-else-if="item.prop === 'id'" :id="'globalSearch' + scope.row.id">{{scope.row[item.prop]}}</span>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<span v-if="scope.row.fields&&scope.row.fields.find(field => field.name === item.prop)">
|
<span v-if="scope.row.fields&&scope.row.fields.find(field => field.name === item.prop)">
|
||||||
{{scope.row.fields.find(field => field.name === item.prop).value.join(',')}}
|
{{scope.row.fields.find(field => field.name === item.prop).value.join(',')}}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@
|
|||||||
{{scope.row[item.prop]}}
|
{{scope.row[item.prop]}}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
<span v-else-if="item.prop === 'id'" :id="'globalSearch' + scope.row.id">{{scope.row[item.prop]}}</span>
|
||||||
<template v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</template>
|
<template v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</template>
|
||||||
<template v-else>-</template>
|
<template v-else>-</template>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -155,6 +155,7 @@
|
|||||||
<span v-if="scope.row[item.prop] === 1">{{$t('project.endpoint.enable')}}</span>
|
<span v-if="scope.row[item.prop] === 1">{{$t('project.endpoint.enable')}}</span>
|
||||||
<span v-else>{{$t('project.endpoint.disable')}}</span>
|
<span v-else>{{$t('project.endpoint.disable')}}</span>
|
||||||
</template>
|
</template>
|
||||||
|
<span v-else-if="item.prop === 'id'" :id="'globalSearch' + scope.row.id">{{scope.row[item.prop]}}</span>
|
||||||
<span v-else>{{scope.row[item.prop] ? scope.row[item.prop] : ''}}</span>
|
<span v-else>{{scope.row[item.prop] ? scope.row[item.prop] : ''}}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|||||||
@@ -56,6 +56,7 @@
|
|||||||
{{scope.row[item.prop]}}
|
{{scope.row[item.prop]}}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
<span v-else-if="item.prop === 'id'" :id="'globalSearch' + scope.row.id">{{scope.row[item.prop]}}</span>
|
||||||
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
|
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
|
||||||
<span v-else>-</span>
|
<span v-else>-</span>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
{{scope.row[item.prop]}}
|
{{scope.row[item.prop]}}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
<span v-else-if="item.prop === 'id'" :id="'globalSearch' + scope.row.id">{{scope.row[item.prop]}}</span>
|
||||||
<span v-else>{{scope.row[item.prop] ? scope.row[item.prop] : ''}}</span>
|
<span v-else>{{scope.row[item.prop] ? scope.row[item.prop] : ''}}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<router-view/>
|
<router-view v-if="isRouteLive"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'container',
|
name: 'container',
|
||||||
data () {
|
computed: {
|
||||||
return {
|
isRouteLive () {
|
||||||
|
return this.$store.getters.getIsRouteLive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,9 +41,14 @@ const store = new Vuex.Store({
|
|||||||
langList: [],
|
langList: [],
|
||||||
i18nReady: false,
|
i18nReady: false,
|
||||||
timeFormatMain: localStorage.getItem('nz-default-dateFormat') || 'YYYY-MM-DD HH:mm:ss',
|
timeFormatMain: localStorage.getItem('nz-default-dateFormat') || 'YYYY-MM-DD HH:mm:ss',
|
||||||
globalShow: false
|
globalShow: false,
|
||||||
|
globalSearchId: '',
|
||||||
|
isRouteLive: true
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
|
getGlobalSearchId (state) {
|
||||||
|
return state.globalSearchId
|
||||||
|
},
|
||||||
getTimeFormatMain (state) {
|
getTimeFormatMain (state) {
|
||||||
return state.timeFormatMain
|
return state.timeFormatMain
|
||||||
},
|
},
|
||||||
@@ -86,6 +91,9 @@ const store = new Vuex.Store({
|
|||||||
getLangList (state) {
|
getLangList (state) {
|
||||||
return state.langList
|
return state.langList
|
||||||
},
|
},
|
||||||
|
getIsRouteLive (state) {
|
||||||
|
return state.isRouteLive
|
||||||
|
},
|
||||||
i18nIsReady (state) {
|
i18nIsReady (state) {
|
||||||
return state.i18nReady
|
return state.i18nReady
|
||||||
}
|
}
|
||||||
@@ -98,7 +106,9 @@ const store = new Vuex.Store({
|
|||||||
currentProjectChange (state, project) {
|
currentProjectChange (state, project) {
|
||||||
state.currentProject = project
|
state.currentProject = project
|
||||||
},
|
},
|
||||||
|
setGlobalSearchId (state, id) {
|
||||||
|
state.globalSearchId = id
|
||||||
|
},
|
||||||
panelShowPanelChange (state, panel) { // 用来panel页控制初始panel的
|
panelShowPanelChange (state, panel) { // 用来panel页控制初始panel的
|
||||||
state.showPanel.id = panel.id
|
state.showPanel.id = panel.id
|
||||||
state.showPanel.name = panel.name
|
state.showPanel.name = panel.name
|
||||||
@@ -181,6 +191,12 @@ const store = new Vuex.Store({
|
|||||||
setGlobalShow (state, globalShow) {
|
setGlobalShow (state, globalShow) {
|
||||||
state.globalShow = globalShow
|
state.globalShow = globalShow
|
||||||
},
|
},
|
||||||
|
setIsRouteLive (state) {
|
||||||
|
state.isRouteLive = false
|
||||||
|
setTimeout(() => {
|
||||||
|
state.isRouteLive = true
|
||||||
|
})
|
||||||
|
},
|
||||||
i18nReady (state, ready) {
|
i18nReady (state, ready) {
|
||||||
state.i18nReady = ready
|
state.i18nReady = ready
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user