|
@@ -10,8 +10,27 @@
|
|
|
append-to-body
|
|
|
@open="visibleChange"
|
|
|
>
|
|
|
- <p class="mb-2">{{ targetDesc }}</p>
|
|
|
- <el-table :data="dataList" border>
|
|
|
+ <div class="mb-2 box-justify">
|
|
|
+ <div class="box-grow mr-2">
|
|
|
+ <span v-for="(target, index) in treeData" :key="target.id">
|
|
|
+ <span>{{ target.name }}占比</span>
|
|
|
+ <span
|
|
|
+ v-if="targetRates[target.id]"
|
|
|
+ :class="[
|
|
|
+ 'mlr-1',
|
|
|
+ targetRates[target.id].valid ? 'color-success' : 'color-danger',
|
|
|
+ ]"
|
|
|
+ >{{ targetRates[target.id].rate }}%</span
|
|
|
+ >
|
|
|
+ <span>({{ target.totalWeight || 0 }}%)</span>
|
|
|
+ <span>{{ index === treeData.length - 1 ? "。" : "," }}</span>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <el-button type="primary" :loading="loading" @click="toSync"
|
|
|
+ >同步</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <el-table :data="dataList" border height="400">
|
|
|
<el-table-column
|
|
|
prop="mainNumber"
|
|
|
label="大题号"
|
|
@@ -73,7 +92,11 @@
|
|
|
<script>
|
|
|
import { calcSum } from "@/plugins/utils";
|
|
|
import { courseTargetList } from "../../base/api";
|
|
|
-import { endScorePaperPositiveDetail, endScorePaperPositiveSave } from "../api";
|
|
|
+import {
|
|
|
+ endScorePaperPositiveDetail,
|
|
|
+ endScorePaperPositiveSave,
|
|
|
+ endScorePaperPositiveSync,
|
|
|
+} from "../api";
|
|
|
import SelectBlueDimensionDialog from "./SelectBlueDimensionDialog.vue";
|
|
|
|
|
|
export default {
|
|
@@ -95,7 +118,8 @@ export default {
|
|
|
curRow: {},
|
|
|
selectedData: [],
|
|
|
treeData: [],
|
|
|
- targetDesc: "",
|
|
|
+ targetRates: {},
|
|
|
+ loading: false,
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
@@ -124,11 +148,6 @@ export default {
|
|
|
}),
|
|
|
};
|
|
|
});
|
|
|
-
|
|
|
- this.targetDesc = this.treeData
|
|
|
- .map((item) => `${item.name}占比${item.totalWeight || 0}%`)
|
|
|
- .join(",");
|
|
|
- this.targetDesc += "。";
|
|
|
},
|
|
|
async getBlueDetail() {
|
|
|
const res = await endScorePaperPositiveDetail({
|
|
@@ -137,6 +156,7 @@ export default {
|
|
|
paperNumber: this.course.paperNumber,
|
|
|
});
|
|
|
this.dataList = res || [];
|
|
|
+ this.updateTargetRates();
|
|
|
},
|
|
|
visibleChange() {
|
|
|
this.getBlueDetail();
|
|
@@ -147,6 +167,21 @@ export default {
|
|
|
open() {
|
|
|
this.modalIsShow = true;
|
|
|
},
|
|
|
+ async toSync() {
|
|
|
+ if (this.loading) return;
|
|
|
+ this.loading = true;
|
|
|
+
|
|
|
+ const res = await endScorePaperPositiveSync({
|
|
|
+ examId: this.course.examId,
|
|
|
+ courseCode: this.course.courseCode,
|
|
|
+ paperNumber: this.course.paperNumber,
|
|
|
+ }).catch(() => {});
|
|
|
+ this.loading = false;
|
|
|
+ if (!res) return;
|
|
|
+
|
|
|
+ this.$message.success(`${res.success},错误:${res.error}`);
|
|
|
+ this.getBlueDetail();
|
|
|
+ },
|
|
|
checkData() {
|
|
|
const valid = !this.dataList.some(
|
|
|
(item) => !item.targetList || !item.targetList.length
|
|
@@ -157,20 +192,10 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const scoreData = {};
|
|
|
- this.dataList.forEach((item) => {
|
|
|
- if (!item.targetList || !item.targetList.length) return;
|
|
|
- const targetId = item.targetList[0].targetId;
|
|
|
- if (!scoreData[targetId]) scoreData[targetId] = 0;
|
|
|
- scoreData[targetId] += item.score;
|
|
|
- });
|
|
|
- // console.log(scoreData);
|
|
|
- const totalScore = calcSum(Object.values(scoreData));
|
|
|
-
|
|
|
const unvalidTargets = [];
|
|
|
- this.treeData.forEach((target) => {
|
|
|
- const rate = (100 * scoreData[target.id]) / totalScore;
|
|
|
- if (rate != target.totalWeight) unvalidTargets.push(target.name);
|
|
|
+ Object.keys(this.targetRates).forEach((tid) => {
|
|
|
+ const target = this.targetRates[tid];
|
|
|
+ if (!target.valid) unvalidTargets.push(target.name);
|
|
|
});
|
|
|
if (unvalidTargets.length) {
|
|
|
this.$message.error(`${unvalidTargets.join("、")}占比不符合要求`);
|
|
@@ -192,6 +217,29 @@ export default {
|
|
|
dimensionSelected(targetList) {
|
|
|
this.curRow.targetList = targetList;
|
|
|
this.curRow.courseTargetName = targetList[0].targetName;
|
|
|
+ this.updateTargetRates();
|
|
|
+ },
|
|
|
+ updateTargetRates() {
|
|
|
+ const scoreData = {};
|
|
|
+ this.dataList.forEach((item) => {
|
|
|
+ if (!item.targetList || !item.targetList.length) return;
|
|
|
+ const targetId = item.targetList[0].targetId;
|
|
|
+ if (!scoreData[targetId]) scoreData[targetId] = 0;
|
|
|
+ scoreData[targetId] += item.score;
|
|
|
+ });
|
|
|
+ const totalScore = calcSum(Object.values(scoreData));
|
|
|
+
|
|
|
+ const targetRates = {};
|
|
|
+ this.treeData.forEach((target) => {
|
|
|
+ const targetScore = scoreData[target.id] || 0;
|
|
|
+ const rate = !totalScore ? 0 : (100 * targetScore) / totalScore;
|
|
|
+ targetRates[target.id] = {
|
|
|
+ rate: Number.isInteger(rate) ? rate : rate.toFixed(2),
|
|
|
+ valid: rate == target.totalWeight,
|
|
|
+ name: target.name,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ this.targetRates = targetRates;
|
|
|
},
|
|
|
async submit() {
|
|
|
if (!this.checkData()) {
|