优化:实训评分规则总分自动统计

This commit is contained in:
fan 2023-02-09 10:34:04 +08:00
parent 7fc9e0fab4
commit 9ef0780377

View File

@ -21,7 +21,7 @@
</el-tooltip>
</el-form-item>
<el-form-item label="总分:" prop="fullMarks" style="display:inline-block">
<el-input-number v-model="addModel.fullMarks" style="width:145px" :min="0" size="mini" :step="1" />
<el-input-number v-model="addModel.fullMarks" :disabled="true" style="width:145px" :min="0" size="mini" :step="1" />
</el-form-item>
</el-form>
<el-table
@ -46,7 +46,7 @@
width="200"
>
<template v-if="addModel.memberId == scope.row.memberId" slot-scope="scope">
<el-input-number v-model="currentStepMap[scope.row.id]" style="width:145px" :min="0" size="mini" :step="1" />
<el-input-number v-model="currentStepMap[scope.row.id]" style="width:145px" :min="0" size="mini" :step="1" @change="stepScoreChange" />
</template>
</el-table-column>
</el-table>
@ -138,19 +138,15 @@ export default {
this.$emit('cancel', this.source);
},
commit() {
console.log('****');
const that = this;
this.$refs.form.validate((valid) => {
if (valid) {
const scoreDetails = [];
let totalScore = 0;
for (const key in this.currentStepMap) {
totalScore += this.currentStepMap[key];
scoreDetails.push({elementId: key, score: this.currentStepMap[key]});
}
if (totalScore !== this.addModel.fullMarks) {
this.$message.error('步骤分总和不等于总分!');
return;
} else if (this.addModel.fullMarks === 0) {
if (this.addModel.fullMarks === 0) {
this.$message.error('规则无评分项!');
return;
}
@ -167,6 +163,13 @@ export default {
});
}
});
},
stepScoreChange(val) {
let fullMarks = 0;
for (const stepKey in this.currentStepMap) {
fullMarks += this.currentStepMap[stepKey];
}
this.addModel.fullMarks = fullMarks;
}
}
};