|
|
|
@ -0,0 +1,21 @@ |
|
|
|
//体积不同单位相加
|
|
|
|
export function addTj(valueArr, unitArr) { |
|
|
|
let unit = ['pL', 'nL', 'uL', 'mL', 'L'] |
|
|
|
|
|
|
|
//计算最小单位
|
|
|
|
let mixIndex = unit.length - 1 |
|
|
|
for (let i = 0; i < unitArr.length; i++) { |
|
|
|
let thisIndex = unit.indexOf(unitArr[i]) |
|
|
|
mixIndex = thisIndex < mixIndex ? thisIndex : mixIndex |
|
|
|
} |
|
|
|
|
|
|
|
let total = 0 |
|
|
|
for (let i = 0; i < unitArr.length; i++) { |
|
|
|
let thisIndex = unit.indexOf(unitArr[i]) |
|
|
|
total += parseFloat(valueArr[i]) * Math.pow(1000, thisIndex - mixIndex) |
|
|
|
} |
|
|
|
return { |
|
|
|
total: total, |
|
|
|
unit: unit[mixIndex] |
|
|
|
} |
|
|
|
} |