|
@@ -62,7 +62,7 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import { courseExamineWeightDetail, courseExamineWeightSave } from "../../api";
|
|
import { courseExamineWeightDetail, courseExamineWeightSave } from "../../api";
|
|
-import { calcSum } from "@/plugins/utils";
|
|
|
|
|
|
+import { calcSum, toPrecision } from "@/plugins/utils";
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "course-examine-weight",
|
|
name: "course-examine-weight",
|
|
@@ -90,6 +90,9 @@ export default {
|
|
this.columns = [];
|
|
this.columns = [];
|
|
await this.getList();
|
|
await this.getList();
|
|
},
|
|
},
|
|
|
|
+ calcSumPrecision(dList) {
|
|
|
|
+ return toPrecision(calcSum(dList), 2);
|
|
|
|
+ },
|
|
async getList() {
|
|
async getList() {
|
|
const res = await courseExamineWeightDetail({
|
|
const res = await courseExamineWeightDetail({
|
|
obeCourseOutlineId: this.rowData.id,
|
|
obeCourseOutlineId: this.rowData.id,
|
|
@@ -135,7 +138,7 @@ export default {
|
|
},
|
|
},
|
|
weightChange(rowIndex, cindex) {
|
|
weightChange(rowIndex, cindex) {
|
|
this.dataList.forEach((item, tindex) => {
|
|
this.dataList.forEach((item, tindex) => {
|
|
- item.totalWeight = calcSum(
|
|
|
|
|
|
+ item.totalWeight = this.calcSumPrecision(
|
|
item.evaluationList.map((elem) => elem.weight || 0)
|
|
item.evaluationList.map((elem) => elem.weight || 0)
|
|
);
|
|
);
|
|
});
|
|
});
|
|
@@ -168,7 +171,7 @@ export default {
|
|
|
|
|
|
// 所有课程目标都应该有设置权重
|
|
// 所有课程目标都应该有设置权重
|
|
this.dataList.forEach((item, tindex) => {
|
|
this.dataList.forEach((item, tindex) => {
|
|
- item.totalWeight = calcSum(
|
|
|
|
|
|
+ item.totalWeight = this.calcSumPrecision(
|
|
item.evaluationList.map((elem) => elem.weight || 0)
|
|
item.evaluationList.map((elem) => elem.weight || 0)
|
|
);
|
|
);
|
|
});
|
|
});
|
|
@@ -182,7 +185,7 @@ export default {
|
|
}
|
|
}
|
|
|
|
|
|
// 目标整体权重
|
|
// 目标整体权重
|
|
- const totalWeight = calcSum(
|
|
|
|
|
|
+ const totalWeight = this.calcSumPrecision(
|
|
this.dataList.map((item) => item.totalWeight || 0)
|
|
this.dataList.map((item) => item.totalWeight || 0)
|
|
);
|
|
);
|
|
if (totalWeight !== 100) {
|
|
if (totalWeight !== 100) {
|
|
@@ -218,13 +221,13 @@ export default {
|
|
}
|
|
}
|
|
|
|
|
|
if (index === lastNo) {
|
|
if (index === lastNo) {
|
|
- sums[index] = calcSum(
|
|
|
|
|
|
+ sums[index] = this.calcSumPrecision(
|
|
this.dataList.map((item) => item.totalWeight || 0)
|
|
this.dataList.map((item) => item.totalWeight || 0)
|
|
);
|
|
);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- sums[index] = calcSum(
|
|
|
|
|
|
+ sums[index] = this.calcSumPrecision(
|
|
this.dataList.map(
|
|
this.dataList.map(
|
|
(item) => item.evaluationList[index - 1].weight || 0
|
|
(item) => item.evaluationList[index - 1].weight || 0
|
|
)
|
|
)
|