Browse Source

Merge remote-tracking branch 'origin/master'

wangchangsheng 2 years ago
parent
commit
f54013eda8

+ 42 - 1
exam-06173-vue/src/views/admin/course/file/index.vue

@@ -96,7 +96,7 @@
               width="180px"
             />
 
-            <el-table-column label="操作" align="center" width="150px">
+            <el-table-column label="操作" align="center" width="200px">
               <template slot-scope="scope">
                 <el-link
                   type="primary"
@@ -105,6 +105,13 @@
                   @click="handlePreview(scope.row)"
                   >在线预览</el-link
                 >
+                <el-link
+                  type="primary"
+                  icon="el-icon-download"
+                  style="margin-left: 10px"
+                  @click="handleDownload(scope.row)"
+                  >课件下载</el-link
+                >
               </template>
             </el-table-column>
           </template>
@@ -224,6 +231,8 @@ import DetailLink from "@/components/DetailLink";
 import VideoPlayer from "@/components/VideoPlayer";
 import PdfReader from "@/components/PdfReader";
 import SecFormat from "@/components/SecFormat";
+import axios from 'axios'
+axios.defaults.withCredentials = true
 
 export default {
   name: "CourseFileList",
@@ -395,6 +404,38 @@ export default {
       this.previewData.viewUrl = data.viewUrl;
       this.previewData.fileUrl = data.fileUrl;
     },
+    handleDownload(data){
+      if(data.fileUrl.includes('pdf') || data.fileUrl.includes('mp4')){
+        this.handlePdfLink(data.fileUrl, data.fileUrl.substring(data.fileUrl.lastIndexOf('/')+1))
+      }else{
+        const a = document.createElement('a')
+        a.target="_blank"
+        a.href = data.fileUrl
+        a.download = ''
+        a.click()
+      }
+    },
+    handlePdfLink(url, filename){
+      axios.get(url, {
+        responseType: 'blob',
+      })
+        .then((res) => {
+          // 生成 Blob 对象,设置 type 等信息
+          const e = new Blob([res.data], {
+            type: 'application/octet-stream',
+            'Content-Disposition':'attachment'
+          })
+          // 将 Blob 对象转为 url
+          const link = window.URL.createObjectURL(e)
+          const a = document.createElement('a')
+          a.target="_blank"
+          a.href = link
+          a.download = filename
+          a.click()
+        }).catch(err => {
+          console.error(err)
+        })
+    },
 
     closePreview() {
       this.previewData = {};

+ 1 - 0
exam-06173-vue/src/views/admin/course/form.vue

@@ -293,6 +293,7 @@ export default {
         videoDrag: false,
         stepLock: false,
         lecturerId: "",
+        timeLimit: false,
         startTime: timeStart.formatDate("yyyy-MM-dd hh:mm:ss"),
         endTime: timeStart.formatDate("yyyy-MM-dd hh:mm:ss"),
         periods: 0,

+ 1 - 0
exam-06173-vue/src/views/admin/course/index.vue

@@ -42,6 +42,7 @@
       />
 
       <el-table-column label="课时" prop="periods" align="center" />
+      <el-table-column label="创建人" align="center" prop="createName" />
 
       <el-table-column label="创建时间" align="center" prop="createTime" />
 

+ 2 - 2
exam-06173-vue/src/views/dashboard/index.vue

@@ -434,7 +434,7 @@ export default {
             {
               data: pxSeriesData,
               type: "line",
-              smooth: true,
+              smooth: false,
               itemStyle: {
                 color: "#1890ff",
               },
@@ -514,7 +514,7 @@ export default {
             {
               data: pxSeriesData,
               type: "line",
-              smooth: true,
+              smooth: false,
               itemStyle: {
                 color: "#1890ff",
               },

+ 3 - 1
exam-06173-vue/src/views/login/index.vue

@@ -37,7 +37,7 @@
                 </el-form-item>
 
                 <el-form-item prop="captchaValue" label="验证码:">
-                  <yf-captcha ref="captcha" v-model="postForm" />
+                  <yf-captcha ref="captcha" :id="captchaId" v-model="postForm" />
                 </el-form-item>
 
                 <el-form-item label-width="0px">
@@ -168,6 +168,7 @@ export default {
         captchaKey: "",
         captchaValue: "",
       },
+      captchaId: 1, //用于控制登录失败时 验证码刷新
       loginRules: {
         username: [
           { required: true, trigger: "blur", message: "用户名不能为空" },
@@ -244,6 +245,7 @@ export default {
             })
             .catch(() => {
               this.loading = false;
+              this.captchaId++
             });
         }
       });

+ 8 - 0
exam-06173-vue/src/views/web/course/list.vue

@@ -86,6 +86,14 @@
           align="center"
           width="150px"
         />
+        <el-table-column label="学习时间" align="center" width="300px">
+          <template slot-scope="scope">
+            <span v-if="!scope.row.timeLimit">
+              {{ scope.row.startTime }} ~ {{ scope.row.endTime }}
+            </span>
+            <span v-else>不限时</span>
+          </template>
+        </el-table-column>
 
         <el-table-column
           label="学习进度"