mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-11 20:06:47 +08:00
feat(course): 支持考试类型资源的选择与上传
- 新增试卷列表获取逻辑,支持考试类型资源展示 - 优化文件上传校验,统一获取文件类型与大小限制 - 调整课程列表请求方法名,增强代码可读性 - 移除冗余的showDialog响应式变量 - 新增自定义考试按钮,区分不同资源类型的上传入口 - 更新文件基础URL配置,使用环境变量动态设置 - 引入试卷相关API模块,支持考试资源操作接口调用 - 扩展useCreateCourseMaps钩子,增加获取试卷列表方法
This commit is contained in:
91
src/api/modules/paper.js
Normal file
91
src/api/modules/paper.js
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
// 试卷
|
||||||
|
import ajax from "./xajax.js";
|
||||||
|
// 分页查询,资源归属,试题模式,关键词查询
|
||||||
|
// pageIndex 第几页
|
||||||
|
// pageSize 一页展示多少行
|
||||||
|
//参数:// ownership2(2级资源归属)
|
||||||
|
// ownership1(1级资源归属)
|
||||||
|
// ownership3(3级资源归属)),paperMode(试卷模式),keyWord(关键词)
|
||||||
|
const querylist = function (query) {
|
||||||
|
return ajax.post("/systemapi/xboe/m/exam/paper/querylist", query);
|
||||||
|
};
|
||||||
|
// 添加
|
||||||
|
// ownership2(2级资源归属)
|
||||||
|
// ownership1(1级资源归属)
|
||||||
|
// ownership3(3级资源归属),testName(试卷名称),paperType(试卷分类)
|
||||||
|
// paperContent(试卷内容) remark 备注 difficulty难度
|
||||||
|
const save = function (data) {
|
||||||
|
return ajax.postJson("/systemapi/xboe/m/exam/paper/save", data);
|
||||||
|
};
|
||||||
|
// 删除
|
||||||
|
// id 试卷id
|
||||||
|
const del = function (id) {
|
||||||
|
return ajax.get("/systemapi/xboe/m/exam/paper/delete?id=" + id);
|
||||||
|
};
|
||||||
|
// 编辑
|
||||||
|
//当前id,// ownership2(2级资源归属)
|
||||||
|
// ownership1(1级资源归属)
|
||||||
|
// ownership3(3级资源归属),testName(试卷名称),paperType(试卷分类)
|
||||||
|
// paperContent(试卷内容) remark 备注 difficulty难度
|
||||||
|
const update = function (data) {
|
||||||
|
return ajax.postJson("/systemapi/xboe/m/exam/paper/update", data);
|
||||||
|
};
|
||||||
|
/* 编辑详情 */
|
||||||
|
const detail = function (id) {
|
||||||
|
return ajax.get("/systemapi/xboe/m/exam/paper/query?id=" + id);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 试卷批量导入计算
|
||||||
|
* num 数目
|
||||||
|
* score 总分
|
||||||
|
* diff1 容易的试题数量
|
||||||
|
* diff2 中等的试题数量
|
||||||
|
* diff3 困难的试题数量
|
||||||
|
* type1 单选的试题数量
|
||||||
|
* type2 单选的试题数量
|
||||||
|
* type3 单选的试题数量
|
||||||
|
*/
|
||||||
|
const batchImportCount = function (data) {
|
||||||
|
return ajax.postJson("/systemapi/xboe/m/exam/paper/batch-count", data);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据生成的试题的id查询所有的试题
|
||||||
|
* @param {试题的集合array} ids
|
||||||
|
*/
|
||||||
|
const batchImportData = function (ids) {
|
||||||
|
return ajax.postJson("/systemapi/xboe/m/exam/paper/batch-count", ids);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询试卷
|
||||||
|
* @param {pageSize,name} data
|
||||||
|
*/
|
||||||
|
const querypaper = function (data) {
|
||||||
|
return ajax.post("/systemapi/xboe/m/exam/paper/queryPaper", data);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回试卷的json内容,字符串
|
||||||
|
* @param {Object} id
|
||||||
|
*/
|
||||||
|
const getPaperContent = function (id) {
|
||||||
|
return ajax.get("/systemapi/xboe/m/exam/paper/paper-content?id=" + id);
|
||||||
|
};
|
||||||
|
const newPaperContent = function (id) {
|
||||||
|
return ajax.get(
|
||||||
|
"/systemapi/xboe/m/course/content/exam/paper-content?courseExamId=" + id
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default {
|
||||||
|
detail,
|
||||||
|
update,
|
||||||
|
del,
|
||||||
|
save,
|
||||||
|
querylist,
|
||||||
|
querypaper,
|
||||||
|
getPaperContent,
|
||||||
|
newPaperContent,
|
||||||
|
batchImportCount,
|
||||||
|
batchImportData,
|
||||||
|
};
|
||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
getPageListByType,
|
getPageListByType,
|
||||||
getType,
|
getType,
|
||||||
getMapsItem,
|
getMapsItem,
|
||||||
|
getPaperList,
|
||||||
} from "@/hooks/useCreateCourseMaps";
|
} from "@/hooks/useCreateCourseMaps";
|
||||||
import apiCourseFile from "@/api/modules/courseFile";
|
import apiCourseFile from "@/api/modules/courseFile";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
@@ -22,7 +23,6 @@ const props = defineProps({
|
|||||||
// 响应式数据
|
// 响应式数据
|
||||||
const tableData = ref([]);
|
const tableData = ref([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const showDialog = ref(false);
|
|
||||||
const fileList = ref([]);
|
const fileList = ref([]);
|
||||||
|
|
||||||
// 表单数据
|
// 表单数据
|
||||||
@@ -145,24 +145,49 @@ const handlePreviewItem = (row) => {
|
|||||||
// 分页改变处理
|
// 分页改变处理
|
||||||
const changePagination = (PAGINATION) => {
|
const changePagination = (PAGINATION) => {
|
||||||
Object.assign(pagination, PAGINATION);
|
Object.assign(pagination, PAGINATION);
|
||||||
getVideoList();
|
getCourseList();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取视频列表
|
// 获取视频列表
|
||||||
const getVideoList = () => {
|
const getCourseList = () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const paramsData = {
|
let paramsData = {};
|
||||||
...form,
|
|
||||||
pageSize: pagination.pageSize,
|
|
||||||
pageIndex: pagination.current,
|
|
||||||
self: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
getPageListByType(paramsData).then((res) => {
|
switch (props.resType) {
|
||||||
loading.value = false;
|
// 考试
|
||||||
tableData.value = res.result.list;
|
case 61:
|
||||||
pagination.total = res.result.count;
|
paramsData = {
|
||||||
});
|
keyWord: form.name,
|
||||||
|
pageSize: pagination.pageSize,
|
||||||
|
pageIndex: pagination.current,
|
||||||
|
};
|
||||||
|
getPaperList(paramsData).then((res) => {
|
||||||
|
loading.value = false;
|
||||||
|
tableData.value = res.result.list.map((item) => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
name: item.testName,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
pagination.total = res.result.count;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// 非考试列表
|
||||||
|
paramsData = {
|
||||||
|
...form,
|
||||||
|
pageSize: pagination.pageSize,
|
||||||
|
pageIndex: pagination.current,
|
||||||
|
self: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
getPageListByType(paramsData).then((res) => {
|
||||||
|
loading.value = false;
|
||||||
|
tableData.value = res.result.list;
|
||||||
|
pagination.total = res.result.count;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 上传成功处理
|
// 上传成功处理
|
||||||
@@ -199,6 +224,10 @@ const handleUploadSuccess = (res, file) => {
|
|||||||
|
|
||||||
// 上传前处理
|
// 上传前处理
|
||||||
const handleBeforeUpload = (file) => {
|
const handleBeforeUpload = (file) => {
|
||||||
|
const { fileType, name, uploadSize, uploadSizeName } = getMapsItem(
|
||||||
|
props.resType
|
||||||
|
);
|
||||||
|
|
||||||
if (file.name.lastIndexOf(".") === -1) {
|
if (file.name.lastIndexOf(".") === -1) {
|
||||||
ElMessage({ message: `文件格式不正确!`, type: "error", offset: 100 });
|
ElMessage({ message: `文件格式不正确!`, type: "error", offset: 100 });
|
||||||
return false;
|
return false;
|
||||||
@@ -208,13 +237,9 @@ const handleBeforeUpload = (file) => {
|
|||||||
fileExtension = fileExtension.toLowerCase();
|
fileExtension = fileExtension.toLowerCase();
|
||||||
|
|
||||||
// 校检文件类型
|
// 校检文件类型
|
||||||
if (
|
if (fileType.join(",").indexOf(fileExtension) === -1) {
|
||||||
getMapsItem(props.resType).fileType.join(",").indexOf(fileExtension) === -1
|
|
||||||
) {
|
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: `文件格式不正确, 请上传正确格式的${
|
message: `文件格式不正确, 请上传正确格式的${name}文件!`,
|
||||||
getMapsItem(props.resType).name
|
|
||||||
}文件!`,
|
|
||||||
type: "error",
|
type: "error",
|
||||||
offset: 100,
|
offset: 100,
|
||||||
});
|
});
|
||||||
@@ -222,14 +247,11 @@ const handleBeforeUpload = (file) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 校检文件大小
|
// 校检文件大小
|
||||||
if (getMapsItem(props.resType).uploadSize) {
|
if (uploadSize) {
|
||||||
const isLt =
|
const isLt = file.size / 1024 / 1024 < uploadSize;
|
||||||
file.size / 1024 / 1024 < getMapsItem(props.resType).uploadSize;
|
|
||||||
if (!isLt) {
|
if (!isLt) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: `上传文件大小不能超过 ${
|
message: `上传文件大小不能超过 ${uploadSizeName} !`,
|
||||||
getMapsItem(props.resType).uploadSize
|
|
||||||
} !`,
|
|
||||||
type: "error",
|
type: "error",
|
||||||
offset: 100,
|
offset: 100,
|
||||||
});
|
});
|
||||||
@@ -248,7 +270,7 @@ const handleBeforeUpload = (file) => {
|
|||||||
|
|
||||||
// 生命周期
|
// 生命周期
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getVideoList();
|
getCourseList();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -270,7 +292,10 @@ onMounted(() => {
|
|||||||
>上传新{{ getType(props.resType) }}</el-button
|
>上传新{{ getType(props.resType) }}</el-button
|
||||||
>
|
>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<span class="desc ml10"
|
<el-button v-if="[61].includes(props.resType)" type="primary"
|
||||||
|
>自定义考试</el-button
|
||||||
|
>
|
||||||
|
<span class="desc ml10" v-if="![61].includes(props.resType)"
|
||||||
>文件大小限制:{{
|
>文件大小限制:{{
|
||||||
getMapsItem(props.resType).uploadSizeName
|
getMapsItem(props.resType).uploadSizeName
|
||||||
}},支持的文件类型:{{ getMapsItem(props.resType).fileType.join(",") }}
|
}},支持的文件类型:{{ getMapsItem(props.resType).fileType.join(",") }}
|
||||||
@@ -283,7 +308,7 @@ onMounted(() => {
|
|||||||
v-model="form.name"
|
v-model="form.name"
|
||||||
clearable
|
clearable
|
||||||
></el-input>
|
></el-input>
|
||||||
<el-button class="ml10" @click="getVideoList" type="primary"
|
<el-button class="ml10" @click="getCourseList" type="primary"
|
||||||
>查询</el-button
|
>查询</el-button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import apiCourseFile from "@/api/modules/courseFile";
|
import apiCourseFile from "@/api/modules/courseFile";
|
||||||
|
import apiExamPaper from "@/api/modules/paper";
|
||||||
// const contentTypeMaps = {
|
// const contentTypeMaps = {
|
||||||
// 10: "视频",
|
// 10: "视频",
|
||||||
// 20: "音频",
|
// 20: "音频",
|
||||||
@@ -152,3 +152,20 @@ export function getPageListByType(params) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getPaperList(params) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
apiExamPaper
|
||||||
|
.querylist(params)
|
||||||
|
.then((res) => {
|
||||||
|
if (res.status === 200) {
|
||||||
|
resolve(res);
|
||||||
|
} else {
|
||||||
|
reject(res.message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export function useMediaComponent(props, emit) {
|
|||||||
emit("update:dialogVideoForm", { ...localDialogVideoForm.value });
|
emit("update:dialogVideoForm", { ...localDialogVideoForm.value });
|
||||||
};
|
};
|
||||||
|
|
||||||
const fileBaseUrl = "http://home.hzer.xyz:9960/upload";
|
const fileBaseUrl = `${process.env.VUE_APP_BOE_API_URL}/upload`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
localDialogVideoForm,
|
localDialogVideoForm,
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ const courseOperations = {
|
|||||||
isNext.value = false;
|
isNext.value = false;
|
||||||
},
|
},
|
||||||
addExam: () => {
|
addExam: () => {
|
||||||
console.log("添加考试功能调用");
|
courseMetadata.resType = 61;
|
||||||
|
showDialog.value = true;
|
||||||
},
|
},
|
||||||
addHomework: () => {
|
addHomework: () => {
|
||||||
console.log("添加作业功能调用");
|
console.log("添加作业功能调用");
|
||||||
|
|||||||
Reference in New Issue
Block a user