fix: 修正三级四级菜单分数计算逻辑
This commit is contained in:
@@ -99,10 +99,43 @@ export default {
|
||||
if (type && condition) {
|
||||
this.toggleLoading(true)
|
||||
get(api.npm.overview.networkAnalysis, params).then(res => {
|
||||
const keyPre = ['tcp', 'http', 'ssl', 'tcpLost', 'packetRetrans']
|
||||
const scoreInfo = {}
|
||||
let index = 0
|
||||
if (res.code === 200) {
|
||||
if (res.data.result.establishLatencyMsAvg || res.data.result.establishLatencyMsAvg === 0) {
|
||||
res.data.result.establishLatencyMs = res.data.result.establishLatencyMsAvg
|
||||
index = 0
|
||||
scoreInfo[keyPre[index] + 'Score'] = computeScore(res.data.result, index)
|
||||
}
|
||||
if (res.data.result.httpResponseLatencyAvg || res.data.result.httpResponseLatencyAvg === 0) {
|
||||
res.data.result.httpResponseLatency = res.data.result.httpResponseLatencyAvg
|
||||
index = 1
|
||||
scoreInfo[keyPre[index] + 'Score'] = computeScore(res.data.result, index)
|
||||
}
|
||||
if (res.data.result.tcpLostlenPercentAvg || res.data.result.tcpLostlenPercentAvg === 0) {
|
||||
res.data.result.tcpLostlenPercent = res.data.result.tcpLostlenPercentAvg
|
||||
index = 3
|
||||
scoreInfo[keyPre[index] + 'Score'] = computeScore(res.data.result, index)
|
||||
}
|
||||
if (res.data.result.pktRetransPercentAvg || res.data.result.pktRetransPercentAvg === 0) {
|
||||
res.data.result.pktRetransPercent = res.data.result.pktRetransPercentAvg
|
||||
index = 4
|
||||
scoreInfo[keyPre[index] + 'Score'] = computeScore(res.data.result, index)
|
||||
}
|
||||
if (res.data.result.sslConLatencyAvg || res.data.result.sslConLatencyAvg === 0) {
|
||||
res.data.result.sslConLatency = res.data.result.sslConLatencyAvg
|
||||
index = 2
|
||||
scoreInfo[keyPre[index] + 'Score'] = computeScore(res.data.result, index)
|
||||
}
|
||||
this.npmNetworkCycleData = res.data.result
|
||||
this.npmNetworkLastCycleQuery()
|
||||
}
|
||||
scoreInfo.score = Math.ceil((scoreInfo.tcpScore + scoreInfo.httpScore + scoreInfo.sslScore + scoreInfo.tcpLostScore + scoreInfo.packetRetransScore) * 6)
|
||||
if (scoreInfo.score > 6) {
|
||||
scoreInfo.score = 6
|
||||
}
|
||||
this.$store.commit('setNpmThirdLevelMenuScore', scoreInfo.score)
|
||||
}).catch(e => {
|
||||
this.toggleLoading(false)
|
||||
})
|
||||
@@ -115,11 +148,40 @@ export default {
|
||||
this.toggleLoading(true)
|
||||
Promise.all([tcp, http, ssl, tcpPercent, packetPercent]).then(res => {
|
||||
this.npmNetworkCycleData = []
|
||||
const keyPre = ['tcp', 'http', 'ssl', 'tcpLost', 'packetRetrans']
|
||||
const scoreInfo = {}
|
||||
let index = 0
|
||||
res.forEach(t => {
|
||||
if (t.code === 200) {
|
||||
if (t.data.result.establishLatencyMsAvg || t.data.result.establishLatencyMsAvg === 0) {
|
||||
t.data.result.establishLatencyMs = t.data.result.establishLatencyMsAvg
|
||||
index = 0
|
||||
}
|
||||
if (t.data.result.httpResponseLatencyAvg || t.data.result.httpResponseLatencyAvg === 0) {
|
||||
t.data.result.httpResponseLatency = t.data.result.httpResponseLatencyAvg
|
||||
index = 1
|
||||
}
|
||||
if (t.data.result.tcpLostlenPercentAvg || t.data.result.tcpLostlenPercentAvg === 0) {
|
||||
t.data.result.tcpLostlenPercent = t.data.result.tcpLostlenPercentAvg
|
||||
index = 3
|
||||
}
|
||||
if (t.data.result.pktRetransPercentAvg || t.data.result.pktRetransPercentAvg === 0) {
|
||||
t.data.result.pktRetransPercent = t.data.result.pktRetransPercentAvg
|
||||
index = 4
|
||||
}
|
||||
if (t.data.result.sslConLatencyAvg || t.data.result.sslConLatencyAvg === 0) {
|
||||
t.data.result.sslConLatency = t.data.result.sslConLatencyAvg
|
||||
index = 2
|
||||
}
|
||||
scoreInfo[keyPre[index] + 'Score'] = computeScore(t.data.result, index)
|
||||
this.npmNetworkCycleData.push(t.data.result)
|
||||
}
|
||||
})
|
||||
scoreInfo.score = Math.ceil((scoreInfo.tcpScore + scoreInfo.httpScore + scoreInfo.sslScore + scoreInfo.tcpLostScore + scoreInfo.packetRetransScore) * 6)
|
||||
if (scoreInfo.score > 6) {
|
||||
scoreInfo.score = 6
|
||||
}
|
||||
this.$store.commit('setNpmThirdLevelMenuScore', scoreInfo.score)
|
||||
this.npmNetworkLastCycleQuery()
|
||||
}).catch(e => {
|
||||
this.toggleLoading(false)
|
||||
@@ -166,31 +228,7 @@ export default {
|
||||
if (type && condition) {
|
||||
this.toggleLoading(true)
|
||||
get(api.npm.overview.networkAnalysis, params).then(res => {
|
||||
const keyPre = ['tcp', 'http', 'ssl', 'tcpLost', 'packetRetrans']
|
||||
const scoreInfo = {}
|
||||
let index = 0
|
||||
if (res.code === 200) {
|
||||
if (res.data.result.establishLatencyMsAvg || res.data.result.establishLatencyMsAvg === 0) {
|
||||
res.data.result.establishLatencyMs = res.data.result.establishLatencyMsAvg
|
||||
index = 0
|
||||
}
|
||||
if (res.data.result.httpResponseLatencyAvg || res.data.result.httpResponseLatencyAvg === 0) {
|
||||
res.data.result.httpResponseLatency = res.data.result.httpResponseLatencyAvg
|
||||
index = 1
|
||||
}
|
||||
if (res.data.result.tcpLostlenPercentAvg || res.data.result.tcpLostlenPercentAvg === 0) {
|
||||
res.data.result.tcpLostlenPercent = res.data.result.tcpLostlenPercentAvg
|
||||
index = 3
|
||||
}
|
||||
if (res.data.result.pktRetransPercentAvg || res.data.result.pktRetransPercentAvg === 0) {
|
||||
res.data.result.pktRetransPercent = res.data.result.pktRetransPercentAvg
|
||||
index = 4
|
||||
}
|
||||
if (res.data.result.sslConLatencyAvg || res.data.result.sslConLatencyAvg === 0) {
|
||||
res.data.result.sslConLatency = res.data.result.sslConLatencyAvg
|
||||
index = 2
|
||||
}
|
||||
scoreInfo[keyPre[index] + 'Score'] = computeScore(res.data.result, index)
|
||||
this.npmNetworkLastCycleData = res.data.result
|
||||
let timer = null
|
||||
if (timer) {
|
||||
@@ -199,15 +237,6 @@ export default {
|
||||
timer = setTimeout(() => {
|
||||
this.npmNetworkQuantity(this.npmNetworkCycleData, this.npmNetworkLastCycleData, 0)
|
||||
}, 300)
|
||||
} else {
|
||||
res[keyPre[index] + 'Score'] = 0
|
||||
}
|
||||
scoreInfo.score = Math.ceil((scoreInfo.tcpScore + scoreInfo.httpScore + scoreInfo.sslScore + scoreInfo.tcpLostScore + scoreInfo.packetRetransScore) * 6)
|
||||
if (scoreInfo.score > 6) {
|
||||
scoreInfo.score = 6
|
||||
}
|
||||
if (!params.q && this.chart.id === 44) {
|
||||
this.$store.commit('setNpmThirdLevelMenuScore', scoreInfo.score)
|
||||
}
|
||||
}).finally(() => {
|
||||
this.toggleLoading(false)
|
||||
|
||||
Reference in New Issue
Block a user