Ver código fonte

fix:修复新建作业功能

BaiQi 1 ano atrás
pai
commit
ea4f85362e

+ 4 - 5
src/views/CourseSquare/component/CourseDetails/component/CourseHomeworkTable.vue

@@ -32,7 +32,7 @@
         <el-table-column :label="role == 'teachers'? '编辑':'写作'" width="60">
           <template #default="scope">
             <el-button @mouseover="handleMouse('over', scope.row.teacherId, scope.row.endDate)" @mouseleave="handleMouse('leave', scope.row.teacherId, scope.row.endDate)"
-                color="#597d3b" circle @click="handleFunctionButton(scope.row.assignmentId)" :disabled="props.disabled || isDisabled(scope.row.teacherId, scope.row.endDate)">
+                color="#597d3b" circle @click="handleFunctionButton(scope.row.assignmentId)" :disabled="props.disabled || isDisabled(scope.row.teacherId, scope.row.teacherPid, scope.row.endDate)">
               <el-icon :size="18">
                 <Edit />
               </el-icon>
@@ -532,11 +532,10 @@ const openEditor = (url: string, title: string) => {
       });
   };
 
-  const isDisabled = (teacherId: string, endDate: string) => {
+  const isDisabled = (teacherId: string, teacherPid: string, endDate: string) => {
     if(props.role == 'teachers'){// 是教师且不是作业发布人则禁用
-      if(+teacherId != store.user.id){
-        return true
-      }
+      // TODO: 需要修改,目前是错误使用,需要一对一
+      return !(+teacherId == store.user.id || +teacherPid == store.user.pid || +teacherId == store.user.pid || +teacherPid == store.user.id);
     } else { // 是学生且超时则禁用
       if(new Date() > new Date(endDate)) return true
     }

+ 7 - 17
src/views/CourseSquare/component/CourseDetails/index.vue

@@ -427,23 +427,13 @@ const enroll = () => {
   教师,是否显示编辑课程按钮
  */
 const isShowEdit = () => {
-  apis.getCourseByTeacherId()
-      .then((res: any) => {
-        let total = res.data.data.total
-        apis.getCourseByTeacherId(1, total)
-            .then((res: any) => {
-              let data = res.data.data.records
-              for(let i = 0 ; i < data.length; i++){
-                if(data[i].courseId == courseId){
-                  showEdit.value = true;
-                  break;
-                }
-              }
-            })
-            .catch((err: any) => {
-              console.error(err);
-            })
-            .finally(() => {});
+  apis.getCourseByCourseId(courseId)
+      .then(res => {
+        const { teacherPid: pid, teacherIds: ids } = res.data.data.records[0];
+
+        if ((pid != null && pid == store.user.pid) || (ids != null && ids.includes(store.user.id))) {
+          showEdit.value = true;
+        }
       })
 
 }