班级管理/课程

dev
LiuJiaNan 2024-03-21 16:21:13 +08:00
parent 82f7c1709b
commit f6e8a66857
9 changed files with 631 additions and 76 deletions

View File

@ -64,3 +64,16 @@ export const setClassManagementInvolvedInTrainingAdd = (params) =>
post("/curriculumpost/saveClassCurPost", params); // 班级管理涉及培训岗位保存 post("/curriculumpost/saveClassCurPost", params); // 班级管理涉及培训岗位保存
export const getClassManagementExamPaperList = (params) => export const getClassManagementExamPaperList = (params) =>
post("/classpost/listClassPost", params); // 班级管理试卷列表 post("/classpost/listClassPost", params); // 班级管理试卷列表
export const setClassManagementExamPaperEffectEvaluationIsRelatedCourseware = (
params
) => post("/postpaper/verifyStrengthenPaper", params); // 班级管理试卷效果评估时是否关联课件
export const setClassManagementExamPaperAdd = (params) =>
post("/postpaper/addPostPaper", params); // 班级管理试卷添加
export const setClassManagementExamPaperEdit = (params) =>
post("/postpaper/editPostPaper", params); // 班级管理试卷修改
export const getClassManagementExamPaperCount = (params) =>
post("/postpaper/getQuestionCount", params); // 班级管理试卷数量
export const getClassManagementExamPaperHasTestPaper = (params) =>
post("/postpaper/getData", params); // 班级管理试卷获取是否有试卷
export const setClassManagementExamPaperBatchAdd = (params) =>
post("/postpaper/batchAddPostPaper", params); // 班级管理试卷批量添加自动生成试卷

View File

