From d9edaf4c278b27b9d69e1b969bb6e7fe8eefddaf Mon Sep 17 00:00:00 2001 From: caiyiling <1321909229@qq.com> Date: Wed, 25 Mar 2026 09:09:35 +0800 Subject: [PATCH] =?UTF-8?q?OCT=E6=A0=87=E5=87=86FCT=E5=B9=B3=E5=9D=87?= =?UTF-8?q?=E5=80=BC=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dicoms/components/OCT/QuestionList.vue | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/views/trials/trials-panel/reading/dicoms/components/OCT/QuestionList.vue b/src/views/trials/trials-panel/reading/dicoms/components/OCT/QuestionList.vue index c3ad9e80..deec77ee 100644 --- a/src/views/trials/trials-panel/reading/dicoms/components/OCT/QuestionList.vue +++ b/src/views/trials/trials-panel/reading/dicoms/components/OCT/QuestionList.vue @@ -687,11 +687,27 @@ export default { const m1 = this.qsForm[this.m1Id] const m2 = this.qsForm[this.m2Id] const m3 = this.qsForm[this.m3Id] - 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 + // 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) } } },