完善 考试流程

This commit is contained in:
小肥羊 2025-08-19 18:34:23 +08:00
parent 733b406eb7
commit 823a2d5fa9
12 changed files with 359 additions and 112 deletions

3
.gitignore vendored
View File

@ -19,4 +19,5 @@ tests/**/coverage/
*.ntvs*
*.njsproj
*.sln
tsconfig.tsbuildinfo
tsconfig.tsbuildinfo
.vscode

View File

@ -1,6 +1,6 @@
{
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.formatOnSave": false,
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
@ -40,4 +40,5 @@
"v-ripple"
],
"vscodeCustomCodeColor.highlightValueColor": "#b392f0",
"vue3snippets.enable-compile-vue-file-on-did-save-code": true,
}

View File

@ -18,7 +18,18 @@ export function ImportExamInfo(id: number, file: File) {
{
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
},
responseType: "blob"
}
);
}
/**
* @description
* @return {object}
*/
export function DeleteExamInfo(data: { classId: number; examId: number }) {
return http.request<any>("post", `ExamClassInfo/DeleteExamInfo`, {
data
});
}

View File

@ -62,6 +62,21 @@ export function cloudSchoolCombo() {
}
);
}
/**
* @description
* @return {object}
*/
export function getClassInfo(id) {
return http.request<Res<any>>("get", `userCenter/back/classes/${id}`);
}
/**
* @description
* @return {object}
*/
export function getSchoolInfo(id) {
return http.request<Res<any>>("get", `userCenter/back/schools/${id}`);
}
/**
* @description
* @return {object}

View File

@ -94,7 +94,8 @@ function appStyle() {
tableHeight.value =
appB.value.parentElement.parentElement.offsetHeight -
145 -
appB_S.value.offsetHeight;
appB_S.value.offsetHeight +
0;
return tableHeight;
}

View File

@ -74,7 +74,7 @@ const convertKeysToCamelCase = <T>(data: any): T => {
const defaultConfig: AxiosRequestConfig = {
baseURL: import.meta.env.VITE_API_BASEURL,
// 请求超时时间
timeout: 10000,
timeout: 20 * 1000,
headers: {
Accept: "application/json, text/plain, */*",
"Content-Type": "application/json",
@ -183,7 +183,8 @@ class PureHttp {
const $config = response.config;
// 关闭进度条动画
NProgress.done();
response.data = convertKeysToCamelCase(response.data);
if (!(response.data instanceof Blob))
response.data = convertKeysToCamelCase(response.data);
// 优先判断post/get等方法是否传入回调否则执行初始化设置等回调
if (typeof $config.beforeResponseCallback === "function") {
$config.beforeResponseCallback(response);

View File

@ -6,10 +6,13 @@ import { fa } from "element-plus/es/locales.mjs";
import { hTableAPI } from "@/api/hTable";
import { getenum } from "@/api/enum";
import { ruleRequired, ruleRequiredNumber } from "@/utils/rules";
import { DeleteExamInfo, ImportExamInfo } from "@/api/exam";
import { entryExamInfo } from "./examFun";
import { ElMessage, ElMessageBox } from "element-plus";
const ControllerName = "ExamClassInfo";
defineOptions({
name: ControllerName
name: ControllerName,
});
const props = defineProps<{
@ -33,10 +36,10 @@ const tableData: TableConfig = {
{
FieldName: "ExamId",
FieldValue: props.data[0].id + "",
ConditionalType: ConditionalType.Equal
}
ConditionalType: ConditionalType.Equal,
},
], //
Conditions: []
Conditions: [],
},
operationColumn: true, //
operationColumnData: [
@ -45,21 +48,21 @@ const tableData: TableConfig = {
topBtn: true, //
label: "添加",
btnStyle: "success",
btnType: "custom"
btnType: "custom",
},
{
topBtn: false, //
show: true,
label: "删除",
btnType: "del", // add edit del
btnStyle: "danger" // topBtn: true success danger
click: deleteInfo,
btnStyle: "danger", // topBtn: true success danger
},
{
topBtn: false, //
show: true,
label: "重新录入",
btnType: "custom", // add edit del
btnStyle: "primary" // topBtn: true success danger
click: reloadImportInfo,
btnStyle: "primary", // topBtn: true success danger
},
{
topBtn: false, //
@ -71,9 +74,9 @@ const tableData: TableConfig = {
title: "考试学生班级详情", // title
src: "exam/userDetails", //
width: "1600px", //
height: "800px" //
}
}
height: "880px", //
},
},
],
column: {
//
@ -83,15 +86,15 @@ const tableData: TableConfig = {
searchType: ConditionalType.Like, //
add: false, //
edit: false, //
width: "180px"
width: "180px",
},
grade: {
label: "年级",
width: "100px",
custom: s => `${s.gradeYear}${s.gradeLevel}`,
custom: (s) => `${s.gradeYear}${s.gradeLevel}`,
search: true,
add: false, //
edit: false //
edit: false, //
},
className: {
label: "班级",
@ -99,37 +102,62 @@ const tableData: TableConfig = {
search: true,
searchType: ConditionalType.Like, //
add: false, //
edit: false //
edit: false, //
},
peopleCount: {
label: "参考人数",
width: "100px",
search: false,
add: false, //
edit: false //
edit: false, //
},
entryPerson: {
label: "录入人",
width: "200px",
search: true,
add: false, //
edit: false //
edit: false, //
},
createTime: {
label: "录入时间",
width: "200px",
search: true,
add: false, //
edit: false //
}
edit: false, //
},
},
data: [],
pageData: {
total: 0
total: 0,
},
selectRows: []
selectRows: [],
};
async function deleteInfo(o, row, c) {
try {
await ElMessageBox.confirm("是否删除考试信息?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
});
await DeleteExamInfo({ examId: row[0].examId, classId: row[0].classId });
} catch (error) {
ElMessage.info("取消删除");
}
}
async function reloadImportInfo(o, row, c) {
try {
await ElMessageBox.confirm("是否重新录入考试信息?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
});
await DeleteExamInfo({ examId: row[0].examId, classId: row[0].classId });
entryExamInfo(row[0].examId);
} catch (error) {
ElMessage.info("取消重新录入");
}
}
const showTable = ref(false);
onMounted(async () => {
//

View File

@ -9,7 +9,7 @@ import { ruleRequired, ruleRequiredNumber } from "@/utils/rules";
const ControllerName = "ExamClassInfo";
defineOptions({
name: "ClassExam"
name: "ClassExam",
});
const props = defineProps<{
@ -29,24 +29,25 @@ const tableData: TableConfig = {
PageIndex: 0,
PageSize: 20,
OrderBy: "Id", //
OrderByType: 1, //
defaultConditions: [], //
Conditions: []
Conditions: [],
},
operationColumn: true, //
operationColumnData: [
{
topBtn: false, //
show: true,
label: "学生成绩详情",
label: "详情",
btnType: "custom",
btnStyle: "primary",
custom: {
title: "考试学生班级详情", // title
src: "exam/userDetails", //
width: "1600px", //
height: "800px" //
}
}
height: "800px", //
},
},
],
column: {
//
@ -56,51 +57,55 @@ const tableData: TableConfig = {
searchType: ConditionalType.Like, //
add: false, //
edit: false, //
width: "180px"
width: "180px",
},
grade: {
label: "年级",
width: "100px",
custom: s => `${s.gradeYear}${s.gradeLevel}`,
width: "120px",
custom: (s) => `${s.gradeYear}${s.gradeLevel}`,
search: true,
add: false, //
edit: false //
edit: false, //
},
className: {
label: "班级",
width: "150px",
width: "80px",
search: true,
searchType: ConditionalType.Like, //
add: false, //
edit: false //
edit: false, //
},
examName: {
label: "最近考试",
width: "200px",
search: false,
},
peopleCount: {
label: "参考人数",
width: "100px",
search: false,
add: false, //
edit: false //
},
entryPerson: {
label: "录入人",
width: "200px",
search: true,
add: false, //
edit: false //
onLineCount: {
label: "重本人数",
width: "100px",
search: false,
},
onLineRate: {
label: "重本率",
width: "100px",
custom: (row) => `${row.onLineRate * 100}%`,
search: false,
},
onLineRanking: {
label: "重本率排名",
search: false,
},
createTime: {
label: "录入时间",
width: "200px",
search: true,
add: false, //
edit: false //
}
},
data: [],
pageData: {
total: 0
total: 0,
},
selectRows: []
selectRows: [],
};
const showTable = ref(false);

36
src/views/exam/examFun.ts Normal file
View File

@ -0,0 +1,36 @@
import { ImportExamInfo } from "@/api/exam";
import { ElMessage } from "element-plus";
export function entryExamInfo(eid: number) {
let fileE = document.createElement("input");
fileE.type = "file";
var formData = new window.FormData();
fileE.onchange = async function () {
formData.append("File", fileE.files[0]);
let res = await ImportExamInfo(eid, fileE.files[0]);
if (res.code != undefined) {
if (res.code !== 200) return ElMessage.error(res.message);
else return ElMessage.success("所有数据录入成功");
} else if (res.type === "application/json") {
let json = await res.text();
if (json !== undefined && json.Code !== 200) {
return ElMessage.error(json.Message);
} else {
return ElMessage.success("操所有数据录入成功作成功");
}
} else if (res === undefined || res.size === 0)
return ElMessage.success("所有数据录入成功");
const url = res && window.URL.createObjectURL(res);
const link = document.createElement("a");
link.href = url;
link.setAttribute("download", "未成功导入的考试信息数据" + ".xlsx");
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
ElMessage.success("操作成功,已导出重复数据");
};
try {
fileE.click();
} catch (error) { }
}

View File

@ -8,10 +8,11 @@ import { getenum } from "@/api/enum";
import { ruleRequired, ruleRequiredNumber } from "@/utils/rules";
import { ImportExamInfo } from "@/api/exam";
import { ElMessage } from "element-plus";
import { entryExamInfo } from "./examFun";
const ControllerName = "Exam";
defineOptions({
name: ControllerName
name: ControllerName,
});
function searchCallback(data) {}
@ -29,7 +30,7 @@ const tableData: TableConfig = {
PageSize: 20,
OrderBy: "Id", //
defaultConditions: [], //
Conditions: []
Conditions: [],
},
operationColumn: true, //
operationColumnData: [
@ -37,21 +38,21 @@ const tableData: TableConfig = {
//
topBtn: false, //
label: "修改",
btnType: "edit" // add edit del custom
btnType: "edit", // add edit del custom
},
{
//
topBtn: true, //
label: "添加",
btnStyle: "success",
btnType: "add" // add edit del custom
btnType: "add", // add edit del custom
},
{
topBtn: false, //
show: true,
label: "删除",
btnType: "del", // add edit del
btnStyle: "danger" // topBtn: true success danger
btnStyle: "danger", // topBtn: true success danger
},
{
topBtn: false, //
@ -63,16 +64,16 @@ const tableData: TableConfig = {
title: "考试班级详情", // title
src: "exam/classDetails", //
width: "1300px", //
height: "800px" //
}
height: "800px", //
},
},
{
topBtn: false, //
show: true,
label: "录入成绩",
click: entryExam,
btnStyle: "primary" // topBtn: true success danger
}
btnStyle: "primary", // topBtn: true success danger
},
],
column: {
//
@ -81,7 +82,7 @@ const tableData: TableConfig = {
search: true,
add: false, //
edit: false, //
width: "150px"
width: "150px",
},
name: {
label: "考试名称",
@ -91,7 +92,7 @@ const tableData: TableConfig = {
searchType: ConditionalType.Like, //
add: true, //
edit: true, //
setting: {}
setting: {},
},
level: {
label: "年级",
@ -101,7 +102,7 @@ const tableData: TableConfig = {
setting: {},
search: true,
add: true, //
edit: true //
edit: true, //
},
testPaperType: {
label: "试卷类型",
@ -111,7 +112,7 @@ const tableData: TableConfig = {
setting: {},
search: true,
add: true, //
edit: true //
edit: true, //
},
type: {
label: "考试类型",
@ -121,7 +122,7 @@ const tableData: TableConfig = {
setting: {},
search: true,
add: true, //
edit: true //
edit: true, //
},
scoreLine: {
label: "划线分数",
@ -130,7 +131,7 @@ const tableData: TableConfig = {
width: "100px",
setting: {},
add: true, //
edit: true //
edit: true, //
},
startTime: {
label: "考试时间",
@ -140,54 +141,24 @@ const tableData: TableConfig = {
type: "datetime",
setting: {},
add: true, //
edit: true //
edit: true, //
},
createTime: {
label: "创建时间",
type: "datetime",
search: true,
add: false, //
edit: false //
}
edit: false, //
},
},
data: [],
pageData: {
total: 0
total: 0,
},
selectRows: []
selectRows: [],
};
function entryExam(obj, row, callBack) {
let fileE = document.createElement("input");
fileE.type = "file";
var formData = new window.FormData();
fileE.onchange = async function () {
formData.append("File", fileE.files[0]);
let res = await ImportExamInfo(row[0].id, fileE.files[0]);
if (res.code != undefined) {
if (res.code !== 200) return ElMessage.error(res.message);
else return ElMessage.success("所有数据录入成功");
} else if (res.type === "application/json") {
let json = await res.text();
if (json !== undefined && json.Code !== 200) {
return ElMessage.error(json.Message);
} else {
return ElMessage.success("操所有数据录入成功作成功");
}
} else if (res === undefined || res.size === 0)
return ElMessage.success("所有数据录入成功");
const url = res && window.URL.createObjectURL(res);
const link = document.createElement("a");
link.href = url;
link.setAttribute("download", "未成功导入的考试信息数据" + ".xlsx");
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
ElMessage.success("操作成功,已导出重复数据");
};
try {
fileE.click();
} catch (error) {}
entryExamInfo(row[0].id);
}
const showTable = ref(false);
onMounted(async () => {
@ -198,9 +169,7 @@ onMounted(async () => {
tableData.column.testPaperType.setting.datasource = (
await getenum("TestPaperTypeEnum")
).data;
tableData.column.type.setting.datasource = (
await getenum("ExamTypeEnum")
).data;
tableData.column.type.setting.datasource = (await getenum("ExamTypeEnum")).data;
showTable.value = true;
});

View File

@ -59,7 +59,13 @@ const tableData: TableConfig = {
topBtn: false, //
label: "个人详情",
btnType: "custom",
btnStyle: "primary" // topBtn: true success danger
btnStyle: "primary",
custom: {
title: "考试学生班级详情", // title
src: "exam/userExam", //
width: "1600px", //
height: "800px" //
}
}
],
column: {

173
src/views/exam/userExam.vue Normal file
View File

@ -0,0 +1,173 @@
<script setup lang="ts">
import ahTable from "@/components/hTable/index.vue";
import { ConditionalType, TableConfig } from "@/components/hTable/hTable";
import { onMounted, ref } from "vue";
import { fa } from "element-plus/es/locales.mjs";
import { hTableAPI } from "@/api/hTable";
import { getenum } from "@/api/enum";
import { ruleRequired, ruleRequiredNumber } from "@/utils/rules";
import { getClassInfo, getSchoolInfo } from "@/api/userCenter";
const ControllerName = "ExamUserInfo";
defineOptions({
name: ControllerName,
});
const props = defineProps<{
data: any;
}>();
function searchCallback(data) {}
const table = ref<{ initTable: (config: TableConfig) => void }>();
const tableData: TableConfig = {
apiUrl: ControllerName,
selectColumn: false, //
border: false, //
searchCallback: searchCallback,
search: {
//
show: true,
PageIndex: 0,
PageSize: 60,
OrderBy: "Id", //
OrderByType: 1,
defaultConditions: [
{
FieldName: "UserId",
FieldValue: props.data[0].userId + "",
},
], //
Conditions: [],
},
operationColumn: true, //
operationColumnData: [],
column: {
//
examName: {
label: "考试名称",
search: true,
searchType: ConditionalType.Like, //
width: "180px",
},
//
type: {
label: "考试类型",
search: true,
type: "dropdown",
setting: {},
width: "150px",
},
//
grade: {
label: "考试阶段",
search: true,
searchType: ConditionalType.Like, //
width: "120px",
}, //
testPaperType: {
label: "试卷类型",
search: true,
type: "dropdown",
setting: {},
width: "150px",
},
语文: {
label: "语文",
search: false,
width: "80px",
custom: (row) => row.subjectDic.语文 ?? "--",
},
数学: {
label: "数学",
search: false,
width: "80px",
custom: (row) => row.subjectDic.数学 ?? "--",
},
英语: {
label: "英语",
search: false,
width: "80px",
custom: (row) => row.subjectDic.英语 ?? "--",
},
物理: {
label: "物理",
search: false,
width: "80px",
custom: (row) => row.subjectDic.物理 ?? "--",
},
化学: {
label: "化学",
search: false,
width: "80px",
custom: (row) => row.subjectDic.化学 ?? "--",
},
生物: {
label: "生物",
search: false,
width: "80px",
custom: (row) => row.subjectDic.生物 ?? "--",
},
政治: {
label: "政治",
search: false,
width: "80px",
custom: (row) => row.subjectDic.政治 ?? "--",
},
历史: {
label: "历史",
search: false,
width: "80px",
custom: (row) => row.subjectDic.历史 ?? "--",
},
地理: {
label: "地理",
search: false,
width: "80px",
custom: (row) => row.subjectDic.地理 ?? "--",
},
assignScore: {
label: "赋分总分",
search: false,
width: "80px",
},
assignRanking: {
label: "赋分后的排名",
search: false,
width: "120px",
},
},
data: [],
pageData: {
total: 0,
},
selectRows: [],
};
const showTable = ref(false);
const exam = props.data[0];
onMounted(async () => {
//
getClassInfo(exam.classId).then((res) => {
exam.className = res.data.name;
});
getSchoolInfo(exam.schoolId).then((res) => {
exam.schoolName = res.data.name;
});
tableData.column.testPaperType.setting.datasource = (
await getenum("TestPaperTypeEnum")
).data;
tableData.column.type.setting.datasource = (await getenum("ExamTypeEnum")).data;
showTable.value = true;
});
</script>
<template>
<div>
<div class="p-[10px] text-[1.3rem]">
<strong>学生{{ exam.userName }}</strong
>&nbsp; &nbsp; {{ exam.schoolName }} {{ exam.grade }}
{{ exam.className }}
</div>
<ahTable v-if="showTable" ref="table" :tableConfig="tableData" />
</div>
</template>