CN-743 下钻配置增加unit相关内容

This commit is contained in:
hyx
2022-10-12 11:11:22 +08:00
parent e005eb7cb4
commit c025109b49
5 changed files with 49 additions and 25 deletions

View File

@@ -73,7 +73,8 @@
</div> </div>
</template> </template>
<template v-else-if="index===2"> <template v-else-if="index===2">
<span class="route-menu" @click="jump(route,item,'',3)">{{$t(item)}}</span> <span v-if="route===wholeScreenRouterMapping.dns" >{{$t(item)}}</span>
<span v-else class="route-menu" @click="jump(route,item,'',3)">{{$t(item)}}</span>
</template> </template>
<template v-else-if="index===1"> <template v-else-if="index===1">
<span class="route-menu" @click="jump(route,'','',2)" v-if="route.indexOf('detection') === -1">{{item}}</span> <span class="route-menu" @click="jump(route,'','',2)" v-if="route.indexOf('detection') === -1">{{item}}</span>
@@ -188,7 +189,8 @@ import {
networkOverviewTabList, networkOverviewTabList,
networkTable, networkTable,
operationType, operationType,
storageKey storageKey,
wholeScreenRouterMapping
} from '@/utils/constants' } from '@/utils/constants'
import { api } from '@/utils/api' import { api } from '@/utils/api'
import { ref } from 'vue' import { ref } from 'vue'
@@ -242,7 +244,8 @@ export default {
], ],
curPageNum: 1, curPageNum: 1,
curTabState: curTabState, curTabState: curTabState,
urlChangeParams: {} urlChangeParams: {},
wholeScreenRouterMapping
} }
}, },
computed: { computed: {

View File

@@ -57,8 +57,8 @@ const user = {
tempArr = tempArr[1].split('&') tempArr = tempArr[1].split('&')
tempArr.forEach(t => { tempArr.forEach(t => {
let firstEqualIndex = t.indexOf('=') let firstEqualIndex = t.indexOf('=')
let key = t.substring(0,firstEqualIndex) let key = t.substring(0, firstEqualIndex)
let value = t.substring(firstEqualIndex+1) let value = t.substring(firstEqualIndex + 1)
query[key] = value query[key] = value
}) })
} }

View File

@@ -97,7 +97,8 @@ export const unitTypes = {
byte: 'byte', byte: 'byte',
bps: 'bps', bps: 'bps',
string: 'string', string: 'string',
percent: 'percent' percent: 'percent',
qps: 'qps'
} }
export const chartTableDefaultPageSize = 10 // table类型图表默认每页数据量 export const chartTableDefaultPageSize = 10 // table类型图表默认每页数据量
export const chartTableTopOptions = [10, 100] // table类型图表的TOP-N选项 export const chartTableTopOptions = [10, 100] // table类型图表的TOP-N选项
@@ -958,7 +959,7 @@ export const dnsServiceInsightsTabList = [
}, },
{ {
label: 'QNames', label: 'QNames',
prop: 'dnsServerRole', prop: 'qname',
queryCycleTotalProp: 'qnames', queryCycleTotalProp: 'qnames',
dillDownProp: ['dns_qname'], dillDownProp: ['dns_qname'],
checked: true, checked: true,
@@ -1123,7 +1124,7 @@ export const networkTable = {
bytesCycleColumnNameGroup: bytesCycleColumnNameGroupForDns, bytesCycleColumnNameGroup: bytesCycleColumnNameGroupForDns,
defaultOrderBy: 'totalBytes' defaultOrderBy: 'totalBytes'
}, },
linkMonitor:{ linkMonitor: {
tabList: linkMonitorTabList, tabList: linkMonitorTabList,
column: customTableTitlesForLinkMonitor, column: customTableTitlesForLinkMonitor,
url: linkMonitorUrl, url: linkMonitorUrl,

View File

@@ -4,6 +4,7 @@ import _ from 'lodash'
const numberUnit = ['', 'K', 'M', 'G', 'T', 'P', 'E'] const numberUnit = ['', 'K', 'M', 'G', 'T', 'P', 'E']
const byteUnit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'] const byteUnit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB']
const bpsUnit = ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps'] const bpsUnit = ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps']
const qpsUnit = ['qps', 'Kqps', 'Mqps', 'Gqps', 'Tqps', 'Pqps', 'Eqps']
const timeUnit = [ // 时间单位步进倍数以ms为基数 const timeUnit = [ // 时间单位步进倍数以ms为基数
{ unit: 'ms', step: 1 }, { unit: 'ms', step: 1 },
{ unit: 's', step: 1000 }, { unit: 's', step: 1000 },
@@ -35,6 +36,9 @@ export function numberUnitConvert (value, sourceUnit, targetUnit, dot = 2) {
export function bpsUnitConvert (value, sourceUnit, targetUnit, dot = 2) { export function bpsUnitConvert (value, sourceUnit, targetUnit, dot = 2) {
return asciiCompute(value, 1000, bpsUnit, dot) return asciiCompute(value, 1000, bpsUnit, dot)
} }
export function qpsUnitConvert (value, sourceUnit, targetUnit, dot = 2) {
return asciiCompute(value, 1000, qpsUnit, dot)
}
export function byteUnitConvert (value, unitType, sourceUnit = 'B', targetUnit, dot = 2) { export function byteUnitConvert (value, unitType, sourceUnit = 'B', targetUnit, dot = 2) {
return asciiCompute(value, 1024, byteUnit, dot) return asciiCompute(value, 1024, byteUnit, dot)
} }
@@ -109,6 +113,9 @@ export default function unitConvert (value, unitType, sourceUnit, targetUnit, do
case unitTypes.byte: { case unitTypes.byte: {
return byteUnitConvert(value, unitType, sourceUnit, targetUnit, dot) return byteUnitConvert(value, unitType, sourceUnit, targetUnit, dot)
} }
case unitTypes.qps: {
return qpsUnitConvert(value, sourceUnit, targetUnit, dot)
}
} }
} }
} }

