import { examPropCount } from "@/api/invigilation"; const paramInfo = { all: { name: "全部应考", param: "allCount", desc: "参加考试的全部考生。", icon: "users", unit: "人", }, finish: { name: "完成率", param: "completionRate", desc: "“已完成”科次数量占应考科次数量的百分比。", icon: "rate", unit: "%", }, prepare: { name: "已待考", param: "prepareCount", desc: "已进入待考界面等待开考的考生。", unit: "人", }, exam: { name: "考试中", param: "examCount", desc: "正在答题的考生。", unit: "人", }, complete: { name: "已交卷", param: "alreadyComplete", desc: "某科次的某次考试已完成“交卷”。", unit: "人", }, trouble: { name: "通讯故障", param: "clientWebsocketStatusCount", desc: "考生端出现断网、断电、软硬件故障等异常导致考生端与监考端无法正常连接的考生。", unit: "人", }, unfinish: { name: "未参加考试", param: "notComplete", desc: "某科次完成“交卷”的考试次数为0。", unit: "人", }, }; const types = { trouble: ["all", "prepare", "exam", "complete", "unfinish"], complete: ["all", "prepare", "exam", "complete", "unfinish"], progress: ["all", "prepare", "exam", "complete", "unfinish"], }; // const types = { // trouble: ["all", "prepare", "exam", "trouble", "unfinish"], // complete: ["all", "prepare", "exam", "complete", "unfinish"], // progress: ["all", "finish", "prepare", "unfinish"], // }; export default { name: "summary-line", props: { examId: { type: String, }, dataType: { type: String, required: true, validator: (val) => { return ["trouble", "complete", "progress"].includes(val); }, }, }, // mounted() { // this.initData(); // }, watch: { examId: { immediate: true, handler() { this.initData(); }, }, }, data() { return { paramList: [], examPropData: {}, }; }, methods: { async initData() { if (!this.examId) return; const res = await examPropCount(this.examId).catch(() => {}); this.examPropData = (res && res.data && res.data.data) || {}; if (this.examPropData["completionRate"]) this.examPropData["completionRate"] = Math.round( this.examPropData["completionRate"] * 100 ); this.paramList = types[this.dataType].map((item) => { let info = paramInfo[item]; return { ...info, content: `${info.name}:${info.desc}`, }; }); }, }, };