|
@@ -7,8 +7,8 @@
|
|
|
:before-upload="handleBeforeUpload"
|
|
|
:action="'/api/ecs_oe_student/offlineExam/submitPaper?examRecordDataId='+course.examRecordDataId"
|
|
|
:max-size="1024*30"
|
|
|
- :format="['pdf','zip']"
|
|
|
- accept="application/zip,application/pdf"
|
|
|
+ :format="uploadFileFormat"
|
|
|
+ :accept="uploadFileAccept"
|
|
|
:on-format-error="handleFormatError"
|
|
|
:on-exceeded-size="handleMaxSize"
|
|
|
:on-success="handleSuccess"
|
|
@@ -21,7 +21,7 @@
|
|
|
style="width: 100%;"
|
|
|
>上传作答</Button>
|
|
|
</Upload>
|
|
|
- <div v-if="file !== null">待上传文件: {{ file.name }}
|
|
|
+ <div v-if="file !== null && loadingStatus">待上传文件: {{ file.name }}
|
|
|
<Button :loading="loadingStatus">{{ loadingStatus ? '上传中...' : '上传' }}</Button>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -38,12 +38,27 @@ export default {
|
|
|
},
|
|
|
file: null,
|
|
|
fileType: null,
|
|
|
- loadingStatus: false
|
|
|
+ loadingStatus: false,
|
|
|
+ uploadFileFormat: [],
|
|
|
+ uploadFileAccept: ""
|
|
|
};
|
|
|
},
|
|
|
props: {
|
|
|
course: Object
|
|
|
},
|
|
|
+ async created() {
|
|
|
+ const res = await this.$http.get(
|
|
|
+ "/api/ecs_exam_work/exam/examOrgProperty/" +
|
|
|
+ this.course.examId +
|
|
|
+ `/OFFLINE_UPLOAD_FILE_TYPE`
|
|
|
+ );
|
|
|
+
|
|
|
+ this.uploadFileFormat = res.data || [];
|
|
|
+ this.uploadFileFormat = this.uploadFileFormat.map(v => v.toLowerCase());
|
|
|
+ this.uploadFileAccept = this.uploadFileFormat
|
|
|
+ .map(v => "application/" + v)
|
|
|
+ .join();
|
|
|
+ },
|
|
|
methods: {
|
|
|
fileFormatCheck(file, resolve, reject) {
|
|
|
function getMimetype(signature) {
|
|
@@ -120,7 +135,11 @@ export default {
|
|
|
]);
|
|
|
this.$Notice.warning({
|
|
|
title: "作答文件损坏",
|
|
|
- desc: file.name + " 文件无法以 .zip 或 .pdf 读取。"
|
|
|
+ desc:
|
|
|
+ file.name +
|
|
|
+ " 文件无法以 " +
|
|
|
+ this.uploadFileFormat.join(" 或 ") +
|
|
|
+ " 格式读取。"
|
|
|
});
|
|
|
this.file = null;
|
|
|
this.loadingStatus = false;
|
|
@@ -145,12 +164,20 @@ export default {
|
|
|
this.$Message.error("上传失败");
|
|
|
},
|
|
|
handleFormatError(file) {
|
|
|
+ this.file = null;
|
|
|
+ this.loadingStatus = false;
|
|
|
this.$Notice.warning({
|
|
|
title: "作答文件格式不对",
|
|
|
- desc: file.name + " 文件格式不对,请选择 .zip 或 .pdf 文件。"
|
|
|
+ desc:
|
|
|
+ file.name +
|
|
|
+ " 文件格式不对,请选择 " +
|
|
|
+ this.uploadFileFormat.join(" 或 ") +
|
|
|
+ " 文件。"
|
|
|
});
|
|
|
},
|
|
|
handleMaxSize(file) {
|
|
|
+ this.file = null;
|
|
|
+ this.loadingStatus = false;
|
|
|
this.$Notice.warning({
|
|
|
title: "超出文件大小限制",
|
|
|
desc: file.name + " 太大,作答文件不能超过30M."
|