CN-754 下钻table的一些bug

This commit is contained in:
hyx
2022-10-21 10:08:49 +08:00
parent 2a6958f61b
commit a87b096c1c
2 changed files with 126 additions and 125 deletions

View File

@@ -90,10 +90,10 @@
</template> </template>
<template v-else> <template v-else>
<template v-if="showUnit && item.unit"> <template v-if="showUnit && item.unit">
{{scope.row[item.prop] ? unitConvert(scope.row[item.prop], item.unit).join(' ') : '-'}} {{(scope.row[item.prop] || scope.row[item.prop]===0) ? unitConvert(scope.row[item.prop], item.unit).join(' ') : '-'}}
</template> </template>
<template v-else> <template v-else>
{{scope.row[item.prop] ? unitConvert(scope.row[item.prop], unitTypes.number).join(' ') : '-'}} {{(scope.row[item.prop] || scope.row[item.prop]===0)? unitConvert(scope.row[item.prop], unitTypes.number).join(' ') : '-'}}
</template> </template>
</template> </template>
</template> </template>
@@ -541,6 +541,7 @@ export default {
const tableDataTmp = this.chartData.map(item => { const tableDataTmp = this.chartData.map(item => {
tabList.push(item[curTab.prop]) tabList.push(item[curTab.prop])
const otherData = { tab: item[curTab.prop] } const otherData = { tab: item[curTab.prop] }
otherData[curTab.prop] = item[curTab.prop]
Object.keys(this.columnNameGroup).forEach(i => { Object.keys(this.columnNameGroup).forEach(i => {
const propName = this.columnNameGroup[i] const propName = this.columnNameGroup[i]
const column = this.customTableTitles.find(tableColumn => { return tableColumn.prop === i }) const column = this.customTableTitles.find(tableColumn => { return tableColumn.prop === i })
@@ -615,7 +616,7 @@ export default {
trend = '' trend = ''
trendPercent = '' trendPercent = ''
} else { } else {
trendPercent = Math.round(Math.abs(chainRatio) * 100) trendPercent = parseFloat(Math.abs(chainRatio) * 100).toFixed(2)
if (totalDiff > 0) { if (totalDiff > 0) {
trend = 'up' trend = 'up'
if (trendPercent <= 500) { if (trendPercent <= 500) {
@@ -642,7 +643,7 @@ export default {
} }
} }
} }
item[tableColumn.prop] = [item[tableColumn.prop] ? item[tableColumn.prop] : '', trend, trendPercent] item[tableColumn.prop] = [(item[tableColumn.prop] || item[tableColumn.prop] === 0) ? item[tableColumn.prop] : '', trend, trendPercent]
}) })
} }
}).catch(e => { }).catch(e => {
@@ -714,7 +715,7 @@ export default {
trend = '' trend = ''
trendPercent = '' trendPercent = ''
} else { } else {
trendPercent = Math.round(Math.abs(chainRatio) * 100) trendPercent = parseFloat(Math.abs(chainRatio) * 100).toFixed(2)
if (totalDiff > 0) { if (totalDiff > 0) {
trend = 'up' trend = 'up'
if (trendPercent <= 500) { if (trendPercent <= 500) {
@@ -742,7 +743,7 @@ export default {
} }
} }
if (!(item[tableColumn.prop] && item[tableColumn.prop].length >= 3)) { if (!(item[tableColumn.prop] && item[tableColumn.prop].length >= 3)) {
item[tableColumn.prop] = [item[tableColumn.prop] ? item[tableColumn.prop] : '', trend, trendPercent] item[tableColumn.prop] = [(item[tableColumn.prop] || item[tableColumn.prop] === 0) ? item[tableColumn.prop] : '', trend, trendPercent]
} }
}) })
} }
@@ -757,6 +758,8 @@ export default {
} }
}) })
} else { } else {
this.tableData = tableDataTmp
this.tableDataBackup = tableDataTmp
this.toggleLoading(false) this.toggleLoading(false)
} }
this.changeUrlTabState() this.changeUrlTabState()
@@ -806,39 +809,24 @@ export default {
this.tableData.slice(0, this.showRecordNum).forEach(val => { this.tableData.slice(0, this.showRecordNum).forEach(val => {
arr.push(val) arr.push(val)
}) })
if (column.prop != 'tab') {
if (column.order == 'descending') { if (column.order == 'descending') {
arr.sort((a, b) => { arr.sort((a, b) => {
const str1 = Array.isArray(a[column.prop]) ? a[column.prop][0] : a[column.prop] const str1 = Array.isArray(a[column.prop]) ? a[column.prop][0] : a[column.prop]
const str2 = Array.isArray(b[column.prop]) ? b[column.prop][0] : b[column.prop] const str2 = Array.isArray(b[column.prop]) ? b[column.prop][0] : b[column.prop]
if ((_.isNumber(str1)) || str1 === '') {
return str2 - str1 return str2 - str1
})
if (this.tableData.length - 1 > this.showRecordNum) {
this.tableData = arr.concat(this.tableDataBackup.slice(this.showRecordNum))
} else { } else {
this.tableData = arr let aObj = a[column.prop] ? a[column.prop] : a[index]
let bObj = b[column.prop] ? b[column.prop] : b[index]
if (!aObj) {
const curTab = this.getCurTab()
aObj = a[curTab.prop]
bObj = b[curTab.prop]
} }
} else if (column.order == 'ascending') {
arr.sort((a, b) => {
const str1 = Array.isArray(a[column.prop]) ? a[column.prop][0] : a[column.prop]
const str2 = Array.isArray(b[column.prop]) ? b[column.prop][0] : b[column.prop]
return str1 - str2
})
if (this.tableData.length - 1 > this.showRecordNum) {
this.tableData = arr.concat(this.tableDataBackup.slice(this.showRecordNum))
} else {
this.tableData = arr
}
} else if (!column.order) {
this.tableData = this.tableDataBackup
}
} else {
if (column.order == 'descending') {
arr.sort((a, b) => {
const aObj = a[column.prop]
const bObj = b[column.prop]
let res = 0 let res = 0
for (let i = 0; ; i++) { if (aObj && bObj) {
const len = aObj.length < bObj.length ? aObj.length : bObj.length
for (let i = 0; i < len; i++) {
const char1 = aObj[i] const char1 = aObj[i]
const char2 = bObj[i] const char2 = bObj[i]
const char1Type = this.getChartType(char1) const char1Type = this.getChartType(char1)
@@ -856,7 +844,9 @@ export default {
break break
} }
} }
}
return res return res
}
}) })
if (this.tableData.length - 1 > this.showRecordNum) { if (this.tableData.length - 1 > this.showRecordNum) {
this.tableData = arr.concat(this.tableDataBackup.slice(this.showRecordNum)) this.tableData = arr.concat(this.tableDataBackup.slice(this.showRecordNum))
@@ -865,10 +855,22 @@ export default {
} }
} else if (column.order == 'ascending') { } else if (column.order == 'ascending') {
arr.sort((a, b) => { arr.sort((a, b) => {
const aObj = a[column.prop] const str1 = Array.isArray(a[column.prop]) ? a[column.prop][0] : a[column.prop]
const bObj = b[column.prop] const str2 = Array.isArray(b[column.prop]) ? b[column.prop][0] : b[column.prop]
if ((_.isNumber(str1)) || str1 === '') {
return str1 - str2
} else {
let aObj = a[column.prop] ? a[column.prop] : a[index]
let bObj = b[column.prop] ? b[column.prop] : b[index]
if (!aObj) {
const curTab = this.getCurTab()
aObj = a[curTab.prop]
bObj = b[curTab.prop]
}
let res = 0 let res = 0
for (let i = 0; ; i++) { if (aObj && bObj) {
const len = aObj.length < bObj.length ? aObj.length : bObj.length
for (let i = 0; i < len; i++) {
const char1 = aObj[i] const char1 = aObj[i]
const char2 = bObj[i] const char2 = bObj[i]
const char1Type = this.getChartType(char1) const char1Type = this.getChartType(char1)
@@ -886,7 +888,9 @@ export default {
break break
} }
} }
}
return res return res
}
}) })
if (this.tableData.length - 1 > this.showRecordNum) { if (this.tableData.length - 1 > this.showRecordNum) {
this.tableData = arr.concat(this.tableDataBackup.slice(this.showRecordNum)) this.tableData = arr.concat(this.tableDataBackup.slice(this.showRecordNum))
@@ -896,7 +900,6 @@ export default {
} else if (!column.order) { } else if (!column.order) {
this.tableData = this.tableDataBackup this.tableData = this.tableDataBackup
} }
}
}, },
// 切换metricbit、packet、session // 切换metricbit、packet、session
changeMetric () { changeMetric () {
@@ -1229,8 +1232,6 @@ export default {
} }
} }
this.urlChangeParams[this.curTabState.queryCondition] = queryCondition.join(' OR ') this.urlChangeParams[this.curTabState.queryCondition] = queryCondition.join(' OR ')
} }
}, },