Browse Source

添加上课功能

lex 1 year ago
parent
commit
b7e2ce19d7

+ 5 - 1
src/components/layout/index.tsx

@@ -284,7 +284,11 @@ export default defineComponent({
           src={toolStartClass}
           id="moveNPopover2"
           style={{
-            display: ['/', '/home'].includes(route.path) ? 'none' : 'block'
+            display: ['/', '/home', '/classList', '/prepare-lessons'].includes(
+              route.path
+            )
+              ? 'none'
+              : 'block'
           }}
           class={[
             styles.toolClassImg,

+ 18 - 7
src/components/layout/layoutTop.tsx

@@ -1,4 +1,4 @@
-import { defineComponent, ref, onMounted, onBeforeMount } from 'vue';
+import { defineComponent, ref, onMounted, onBeforeMount, nextTick } from 'vue';
 import styles from './index.module.less';
 import { NImage, NBadge, NPopover, NIcon, NModal, NTooltip } from 'naive-ui';
 import schoolIcon from './images/schoolIcon.png';
@@ -38,17 +38,27 @@ export default defineComponent({
     const resetPwd = () => {
       showWord.value = true;
     };
+    const body = document.querySelector('body');
+    console.log(body, 'mask');
+    if (body) {
+      body.className = 'myBody body';
+    }
 
     onMounted(() => {
       window.addEventListener('message', onImMessage);
       showImGroup.value = true;
 
-      setTimeout(() => {
-        showImGroup.value = false;
-      }, 50);
-      setTimeout(() => {
-        showImGroupLoading.value = false;
-      }, 1000);
+      nextTick(() => {
+        setTimeout(() => {
+          showImGroup.value = false;
+        }, 50);
+        setTimeout(() => {
+          showImGroupLoading.value = false;
+          if (body) {
+            body.className = 'myBody';
+          }
+        }, 1000);
+      });
     });
 
     const onImMessage = (evt: MessageEvent) => {
@@ -216,6 +226,7 @@ export default defineComponent({
             v-model:show={showImGroup.value}
             showIcon={false}
             class={showImGroupLoading.value ? styles.hideModal : ''}
+            {...{ id: 'imGroupDiv' }}
             displayDirective="show">
             <ImGroup />
           </NModal>

+ 5 - 0
src/styles/index.less

@@ -346,3 +346,8 @@ body {
 .n-base-close:not(.n-base-close--disabled):focus::before {
   background-color: transparent !important;
 }
+
+
+.body .n-modal-mask {
+  background-color: transparent !important;
+}

+ 54 - 88
src/views/home/modals/chioseModal.tsx

@@ -9,7 +9,7 @@ import {
   useMessage
 } from 'naive-ui';
 import { useRouter } from 'vue-router';
-import { getCourseChapter } from '../../classList/api';
+import { classGroupList, getCourseChapter } from '../../classList/api';
 import {
   bookVersionPage,
   courseScheduleStart,
@@ -18,16 +18,20 @@ import {
 } from '../../prepare-lessons/api';
 import { useThrottleFn } from '@vueuse/core';
 import { useCatchStore } from '/src/store/modules/catchData';
+import { gradeToCN } from '/src/utils/contants';
 export default defineComponent({
   name: 'train-update',
   emits: ['close'],
   setup(props, { emit }) {
     const forms = reactive({
+      currentClass: null,
       bookVersionId: null,
       classGroupId: null,
       category: null,
       chapter: null,
       subjectId: null,
+      gradeList: [] as any,
+      classList: [] as any,
       musicTagList: [] as any,
       loading: false,
       list: [] as any,
@@ -42,31 +46,31 @@ export default defineComponent({
     const gotoClassPage = () => {
       formsRef.value.validate(async (error: any) => {
         if (error) return;
-        // const { data } = await queryCourseware({
-        //   coursewareDetailKnowledgeId: forms.chapter,
-        //   subjectId: forms.subjectId,
-        //   page: 1,
-        //   rows: 99
-        // });
-        // await courseScheduleStart({
-        //   lessonCoursewareKnowledgeDetailId: forms.chapter,
-        //   classGroupId: props.activeRow.id
-        // });
-        // if (data.rows && data.rows.length > 0) {
-        //   const { href } = router.resolve({
-        //     path: '/attend-class',
-        //     query: {
-        //       type: 'class',
-        //       classGroupId: props.activeRow.id,
-        //       subjectId: forms.subjectId,
-        //       detailId: forms.chapter
-        //     }
-        //   });
-        //   emit('close');
-        //   window.open(href, +new Date() + '', 'fullscreen=yes');
-        // } else {
-        //   message.error('当前章节暂无课件,请重新选择');
-        // }
+        const { data } = await queryCourseware({
+          coursewareDetailKnowledgeId: forms.chapter,
+          subjectId: forms.subjectId,
+          page: 1,
+          rows: 99
+        });
+        await courseScheduleStart({
+          lessonCoursewareKnowledgeDetailId: forms.chapter,
+          classGroupId: forms.currentClass
+        });
+        if (data.rows && data.rows.length > 0) {
+          const { href } = router.resolve({
+            path: '/attend-class',
+            query: {
+              type: 'class',
+              classGroupId: forms.currentClass,
+              subjectId: forms.subjectId,
+              detailId: forms.chapter
+            }
+          });
+          emit('close');
+          window.open(href, +new Date() + '', 'fullscreen=yes');
+        } else {
+          message.error('当前章节暂无课件,请重新选择');
+        }
       });
     };
 
@@ -160,52 +164,29 @@ export default defineComponent({
     };
 
     // 获取年级班级
-    // const getClassList = async () => {
-    //   try {
-    //     const { data } = await classGroupList({ removeZeroClass: true });
-    //     const cList = data || [];
-    //     const gradeList: any = [];
-    //     const popSelectOptions: any = [];
-    //     cList.forEach((item: any, index: number) => {
-    //       if (index === 0) {
-    //         const temp = item.classGroupList[0];
-    //         forms.classSelect = {
-    //           currentGradeNum: item.currentGradeNum,
-    //           currentClass: temp.id,
-    //           name: temp.name
-    //         };
-    //       }
-
-    //       const classList: any = [];
-    //       item.classGroupList.forEach((i: any) => {
-    //         classList.push({
-    //           label: i.currentClass + '班',
-    //           value: i.id,
-    //           lastStudy: i.lastStudy
-    //         });
+    const getClassList = async () => {
+      try {
+        const { data } = await classGroupList({ removeZeroClass: true });
 
-    //         popSelectOptions.push({
-    //           label: i.name,
-    //           value: i.id,
-    //           currentGradeNum: item.currentGradeNum,
-    //           lastStudy: i.lastStudy
-    //         });
-    //       });
+        const cList = data.rows || [];
+        const gradeList: any = [];
+        cList.forEach((item: any) => {
+          gradeList.push({
+            label: item.name,
+            value: item.currentClass
+          });
+        });
+        forms.gradeList = gradeList;
 
-    //       gradeList.push({
-    //         label: gradeToCN[item.currentGradeNum],
-    //         value: item.currentGradeNum,
-    //         childrens: classList
-    //       });
-    //     });
-    //     forms.popSelectOptions = popSelectOptions;
-    //     forms.gradeList = gradeList;
-    //   } catch {
-    //     //
-    //   }
-    // };
+        console.log(forms.gradeList, 'gradeList');
+      } catch (e: any) {
+        //
+        console.log(e, 'e');
+      }
+    };
 
     onMounted(async () => {
+      await getClassList();
       await catchStore.getSubjects();
       forms.subjectList = catchStore.getSubjectList.map((item: any) => {
         return {
@@ -223,20 +204,19 @@ export default defineComponent({
           ref={formsRef}
           model={forms}>
           <NFormItem
-            label="年级"
-            path="currentGradeNum"
+            path="currentClass"
             rule={[
               {
                 required: true,
-                message: '请选择级',
+                message: '请选择级',
                 trigger: 'change',
                 type: 'number'
               }
             ]}>
             <NSelect
-              v-model:value={forms.currentGradeNum}
-              placeholder="请选择级"
-              options={props.gradeList as any}
+              v-model:value={forms.currentClass}
+              placeholder="请选择级"
+              options={forms.gradeList as any}
               clearable
               onUpdate:value={() => {
                 forms.classGroupId = null;
@@ -245,20 +225,6 @@ export default defineComponent({
             />
           </NFormItem>
           <NFormItem
-            label="班级"
-            path="classGroupId"
-            rule={[
-              { required: true, message: '请选择班级', trigger: 'change' }
-            ]}>
-            <NSelect
-              v-model:value={forms.classGroupId}
-              placeholder="请选择班级"
-              clearable
-              options={forms.classList}
-              disabled={!forms.currentGradeNum}
-            />
-          </NFormItem>
-          <NFormItem
             path="bookVersionId"
             rule={[{ required: true, message: '选择教材版本' }]}>
             <NSelect