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

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