View File

@@ -47,7 +47,12 @@
<template v-if="item.columnType === tableColumnType.chainRatio" > <template v-if="item.columnType === tableColumnType.chainRatio" >
<div class="data-total" > <div class="data-total" >
<div class="data-value"> <div class="data-value">
<template v-if="showUnit && item.unit">
{{scope.row[item.prop]?((scope.row[item.prop][0]||scope.row[item.prop][0]===0)? unitConvert(scope.row[item.prop][0], item.unit).join(' ') : '-'):'' }}
</template>
<template v-else>
{{scope.row[item.prop]?((scope.row[item.prop][0]||scope.row[item.prop][0]===0)? unitConvert(scope.row[item.prop][0], unitTypes.number).join(' ') : '-'):'' }} {{scope.row[item.prop]?((scope.row[item.prop][0]||scope.row[item.prop][0]===0)? unitConvert(scope.row[item.prop][0], unitTypes.number).join(' ') : '-'):'' }}
</template>
</div> </div>
<div class="data-trend"> <div class="data-trend">
<template v-if="scope.row[item.prop]"> <template v-if="scope.row[item.prop]">
@@ -73,20 +78,25 @@
</template> </template>
<template v-else-if="item.columnType === tableColumnType.percent" > <template v-else-if="item.columnType === tableColumnType.percent" >
<div class="dns-in-ex"> <div class="dns-in-ex">
<div class="dns-percent-pic" > <div class="dns-percent-pic">
<div v-if="scope.row[item.prop][0] !== false" class="div-green" id="green" :style="`width:${scope.row[item.prop][0]}`"></div> <div v-if="scope.row[item.prop][0] !== false" class="div-green" id="green" :style="`width:${scope.row[item.prop][0]}`"></div>
<div v-if="scope.row[item.prop][0] !== false" class="div-yellow" id="yellow" :style="`width:${scope.row[item.prop][1]}`"></div> <div v-if="scope.row[item.prop][0] !== false" class="div-yellow" id="yellow" :style="`width:${scope.row[item.prop][1]}`"></div>
</div> </div>
<div class="dns-percent" >{{scope.row[item.prop][2]}}</div> <div class="dns-percent">{{scope.row[item.prop][2]}}</div>
</div> </div>
</template> </template>
<template v-else-if="item.prop === 'score'" > <template v-else-if="item.prop === 'score'" >
{{scope.row[item.prop] ? unitConvert(scope.row[item.prop], unitTypes.number).join(' ') : '0'}} {{scope.row[item.prop] ? unitConvert(scope.row[item.prop], unitTypes.number).join(' ') : '0'}}
</template> </template>
<template v-else>
<template v-if="showUnit && item.unit">
{{scope.row[item.prop] ? unitConvert(scope.row[item.prop], item.unit).join(' ') : '-'}}
</template>
<template v-else> <template v-else>
{{scope.row[item.prop] ? unitConvert(scope.row[item.prop], unitTypes.number).join(' ') : '-'}} {{scope.row[item.prop] ? unitConvert(scope.row[item.prop], unitTypes.number).join(' ') : '-'}}
</template> </template>
</template> </template>
</template>
</el-table-column> </el-table-column>
</template> </template>
<template v-slot:empty> <template v-slot:empty>
@@ -250,7 +260,8 @@ export default {
tableSortColumn: '', tableSortColumn: '',
tableSortType: '', tableSortType: '',
tableSortTab: '', tableSortTab: '',
urlChangeParams: {} urlChangeParams: {},
showUnit: false
} }
}, },
props: { props: {
@@ -350,18 +361,18 @@ export default {
} }
}, },
isThirdMenu () { // 当前是否为3级 isThirdMenu () { // 当前是否为3级
if(this.isOnlyRead){ if (this.isOnlyRead) {
return false return false
}else { } else {
const thirdMenu = this.getUrlParam(this.curTabState.thirdMenu, '') const thirdMenu = this.getUrlParam(this.curTabState.thirdMenu, '')
const fourthMenu = this.getUrlParam(this.curTabState.fourthMenu, '') const fourthMenu = this.getUrlParam(this.curTabState.fourthMenu, '')
return thirdMenu && !fourthMenu return thirdMenu && !fourthMenu
} }
}, },
isFourthMenu () { // 当前是否为4级 isFourthMenu () { // 当前是否为4级
if(this.isOnlyRead){ if (this.isOnlyRead) {
return false return false
}else { } else {
const thirdMenu = this.getUrlParam(this.curTabState.thirdMenu, '') const thirdMenu = this.getUrlParam(this.curTabState.thirdMenu, '')
const fourthMenu = this.getUrlParam(this.curTabState.fourthMenu, '') const fourthMenu = this.getUrlParam(this.curTabState.fourthMenu, '')
return thirdMenu && fourthMenu return thirdMenu && fourthMenu
@@ -408,11 +419,11 @@ export default {
// 针对network overview app list 点击标题触发下钻,相关内容处理 // 针对network overview app list 点击标题触发下钻,相关内容处理
const thirdMenu = this.getUrlParam(this.curTabState.thirdMenu, '') const thirdMenu = this.getUrlParam(this.curTabState.thirdMenu, '')
//const fourthMenu = this.getUrlParam(this.curTabState.fourthMenu, '') // const fourthMenu = this.getUrlParam(this.curTabState.fourthMenu, '')
if (this.isFourthMenu()) { if (this.isFourthMenu()) {
this.list.forEach(item => { this.list.forEach(item => {
if (item.label === thirdMenu) { if (item.label === thirdMenu) {
//item.checked = false // item.checked = false
} }
}) })
} else if (this.isThirdMenu()) { } else if (this.isThirdMenu()) {
@@ -463,7 +474,7 @@ export default {
this.showCustomizeTabs = false this.showCustomizeTabs = false
} else if (curOperationType === operationType.changeTab) { // 切换tab } else if (curOperationType === operationType.changeTab) { // 切换tab
this.showCustomizeTabs = true this.showCustomizeTabs = true
} else if (curOperationType === operationType.secondMenu || curOperationType === operationType.mainMenu ) { // 点击的为第二级菜单、或者点击菜单进入、 } else if (curOperationType === operationType.secondMenu || curOperationType === operationType.mainMenu) { // 点击的为第二级菜单、或者点击菜单进入、
if (curTab) { if (curTab) {
this.showTab(curTab) this.showTab(curTab)
this.urlChangeParams[this.curTabState.curTab] = curTab.prop this.urlChangeParams[this.curTabState.curTab] = curTab.prop
@@ -519,7 +530,7 @@ export default {
this.showCustomizeTabs = true this.showCustomizeTabs = true
}) })
} }
}else { } else {
this.showCustomizeTabs = true this.showCustomizeTabs = true
} }
this.changeUrlTabState() this.changeUrlTabState()
@@ -961,7 +972,7 @@ export default {
item.disabled = false item.disabled = false
if (columnValue) { if (columnValue) {
if (item.label === columnName) { if (item.label === columnName) {
//item.disabled = true // item.disabled = true
} }
} }
}) })
@@ -1022,7 +1033,7 @@ export default {
item.disabled = false item.disabled = false
if (columnValue) { if (columnValue) {
if (item.label === columnName) { if (item.label === columnName) {
//item.disabled = true // item.disabled = true
} }
} }
}) })
@@ -1085,7 +1096,7 @@ export default {
this.urlChangeParams[this.curTabState.networkOverviewBeforeTab] = tab.prop this.urlChangeParams[this.curTabState.networkOverviewBeforeTab] = tab.prop
}, },
setQueryCondition (tab, value) { setQueryCondition (tab, value) {
value = value.replaceAll("'","\\\\'") value = value.replaceAll("'", "\\\\'")
const queryCondition = [] const queryCondition = []
const searchProps = tab.dillDownProp const searchProps = tab.dillDownProp
if (tab.prop === 'protocolPort') { if (tab.prop === 'protocolPort') {
@@ -1189,7 +1200,7 @@ export default {
}) })
}, },
handleSearchParams (columnValue) { handleSearchParams (columnValue) {
columnValue = columnValue.replaceAll("'","\\\\'") columnValue = columnValue.replaceAll("'", "\\\\'")
const queryCondition = [] const queryCondition = []
const curTab = this.getCurTab() const curTab = this.getCurTab()
const searchProps = curTab.dillDownProp const searchProps = curTab.dillDownProp
@@ -1519,6 +1530,7 @@ export default {
column.name = commonColumn ? commonColumn.name : '' column.name = commonColumn ? commonColumn.name : ''
column.label = commonColumn ? commonColumn.i18n : '' column.label = commonColumn ? commonColumn.i18n : ''
column.prop = commonColumn ? commonColumn.prop : '' column.prop = commonColumn ? commonColumn.prop : ''
column.unit = commonColumn ? commonColumn.unit : null
column.checked = !((hiddenColumnList.indexOf(columnName) >= 0)) column.checked = !((hiddenColumnList.indexOf(columnName) >= 0))
column.disabled = (disabledColumnList.indexOf(columnName) >= 0) column.disabled = (disabledColumnList.indexOf(columnName) >= 0)
column.columnType = commonColumn ? commonColumn.columnType : '' column.columnType = commonColumn ? commonColumn.columnType : ''
@@ -1701,6 +1713,7 @@ export default {
this.columnNameGroup = this.curTable.bytesColumnNameGroup this.columnNameGroup = this.curTable.bytesColumnNameGroup
this.cycleColumnNameGroup = this.curTable.bytesCycleColumnNameGroup this.cycleColumnNameGroup = this.curTable.bytesCycleColumnNameGroup
this.isOnlyRead = this.curTable.isOnlyRead ? this.curTable.isOnlyRead : false this.isOnlyRead = this.curTable.isOnlyRead ? this.curTable.isOnlyRead : false
this.showUnit = this.curTable.showUnit ? this.curTable.showUnit : false
if (this.curTableInCode.defaultOrderBy) { if (this.curTableInCode.defaultOrderBy) {
this.orderBy = this.curTableInCode.defaultOrderBy this.orderBy = this.curTableInCode.defaultOrderBy
} }