perf: 解决subtable抖动问题

This commit is contained in:
chenjinsong
2021-08-15 18:53:27 +08:00
parent 2c66482fbb
commit 7203213257
2 changed files with 35 additions and 35 deletions

View File

@@ -21,6 +21,7 @@
style="width: 100%;" style="width: 100%;"
:show-header="false" :show-header="false"
:size="'mini'" :size="'mini'"
v-loading="subLoading"
:height="'100%'"> :height="'100%'">
<el-table-column <el-table-column
width="48"> width="48">
@@ -168,22 +169,19 @@ export default {
prop: 'bytes', prop: 'bytes',
width: '18%' width: '18%'
} }
] ],
subLoading: true
} }
}, },
methods: { methods: {
// rowChange (echartParams) {
// const nameColumnKey = this.nameColumn === 'fqdnCategoryName' ? 'categoryName' : 'reputationLevel'
// const row = this.pieTableData.find(item => echartParams.name === item[nameColumnKey])
// this.toggleRowExpansion(row)
// },
// toggleRowExpansion (row) {
// this.$refs.table.toggleRowExpansion(row)
// },
currentChange (row, expandedRows) { currentChange (row, expandedRows) {
this.subLoading = true
this.childrenTableData = [] this.childrenTableData = []
if (this.expandRowKeys[0] && (row.domain === this.expandRowKeys[0])) {
// this.$refs.table.toggleRowExpansion(row) this.expandRowKeys = []
} else {
this.expandRowKeys = [row.domain]
}
const url = this.chartInfo.params.urlChildrenTable const url = this.chartInfo.params.urlChildrenTable
const queryParams = { const queryParams = {
startTime: parseInt(this.timeFilter.startTime / 1000), startTime: parseInt(this.timeFilter.startTime / 1000),
@@ -192,16 +190,15 @@ export default {
domain: row.domain, domain: row.domain,
limit: 10 limit: 10
} }
setTimeout(() => {
get(replaceUrlPlaceholder(url, queryParams)).then(response2 => { get(replaceUrlPlaceholder(url, queryParams)).then(response2 => {
if (response2.code === 200) { if (response2.code === 200) {
this.childrenTableData = response2.data.result this.childrenTableData = response2.data.result
} }
if (this.expandRowKeys[0] && (row.domain === this.expandRowKeys[0])) { }).finally(() => {
this.expandRowKeys = [] this.subLoading = false
} else {
this.expandRowKeys = [row.domain]
}
}) })
}, 500)
}, },
getRowKey (row) { getRowKey (row) {
return row.domain return row.domain

View File

@@ -516,6 +516,7 @@ export default {
} }
}, },
timeLineIsAllZero (data) { timeLineIsAllZero (data) {
if (data.resultType === 'matrix') {
let allZero = true let allZero = true
try { try {
data.forEach(d => { data.forEach(d => {
@@ -528,6 +529,7 @@ export default {
}) })
} catch (e) {} } catch (e) {}
return allZero return allZero
}
}, },
initECharts (chartParams) { initECharts (chartParams) {
const queryParams = { startTime: parseInt(this.timeFilter.startTime / 1000), endTime: parseInt(this.timeFilter.endTime / 1000), ...this.entity } const queryParams = { startTime: parseInt(this.timeFilter.startTime / 1000), endTime: parseInt(this.timeFilter.endTime / 1000), ...this.entity }
@@ -540,7 +542,7 @@ export default {
this.noData = false this.noData = false
} }
const seriesTemplate = this.chartOption.series[0] const seriesTemplate = this.chartOption.series[0]
const allZero = this.timeLineIsAllZero(response.data.result) const allZero = this.timeLineIsAllZero(response.data)
if (allZero) { if (allZero) {
this.chartOption.yAxis = { this.chartOption.yAxis = {
...this.chartOption.yAxis, ...this.chartOption.yAxis,
@@ -581,7 +583,7 @@ export default {
} else { } else {
this.noData = false this.noData = false
} }
const allZero = this.timeLineIsAllZero(response.data.result) const allZero = this.timeLineIsAllZero(response.data)
if (allZero) { if (allZero) {
this.chartOption.yAxis = { this.chartOption.yAxis = {
...this.chartOption.yAxis, ...this.chartOption.yAxis,
@@ -625,13 +627,14 @@ export default {
tableQueryParams[chartParams.nameColumn] = [] // 处理两个图表不一样的地方 tableQueryParams[chartParams.nameColumn] = [] // 处理两个图表不一样的地方
get(replaceUrlPlaceholder(chartParams.url, queryParams)).then(response => { get(replaceUrlPlaceholder(chartParams.url, queryParams)).then(response => {
if (response.code === 200) { if (response.code === 200) {
console.info(response)
if (this.$_.isEmpty(response.data.result)) { if (this.$_.isEmpty(response.data.result)) {
this.noData = true this.noData = true
return return
} else { } else {
this.noData = false this.noData = false
} }
const allZero = this.timeLineIsAllZero(response.data.result) const allZero = this.timeLineIsAllZero(response.data)
if (allZero) { if (allZero) {
this.chartOption.yAxis = { this.chartOption.yAxis = {
...this.chartOption.yAxis, ...this.chartOption.yAxis,