From bb4193730e0f4eb8a5dc7b4c36352c075ca3d3f6 Mon Sep 17 00:00:00 2001 From: caiyiling <1321909229@qq.com> Date: Wed, 30 Oct 2024 13:31:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E9=97=AE=E9=A2=98=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=AE=A1=E7=AE=97=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customize/CustomizeQuestionFormItem.vue | 75 +++++++++++++++---- .../CustomizeQuestionTableFormItem.vue | 17 +---- 2 files changed, 63 insertions(+), 29 deletions(-) diff --git a/src/views/trials/trials-panel/reading/dicoms/customize/CustomizeQuestionFormItem.vue b/src/views/trials/trials-panel/reading/dicoms/customize/CustomizeQuestionFormItem.vue index 798750ac..f41ee6d0 100644 --- a/src/views/trials/trials-panel/reading/dicoms/customize/CustomizeQuestionFormItem.vue +++ b/src/views/trials/trials-panel/reading/dicoms/customize/CustomizeQuestionFormItem.vue @@ -763,35 +763,84 @@ export default { } // this.$emit('formItemNumberChange') }, + // formItemTableNumberChange() { + // this.question.TableQuestions.Questions.forEach(v => { + // if (v.Type === 'number' && v.DataSource === 1) { + // var CalculateQuestions = JSON.parse(v.CalculateQuestions) + // var num + // CalculateQuestions.forEach((o, i) => { + // if (i === 0) { + // num = this.QuestionsForm[o.TableQuestionId] + // } else { + // switch (v.CustomCalculateMark) { + // case 1: + // num += this.QuestionsForm[o.TableQuestionId] + // break; + // case 2: + // num -= this.QuestionsForm[o.TableQuestionId] + // break; + // case 3: + // num *= this.QuestionsForm[o.TableQuestionId] + // break; + // case 4: + // num /= this.QuestionsForm[o.TableQuestionId] + // break; + // } + // } + // }) + // this.$set(this.QuestionsForm, v.Id, num.toString()) + // } + // }) + + // }, formItemTableNumberChange() { - this.question.TableQuestions.Questions.forEach(v => { - if (v.Type === 'number' && v.DataSource === 1) { - var CalculateQuestions = JSON.parse(v.CalculateQuestions) - var num + this.question.TableQuestions.Questions.forEach((v) => { + if (v.Type === "number" && v.DataSource === 1) { + var CalculateQuestions = JSON.parse(v.CalculateQuestions); + var num, + arr = []; CalculateQuestions.forEach((o, i) => { if (i === 0) { - num = this.QuestionsForm[o.TableQuestionId] + num = parseFloat(this.QuestionsForm[o.TableQuestionId]); + 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 = + arr.length === 0 + ? 0 + : arr.reduce((acc, curr) => { + return acc + (typeof curr === "number" ? curr : 0); + }, 0) / arr.length; + break; + case 8: + arr.push(parseFloat(this.QuestionsForm[o.TableQuestionId])); + num = arr.length === 0 ? 0 : Math.max(...arr); + break; + case 9: + arr.push(parseFloat(this.QuestionsForm[o.TableQuestionId])); + num = arr.length === 0 ? 0 : Math.min(...arr); + // console.log('min', this.questionForm[o.QuestionId], arr, num) break; } } - }) - this.$set(this.QuestionsForm, v.Id, num.toString()) + }); + this.$set(this.QuestionsForm, v.Id, num.toString()); } - }) - + }); }, openAddTableCol(row, index) { this.addOrEdit.visible = true diff --git a/src/views/trials/trials-panel/reading/dicoms/customize/CustomizeQuestionTableFormItem.vue b/src/views/trials/trials-panel/reading/dicoms/customize/CustomizeQuestionTableFormItem.vue index 9b90234b..6aa5e0df 100644 --- a/src/views/trials/trials-panel/reading/dicoms/customize/CustomizeQuestionTableFormItem.vue +++ b/src/views/trials/trials-panel/reading/dicoms/customize/CustomizeQuestionTableFormItem.vue @@ -482,22 +482,7 @@ export default { return num.toFixed(digitPlaces) }, formItemNumberChange(v, question) { - this.CalculationList.forEach((v, i) => { - console.log('v', v) - var find = v.CalculateQuestionList.filter(o => { - return o.QuestionId === question.Id - }) - console.log('find', find) - // find的自动计算值number - if (find) { - var num = this.logic(v) - console.log(num) - if (num !== false) { - this.$set(this.questionForm, v.QuestionId, num) - // this.$emit('setFormItemData', { key: v.QuestionId, val: num }) - } - } - }) + this.$emit('formItemTableNumberChange', v, question) // this.$emit('formItemTableNumberChange', v, question) }, resetChild(obj) {