@ -0,0 +1,211 @@
<template>
<el-dialog v-model="visible" title="平台试卷" @close="fnClose">
<el-form ref="formRef" :model="form" :rules="rules" label-position="top">
<el-form-item v-if="type !== 'batchAdd'" label="试卷名称" prop="EXAMNAME">
<el-input v-model="form.EXAMNAME" />
</el-form-item>
<el-form-item label="试卷分数" prop="EXAMSCORE">
<el-input-number v-model="form.EXAMSCORE" :min="0" />
</el-form-item>
<el-form-item label="合格分数" prop="PASSSCORE">
<el-input-number v-model="form.PASSSCORE" :min="0" />
</el-form-item>
<el-form-item prop="DANYUANTICOUNT">
<template #label>
单选题数
<span v-if="type !== 'batchAdd'">
可选题数{{ form.OPTIONALDANYUANTICOUNT }}
</span>
</template>
<el-input-number v-model="form.DANYUANTICOUNT" :min="0" />
</el-form-item>
<el-form-item label="单选分值" prop="DANXUANTINUMBER">
<el-input-number v-model="form.DANXUANTINUMBER" :min="0" />
</el-form-item>
<el-form-item prop="DUOXUANTICOUNT">
<template #label>
多选题数
<span v-if="type !== 'batchAdd'">
可选题数{{ form.OPTIONALDUOXUANTICOUNT }}
</span>
</template>
<el-input-number v-model="form.DUOXUANTICOUNT" :min="0" />
</el-form-item>
<el-form-item label="多选分值" prop="DUOXUANTINUMBER">
<el-input-number v-model="form.DUOXUANTINUMBER" :min="0" />
</el-form-item>
<el-form-item prop="PANDUITICOUNT">
<template #label>
判断题数
<span v-if="type !== 'batchAdd'">
可选题数{{ form.OPTIONALPANDUITICOUNT }}
</span>
</template>
<el-input-number v-model="form.PANDUITICOUNT" :min="0" />
</el-form-item>
<el-form-item label="判断分值" prop="PANDUITINUMBER">
<el-input-number v-model="form.PANDUITINUMBER" :min="0" />
</el-form-item>
<el-form-item label="考试时长(分钟)" prop="ANSWERSHEETTIME">
<el-input-number v-model="form.ANSWERSHEETTIME" :min="0" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="fnClose"></el-button>
<el-button type="primary" @click="fnSubmit"></el-button>
</template>
</el-dialog>
</template>
<script setup>
import { useVModels } from "@vueuse/core";
import { ref } from "vue";
import { debounce } from "throttle-debounce";
import useFormValidate from "@/assets/js/useFormValidate.js";
import { ElMessage, ElMessageBox } from "element-plus";
import { getClassManagementExamPaperHasTestPaper } from "@/request/training_process_management.js";
const props = defineProps({
visible: {
type: Boolean,
required: true,
default: false,
},
form: {
type: Object,
required: true,
default: () => ({}),
},
type: {
type: String,
required: true,
default: "",
},
classPostId: {
type: String,
required: true,
default: "",
},
});
const emits = defineEmits(["update:visible", "update:form", "submit"]);
const { visible, form } = useVModels(props, emits);
const formRef = ref(null);
const rules = {
EXAMNAME: [{ required: true, message: "请输入试卷名称", trigger: "blur" }],
EXAMSCORE: [{ required: true, message: "请输入试卷分数", trigger: "blur" }],
PASSSCORE: [{ required: true, message: "请输入合格分数", trigger: "blur" }],
DANYUANTICOUNT: [
{ required: true, message: "请输入单选题数", trigger: "blur" },
],
DANXUANTINUMBER: [
{ required: true, message: "请输入单选分值", trigger: "blur" },
],
DUOXUANTICOUNT: [
{ required: true, message: "请输入多选题数", trigger: "blur" },
],
DUOXUANTINUMBER: [
{ required: true, message: "请输入多选分值", trigger: "blur" },
],
PANDUITICOUNT: [
{ required: true, message: "请输入判断题数", trigger: "blur" },
],
PANDUITINUMBER: [
{ required: true, message: "请输入判断分值", trigger: "blur" },
],
ANSWERSHEETTIME: [
{ required: true, message: "请输入考试时长(分钟)", trigger: "blur" },
],
};
const fnClose = () => {
formRef.value.resetFields();
visible.value = false;
};
const fnSubmit = debounce(
1000,
async () => {
await useFormValidate(formRef);
const {
EXAMSCORE,
PASSSCORE,
DANYUANTICOUNT,
OPTIONALDANYUANTICOUNT,
DANXUANTINUMBER,
DUOXUANTICOUNT,
OPTIONALDUOXUANTICOUNT,
DUOXUANTINUMBER,
PANDUITICOUNT,
OPTIONALPANDUITICOUNT,
PANDUITINUMBER,
} = form.value;
if (props.type === "add" || props.type === "edit") {
if (DANYUANTICOUNT > OPTIONALDANYUANTICOUNT) {
ElMessage.warning("单选题题数不足");
return;
}
if (DUOXUANTICOUNT > OPTIONALDUOXUANTICOUNT) {
ElMessage.warning("多选题题数不足");
return;
}
if (PANDUITICOUNT > OPTIONALPANDUITICOUNT) {
ElMessage.warning("判断题题数不足");
return;
}
if (
DANYUANTICOUNT * DANXUANTINUMBER +
DUOXUANTICOUNT * DUOXUANTINUMBER +
PANDUITICOUNT * PANDUITINUMBER !==
EXAMSCORE * 1
) {
ElMessage.warning("所有题的分数相加必须等于试卷分数");
return;
}
if (PASSSCORE > EXAMSCORE) {
ElMessage.warning("合格分数不能大于试卷分数");
return;
}
emits("submit", form.value);
} else if (props.type === "batchAdd") {
if (
DANYUANTICOUNT * DANXUANTINUMBER +
DUOXUANTICOUNT * DUOXUANTINUMBER +
PANDUITICOUNT * PANDUITINUMBER !==
EXAMSCORE * 1
) {
ElMessage.warning("所有题的分数相加必须等于试卷分数");
return;
}
if (PASSSCORE > EXAMSCORE) {
ElMessage.warning("合格分数不能大于试卷分数");
return;
}
const resData = await getClassManagementExamPaperHasTestPaper({
CLASSPOST_IDS: props.classPostId,
});
if (resData.varList.length > 0) {
const depart_post = [];
for (let i = 0; i < resData.varList.length; i++) {
depart_post[i] =
"【" +
resData.varList[i].DEPARTMENT_NAME +
"-" +
resData.varList[i].POST_NAME +
"】";
}
await ElMessageBox.confirm(
"已选择的工种可能存在试卷,如继续操作可能造成" +
depart_post +
"试卷被覆盖,是否继续?",
{ type: "warning" }
);
emits("submit", form.value);
} else {
emits("submit", form.value);
}
}
fnClose();
},
{ atBegin: true }
);
</script>
<style scoped lang="scss"></style>

View File

