预览计算问题修改

uat_us
wangxiaoshuang 2024-03-27 18:06:07 +08:00
parent 1724e020f6
commit 595da0a7de
1 changed files with 26 additions and 6 deletions

View File

@ -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 {
// findnumber
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 {
})
// findnumber
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
}
}