|
@@ -0,0 +1,106 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-dialog
|
|
|
+ custom-class="import-file-dialog"
|
|
|
+ :visible.sync="modalIsShow"
|
|
|
+ title="教学大纲管理"
|
|
|
+ width="500px"
|
|
|
+ :modal="true"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :close-on-press-escape="false"
|
|
|
+ append-to-body
|
|
|
+ destroy-on-close
|
|
|
+ @open="visibleChange"
|
|
|
+ >
|
|
|
+ <el-form v-if="course?.outlineFilePath" label-width="80px">
|
|
|
+ <el-form-item label="文档:">
|
|
|
+ <el-link :href="course.outlineFilePath" target="_blank"
|
|
|
+ >教学大纲PDF</el-link
|
|
|
+ >
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div class="upload-gray-box">
|
|
|
+ <import-file
|
|
|
+ ref="ImportFile"
|
|
|
+ :format="['pdf']"
|
|
|
+ only-fetch-file
|
|
|
+ @file-change="fileChange"
|
|
|
+ ></import-file>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div slot="footer">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ :disabled="!this.fileData.file"
|
|
|
+ :loading="loading"
|
|
|
+ @click="confirm"
|
|
|
+ >确认</el-button
|
|
|
+ >
|
|
|
+ <el-button @click="cancel">取消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import ImportFile from "@/components/ImportFile.vue";
|
|
|
+import { courseOurlineImportApi } from "../api";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "CourseOutlineDialog",
|
|
|
+ components: { ImportFile },
|
|
|
+ props: {
|
|
|
+ course: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({}),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ modalIsShow: false,
|
|
|
+ fileData: {},
|
|
|
+ loading: false,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ visibleChange() {
|
|
|
+ this.fileData = {};
|
|
|
+ },
|
|
|
+ cancel() {
|
|
|
+ this.modalIsShow = false;
|
|
|
+ },
|
|
|
+ open() {
|
|
|
+ this.modalIsShow = true;
|
|
|
+ },
|
|
|
+ fileChange(fileData) {
|
|
|
+ this.fileData = fileData;
|
|
|
+ },
|
|
|
+ async confirm() {
|
|
|
+ if (!this.fileData.file) {
|
|
|
+ this.$message.warning("请上传教学大纲文件!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.loading) return;
|
|
|
+ this.loading = true;
|
|
|
+ this.$refs.ImportFile.setLoading(true);
|
|
|
+
|
|
|
+ let formData = new FormData();
|
|
|
+ formData.append("file", this.fileData.file);
|
|
|
+ formData.append("id", this.course.id);
|
|
|
+
|
|
|
+ const res = await courseOurlineImportApi(formData, {
|
|
|
+ md5: this.fileData.md5,
|
|
|
+ }).catch(() => {});
|
|
|
+ this.loading = false;
|
|
|
+ this.$refs.ImportFile.setLoading(false);
|
|
|
+
|
|
|
+ if (!res) return;
|
|
|
+
|
|
|
+ this.$message.success("导入成功!");
|
|
|
+ this.$emit("modified");
|
|
|
+ this.cancel();
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|