2022-02-25 14:31:36 +08:00
|
|
|
import alertDaysInfo from '@/components/common/alert/alertDaysInfo'
|
|
|
|
|
|
2021-04-07 09:58:34 +08:00
|
|
|
export default {
|
2022-02-25 14:31:36 +08:00
|
|
|
components: {
|
|
|
|
|
alertDaysInfo
|
|
|
|
|
},
|
2021-04-12 13:00:59 +08:00
|
|
|
props: {
|
|
|
|
|
tableData: {
|
|
|
|
|
type: Array
|
|
|
|
|
},
|
|
|
|
|
customTableTitle: {
|
|
|
|
|
type: Array
|
|
|
|
|
},
|
|
|
|
|
height: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '100%'
|
|
|
|
|
},
|
2021-04-16 21:10:31 +08:00
|
|
|
api: {
|
|
|
|
|
type: String
|
|
|
|
|
},
|
|
|
|
|
tableId: {
|
2021-04-12 13:00:59 +08:00
|
|
|
type: String
|
2021-10-13 18:24:09 +08:00
|
|
|
},
|
|
|
|
|
orderByFa: {}
|
2021-04-12 13:00:59 +08:00
|
|
|
},
|
2021-04-07 09:58:34 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
2021-10-13 18:24:09 +08:00
|
|
|
operationWidth: '165', // 操作列宽
|
2022-03-04 13:59:25 +08:00
|
|
|
orderBy: null,
|
2022-02-24 17:43:34 +08:00
|
|
|
severityDataWeight: this.$store.getters.severityDataWeight
|
2021-04-07 09:58:34 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2021-04-22 12:25:23 +08:00
|
|
|
tableOperation ([command, row, param]) {
|
2021-04-07 09:58:34 +08:00
|
|
|
switch (command) {
|
|
|
|
|
case 'delete': {
|
2021-04-12 13:00:59 +08:00
|
|
|
this.$emit('del', row)
|
2021-04-07 09:58:34 +08:00
|
|
|
break
|
|
|
|
|
}
|
2021-05-12 19:36:51 +08:00
|
|
|
case 'recordTab': {
|
|
|
|
|
this.$emit('showBottomBox', 'recordTab', row)
|
2021-04-13 20:33:12 +08:00
|
|
|
break
|
|
|
|
|
}
|
2021-05-19 23:17:24 +08:00
|
|
|
case 'endpointQuery': {
|
|
|
|
|
this.$emit('showBottomBox', 'endpointQuery', row)
|
2021-05-12 19:36:51 +08:00
|
|
|
break
|
|
|
|
|
}
|
2021-05-20 14:07:58 +08:00
|
|
|
case 'sync': {
|
|
|
|
|
// this.$emit('copy', row)
|
|
|
|
|
this.$emit('sync', row)
|
|
|
|
|
break
|
|
|
|
|
}
|
2021-06-01 14:26:09 +08:00
|
|
|
case 'fastSilence': {
|
|
|
|
|
// this.$emit('copy', row)
|
|
|
|
|
this.$emit('addSilence', row, param)
|
|
|
|
|
break
|
|
|
|
|
}
|
2022-03-17 16:42:56 +08:00
|
|
|
case 'topology': {
|
|
|
|
|
// this.$emit('copy', row)
|
|
|
|
|
this.$emit('topology', row, param)
|
|
|
|
|
break
|
|
|
|
|
}
|
2021-04-07 09:58:34 +08:00
|
|
|
default:
|
2022-03-17 16:42:56 +08:00
|
|
|
this.$emit(command, row, param)
|
2021-04-07 09:58:34 +08:00
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-04-13 10:00:48 +08:00
|
|
|
selectionChange (objs) {
|
|
|
|
|
this.$emit('selectionChange', objs)
|
|
|
|
|
},
|
2021-04-12 13:00:59 +08:00
|
|
|
isBuiltIn (row) {
|
2021-04-08 20:28:54 +08:00
|
|
|
return (row.buildIn && row.buildIn == 1) || (row.builtIn && row.builtIn == 1)
|
|
|
|
|
},
|
2021-04-07 09:58:34 +08:00
|
|
|
dragend () {
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs.dataTable.doLayout()
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-04-12 13:00:59 +08:00
|
|
|
showBottomBox (targetTab, row) {
|
|
|
|
|
this.$emit('showBottomBox', targetTab, JSON.parse(JSON.stringify(row)))
|
2021-04-07 09:58:34 +08:00
|
|
|
},
|
|
|
|
|
tableDataSort (item) {
|
|
|
|
|
let orderBy = ''
|
2021-06-30 17:11:46 +08:00
|
|
|
let str = item.prop
|
|
|
|
|
if (str === 'dc') {
|
|
|
|
|
str = 'datacenter'
|
|
|
|
|
}
|
2021-04-07 09:58:34 +08:00
|
|
|
if (item.order === 'ascending') {
|
2021-06-30 17:11:46 +08:00
|
|
|
orderBy = str
|
2021-04-07 09:58:34 +08:00
|
|
|
}
|
|
|
|
|
if (item.order === 'descending') {
|
2021-06-30 17:11:46 +08:00
|
|
|
orderBy = '-' + str
|
2021-04-07 09:58:34 +08:00
|
|
|
}
|
2021-04-12 13:00:59 +08:00
|
|
|
this.$emit('orderBy', orderBy)
|
2022-02-24 17:43:34 +08:00
|
|
|
},
|
|
|
|
|
getWeeksTime () {
|
|
|
|
|
const localOffset = new Date().getTimezoneOffset() // 默认 显示时区偏移的结果 单位分钟
|
|
|
|
|
const now = new Date(new Date().toLocaleDateString()).getTime() - localOffset * 60 * 1000
|
|
|
|
|
const arr = []
|
|
|
|
|
for (let i = 0; i < 7; i++) {
|
|
|
|
|
const obj = {
|
|
|
|
|
time: now - i * 24 * 60 * 60 * 1000,
|
|
|
|
|
tooltipShow: false,
|
|
|
|
|
position: {
|
|
|
|
|
left: 0,
|
|
|
|
|
top: 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.severityDataWeight.forEach(item => {
|
|
|
|
|
obj[item.name] = 0
|
|
|
|
|
obj[item.name + 'Color'] = item.color
|
|
|
|
|
})
|
|
|
|
|
arr.unshift(obj)
|
|
|
|
|
}
|
|
|
|
|
return arr
|
2022-02-25 14:07:17 +08:00
|
|
|
},
|
|
|
|
|
tooltipHover (item, flag, e) {
|
|
|
|
|
if (e) {
|
|
|
|
|
const dom = e.currentTarget
|
|
|
|
|
const position = dom.getBoundingClientRect()
|
|
|
|
|
item.left = position.left
|
|
|
|
|
this.$set(item, 'left', position.left)
|
|
|
|
|
if (position.top > window.innerHeight / 2) {
|
|
|
|
|
this.$set(item, 'top', position.top - 55)
|
|
|
|
|
} else {
|
|
|
|
|
this.$set(item, 'top', position.top + 30)
|
|
|
|
|
}
|
|
|
|
|
this.$set(item, 'alertNumtooltipShow', flag)
|
|
|
|
|
}
|
2021-04-08 20:28:54 +08:00
|
|
|
}
|
2021-10-13 18:24:09 +08:00
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
orderByFa: {
|
|
|
|
|
immediate: true,
|
|
|
|
|
handler (n) {
|
|
|
|
|
if (n) {
|
|
|
|
|
const index = n.indexOf('-')
|
|
|
|
|
if (index !== -1) {
|
2022-03-04 13:59:25 +08:00
|
|
|
this.orderBy = { prop: n.slice(index + 1), order: 'descending' }
|
2021-10-13 18:24:09 +08:00
|
|
|
} else {
|
2022-03-04 13:59:25 +08:00
|
|
|
this.orderBy = { prop: n, order: 'ascending' }
|
2021-10-13 18:24:09 +08:00
|
|
|
}
|
2022-03-04 13:59:25 +08:00
|
|
|
// this.orderBy = JSON.parse(JSON.stringify(this.orderBy))
|
2021-10-13 18:24:09 +08:00
|
|
|
}
|
|
|
|
|
}
|
2022-01-17 16:32:00 +08:00
|
|
|
},
|
|
|
|
|
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)
|
|
|
|
|
}
|
2022-02-24 17:43:34 +08:00
|
|
|
if (this.needAlertDaysData) {
|
|
|
|
|
const weekDays = this.getWeeksTime()
|
|
|
|
|
n.forEach(item => {
|
|
|
|
|
const params = {
|
|
|
|
|
type: 'total',
|
|
|
|
|
dimension: 'priority',
|
|
|
|
|
step: 'd'
|
|
|
|
|
}
|
|
|
|
|
params[this.trendKey] = item.id
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.$get('/stat/alertMessage/trend', params).then((res) => {
|
2022-03-10 13:34:24 +08:00
|
|
|
if (!res.data) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2022-02-24 17:43:34 +08:00
|
|
|
const alertDaysData = res.data.result ? res.data.result[0].values : []
|
|
|
|
|
const newWeekDays = JSON.parse(JSON.stringify(weekDays))
|
|
|
|
|
alertDaysData.forEach(item => {
|
|
|
|
|
item.values.forEach(time => {
|
|
|
|
|
const findItem = newWeekDays.find(days => days.time == time[0])
|
|
|
|
|
if (findItem) {
|
|
|
|
|
findItem[item.metric.priority] = time[1]
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
item.alertDaysData = newWeekDays
|
|
|
|
|
item.trendLoading = false
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-01-17 16:32:00 +08:00
|
|
|
}
|
|
|
|
|
}
|
2021-10-13 18:24:09 +08:00
|
|
|
}
|
2022-01-17 16:32:00 +08:00
|
|
|
// document.querySelector("#header").scrollIntoView(true);
|
2021-04-07 09:58:34 +08:00
|
|
|
}
|
|
|
|
|
}
|