Procházet zdrojové kódy

fix:修改课件部分部分函数的实现

chillqi před 3 roky
rodič
revize
bcbec8c019

+ 35 - 30
src/router/index.js

@@ -143,45 +143,50 @@ const router = createRouter({
   routes,
 });
 
-const unauthorizedRoutes = ["Portal", "Auth", "Course", "Test","Project", "CompletePhone", "courseWareDetails"];
+const unauthorizedRoutes = ["Portal", "Auth", "Course", "Test","Project", "CompletePhone"];
 
 router.beforeEach((to, from, next) => {
-  //let token = localStorage.getItem("token");
-  //if (token && to.name === "courseWareDetails") {
-    //console.log(to);
-    //next({ name: "courseWareDetails", params: to.params});
-    //next();
-  //} else {
-      if (unauthorizedRoutes.indexOf(to.name) !== -1) {
-        next();
-      } else if (!store.state.user.token) {
+  let token = localStorage.getItem("token");
+  console.log(token);
+    if (unauthorizedRoutes.indexOf(to.name) !== -1) {
+      console.log(1);
+      next();
+    }
+    // else if (token && to.name === "courseWareDetails") {
+    //   console.log(localStorage);
+    //   if (localStorage.s === "true") {
+    //     console.log(3);
+    //     next();
+    //   }
+    // }
+    else if (!store.state.user.token) {
+      ElMessage({
+        showClose: true,
+        message: "请先登录",
+        type: "warning",
+        duration: 1000,
+      });
+      next({ name: "Auth", params: { login_to: to.path } });
+    } else {
+      if (to.name === "Manage" && !store.getters.isTeacher) {
+        ElMessage({
+          showClose: true,
+          message: "当前用户无权访问教师页面",
+          type: "error",
+          duration: 1000,
+        });
+      } else if (to.name === "Task" && !store.getters.isStudent) {
         ElMessage({
           showClose: true,
-          message: "请先登录",
+          message: "当前用户无需访问任务页面",
           type: "warning",
           duration: 1000,
         });
-        next({ name: "Auth", params: { login_to: to.path } });
       } else {
-        if (to.name === "Manage" && !store.getters.isTeacher) {
-          ElMessage({
-            showClose: true,
-            message: "当前用户无权访问教师页面",
-            type: "error",
-            duration: 1000,
-          });
-        } else if (to.name === "Task" && !store.getters.isStudent) {
-          ElMessage({
-            showClose: true,
-            message: "当前用户无需访问任务页面",
-            type: "warning",
-            duration: 1000,
-          });
-        } else {
-          next();
-        }
+        next();
       }
- // }
+    }
+  //}
 });
 
 router.afterEach(() => {

+ 5 - 1
src/views/AuthPage/components/AuthCard.vue

@@ -157,6 +157,7 @@ export default {
       }
     };
     return {
+      st: "false",
       cardType: "login",
       cardButtonDisabled: false,
       cardButtonText: "获取验证码",
@@ -338,13 +339,16 @@ export default {
                       localStorage.phone = this.cardForm.phone;
                       localStorage.password = this.cardForm.password;
                       localStorage.rememberMe = this.rememberMe;
+                      this.st="true";//修改登录状态为true
+                      localStorage.setItem("s",this.st);
+                      console.log(localStorage);
                     } else {
                       localStorage.removeItem("rememberMe");
                       localStorage.removeItem("phone");
                       localStorage.removeItem("password");
                     }
 
-                    localStorage.setItem("token", res.data.data.token);
+                    //localStorage.setItem("token", res.data.data.token);
 
                     this.$store.commit("state_set_user", res.data.data);
                     this.$message({

+ 130 - 81
src/views/CourseDetailPage/tabs/CoursewareTab.vue

@@ -69,12 +69,14 @@
       <el-table :data="fileEntryList" style="width: 100%">
         <el-table-column
             type="index"
-            width="30">
+            width="30"
+        >
         </el-table-column>
         <el-table-column
           prop="name"
           label="文件名"
-          width="260">
+          width="260"
+          >
           <template #default="scope">
             <el-icon v-if="scope.row['courseWareVO'].useMethod === 'SCAN'" style="color: #337ecc" class="myicon"><Reading /></el-icon>
             <el-icon v-if="scope.row['courseWareVO'].useMethod === 'ATTACHMENT'" style="color: green" class="myicon"><Paperclip /></el-icon>
@@ -96,7 +98,7 @@
         <el-table-column
         prop="created_time"
         label="上传时间"
-        width="140"
+        width="160"
         :sortable="true"
         >
           <template #default="scope">
@@ -105,8 +107,7 @@
         </el-table-column>
         <el-table-column
           prop="operation"
-          label="操作"
-          width="200">
+          label="操作">
           <template #default="scope">
 <!--            <a :href="scope.row['courseWareVO'].fileUrl" v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'OFFICE'">-->
 <!--              <el-button style="color: #409EFF; margin-right: 10px" type="text">预览</el-button>-->
@@ -227,8 +228,10 @@ export default {
       this.init();
   },
   methods: {
-      async init() {
-          this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
+      init() {
+          this.$apis.getCourseWaresByCourseId(this.courseId).then(res => {
+              this.fileEntryList = res.data.data;
+          });
           console.log(this.fileEntryList);
       },
 
@@ -255,11 +258,11 @@ export default {
               type: "warning",
               center: true,
           })
-              .then(() => {
-                  this.newName = null;
-                  this.nameAppend = null;
-                  this.nameChangeDialogVisible = false;
-              });
+          .then(() => {
+              this.newName = null;
+              this.nameAppend = null;
+              this.nameChangeDialogVisible = false;
+          });
       },
 
       handleConfirmChangeName() {
@@ -270,36 +273,39 @@ export default {
               });
               return;
           }
-          ElMessageBox.confirm("是否确定修改课件名称?", "提示", {
-              confirmButtonText: "确认修改",
-              cancelButtonText: "我再想想",
-              type: "warning",
-              center: true,
-          })
-              .then(async () => {
-                  const isNameUnique = (await this.$apis.checkCourseWareNameUnique(this.courseId, this.newName + this.nameAppend)).data.data;
+          // ElMessageBox.confirm("是否确定修改课件名称?", "提示", {
+          //     confirmButtonText: "确认修改",
+          //     cancelButtonText: "我再想想",
+          //     type: "warning",
+          //     center: true,
+          // })
+          // .then(res => {
+              this.$apis.checkCourseWareNameUnique(this.courseId, this.newName + this.nameAppend)
+              .then(res=> {
+                  const isNameUnique = res.data.data;
                   if (!isNameUnique) {
                       this.$message({
                           message: "该课程下已存在同名课件",
                           type: "error"
                       });
-                      return;
+                  } else {
+                      this.$apis.changeCourseWareName(this.idToBeChangeName, this.newName + this.nameAppend)
+                          .then(res=> {
+                              this.$apis.getCourseWaresByCourseId(this.courseId).then(res => {
+                                  this.fileEntryList = res.data.data;
+                              });
+                              this.newName = null;
+                              this.nameAppend = null;
+                              this.nameChangeDialogVisible = false;
+                          });
                   }
-
-                  this.$apis.changeCourseWareName(this.idToBeChangeName, this.newName + this.nameAppend)
-                      .then(async () => {
-                          console.log("1");
-                          this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
-                      });
-                  this.newName = null;
-                  this.nameAppend = null;
-                  this.nameChangeDialogVisible = false;
               });
+         // });
       },
 
       timestampToTime: portal.functions.timestampToTime,
 
-      async handleUploadFile(file, fileList) {
+      handleUploadFile(file, fileList) {
           console.log(file);
           console.log(fileList);
           const fileType = file.name.substring(file.name.lastIndexOf(".") + 1);
@@ -330,71 +336,114 @@ export default {
           }
           this.file = file;
           this.fileList = fileList;
-          const isNameUnique = (await this.$apis.checkCourseWareNameUnique(this.courseId, this.file.name)).data.data;
-          if (!isNameUnique) {
-              this.$message({
-                  message: "该课程下已存在同名课件",
-                  type: "error"
-              });
-          } else {
-              this.isNameUnique = true;
-              this.fileNum = 1;
-          }
+          this.$apis.checkCourseWareNameUnique(this.courseId, this.file.name)
+          .then(res => {
+              const isNameUnique = res.data.data;
+              if (!isNameUnique) {
+                  this.$message({
+                      message: "该课程下已存在同名课件",
+                      type: "error"
+                  });
+              } else {
+                  this.isNameUnique = true;
+                  this.fileNum = 1;
+              }
+          });
       },
 
-      async handleConfirmUpload() {
+      handleConfirmUpload() {
         if (this.file === null) {
             this.$message({
               message: "尚未上传课件",
               type: "error"
             });
-            return;
         }
-        if (this.newName === null && this.nameAppend !== null) {
-            this.$message({
-                message: "课件名称不可为空,请重新修改课件名称",
-                type: "error"
+        else if (this.newName !== null) {
+            this.$apis.checkCourseWareNameUnique(this.courseId, this.newName + this.nameAppend)
+            .then(res => {
+                const isNameUnique = res.data.data;
+                if (!isNameUnique) {
+                    this.$message({
+                        message: "该课程下已存在同名课件",
+                        type: "error"
+                    });
+                    this.newName = null;
+                } else {
+                    this.$apis.uploadCourseWareFile(this.courseId + "/" + this.newName + this.nameAppend, this.file.raw)
+                        .then(res => {
+                            const fileUrl = res.data.data;
+                            this.$apis.createCourseWare({
+                                name: this.newName === null ? this.file.name : (this.newName + this.nameAppend),
+                                size: this.file.size,
+                                senderId: this.$store.state.user.id,
+                                courseId: this.courseId,
+                                createdTime: new Date(),
+                                useTime: "BEFORE_CLASS",
+                                useMethod: this.form.useMethod,
+                                fileUrl: fileUrl,
+                                canDownload: this.downloadValue
+                            }).then(res => {
+                                this.$apis.getCourseWaresByCourseId(this.courseId)
+                                    .then(res => {
+                                        this.fileEntryList = res.data.data;
+                                        this.$message({
+                                            message: "上传课件成功",
+                                            type: "success"
+                                        });
+                                        this.uploadDialogVisible = false;
+                                        this.isChangeNameWhenUpload = false;
+                                        this.isNameUnique = false;
+                                        this.fileNum = 0;
+                                        this.newName = null;
+                                        this.nameAppend = null;
+                                        this.file = null;
+                                    });
+                            });
+                        });
+                }
             });
-            return;
         }
-        if (this.newName !== null) {
-          const isNameUnique = (await this.$apis.checkCourseWareNameUnique(this.courseId, this.newName + this.nameAppend)).data.data;
-          if (!isNameUnique) {
+        else if (this.nameAppend !== null) {
               this.$message({
-                  message: "该课程下已存在同名课件",
+                  message: "课件名称不可为空,请重新修改课件名称",
                   type: "error"
               });
-              return;
-          }
+              this.nameAppend = null;
+        }
+        else {
+            this.$apis.uploadCourseWareFile(this.courseId + "/" + this.file.name, this.file.raw)
+                .then(res => {
+                    const fileUrl = res.data.data;
+                    this.$apis.createCourseWare({
+                        name: this.newName === null ? this.file.name : (this.newName + this.nameAppend),
+                        size: this.file.size,
+                        senderId: this.$store.state.user.id,
+                        courseId: this.courseId,
+                        createdTime: new Date(),
+                        useTime: "BEFORE_CLASS",
+                        useMethod: this.form.useMethod,
+                        fileUrl: fileUrl,
+                        canDownload: this.downloadValue
+                    }).then(res => {
+                        this.$apis.getCourseWaresByCourseId(this.courseId)
+                            .then(res => {
+                                this.fileEntryList = res.data.data;
+                                this.$message({
+                                    message: "上传课件成功",
+                                    type: "success"
+                                });
+                                this.uploadDialogVisible = false;
+                                this.isChangeNameWhenUpload = false;
+                                this.isNameUnique = false;
+                                this.fileNum = 0;
+                                this.file = null;
+                            });
+                    });
+                });
         }
 
-        const fileUrl = (await this.$apis.uploadCourseWareFile(this.courseId + "/" + (this.newName == null ?
-            this.file.name : (this.newName + this.nameAppend)), this.file.raw)).data.data;
-            console.log(this.downloadValue);
-          this.$apis.createCourseWare({
-            name: this.newName === null ? this.file.name : (this.newName + this.nameAppend),
-            size: this.file.size,
-            senderId: this.$store.state.user.id,
-            courseId: this.courseId,
-            createdTime: new Date(),
-            useTime: "BEFORE_CLASS",
-            useMethod: this.form.useMethod,
-            fileUrl: fileUrl,
-            canDownload: this.downloadValue
-        }).then(async () => {
-            this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
-        });
-        this.$message({
-          message: "上传课件成功",
-          type: "success"
-        });
-        this.uploadDialogVisible = false;
-        this.isChangeNameWhenUpload = false;
-        this.isNameUnique = false;
-        this.fileNum = 0;
-        this.newName = null;
-        this.nameAppend = null;
-        this.file = null;
+
+
       },
 
       handleCancelUpload(done) {

+ 63 - 0
src/views/CourseWarePage/CourseWarePage.vue

@@ -41,6 +41,69 @@
             };
         },
         mounted() {
+            const params = {
+                phone: localStorage.phone,
+                password: localStorage.password
+            };
+            // this.$apis.loginAPI(params)
+            //     .then((res) => {
+            //         if (res.data.code === 0) {
+            //             console.log(res);
+            //             if (this.rememberMe) {
+            //                 localStorage.phone = this.cardForm.phone;
+            //                 localStorage.password = this.cardForm.password;
+            //                 localStorage.rememberMe = this.rememberMe;
+            //                 this.st="true";//修改登录状态为true
+            //                 localStorage.setItem("s",this.st);
+            //                 console.log(localStorage);
+            //             } else {
+            //                 localStorage.removeItem("rememberMe");
+            //                 localStorage.removeItem("phone");
+            //                 localStorage.removeItem("password");
+            //             }
+            //
+            //             //localStorage.setItem("token", res.data.data.token);
+            //
+            //             this.$store.commit("state_set_user", res.data.data);
+            //             this.$message({
+            //                 showClose: true,
+            //                 message: "登录成功",
+            //                 type: "success",
+            //                 duration: 1000,
+            //             });
+            //             // setTimeout(() => {
+            //             //     if (!res.data.data.redirectUri) {
+            //             //         if (this.$route.params.login_to) {
+            //             //             this.$router.push(String(this.$route.params.login_to));
+            //             //         } else {
+            //             //             this.$router.push("/portal");
+            //             //         }
+            //             //     } else {
+            //             //         let p = new Promise(function (resolve, reject) {
+            //             //             setCookie({redirect_uri: ""}, -1);
+            //             //             resolve();
+            //             //         }).then(r => {
+            //             //             window.location.href = res.data.data.redirectUri + "?id_token=" + res.data.data.token;
+            //             //         });
+            //             //     }
+            //             // }, 500);
+            //         } else {
+            //             this.$message({
+            //                 showClose: true,
+            //                 message: res.data.message,
+            //                 type: "error"
+            //             });
+            //             Object.assign(this.$data, this.$options.data());
+            //             this.$refs.verifier.init();
+            //         }
+            //     })
+            //     .catch((e) => {
+            //         this.$message({
+            //             showClose: true,
+            //             message: e,
+            //             type: "error"
+            //         });
+            //     });
             this.$store.commit(SET_CURRENT_PAGE, { currentPage: 1 });
             this.$apis.getCourseWareUrlById(this.$route.params.courseWareId).then(res => {
                 this.$apis.previewpdf(res.data.data).then(res => {

+ 0 - 1
src/views/CourseWarePage/pdf/PdfController.vue

@@ -34,7 +34,6 @@ export default {
   },
   mounted() {
     this.handleCanDownload();
-    console.log(this.currentPage);
   },
   computed: {
     ...mapState({