Ver Fonte

fix: 教师名称显示统一采用name而不是username,如若没有name则暂时使用username代替

mjh há 4 anos atrás
pai
commit
1af254974b

+ 20 - 4
src/components/CoderCard.vue

@@ -20,7 +20,7 @@
       </el-col>
       </el-col>
     </el-row>
     </el-row>
     <el-row class="teacher">
     <el-row class="teacher">
-      教师: {{ coderVO.creator.username }}
+      教师: {{ teacher.name }}
     </el-row>
     </el-row>
     <el-row class="course">
     <el-row class="course">
       所属课程: {{ coderVO.course }}
       所属课程: {{ coderVO.course }}
@@ -49,6 +49,16 @@ export default {
       },
       },
     }
     }
   },
   },
+  data() {
+    return {
+      teacher: {
+        type: Object,
+        default: {
+          name: "暂无信息",
+        },
+      },
+    };
+  },
   computed: {
   computed: {
     state: function () {
     state: function () {
       if (this.coderVO.status === "CLOSED") {
       if (this.coderVO.status === "CLOSED") {
@@ -65,7 +75,13 @@ export default {
       return this.$store.state.user.role === "TEACHER";
       return this.$store.state.user.role === "TEACHER";
     }
     }
   },
   },
-  mounted() {
+  async mounted() {
+    const res = await this.$apis.getUserAPI(this.coderVO.creator.id);
+    if (res.data.code === 0) {
+      this.teacher = res.data.data;
+    } else {
+      this.teacher = {name: this.coderVO.creator.username};
+    }
   },
   },
   methods: {
   methods: {
     timestampToTime(timestamp) {
     timestampToTime(timestamp) {
@@ -86,10 +102,10 @@ export default {
       let cancelButtonText = "让我想想";
       let cancelButtonText = "让我想想";
       let nextURL = "";
       let nextURL = "";
       if (this.isTeacher) {
       if (this.isTeacher) {
-        if(this.$store.state.user.id === this.coderVO.id){
+        if (this.$store.state.user.id === this.coderVO.id) {
           nextURL = "https://coder.seec.seecoder.cn/exam/" + this.coderVO.id + "?id_token=" + this.$store.state.user.token;
           nextURL = "https://coder.seec.seecoder.cn/exam/" + this.coderVO.id + "?id_token=" + this.$store.state.user.token;
           window.open(nextURL);
           window.open(nextURL);
-        }else{
+        } else {
           ElMessage.error("无权访问其他教师创建的测试");
           ElMessage.error("无权访问其他教师创建的测试");
         }
         }
       } else {
       } else {

+ 0 - 1
src/views/ManagePage/ManagePage.vue

@@ -99,7 +99,6 @@ import CourseCard from "@/components/CourseCard";
 import {ElMessage, ElMessageBox} from "element-plus";
 import {ElMessage, ElMessageBox} from "element-plus";
 import GlobalFooter from "@/components/GlobalFooter";
 import GlobalFooter from "@/components/GlobalFooter";
 import client from "@/utils/oss";
 import client from "@/utils/oss";
-import axios from "axios";
 
 
 export default {
 export default {
   name: "ManagePage",
   name: "ManagePage",

+ 11 - 4
src/views/PortalPage/components/MyTestCard.vue

@@ -39,10 +39,10 @@
 
 
     <el-row>
     <el-row>
       <el-col v-if="type==='eval'" class="teacher">
       <el-col v-if="type==='eval'" class="teacher">
-        发起人: {{ evalTeacher.name }}
+        教师: {{ teacher.name }}
       </el-col>
       </el-col>
       <el-col v-else class="teacher">
       <el-col v-else class="teacher">
-        发起人: {{ testVO.creator.username }}
+        教师: {{ testVO.creator.username }}
       </el-col>
       </el-col>
     </el-row>
     </el-row>
 
 
@@ -69,7 +69,7 @@ export default {
   },
   },
   data() {
   data() {
     return {
     return {
-      evalTeacher: {
+      teacher: {
         type: Object,
         type: Object,
         default: {
         default: {
           name: "暂无信息",
           name: "暂无信息",
@@ -110,7 +110,14 @@ export default {
   async mounted() {
   async mounted() {
     if (this.type === "eval") {
     if (this.type === "eval") {
       const res = await this.$apis.getUserAPI(this.testVO.creatorId);
       const res = await this.$apis.getUserAPI(this.testVO.creatorId);
-      this.evalTeacher = res.data.data;
+      this.teacher = res.data.data;
+    }else{
+      const res = await this.$apis.getUserAPI(this.test.creator.id);
+      if(res.data.code === 0){
+        this.teacher = res.data.data;
+      }else{
+        this.teacher = {name: this.coderVO.creator.username};
+      }
     }
     }
   },
   },
   methods: {
   methods: {