Sfoglia il codice sorgente

feat: 课程管理教学大纲

zhangjie 1 mese fa
parent
commit
1d14b24740

+ 5 - 0
src/modules/questions/api.js

@@ -78,3 +78,8 @@ export const courseExportApi = (params) => {
     responseType: "blob",
   });
 };
+export const courseOurlineImportApi = (data, headData) => {
+  return $httpWithMsg.post(QUESTION_API + "/course/outline/upload", data, {
+    headers: headData,
+  });
+};

+ 106 - 0
src/modules/questions/component/CourseOutlineDialog.vue

@@ -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>

+ 26 - 11
src/modules/questions/views/Course.vue

@@ -103,17 +103,16 @@
           label="更新时间"
           width="170"
         />
-        <el-table-column label="操作" width="220">
+        <el-table-column label="操作" width="240">
           <div slot-scope="scope">
-            <!-- <el-button
-                size="mini"
-                type="primary"
-                plain
-                icon="el-icon-share"
-                @click="relation(scope.row)"
-              >
-                关联专业
-              </el-button> -->
+            <el-button
+              size="medium"
+              type="text"
+              class="normal"
+              @click="outlineCourse(scope.row)"
+            >
+              教学大纲
+            </el-button>
             <el-button
               size="medium"
               type="text"
@@ -230,6 +229,13 @@
         <el-button @click="errDialog = false">确定</el-button>
       </span>
     </el-dialog>
+
+    <!-- 课程大纲 -->
+    <course-outline-dialog
+      ref="CourseOutlineDialog"
+      :course="curCourse"
+      @comfirm="searchForm"
+    ></course-outline-dialog>
   </section>
 </template>
 
@@ -241,10 +247,11 @@ import { courseExportApi } from "../api";
 import { downloadByApi } from "@/plugins/download";
 import ImportFileDialog from "@/components/ImportFileDialog.vue";
 import SvgBtn from "@/components/SvgBtn.vue";
+import CourseOutlineDialog from "../component/CourseOutlineDialog.vue";
 
 export default {
   name: "Course",
-  components: { ImportFileDialog, SvgBtn },
+  components: { ImportFileDialog, SvgBtn, CourseOutlineDialog },
   data() {
     return {
       formSearch: {
@@ -268,6 +275,10 @@ export default {
       pageSize: 10,
       total: 10,
 
+      // course outline
+      outlineDialog: false,
+      curCourse: null,
+
       uploadCourseUrl: `${QUESTION_API}/course/import`,
       courseTemplateUrl: `${QUESTION_API}/course/importTemplate`,
       uploadHeaders: {},
@@ -459,6 +470,10 @@ export default {
 
       this.courseDialog = true;
     },
+    outlineCourse(row) {
+      this.curCourse = row;
+      this.$refs.CourseOutlineDialog.open();
+    },
     async exportCourse() {
       if (this.downloading) return;
       this.downloading = true;