fix:修复 alertMessage 图表不显示的问题 以及 查看图表后 分页查询带了时间参数的问题

This commit is contained in:
zhangyu
2021-05-14 15:24:32 +08:00
parent 212cb25ad0
commit 801180443f
22 changed files with 72 additions and 44 deletions

View File

@@ -89,7 +89,7 @@
<div slot="title">
{{$t("project.endpoint.dialogTitle")}}
<div class="float-right panel-calendar dialog-tool" style="display: flex">
<pick-time v-model="searchTime" :refresh-data-func="queryChartDate" :use-chart-unit="false" :use-refresh="false" style="height: 28px;" @unitChange="chartUnitChange"></pick-time>
<pick-time v-model="searchTimeDialog" :refresh-data-func="queryChartDate" :use-chart-unit="false" :use-refresh="false" style="height: 28px;" @unitChange="chartUnitChange"></pick-time>
</div>
</div>
<chart ref="messageChart" :unit="chartUnit" name="alertMessageChart"></chart>
@@ -132,6 +132,7 @@ export default {
sameLabels: ['instance', 'module', 'project', 'asset', 'endpoint', 'datacenter'],
legend: [],
searchTime: [],
searchTimeDialog: [],
searchTimeSelect: bus.getTimezontDateRange(),
currentMsg: {},
chartUnit: 5,
@@ -193,7 +194,7 @@ export default {
return (key, value) => {
if (key == 'type') {
if (value == 1) {
value = this.$t('project.project.project')
value = this.$t('project.project.projectName')
} else if (value == 2) {
value = this.$t('module.module.module')
} else if (value == 3) {
@@ -247,7 +248,7 @@ export default {
// const end = this.searchTime[1] ? this.searchTime[1] : getTime(0, 'h')
const start = this.currentMsg.startAt
const end = this.currentMsg.endAt
this.searchTime = [start, end]
this.searchTimeDialog = [start, end]
const timeDiff = (new Date(end).getTime() - new Date(start).getTime()) / 1000 / (24 * 60 * 60)
let step = '15s'
if (timeDiff < 1) {
@@ -323,7 +324,7 @@ export default {
chartData.name += '}'
const legend = {
name: chartData.name,
alias: alias,
alias: chartData.name,
isGray: false
}
this.legend.push(legend)
@@ -344,7 +345,7 @@ export default {
this.$refs.messageChart.endLoading()
})
} catch (err) {
this.$message.error(err)
// this.$message.error(err)
this.$refs.messageChart.endLoading()
}
})
@@ -584,7 +585,26 @@ export default {
this.$refs.dataTable.$refs.dataTable.bodyWrapper.scrollTop = 0
}
this.getTableData()
}
},
computeDistance (str) {
let width = 0
const html = document.createElement('span')
html.innerText = str
html.className = 'getTextWidth'
document.querySelector('body').appendChild(html)
width = document.querySelector('.getTextWidth').offsetWidth
document.querySelector('.getTextWidth').remove()
return Number('-' + (width + 5))
},
returnMarkArea () {
if (this.currentMsg) {
if (this.currentMsg.alertRule.operator == '>' || this.currentMsg.alertRule.operator == '>=') {
return [{ yAxis: this.currentMsg.alertRule.threshold }, {}]
} else {
return [{}, { yAxis: this.currentMsg.alertRule.threshold }]
}
}
},
}
}
</script>