分析值保留两位有效数字计算退回

This commit is contained in:
2026-02-06 08:49:03 +08:00
parent da01e1efcd
commit 08b82f02e3
4 changed files with 2046 additions and 50 deletions

View File

@@ -674,7 +674,7 @@ const saveDetail = async () => {
if (item.calcMethod === 'calculateAverageValue') {
item.value = calcAverageValue(sourceKey, currentAssayType.value.tableData)
} else {
item.value = handleRoundFiveNumber(row[sourceKey].value, row.decimalPosition, row.type === 'project')
item.value = handleRoundFiveNumber(row[sourceKey].value, row.decimalPosition)
}
// 如果处理后的值不为空,重新赋值该字段到其他样品类型下的样品上,并触发每一个样品的计算
for (const col of currentAssayType.value.columns) {
@@ -707,10 +707,9 @@ const saveDetail = async () => {
function calcAverageValue(fieldIndex, tableData) {
const rows = tableData.map(row => row[fieldIndex])
const decimalPosition = rows[0].decimalPosition
const isProject = rows[0].type === 'project'
const values = rows.map(row => Number(row.value))
if (values.some(item => item == null)) return null
return handleRoundFiveNumber(math.mean(values), decimalPosition, isProject)
return handleRoundFiveNumber(math.mean(values), decimalPosition)
}
// 表格数据更新后重新计算
@@ -1110,13 +1109,12 @@ const listenNumKeyboard = () => {
}
//自动补全小数位数
const decimalPosition = selectedField.value.decimalPosition
const isProject = selectedField.value.type === 'project'
let val = res.val
const symbol = res.symbol
if (decimalPosition == null) {
selectedField.value.value = val
} else {
selectedField.value.value = handleRoundFiveNumber(val, decimalPosition, isProject)
selectedField.value.value = handleRoundFiveNumber(val, decimalPosition)
}
if (symbol) {
selectedField.value.symbol = symbol

File diff suppressed because it is too large Load Diff