Compare commits
No commits in common. "dd3d738eedc21656956db3b3e6ec6d5a61043e13" and "a5e0dd89fff08fe369e5b04df1a05189e396308f" have entirely different histories.
dd3d738eed
...
a5e0dd89ff
|
|
@ -687,27 +687,11 @@ export default {
|
||||||
const m1 = this.qsForm[this.m1Id]
|
const m1 = this.qsForm[this.m1Id]
|
||||||
const m2 = this.qsForm[this.m2Id]
|
const m2 = this.qsForm[this.m2Id]
|
||||||
const m3 = this.qsForm[this.m3Id]
|
const m3 = this.qsForm[this.m3Id]
|
||||||
// if (isNaN(parseFloat(m1)) || isNaN(parseFloat(m2)) || isNaN(parseFloat(m3))) {
|
if (isNaN(parseFloat(m1)) || isNaN(parseFloat(m2)) || isNaN(parseFloat(m3))) {
|
||||||
// this.$set(this.qsForm, this.avgId, null)
|
|
||||||
// } else {
|
|
||||||
// const avg = (parseFloat(m1) + parseFloat(m2) + parseFloat(m3)) / 3
|
|
||||||
// this.$set(this.qsForm, this.avgId, this.numberToFixed(avg))
|
|
||||||
// }
|
|
||||||
//转成有效数字,无效的过滤掉
|
|
||||||
const validNumbers = []
|
|
||||||
if (!isNaN(parseFloat(m1))) validNumbers.push(parseFloat(m1))
|
|
||||||
if (!isNaN(parseFloat(m2))) validNumbers.push(parseFloat(m2))
|
|
||||||
if (!isNaN(parseFloat(m3))) validNumbers.push(parseFloat(m3))
|
|
||||||
|
|
||||||
//只要有效数字的平均值
|
|
||||||
if (validNumbers.length > 0) {
|
|
||||||
// 总和 / 有效数字的个数
|
|
||||||
const sum = validNumbers.reduce((a, b) => a + b, 0)
|
|
||||||
const avg = sum / validNumbers.length
|
|
||||||
this.$set(this.qsForm, this.avgId, this.numberToFixed(avg))
|
|
||||||
} else {
|
|
||||||
// 一个有效数字都没有 → 清空平均值
|
|
||||||
this.$set(this.qsForm, this.avgId, null)
|
this.$set(this.qsForm, this.avgId, null)
|
||||||
|
} else {
|
||||||
|
const avg = (parseFloat(m1) + parseFloat(m2) + parseFloat(m3)) / 3
|
||||||
|
this.$set(this.qsForm, this.avgId, this.numberToFixed(avg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue