<script> export default { data() { return { subjectnum: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], index: 0, subjectinfo: [], result: 0 } }, methods: { bindPickerChange(e) { if (Number(this.index) > Number(e.detail.value)) { var count = this.index - e.detail.value; var temp = this.subjectinfo.slice(); for (var i = 0; i < count; i++) { temp.pop(); } this.subjectinfo = temp; } else if (Number(this.index) < Number(e.detail.value)) { var count = e.detail.value-this.index var temp = this.subjectinfo.slice() for (var i = 0;i < count;i++) { temp.push({ subject: "科目", credit: 0, grade: 0 }) } this.subjectinfo = temp } this.index = e.detail.value this.result = 0 console.log(this.subjectinfo) }, confirmCredit(e) { this.subjectinfo[e.currentTarget.dataset.index].credit = e.detail.value console.log(this.subjectinfo) }, confirmGrade(e) { this.subjectinfo[e.currentTarget.dataset.index].grade = e.detail.value console.log(this.subjectinfo) }, cal() { const t = this.subjectinfo var sumc = 0 var sum = 0 for (var i = 0;i < this.index;i++) { sumc+=Number(t[i].credit) sum+=Number(t[i].credit)*(4-3*(100-Number(t[i].grade))*(100-Number(t[i].grade))/1600) } var result = sum/sumc this.result = result }, } } </script>
|