@ -59,7 +59,7 @@
</template> </template>
</el-table-column> </el-table-column>
<template #button> <template #button>
<el-button type="primary"> 批量添加试卷 </el-button> <el-button type="primary" @click="fnBatch"> </el-button>
</template> </template>
</layout-table> </layout-table>
<template #footer> <template #footer>
@ -76,6 +76,8 @@
:class-post-id="data.testPaperTypeDialog.CLASSPOST_ID" :class-post-id="data.testPaperTypeDialog.CLASSPOST_ID"
:post-paper-id="data.testPaperTypeDialog.POSTPAPER_ID" :post-paper-id="data.testPaperTypeDialog.POSTPAPER_ID"
:curriculum-ids="data.testPaperTypeDialog.CURRICULUM_IDS" :curriculum-ids="data.testPaperTypeDialog.CURRICULUM_IDS"
:batch-data="data.testPaperTypeDialog.batchData"
@get-data="fnResetPagination"
/> />
</template> </template>
@ -92,6 +94,7 @@ import {
import { reactive, watchEffect } from "vue"; import { reactive, watchEffect } from "vue";
import ExamPaperDetails from "./exam_paper_details.vue"; import ExamPaperDetails from "./exam_paper_details.vue";
import TestPaperType from "./test_paper_type.vue"; import TestPaperType from "./test_paper_type.vue";
import { ElMessage } from "element-plus";
const route = useRoute(); const route = useRoute();
const { CLASS_ID } = route.query; const { CLASS_ID } = route.query;
@ -120,6 +123,7 @@ const data = reactive({
CLASSPOST_ID: "", CLASSPOST_ID: "",
POSTPAPER_ID: "", POSTPAPER_ID: "",
CURRICULUM_IDS: "", CURRICULUM_IDS: "",
batchData: [],
}, },
}); });
watchEffect(() => { watchEffect(() => {
@ -141,6 +145,22 @@ const fnTestPaperType = (type, CLASSPOST_ID, POSTPAPER_ID, CURRICULUM_IDS) => {
data.testPaperTypeDialog.CLASSPOST_ID = CLASSPOST_ID; data.testPaperTypeDialog.CLASSPOST_ID = CLASSPOST_ID;
data.testPaperTypeDialog.POSTPAPER_ID = POSTPAPER_ID; data.testPaperTypeDialog.POSTPAPER_ID = POSTPAPER_ID;
data.testPaperTypeDialog.CURRICULUM_IDS = CURRICULUM_IDS; data.testPaperTypeDialog.CURRICULUM_IDS = CURRICULUM_IDS;
data.testPaperTypeDialog.batchData = [];
data.testPaperTypeDialog.visible = true;
};
const fnBatch = () => {
const selectionData = tableRef.value.getSelectionRows();
if (selectionData.length === 0) {
ElMessage.warning("请选择要添加的项");
return;
}
data.testPaperTypeDialog.CLASSPOST_ID = selectionData
.map((item) => item.CLASSPOST_ID)
.join(";");
data.testPaperTypeDialog.batchData = [...selectionData];
data.testPaperTypeDialog.type = "batchAdd";
data.testPaperTypeDialog.POSTPAPER_ID = "";
data.testPaperTypeDialog.CURRICULUM_IDS = "";
data.testPaperTypeDialog.visible = true; data.testPaperTypeDialog.visible = true;
}; };
</script> </script>

View File

@ -1,5 +1,5 @@
<template> <template>
<el-dialog v-model="visible" title="延期" :on-close="fnClose"> <el-dialog v-model="visible" title="延期" @close="fnClose">
<el-form ref="formRef" :model="form" :rules="rules" label-width="60px"> <el-form ref="formRef" :model="form" :rules="rules" label-width="60px">
<el-form-item label="日期" prop="TIME"> <el-form-item label="日期" prop="TIME">
<el-date-picker <el-date-picker

View File

@ -1,5 +1,5 @@
<template> <template>
<el-dialog v-model="visible" title="涉及培训岗位" :on-close="fnClose"> <el-dialog v-model="visible" title="涉及培训岗位" @close="fnClose">
<el-form ref="formRef" :model="form" label-width="70px"> <el-form ref="formRef" :model="form" label-width="70px">
<el-row class="mb-10"> <el-row class="mb-10">
<el-col class="tr"> <el-col class="tr">

View File

@ -1,5 +1,5 @@
<template> <template>
<el-dialog v-model="visible" title="修改考试次数" :on-close="fnClose"> <el-dialog v-model="visible" title="修改考试次数" @close="fnClose">
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px"> <el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
<el-form-item label="原考试次数" prop="source"> <el-form-item label="原考试次数" prop="source">
<el-input-number v-model="form.source" disabled /> <el-input-number v-model="form.source" disabled />

View File

@ -0,0 +1,230 @@
<template>
<el-dialog v-model="visible" title="平台试卷" width="70%" @close="fnClose">
<el-row :gutter="24">
<el-col :span="16">
<el-form
:model="searchForm"
label-width="100px"
@submit.prevent="fnResetPagination"
>
<el-row>
<el-col :span="8">
<el-form-item label="试卷名称" prop="KEYWORDS">
<el-input v-model="searchForm.KEYWORDS" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label-width="10px">
<el-button type="primary" native-type="submit">搜索</el-button>
<el-button native-type="reset" @click="fnResetPagination">
重置
</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
<layout-table
v-model:pagination="pagination"
:data="list"
@get-data="fnGetData"
>
<el-table-column label="序号" width="60">
<template #default="{ $index }">
{{ serialNumber(pagination, $index) }}
</template>
</el-table-column>
<el-table-column
show-overflow-tooltip
prop="EXAMNAME"
label="试卷名称"
/>
<el-table-column label="操作" width="100px">
<template #default="{ row }">
<el-button
type="primary"
text
link
@click="fnView(row.STAGEEXAMPAPERINPUT_ID)"
>
预览
</el-button>
<el-button type="primary" text link @click="fnApply(row)">
使用
</el-button>
</template>
</el-table-column>
</layout-table>
</el-col>
<el-col :span="8">
<el-divider content-position="left">考试设置</el-divider>
<el-form
ref="formRef"
:model="data.form"
:rules="rules"
label-position="top"
>
<el-form-item label="试卷名称">
<el-input :model-value="data.form.EXAMNAME" readonly />
</el-form-item>
<el-form-item label="试卷分数">
<el-input :model-value="data.form.EXAMSCORE" readonly />
</el-form-item>
<el-form-item label="合格分数">
<el-input :model-value="data.form.PASSSCORE" readonly />
</el-form-item>
<el-form-item label="考试时长(分)" prop="ANSWERSHEETTIME">
<el-input-number v-model="data.form.ANSWERSHEETTIME" :min="0" />
</el-form-item>
</el-form>
</el-col>
</el-row>
<template #footer>
<el-button @click="fnClose"></el-button>
<el-button type="primary" @click="fnSubmit"></el-button>
</template>
</el-dialog>
<exam-paper-details
v-model:visible="data.viewDialog.visible"
:info="data.viewDialog.info"
/>
</template>
<script setup>
import { useVModel } from "@vueuse/core";
import useListData from "@/assets/js/useListData.js";
import {
getExamPaperManagementList,
getExamPaperManagementTestQuestions,
getExamPaperManagementView,
} from "@/request/training_resource_management.js";
import { reactive, ref, watchEffect } from "vue";
import { serialNumber } from "@/assets/js/utils.js";
import ExamPaperDetails from "./exam_paper_details.vue";
import { debounce } from "throttle-debounce";
import useFormValidate from "@/assets/js/useFormValidate.js";
import { ElMessage, ElMessageBox } from "element-plus";
import {
getClassManagementExamPaperHasTestPaper,
setClassManagementExamPaperEffectEvaluationIsRelatedCourseware,
} from "@/request/training_process_management.js";
import { useRoute } from "vue-router";
const route = useRoute();
const { ISSTRENGTHEN } = route.query;
const props = defineProps({
visible: {
type: Boolean,
required: true,
default: false,
},
type: {
type: String,
required: true,
default: "",
},
classPostId: {
type: String,
required: true,
default: "",
},
});
const emits = defineEmits(["update:visible", "submit"]);
const visible = useVModel(props, "visible", emits);
const { list, searchForm, pagination, fnGetData, fnResetPagination } =
useListData(getExamPaperManagementList, { immediate: false });
watchEffect(() => {
if (visible.value) fnResetPagination();
});
const data = reactive({
viewDialog: {
visible: false,
info: {},
},
form: {
STAGEEXAMPAPERINPUT_ID: "",
EXAMNAME: "",
EXAMSCORE: "",
PASSSCORE: "",
ANSWERSHEETTIME: 60,
},
});
const formRef = ref(null);
const rules = {
ANSWERSHEETTIME: [
{ required: true, message: "请输入考试时长", trigger: "blur" },
],
};
const fnView = async (STAGEEXAMPAPERINPUT_ID) => {
const { pd } = await getExamPaperManagementView({
STAGEEXAMPAPERINPUT_ID,
});
data.viewDialog.info = pd;
const { varList } = await getExamPaperManagementTestQuestions({
STAGEEXAMPAPERINPUT_ID,
});
data.viewDialog.info.testPaper = varList;
data.viewDialog.visible = true;
};
const fnApply = ({
STAGEEXAMPAPERINPUT_ID,
EXAMNAME,
EXAMSCORE,
PASSSCORE,
}) => {
data.form.STAGEEXAMPAPERINPUT_ID = STAGEEXAMPAPERINPUT_ID;
data.form.EXAMNAME = EXAMNAME;
data.form.EXAMSCORE = EXAMSCORE;
data.form.PASSSCORE = PASSSCORE;
};
const fnClose = () => {
formRef.value.resetFields();
data.form.STAGEEXAMPAPERINPUT_ID = "";
visible.value = false;
};
const fnSubmit = debounce(
1000,
async () => {
await useFormValidate(formRef);
if (!data.form.STAGEEXAMPAPERINPUT_ID) {
ElMessage.warning("请选择要使用的试卷");
return;
}
if (props.type === "add" || props.type === "edit") {
if (ISSTRENGTHEN === "1") {
await setClassManagementExamPaperEffectEvaluationIsRelatedCourseware({
STAGEEXAMPAPERINPUT_ID: data.form.STAGEEXAMPAPERINPUT_ID,
});
}
emits("submit", data.form);
} else if (props.type === "batchAdd") {
const resData = await getClassManagementExamPaperHasTestPaper({
CLASSPOST_IDS: props.classPostId,
});
if (resData.varList.length > 0) {
const depart_post = [];
for (let i = 0; i < resData.varList.length; i++) {
depart_post[i] =
"【" +
resData.varList[i].DEPARTMENT_NAME +
"-" +
resData.varList[i].POST_NAME +
"】";
}
await ElMessageBox.confirm(
"已选择的工种可能存在试卷,如继续操作可能造成" +
depart_post +
"试卷被覆盖,是否继续?",
{ type: "warning" }
);
emits("submit", data.form);
} else {
emits("submit", data.form);
}
}
fnClose();
},
{ atBegin: true }
);
</script>
<style scoped lang="scss"></style>

View File

@ -202,13 +202,11 @@ import { reactive } from "vue";
import { translationStatus } from "@/assets/js/utils.js"; import { translationStatus } from "@/assets/js/utils.js";
import useListData from "@/assets/js/useListData.js"; import useListData from "@/assets/js/useListData.js";
import { import {
getClassManagementExportLearningRecords,
getClassManagementStudentList, getClassManagementStudentList,
setClassManagementStudentDelete, setClassManagementStudentDelete,
} from "@/request/training_process_management.js"; } from "@/request/training_process_management.js";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { ElMessage, ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus";
import * as XLSX from "xlsx";
import { debounce } from "throttle-debounce"; import { debounce } from "throttle-debounce";
import AddStudent from "./add_student.vue"; import AddStudent from "./add_student.vue";
@ -274,71 +272,22 @@ const fnGetLearningRecords = async () => {
await ElMessageBox.confirm("确定要导出查询出来所有的学习记录?", { await ElMessageBox.confirm("确定要导出查询出来所有的学习记录?", {
type: "warning", type: "warning",
}); });
const resData = await getClassManagementExportLearningRecords({ window.location.href =
CLASS_ID, import.meta.env[import.meta.env.DEV ? "VITE_PROXY" : "VITE_BASE_URL"] +
...searchForm.value, "/student/exportStudentInfo?CLASS_ID=" +
START_TIME: searchForm.value.TIME?.[0], CLASS_ID +
END_TIME: searchForm.value.TIME?.[1], "&START_TIME=" +
}); searchForm.value.TIME?.[0] +
if (resData.varList.length > 0) fnExportLearningRecords(resData.varList); "&END_TIME=" +
else ElMessage.warning("没有学习记录"); searchForm.value.TIME?.[1] +
}; "&DEPARTMENT_ID=" +
const fnExportLearningRecords = (list) => { searchForm.value.DEPARTMENT_ID +
const tableData = [ "&POST_ID=" +
[ searchForm.value.POST_ID +
"序号", "&STUDYSTATE=" +
"身份证", searchForm.value.STUDYSTATE +
"姓名", "&STAGEEXAMSTATE=" +
"性别", searchForm.value.STAGEEXAMSTATE;
"手机号",
"部门",
"岗位",
"要求总学时",
"已完成学时",
"是否考试通过",
"考试分数",
"学习状态",
"班级名称",
],
];
list.forEach((item, index) => {
for (let i = 0; i < learningStatus.length; i++) {
if (learningStatus[i].ID === item.STUDYSTATE) {
item.STUDYSTATE = learningStatus[i].NAME;
break;
}
}
for (let i = 0; i < examStatus.length; i++) {
if (learningStatus[i].ID === item.STAGEEXAMSTATE) {
item.STAGEEXAMSTATE = learningStatus[i].NAME;
break;
}
}
if (item.ALL_CLASSHOUR === "0.0") item.ALL_CLASSHOUR = "0";
const COMPLETE_CLASSHOUR =
item.COMPLETE_CLASSHOUR === "0.0"
? 0
: parseFloat(item.COMPLETE_CLASSHOUR).toFixed(1);
tableData.push([
index + 1,
item.USER_ID_CARD,
item.NAME,
item.SEX,
item.PHONE,
item.DEPARTMENT_NAME,
item.POST_NAME,
item.ALL_CLASSHOUR,
COMPLETE_CLASSHOUR,
item.STAGEEXAMSTATE,
item.EXAMSCORE,
item.STUDYSTATE,
item.CLASS_NAME,
]);
});
const ws = XLSX.utils.aoa_to_sheet(tableData);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "学员统计");
XLSX.writeFile(wb, "学员统计表.xlsx");
ElMessage.success("导出成功"); ElMessage.success("导出成功");
}; };
const fnDelete = debounce( const fnDelete = debounce(

View File

@ -1,5 +1,5 @@
<template> <template>
<el-dialog v-model="visible" title="试卷类型" :on-close="fnClose"> <el-dialog v-model="visible" title="试卷类型" @close="fnClose">
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px"> <el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
<el-form-item label="试卷类型" prop="PAPERSELECTTYPE"> <el-form-item label="试卷类型" prop="PAPERSELECTTYPE">
<el-select v-model="form.PAPERSELECTTYPE"> <el-select v-model="form.PAPERSELECTTYPE">
@ -10,16 +10,41 @@
</el-form> </el-form>
<template #footer> <template #footer>
<el-button @click="fnClose"></el-button> <el-button @click="fnClose"></el-button>
<el-button type="primary" @click="fnSubmit"></el-button> <el-button type="primary" @click="fnConfirm"></el-button>
</template> </template>
</el-dialog> </el-dialog>
<platform-test-paper
v-model:visible="data.platformTestPaperDialogVisible"
:type="type"
:class-post-id="classPostId"
@submit="fnSubmit"
/>
<automatically-generate-test-papers
v-model:visible="data.automaticallyGenerateTestPapersDialog.visible"
v-model:form="data.automaticallyGenerateTestPapersDialog.form"
:type="type"
:class-post-id="classPostId"
@submit="fnSubmit"
/>
</template> </template>
<script setup> <script setup>
import { useVModel } from "@vueuse/core"; import { useVModel } from "@vueuse/core";
import { ref } from "vue"; import { nextTick, reactive, ref } from "vue";
import useFormValidate from "@/assets/js/useFormValidate.js"; import useFormValidate from "@/assets/js/useFormValidate.js";
import PlatformTestPaper from "./platform_test_paper.vue";
import AutomaticallyGenerateTestPapers from "./automatically_generate_test_papers.vue";
import {
getClassManagementExamPaperCount,
setClassManagementExamPaperAdd,
setClassManagementExamPaperBatchAdd,
setClassManagementExamPaperEdit,
} from "@/request/training_process_management.js";
import { useRoute } from "vue-router";
import { ElMessage, ElMessageBox } from "element-plus";
const route = useRoute();
const { CLASS_ID } = route.query;
const props = defineProps({ const props = defineProps({
visible: { visible: {
type: Boolean, type: Boolean,
@ -46,8 +71,13 @@ const props = defineProps({
required: true, required: true,
default: "", default: "",
}, },
batchData: {
type: Array,
required: true,
default: () => [],
},
}); });
const emits = defineEmits(["update:visible"]); const emits = defineEmits(["update:visible", "get-data"]);
const visible = useVModel(props, "visible", emits); const visible = useVModel(props, "visible", emits);
const formRef = ref(null); const formRef = ref(null);
const form = ref({ PAPERSELECTTYPE: "" }); const form = ref({ PAPERSELECTTYPE: "" });
@ -58,12 +88,114 @@ const rules = {
trigger: "change", trigger: "change",
}, },
}; };
const data = reactive({
platformTestPaperDialogVisible: false,
automaticallyGenerateTestPapersDialog: {
visible: false,
form: {
OPTIONALDANYUANTICOUNT: 0,
OPTIONALDUOXUANTICOUNT: 0,
OPTIONALPANDUITICOUNT: 0,
COURSEWAREIDS: "",
EXAMNAME: "",
EXAMSCORE: 0,
PASSSCORE: 0,
DANYUANTICOUNT: 0,
DANXUANTINUMBER: 0,
DUOXUANTICOUNT: 0,
DUOXUANTINUMBER: 0,
PANDUITICOUNT: 0,
PANDUITINUMBER: 0,
ANSWERSHEETTIME: 0,
},
},
});
const fnClose = () => { const fnClose = () => {
formRef.value.resetFields(); formRef.value.resetFields();
visible.value = false; visible.value = false;
}; };
const fnSubmit = async () => { const fnConfirm = async () => {
await useFormValidate(formRef); await useFormValidate(formRef);
if (form.value.PAPERSELECTTYPE === "1") {
data.platformTestPaperDialogVisible = true;
}
if (form.value.PAPERSELECTTYPE === "2") {
if (props.type === "batchAdd") {
data.automaticallyGenerateTestPapersDialog.visible = true;
await nextTick();
data.automaticallyGenerateTestPapersDialog.form.ANSWERSHEETTIME = 60;
} else {
if (!props.curriculumIds) {
ElMessage.warning("请配置涉及课程");
return;
}
await fnGetExamPaperCount();
}
}
};
const fnGetExamPaperCount = async () => {
const resData = await getClassManagementExamPaperCount({
CLASS_ID,
CURRICULUM_IDS: props.curriculumIds,
});
if (resData.message) {
ElMessage.warning(resData.message);
} else {
data.automaticallyGenerateTestPapersDialog.visible = true;
await nextTick();
const countMap = {
1: "OPTIONALDANYUANTICOUNT",
2: "OPTIONALDUOXUANTICOUNT",
3: "OPTIONALPANDUITICOUNT",
};
for (let i = 0; i < resData.questionCount.length; i++) {
const item = resData.questionCount[i];
data.automaticallyGenerateTestPapersDialog.form[
countMap[item.QUESTIONTYPE]
] = item.NUM;
}
data.automaticallyGenerateTestPapersDialog.form.COURSEWAREIDS =
JSON.stringify(resData.coursewareIds.COURSEWAREIDS);
data.automaticallyGenerateTestPapersDialog.form.ANSWERSHEETTIME = 60;
}
};
const fnSubmit = async (value) => {
const params = {
...value,
CLASS_ID,
PAPERSELECTTYPE: form.value.PAPERSELECTTYPE,
CLASSPOST_ID: props.classPostId,
POSTPAPER_ID: props.postPaperId,
};
if (
props.type === "add" ||
(props.type === "batchAdd" && form.value.PAPERSELECTTYPE === "1")
) {
await setClassManagementExamPaperAdd(params);
ElMessage.success("操作成功");
}
if (props.type === "edit") {
await setClassManagementExamPaperEdit(params);
ElMessage.success("操作成功");
}
if (props.type === "batchAdd" && form.value.PAPERSELECTTYPE === "2") {
const resData = await setClassManagementExamPaperBatchAdd({
...value,
PAPERSELECTTYPE: form.value.PAPERSELECTTYPE,
CLASS_ID,
batchdata: JSON.stringify(props.batchData),
});
if (resData.message) {
await ElMessageBox.confirm(resData.message.replace(/\n/g, "<br/>"), {
type: "warning",
dangerouslyUseHTMLString: true,
});
} else {
ElMessage.success("操作成功");
}
}
fnClose();
emits("get-data");
}; };
</script> </script>