|
@@ -1,46 +1,31 @@
|
|
|
<template>
|
|
|
<div class="mark-param-subjective-answer">
|
|
|
- <div class="part-box part-box-pad">
|
|
|
- <div>
|
|
|
- <p class="tips-info">1.主观题标答请上传PDF文档;</p>
|
|
|
- <p class="tips-info">
|
|
|
- 2.主观题标答文档上传后,在评卷界面小助手里可以打开进行查看,作为评卷参考;
|
|
|
- </p>
|
|
|
- <p class="tips-info">3.支持重复提交,以最后一次提交标答文件为准。</p>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="part-box part-box-pad">
|
|
|
- <el-form ref="modalFormComp" :model="infos" label-width="50px">
|
|
|
- <div class="part-box">
|
|
|
- <h3 class="mb-2">卷型{{ basicInfo.paperType }}</h3>
|
|
|
- <el-form-item prop="file" label="标答:">
|
|
|
- <select-file
|
|
|
- :format="fileFormat"
|
|
|
- :disabled="loading"
|
|
|
- @file-change="fileChange"
|
|
|
- ></select-file>
|
|
|
- <p v-if="infos.errorMsg" class="tips-info tips-error">
|
|
|
- {{ infos.errorMsg }}
|
|
|
- </p>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item v-if="answerFileUrl">
|
|
|
- <span
|
|
|
- class="cont-link"
|
|
|
- title="点击查看已上传标答文件"
|
|
|
- @click="toViewAnswer"
|
|
|
- >
|
|
|
- <i class="el-icon-document mr-1"></i>{{ answerFileName }}
|
|
|
- </span>
|
|
|
- </el-form-item>
|
|
|
- </div>
|
|
|
- </el-form>
|
|
|
- </div>
|
|
|
- <div class="text-center">
|
|
|
- <el-button type="primary" :disabled="loading" @click="submit"
|
|
|
- >确认</el-button
|
|
|
+ <el-form
|
|
|
+ v-for="item in subjectiveAnswerList"
|
|
|
+ :key="item.paperType"
|
|
|
+ label-width="50px"
|
|
|
+ >
|
|
|
+ <el-form-item
|
|
|
+ prop="file"
|
|
|
+ :label="`${item.paperType}卷:`"
|
|
|
+ :error="item.errorMsg"
|
|
|
>
|
|
|
- <el-button @click="cancel">取消</el-button>
|
|
|
- </div>
|
|
|
+ <select-file
|
|
|
+ :format="fileFormat"
|
|
|
+ :disabled="item.loading"
|
|
|
+ @file-change="(data) => fileChange(data, item)"
|
|
|
+ ></select-file>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="item.answerFileUrl">
|
|
|
+ <span
|
|
|
+ class="cont-link"
|
|
|
+ title="点击查看已上传标答文件"
|
|
|
+ @click="toViewAnswer(item)"
|
|
|
+ >
|
|
|
+ <i class="el-icon-document mr-1"></i>{{ item.answerFileName }}
|
|
|
+ </span>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
|
|
|
<!-- PreviewFile -->
|
|
|
<preview-file ref="PreviewFile" :data="curFile"></preview-file>
|
|
@@ -48,7 +33,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { mapState } from "vuex";
|
|
|
+import { mapState, mapMutations } from "vuex";
|
|
|
import {
|
|
|
markSubjectiveQuestionList,
|
|
|
markSubjectiveQuestionUpload,
|
|
@@ -62,10 +47,8 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
modalIsShow: false,
|
|
|
- loading: false,
|
|
|
- infos: { file: null, md5: null, errorMsg: null },
|
|
|
fileFormat: ["pdf"],
|
|
|
- answerFileUrl: "",
|
|
|
+ subjectiveAnswerList: [],
|
|
|
// preview file
|
|
|
curFile: {
|
|
|
url: "",
|
|
@@ -75,66 +58,95 @@ export default {
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState("markParam", ["basicInfo"]),
|
|
|
- answerFileName() {
|
|
|
- return `${this.basicInfo.courseName}-标答文件`;
|
|
|
- },
|
|
|
},
|
|
|
mounted() {
|
|
|
this.initData();
|
|
|
},
|
|
|
methods: {
|
|
|
+ ...mapMutations("markParam", ["setSubjectiveAnswer"]),
|
|
|
async initData() {
|
|
|
+ this.initSubjectiveAnswerList();
|
|
|
+
|
|
|
const params = {
|
|
|
examId: this.basicInfo.examId,
|
|
|
paperNumber: this.basicInfo.paperNumber,
|
|
|
};
|
|
|
const res = await markSubjectiveQuestionList(params);
|
|
|
- this.answerFileUrl = res || "";
|
|
|
+ (res || []).forEach((item, index) => {
|
|
|
+ this.subjectiveAnswerList[index].answerFileUrl = item;
|
|
|
+ });
|
|
|
+
|
|
|
+ this.updateSubjectiveAnswer();
|
|
|
+ },
|
|
|
+ initSubjectiveAnswerList() {
|
|
|
+ this.subjectiveAnswerList = this.basicInfo.paperType
|
|
|
+ .split(",")
|
|
|
+ .map((paperType) => {
|
|
|
+ return {
|
|
|
+ paperType,
|
|
|
+ answerFileUrl: "",
|
|
|
+ file: null,
|
|
|
+ md5: null,
|
|
|
+ errorMsg: null,
|
|
|
+ loading: false,
|
|
|
+ answerFileName: `${this.basicInfo.courseName}-${paperType}卷-标答文件`,
|
|
|
+ };
|
|
|
+ });
|
|
|
},
|
|
|
- toViewAnswer() {
|
|
|
- // window.open(this.answerFileUrl);
|
|
|
+ toViewAnswer(item) {
|
|
|
this.curFile = {
|
|
|
- url: this.answerFileUrl,
|
|
|
+ url: item.answerFileUrl,
|
|
|
type: "application/pdf",
|
|
|
};
|
|
|
this.$refs.PreviewFile.open();
|
|
|
},
|
|
|
- fileChange(data) {
|
|
|
+ fileChange(data, item) {
|
|
|
if (data.errorMsg) {
|
|
|
- this.infos.file = null;
|
|
|
- this.infos.md5 = null;
|
|
|
- this.infos.errorMsg = data.errorMsg;
|
|
|
+ item.file = null;
|
|
|
+ item.md5 = null;
|
|
|
+ item.errorMsg = data.errorMsg;
|
|
|
} else {
|
|
|
- this.infos.file = data.file;
|
|
|
- this.infos.md5 = data.md5;
|
|
|
- this.infos.errorMsg = null;
|
|
|
+ item.file = data.file;
|
|
|
+ item.md5 = data.md5;
|
|
|
+ item.errorMsg = null;
|
|
|
+ this.submit(item);
|
|
|
}
|
|
|
},
|
|
|
- async submit() {
|
|
|
- if (!this.infos.file) {
|
|
|
- this.$message.error("请选择标答文件");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (this.loading) return;
|
|
|
- this.loading = true;
|
|
|
+ async submit(item) {
|
|
|
+ if (item.loading) return;
|
|
|
+ item.loading = true;
|
|
|
|
|
|
- let formData = new FormData();
|
|
|
+ const formData = new FormData();
|
|
|
formData.append("examId", this.basicInfo.examId);
|
|
|
formData.append("paperNumber", this.basicInfo.paperNumber);
|
|
|
- formData.append(`file`, this.infos.file);
|
|
|
- formData.append(`md5`, this.infos.md5);
|
|
|
- const data = await markSubjectiveQuestionUpload(formData).catch(() => {});
|
|
|
- this.loading = false;
|
|
|
+ formData.append(`file`, item.file);
|
|
|
+ formData.append(`md5`, item.md5);
|
|
|
+ formData.append(`paperType`, item.paperType);
|
|
|
+ const data = await markSubjectiveQuestionUpload(formData).catch(
|
|
|
+ (error) => {
|
|
|
+ item.errorMsg = error.message || "上传失败";
|
|
|
+ }
|
|
|
+ );
|
|
|
+ item.loading = false;
|
|
|
if (!data) return;
|
|
|
|
|
|
- this.answerFileUrl = data;
|
|
|
+ item.answerFileUrl = data;
|
|
|
this.$message.success("上传成功!");
|
|
|
- // this.$emit("confirm");
|
|
|
+ this.updateSubjectiveAnswer();
|
|
|
},
|
|
|
cancel() {
|
|
|
this.$emit("cancel");
|
|
|
},
|
|
|
+ updateSubjectiveAnswer() {
|
|
|
+ this.setSubjectiveAnswer(
|
|
|
+ this.subjectiveAnswerList.map((item) => {
|
|
|
+ return {
|
|
|
+ answerFileUrl: item.answerFileUrl,
|
|
|
+ paperType: item.paperType,
|
|
|
+ };
|
|
|
+ })
|
|
|
+ );
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|