NEZ-1514 feat:全局搜索功能(90%)

This commit is contained in:
zhangyu
2022-01-17 14:25:39 +08:00
parent dd5300d5a1
commit 44002bf222
12 changed files with 145 additions and 21 deletions

View File

@@ -96,6 +96,7 @@
} }
.list-item{ .list-item{
height: 64px; height: 64px;
position: relative;
display: flex; display: flex;
align-items: center; align-items: center;
flex-direction: column; flex-direction: column;
@@ -115,6 +116,18 @@
vertical-align: middle vertical-align: middle
} }
} }
.is-jump{
position: absolute;
right: 20px;
top: 20px;
padding: 0;
width: 24px;
height: 24px;
display: none;
.el-loading-mask{
transform: scale(0.5);
}
}
.list-item-content{ .list-item-content{
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;
@@ -137,6 +150,9 @@
} }
.lise-item-active { .lise-item-active {
background: $--table-row-hover-background-color; background: $--table-row-hover-background-color;
.is-jump{
display: inline-block;
}
} }
} }
.global-search-footer { .global-search-footer {

View File

@@ -43,7 +43,7 @@
display: flex; display: flex;
height: 47px; height: 47px;
.search-item-key{ .search-item-key{
width: 100px; width: 120px;
font-size: 14px; font-size: 14px;
line-height: 47px; line-height: 47px;
color:$--color-text-regular; color:$--color-text-regular;
@@ -52,12 +52,15 @@
} }
.search-item-value-box{ .search-item-value-box{
line-height: 47px; line-height: 47px;
width: calc(100% - 100px); width: calc(100% - 120px);
display: flex; display: flex;
.nz-icon{ .nz-icon{
line-height: 47px; line-height: 47px;
margin-right: 10px; margin-right: 10px;
} }
.nz-icon-guzhangshuju{
color: $--color-primary;
}
.search-item-value{ .search-item-value{
width: calc(100% - 30px); width: calc(100% - 30px);
font-size: 14px; font-size: 14px;

View File

@@ -260,11 +260,8 @@ export default {
layoutUpdate () { layoutUpdate () {
if (this.layout !== undefined && this.originalLayout !== null) { if (this.layout !== undefined && this.originalLayout !== null) {
if (this.layout.length !== this.originalLayout.length) { if (this.layout.length !== this.originalLayout.length) {
// console.log("### LAYOUT UPDATE!", this.layout.length, this.originalLayout.length);
const diff = this.findDifference(this.layout, this.originalLayout) const diff = this.findDifference(this.layout, this.originalLayout)
if (diff.length > 0) { if (diff.length > 0) {
// console.log(diff);
if (this.layout.length > this.originalLayout.length) { if (this.layout.length > this.originalLayout.length) {
this.originalLayout = this.originalLayout.concat(diff) this.originalLayout = this.originalLayout.concat(diff)
} else { } else {

View File

@@ -219,7 +219,6 @@ export default {
}, },
changeGroupHeight (copyList, group, flag) { changeGroupHeight (copyList, group, flag) {
const height = getGroupHeight(copyList) const height = getGroupHeight(copyList)
// console.log(this.$refs.layout)
const groupFind = this.copyDataList.find(item => item.id == group.id) const groupFind = this.copyDataList.find(item => item.id == group.id)
if (group && groupFind) { if (group && groupFind) {
groupFind.height = groupFind.h = height + this.headerHPadding groupFind.height = groupFind.h = height + this.headerHPadding
@@ -279,7 +278,6 @@ export default {
panelId: this.panelId, panelId: this.panelId,
charts: charts charts: charts
} }
// console.log(this.copyDataList)
this.$put('/visual/panel/chart/weights', params).then(() => { this.$put('/visual/panel/chart/weights', params).then(() => {
const position = getLayoutPosition(this.copyDataList) const position = getLayoutPosition(this.copyDataList)
this.$store.commit('setChartLastPosition', position) this.$store.commit('setChartLastPosition', position)

View File

@@ -1748,7 +1748,6 @@ export default {
imgArr.push({ ...item }) imgArr.push({ ...item })
}) })
Promise.all(promiseArr).then((res2, header) => { Promise.all(promiseArr).then((res2, header) => {
// console.log(res2)
this.iconArray = [...res.data.list] this.iconArray = [...res.data.list]
this.iconArray.forEach((item, index) => { this.iconArray.forEach((item, index) => {
item.image = res2[index].data item.image = res2[index].data

View File

@@ -57,6 +57,9 @@
<div class="list-item-sub" v-if="item.sub"> <div class="list-item-sub" v-if="item.sub">
{{ item.sub }} {{ item.sub }}
</div> </div>
<div class="is-jump" v-loading="jumpLoading">
<i class="nz-icon nz-icon-huiche"></i>
</div>
</li> </li>
<li class="list-item" v-if="nextLoading" v-loading="nextLoading"></li> <li class="list-item" v-if="nextLoading" v-loading="nextLoading"></li>
<!-- <li class="list-item" v-if="noMore&&!nextLoading">没有更多了</li>--> <!-- <li class="list-item" v-if="noMore&&!nextLoading">没有更多了</li>-->
@@ -133,6 +136,7 @@ export default {
searchStr: '', searchStr: '',
loading: false, loading: false,
nextLoading: false, nextLoading: false,
jumpLoading: false,
selectIndex: '', selectIndex: '',
tableData: [], tableData: [],
isNoData: false, isNoData: false,
@@ -192,6 +196,7 @@ export default {
this.firstShow = true this.firstShow = true
this.selectIndex = 0 this.selectIndex = 0
this.pageObj.pageNo = 1 this.pageObj.pageNo = 1
this.jumpLoading = false
this.tableData = [] this.tableData = []
this.$store.commit('setGlobalShow', false) this.$store.commit('setGlobalShow', false)
this.scope.forEach((item) => { this.scope.forEach((item) => {
@@ -200,7 +205,6 @@ export default {
this.unbindEvent() this.unbindEvent()
}, },
selectIcon (item) { selectIcon (item) {
// console.log(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-model'
@@ -228,7 +232,6 @@ export default {
const offsetTop = liBox.offsetTop - ulBox.offsetTop const offsetTop = liBox.offsetTop - ulBox.offsetTop
const scrollTop = ulBox.scrollTop const scrollTop = ulBox.scrollTop
// liBox.focus() // liBox.focus()
// console.log(height, liHeight, offsetTop, scrollTop)
if (offsetTop - scrollTop < 0) { if (offsetTop - scrollTop < 0) {
ulBox.scrollTop = offsetTop ulBox.scrollTop = offsetTop
} else if (offsetTop - scrollTop >= height - liHeight) { } else if (offsetTop - scrollTop >= height - liHeight) {
@@ -236,6 +239,9 @@ export default {
} }
}, },
changeSelectIndex (index) { changeSelectIndex (index) {
if (this.jumpLoading) {
return
}
if (this.isKeyDown) { if (this.isKeyDown) {
this.getItemInfo() this.getItemInfo()
return return
@@ -244,7 +250,9 @@ export default {
this.getItemInfo() this.getItemInfo()
}, },
keyDown (e) { keyDown (e) {
// console.log(e, e.target, e.keyCode) if (this.jumpLoading) {
return
}
if (e.keyCode === 13) { if (e.keyCode === 13) {
this.jumpTo() this.jumpTo()
} }
@@ -281,12 +289,61 @@ export default {
}, 300) }, 300)
}, },
jumpTo () { jumpTo () {
this.jumpLoading = true
const routerPath = this.getRouterPath()
const params = {
table: this.tableData[this.selectIndex].type,
id: this.tableData[this.selectIndex].id,
pageSize: routerPath.pageSize
}
this.$get('/stat/rownum', params).then(res => {
if (res.code === 200) {
this.close()
this.$router.push({
path: routerPath.route,
query: {
pageNo: res.data.pageNo,
pageSize: res.data.pageSize,
rownum: res.data.rownum
}
})
} else {
this.$message.error(res.msg)
this.jumpLoading = false
}
})
},
getRouterPath () {
const type = this.tableData[this.selectIndex].type
let tableId = ''
let route = '/'
if (type === 'datacenter') {
tableId = 'dcTable'
route += 'dc'
} else if (type === 'alertRule') {
tableId = 'alertRuleTable'
route += 'alertRule'
} else if (type === 'asset') {
tableId = type + 'Table'
route += 'asset'
} else {
tableId = type + 'Table'
route += 'monitor/' + type
}
let pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + tableId)
if (!(pageSize && pageSize !== 'undefined')) {
pageSize = 20
}
return {
pageSize,
route
}
}, },
getItemInfo () { getItemInfo () {
this.obj = {} this.obj = {}
}, },
searchAll () { searchAll () {
// this.getSeverityData()
if (this.searchTimer) { if (this.searchTimer) {
clearInterval(this.searchTimer) clearInterval(this.searchTimer)
this.searchTimer = null this.searchTimer = null
@@ -371,6 +428,9 @@ export default {
}) })
} }
}, },
mounted () {
this.getSeverityData()
},
destroyed () { destroyed () {
window.removeEventListener('keydown', this.keyDown) window.removeEventListener('keydown', this.keyDown)
} }

View File

@@ -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)"/> <i v-if="item.icon" 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>
@@ -72,6 +72,7 @@
<script> <script>
import lodash from 'lodash' import lodash from 'lodash'
import chartDataFormat from '@/components/charts/chartDataFormat'
export default { export default {
name: 'searchItemInfo', name: 'searchItemInfo',
props: { props: {
@@ -259,6 +260,26 @@ export default {
}, { }, {
key: 'type', key: 'type',
label: this.$t('alert.type') label: this.$t('alert.type')
}, {
key: 'severityId',
label: this.$t('alert.severity'),
color: this.severityColor,
icon: 'nz-icon nz-icon-circle'
}, {
key: 'expr',
label: this.$t('alert.config.expr')
}, {
key: 'alertNum',
icon: 'nz-icon-overview-alert',
label: this.$t('overall.alert')
}, {
key: 'trbShot',
icon: 'nz-icon-guzhangshuju',
label: this.$t('alert.config.trbShot')
}, {
key: 'state',
label: this.$t('overall.state'),
icon: 'nz-icon nz-icon-circle'
} }
] ]
}, },
@@ -324,9 +345,7 @@ export default {
this.$get('/alert/rule/' + this.obj.id).then((res) => { this.$get('/alert/rule/' + this.obj.id).then((res) => {
if (res.msg === 'success') { if (res.msg === 'success') {
this.loading = false this.loading = false
this.severityData.forEach(item => { this.severityColor = this.severityData.find(item => res.data.severityId == item.id).color
this.severityColor = item.color
})
this.alertLabelData = res.data this.alertLabelData = res.data
} else { } else {
this.$message.error(res.msg) this.$message.error(res.msg)
@@ -348,14 +367,43 @@ export default {
if (item.key === 'pingInfo.rtt') { if (item.key === 'pingInfo.rtt') {
str += this.alertLabelData.pingInfo.status ? 'red-bg' : 'green-bg' str += this.alertLabelData.pingInfo.status ? 'red-bg' : 'green-bg'
} }
if (item.key === 'state' && this.obj.type === 'alertrule') {
str += !this.alertLabelData.state ? 'red' : 'green'
}
return str return str
}, },
searchItemStyle (item) {
const style = {}
if (item.key === 'severityId' && this.obj.type === 'alertrule') {
style.color = this.severityColor
style['font-size'] = '12px'
style['margin-right'] = '5px'
}
return style
},
alertruleStr () {
const arr = [this.$t('project.metrics.metrics'), this.$t('overall.logs'), 'SNMP trap']
if (this.alertLabelData.type) {
return arr[this.alertLabelData.type - 1]
} else {
return '--'
}
},
getPathContent (key) { getPathContent (key) {
let str = lodash.get(this.alertLabelData, key, '--') let str = lodash.get(this.alertLabelData, key, '--')
str += '' str += ''
if (key === 'pingInfo.rtt' && str) { if (key === 'pingInfo.rtt' && str) {
str += ' ms' str += ' ms'
} }
if (key === 'type' && this.obj.type === 'alertrule') {
str = this.alertruleStr()
}
if (key === 'expr' && this.obj.type === 'alertrule' && this.alertRuleData && this.alertRuleData.expr) {
str = this.alertRuleData.expr + this.alertRuleData.operator + this.formatThreshold(this.alertRuleData.threshold, this.alertRuleData.unit)
}
if (key === 'state' && this.obj.type === 'alertrule') {
str = this.alertLabelData.state ? this.$t('overall.enabled') : this.$t('overall.disabled')
}
return str || '--' return str || '--'
}, },
selectIcon (item) { selectIcon (item) {
@@ -380,6 +428,14 @@ export default {
case 'alertrule' : str += '<span>Alert</span> <span>/</span> <span>Alert rule</span>'; break case 'alertrule' : str += '<span>Alert</span> <span>/</span> <span>Alert rule</span>'; break
} }
return str return str
},
formatThreshold (value, unit) {
const unitMethod = chartDataFormat.getUnit(unit)
if (unitMethod && value) {
return unitMethod.compute(value, null, 2)
} else {
return value
}
} }
} }
} }

View File

@@ -122,7 +122,6 @@ export default {
self.menus = response.data.menus self.menus = response.data.menus
self.selectedIds = response.data.selectedIds self.selectedIds = response.data.selectedIds
self.menus[0].children[0].disabled = true self.menus[0].children[0].disabled = true
console.log(self.menus[0].children[0])
} else { } else {
self.$message.error('load menu faild') self.$message.error('load menu faild')
} }

View File

@@ -766,7 +766,6 @@ export default {
if (response.data.purchaseDate) { if (response.data.purchaseDate) {
response.data.purchaseDate += ' 00:00:00' response.data.purchaseDate += ' 00:00:00'
response.data.purchaseDate = new Date(response.data.purchaseDate) response.data.purchaseDate = new Date(response.data.purchaseDate)
console.log(response.data.purchaseDate)
} }
this.object = response.data this.object = response.data
this.rightBox.show = true this.rightBox.show = true

View File

@@ -193,7 +193,6 @@ export default {
}, },
save: function (obj) { save: function (obj) {
const copy = JSON.parse(JSON.stringify(obj)) const copy = JSON.parse(JSON.stringify(obj))
console.log(copy.expireAt)
copy.expireAt = new Date(copy.expireAt).getTime() copy.expireAt = new Date(copy.expireAt).getTime()
copy.expireAt = this.timezoneToUtcTimeStr(copy.expireAt, 'YYYY-MM-DD HH:mm:ss') copy.expireAt = this.timezoneToUtcTimeStr(copy.expireAt, 'YYYY-MM-DD HH:mm:ss')
if (copy.role) { if (copy.role) {

View File

@@ -809,7 +809,6 @@ export default {
expressionChange () { expressionChange () {
const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
this.pageObj.pageNo = 1 this.pageObj.pageNo = 1
// console.log(this.filterTime,nowTimeType);
this.setSearchTime(nowTimeType.type, nowTimeType.value) this.setSearchTime(nowTimeType.type, nowTimeType.value)
if (this.showMetrics) { if (this.showMetrics) {
if (this.expressions && this.expressions.length >= 1) { if (this.expressions && this.expressions.length >= 1) {

View File

@@ -422,7 +422,6 @@ export default {
str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${item.color};}'></span>${alias || item.seriesName}: </div>` str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${item.color};}'></span>${alias || item.seriesName}: </div>`
str += '<div style="padding-left: 10px;">' str += '<div style="padding-left: 10px;">'
let dot = bus.countDecimals(val) let dot = bus.countDecimals(val)
// console.log(dot,val)
if (dot < this.chartDot) { if (dot < this.chartDot) {
dot = this.chartDot dot = this.chartDot
} else if (dot > 6) { } else if (dot > 6) {