表格问题自动计算更改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
a19d756879
commit
bb4193730e
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue