预览计算问题修改
parent
1724e020f6
commit
595da0a7de
|
@ -433,6 +433,7 @@ export default {
|
||||||
this.addOrEdit.visible = false
|
this.addOrEdit.visible = false
|
||||||
},
|
},
|
||||||
logic(rules, num = 0) {
|
logic(rules, num = 0) {
|
||||||
|
console.log(rules,'rules')
|
||||||
try {
|
try {
|
||||||
if (rules.CalculateQuestionList.length === 0) {
|
if (rules.CalculateQuestionList.length === 0) {
|
||||||
return false
|
return false
|
||||||
|
@ -522,6 +523,7 @@ export default {
|
||||||
// find的自动计算值number
|
// find的自动计算值number
|
||||||
console.log('find', find)
|
console.log('find', find)
|
||||||
if (find) {
|
if (find) {
|
||||||
|
console.log(v,'111111')
|
||||||
var num = this.logic(v)
|
var num = this.logic(v)
|
||||||
if (num !== false) {
|
if (num !== false) {
|
||||||
this.$emit('setFormItemData', { key: v.QuestionId, val: num })
|
this.$emit('setFormItemData', { key: v.QuestionId, val: num })
|
||||||
|
@ -535,6 +537,7 @@ export default {
|
||||||
})
|
})
|
||||||
// find的自动计算值number
|
// find的自动计算值number
|
||||||
if (find) {
|
if (find) {
|
||||||
|
console.log(v,'222222')
|
||||||
var num = this.logic(v)
|
var num = this.logic(v)
|
||||||
if (num !== false) {
|
if (num !== false) {
|
||||||
this.$emit('setFormItemData', { key: v.QuestionId, val: num })
|
this.$emit('setFormItemData', { key: v.QuestionId, val: num })
|
||||||
|
@ -548,23 +551,40 @@ export default {
|
||||||
this.question.TableQuestions.Questions.forEach(v => {
|
this.question.TableQuestions.Questions.forEach(v => {
|
||||||
if (v.Type === 'number' && v.DataSource === 1) {
|
if (v.Type === 'number' && v.DataSource === 1) {
|
||||||
var CalculateQuestions = JSON.parse(v.CalculateQuestions)
|
var CalculateQuestions = JSON.parse(v.CalculateQuestions)
|
||||||
var num
|
var num, minArr=[],maxArr=[],arr=[]
|
||||||
CalculateQuestions.forEach((o, i) => {
|
CalculateQuestions.forEach((o, i) => {
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
num = this.QuestionsForm[o.TableQuestionId]
|
num = parseFloat(this.QuestionsForm[o.TableQuestionId])
|
||||||
|
minArr = [num];
|
||||||
|
maxArr = [num];
|
||||||
|
arr = [num];
|
||||||
} else {
|
} else {
|
||||||
switch (v.CustomCalculateMark) {
|
switch (v.CustomCalculateMark) {
|
||||||
case 1:
|
case 1:
|
||||||
num += this.QuestionsForm[o.TableQuestionId]
|
num += parseFloat(this.QuestionsForm[o.TableQuestionId])
|
||||||
break
|
break
|
||||||
case 2:
|
case 2:
|
||||||
num -= this.QuestionsForm[o.TableQuestionId]
|
num -= parseFloat(this.QuestionsForm[o.TableQuestionId])
|
||||||
break
|
break
|
||||||
case 3:
|
case 3:
|
||||||
num *= this.QuestionsForm[o.TableQuestionId]
|
num *= parseFloat(this.QuestionsForm[o.TableQuestionId])
|
||||||
break
|
break
|
||||||
case 4:
|
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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue