From 595da0a7de019268a8d29f38f94e289066ca28b1 Mon Sep 17 00:00:00 2001 From: wangxiaoshuang <825034831@qq.com> Date: Wed, 27 Mar 2024 18:06:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E8=A7=88=E8=AE=A1=E7=AE=97=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/QuestionFormItem.vue | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 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 2c4f5256..571c2f3a 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 @@ -433,6 +433,7 @@ export default { this.addOrEdit.visible = false }, logic(rules, num = 0) { + console.log(rules,'rules') try { if (rules.CalculateQuestionList.length === 0) { return false @@ -522,6 +523,7 @@ export default { // find的自动计算值number console.log('find', find) if (find) { + console.log(v,'111111') var num = this.logic(v) if (num !== false) { this.$emit('setFormItemData', { key: v.QuestionId, val: num }) @@ -535,6 +537,7 @@ export default { }) // find的自动计算值number if (find) { + console.log(v,'222222') var num = this.logic(v) if (num !== false) { this.$emit('setFormItemData', { key: v.QuestionId, val: num }) @@ -548,23 +551,40 @@ export default { this.question.TableQuestions.Questions.forEach(v => { if (v.Type === 'number' && v.DataSource === 1) { var CalculateQuestions = JSON.parse(v.CalculateQuestions) - var num + var num, minArr=[],maxArr=[],arr=[] CalculateQuestions.forEach((o, i) => { if (i === 0) { - num = this.QuestionsForm[o.TableQuestionId] + num = parseFloat(this.QuestionsForm[o.TableQuestionId]) + minArr = [num]; + maxArr = [num]; + arr = [num]; } else { switch (v.CustomCalculateMark) { case 1: - num += this.QuestionsForm[o.TableQuestionId] + num += parseFloat(this.QuestionsForm[o.TableQuestionId]) break case 2: - num -= this.QuestionsForm[o.TableQuestionId] + num -= parseFloat(this.QuestionsForm[o.TableQuestionId]) break case 3: - num *= this.QuestionsForm[o.TableQuestionId] + num *= parseFloat(this.QuestionsForm[o.TableQuestionId]) break case 4: - num /= this.QuestionsForm[o.TableQuestionId] + num /= parseFloat(this.QuestionsForm[o.TableQuestionId]) + break + case 7: + arr.push(parseFloat(this.QuestionsForm[o.TableQuestionId])) + num += parseFloat(this.QuestionsForm[o.TableQuestionId]) + num = arr.length === 0 ? 0 : num / arr.length + break + case 8: + maxArr.push(parseFloat(this.QuestionsForm[o.TableQuestionId])) + num = maxArr.length === 0 ? 0 : Math.max(...maxArr) + break + case 9: + minArr.push(parseFloat(this.QuestionsForm[o.TableQuestionId])) + num = minArr.length === 0 ? 0 : Math.min(...minArr) + // console.log('min', this.questionForm[o.QuestionId], arr, num) break } }