From 4b84c7df3b5b3dee6885b07351b8ec446e243001 Mon Sep 17 00:00:00 2001 From: caiyiling <1321909229@qq.com> Date: Fri, 18 Oct 2024 14:34:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=AE=A1=E7=AE=97=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/QuestionFormItem.vue | 26 ++++++++++++++++--- .../components/QuestionTableFormItem.vue | 2 +- .../reading-unit/components/QuestionsForm.vue | 15 ++++++----- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/views/trials/trials-panel/setting/reading-unit/components/QuestionFormItem.vue b/src/views/trials/trials-panel/setting/reading-unit/components/QuestionFormItem.vue index de2f752d..7b4f8b92 100644 --- a/src/views/trials/trials-panel/setting/reading-unit/components/QuestionFormItem.vue +++ b/src/views/trials/trials-panel/setting/reading-unit/components/QuestionFormItem.vue @@ -499,9 +499,10 @@ export default { if (rules.CalculateQuestionList.length === 0) { return false; } + let dataArr = [] rules.CalculateQuestionList.forEach((o, i) => { if (i === 0) { - if (rules.CustomCalculateMark > 4) { + if (rules.CustomCalculateMark > 4 && rules.CustomCalculateMark < 10) { switch (rules.CustomCalculateMark) { case 5: this.questionForm[o.QuestionId].forEach((q, qi) => { @@ -552,6 +553,7 @@ export default { } } else { num = parseFloat(this.questionForm[o.TableQuestionId]); + dataArr.push(num) } } else { switch (rules.CustomCalculateMark) { @@ -567,6 +569,26 @@ export default { case 4: num /= parseFloat(this.questionForm[o.TableQuestionId]); break; + case 10: + if (!isNaN(parseFloat(this.questionForm[o.TableQuestionId]))) { + dataArr.push(parseFloat(this.questionForm[o.TableQuestionId])) + } + num = dataArr.length === 0 ? 0 : dataArr.reduce((acc, curr) => { + return acc + (typeof curr === "number" ? curr : 0); + }, 0) / dataArr.length; + break; + case 11: + if (!isNaN(parseFloat(this.questionForm[o.TableQuestionId]))) { + dataArr.push(parseFloat(this.questionForm[o.TableQuestionId])) + } + num = Math.max(...dataArr); + break; + case 12: + if (!isNaN(parseFloat(this.questionForm[o.TableQuestionId]))) { + dataArr.push(parseFloat(this.questionForm[o.TableQuestionId])) + } + num = Math.min(...dataArr); + break; } } }); @@ -581,8 +603,6 @@ export default { var find = v.CalculateQuestionList.filter((o) => { return o.QuestionId === questionId; }); - // find的自动计算值number - console.log("find", find); if (find) { var num = this.logic(v); if (num !== false) { diff --git a/src/views/trials/trials-panel/setting/reading-unit/components/QuestionTableFormItem.vue b/src/views/trials/trials-panel/setting/reading-unit/components/QuestionTableFormItem.vue index cffafe01..ea421bcd 100644 --- a/src/views/trials/trials-panel/setting/reading-unit/components/QuestionTableFormItem.vue +++ b/src/views/trials/trials-panel/setting/reading-unit/components/QuestionTableFormItem.vue @@ -246,7 +246,7 @@ export default { deep: true, immediate: true, handler(v) { - console.log(v) + // console.log(v) } } }, diff --git a/src/views/trials/trials-panel/setting/reading-unit/components/QuestionsForm.vue b/src/views/trials/trials-panel/setting/reading-unit/components/QuestionsForm.vue index cd8e4390..13943606 100644 --- a/src/views/trials/trials-panel/setting/reading-unit/components/QuestionsForm.vue +++ b/src/views/trials/trials-panel/setting/reading-unit/components/QuestionsForm.vue @@ -518,7 +518,7 @@
@@ -528,7 +528,7 @@
@@ -561,13 +561,13 @@ > {{ - [1, 2, 3, 4].includes(form.CustomCalculateMark) ? $t('trials:readingUnit:qsList:message:msg1') : $t('trials:readingUnit:qsList:message:msg2') + [1, 2, 3, 4, 10, 11, 12].includes(form.CustomCalculateMark) ? $t('trials:readingUnit:qsList:message:msg1') : $t('trials:readingUnit:qsList:message:msg2') }}
@@ -947,7 +947,8 @@ export default { }, CustomCalculateMarkChange() { this.isShow = false - if (this.form.CustomCalculateMark <= 4) { + if (this.form.CustomCalculateMark <= 4 || this.form.CustomCalculateMark >= 10) { + console.log('1111') this.form.CalculateQuestions = [ { IsTable: false,