|
@@ -8,6 +8,7 @@
|
|
:close-on-click-modal="false"
|
|
:close-on-click-modal="false"
|
|
:close-on-press-escape="false"
|
|
:close-on-press-escape="false"
|
|
append-to-body
|
|
append-to-body
|
|
|
|
+ destroy-on-close
|
|
@opened="visibleChange"
|
|
@opened="visibleChange"
|
|
>
|
|
>
|
|
<div class="file-upload-body">
|
|
<div class="file-upload-body">
|
|
@@ -17,14 +18,16 @@
|
|
<upload-file-view
|
|
<upload-file-view
|
|
input-width="360px"
|
|
input-width="360px"
|
|
:format="curConfig.format"
|
|
:format="curConfig.format"
|
|
- :upload-url="uploadUrl"
|
|
|
|
|
|
+ :upload-url="curConfig.uploadUrl"
|
|
:upload-data="curConfig.uploadData"
|
|
:upload-data="curConfig.uploadData"
|
|
@uploading="uplaoding"
|
|
@uploading="uplaoding"
|
|
@upload-error="uplaodError"
|
|
@upload-error="uplaodError"
|
|
@upload-success="uploadSuccess"
|
|
@upload-success="uploadSuccess"
|
|
ref="UploadFileView"
|
|
ref="UploadFileView"
|
|
></upload-file-view>
|
|
></upload-file-view>
|
|
- <el-button @click="toPreview" style="margin-left: 10px;">预览</el-button>
|
|
|
|
|
|
+ <el-button type="info" @click="toPreview" style="margin-left: 10px;"
|
|
|
|
+ >预览</el-button
|
|
|
|
+ >
|
|
</div>
|
|
</div>
|
|
<div slot="footer">
|
|
<div slot="footer">
|
|
<el-button type="primary" @click="confirm" :disabled="loading"
|
|
<el-button type="primary" @click="confirm" :disabled="loading"
|
|
@@ -61,24 +64,30 @@ export default {
|
|
return {
|
|
return {
|
|
modalIsShow: false,
|
|
modalIsShow: false,
|
|
loading: false,
|
|
loading: false,
|
|
|
|
+ hasViewed: false,
|
|
attachment: {},
|
|
attachment: {},
|
|
config: {
|
|
config: {
|
|
paper: {
|
|
paper: {
|
|
title: "试卷文件",
|
|
title: "试卷文件",
|
|
format: ["pdf"],
|
|
format: ["pdf"],
|
|
- uploadData: { type: "PAPER" }
|
|
|
|
|
|
+ uploadData: { type: "PAPER" },
|
|
|
|
+ uploadUrl: "/api/admin/common/file/exam_paper_upload"
|
|
},
|
|
},
|
|
paperConfirm: {
|
|
paperConfirm: {
|
|
title: "附件",
|
|
title: "附件",
|
|
format: ["jpg", "png"],
|
|
format: ["jpg", "png"],
|
|
- uploadData: { type: "UPLOAD" }
|
|
|
|
|
|
+ uploadData: { type: "UPLOAD" },
|
|
|
|
+ uploadUrl: "/api/admin/common/file/upload"
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- curConfig: { format: [] },
|
|
|
|
- // import
|
|
|
|
- uploadUrl: "/api/admin/common/file/upload"
|
|
|
|
|
|
+ curConfig: { format: [], uploadUrl: "" }
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
+ computed: {
|
|
|
|
+ IS_UPLOAD_PAPER() {
|
|
|
|
+ return this.uploadType === "paper";
|
|
|
|
+ }
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
visibleChange() {
|
|
visibleChange() {
|
|
this.$refs.UploadFileView.setAttachmentName(
|
|
this.$refs.UploadFileView.setAttachmentName(
|
|
@@ -86,6 +95,7 @@ export default {
|
|
);
|
|
);
|
|
this.attachment = { ...this.paperAttachment };
|
|
this.attachment = { ...this.paperAttachment };
|
|
this.curConfig = this.config[this.uploadType];
|
|
this.curConfig = this.config[this.uploadType];
|
|
|
|
+ this.hasViewed = false;
|
|
},
|
|
},
|
|
// upload-handler
|
|
// upload-handler
|
|
uplaodError(errorData) {
|
|
uplaodError(errorData) {
|
|
@@ -98,12 +108,23 @@ export default {
|
|
uploadSuccess(data) {
|
|
uploadSuccess(data) {
|
|
this.loading = false;
|
|
this.loading = false;
|
|
this.$message.success("上传成功!");
|
|
this.$message.success("上传成功!");
|
|
- let infos = {
|
|
|
|
- attachmentId: data.id,
|
|
|
|
- filename: data.filename,
|
|
|
|
- url: data.url,
|
|
|
|
- pages: data.pages
|
|
|
|
- };
|
|
|
|
|
|
+ let infos = {};
|
|
|
|
+ if (this.IS_UPLOAD_PAPER) {
|
|
|
|
+ infos = {
|
|
|
|
+ attachmentId: data.translate.id,
|
|
|
|
+ filename: data.filename,
|
|
|
|
+ url: data.translate.url,
|
|
|
|
+ pages: data.translate.pages,
|
|
|
|
+ original: data.original
|
|
|
|
+ };
|
|
|
|
+ } else {
|
|
|
|
+ infos = {
|
|
|
|
+ attachmentId: data.id,
|
|
|
|
+ filename: data.filename,
|
|
|
|
+ url: data.url,
|
|
|
|
+ pages: data.pages
|
|
|
|
+ };
|
|
|
|
+ }
|
|
this.attachment = Object.assign(this.attachment, infos);
|
|
this.attachment = Object.assign(this.attachment, infos);
|
|
},
|
|
},
|
|
uplaoding() {
|
|
uplaoding() {
|
|
@@ -116,6 +137,18 @@ export default {
|
|
this.modalIsShow = true;
|
|
this.modalIsShow = true;
|
|
},
|
|
},
|
|
confirm() {
|
|
confirm() {
|
|
|
|
+ if (!this.attachment.attachmentId) {
|
|
|
|
+ this.$message.error(`请先上传${this.curConfig.title}!`);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (
|
|
|
|
+ !this.hasViewed &&
|
|
|
|
+ this.IS_UPLOAD_PAPER &&
|
|
|
|
+ this.attachment.attachmentId !== this.paperAttachment.attachmentId
|
|
|
|
+ ) {
|
|
|
|
+ this.$message.error(`请先预览上传的试卷!`);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
this.$emit("confirm", this.attachment, this.uploadType);
|
|
this.$emit("confirm", this.attachment, this.uploadType);
|
|
this.cancel();
|
|
this.cancel();
|
|
},
|
|
},
|
|
@@ -124,7 +157,11 @@ export default {
|
|
this.$message.error(`请先上传${this.curConfig.title}!`);
|
|
this.$message.error(`请先上传${this.curConfig.title}!`);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- const data = await attachmentPreview(this.attachment.attachmentId);
|
|
|
|
|
|
+
|
|
|
|
+ let attachmentId = this.attachment.attachmentId;
|
|
|
|
+ if (this.IS_UPLOAD_PAPER) this.hasViewed = true;
|
|
|
|
+
|
|
|
|
+ const data = await attachmentPreview(attachmentId);
|
|
window.open(data.url);
|
|
window.open(data.url);
|
|
}
|
|
}
|
|
}
|
|
}
|