Browse Source

修改问题

lex 1 year ago
parent
commit
7d0e2662c8

+ 27 - 13
src/views/content-information/content-music/components/list/search-group-resources.tsx

@@ -2,6 +2,7 @@ import { PropType, computed, defineComponent, onMounted, reactive } from 'vue';
 import styles from './index.module.less';
 import { NButton, NForm, NFormItem, NPopselect, NSpace } from 'naive-ui';
 import TheSearch from '/src/components/TheSearch';
+import deepClone from '/src/helpers/deep-clone';
 export default defineComponent({
   name: 'search-group',
   props: {
@@ -45,24 +46,37 @@ export default defineComponent({
       const child = categoryChildList.find(
         (item: any) => item.id === forms.wikiCategoryId
       );
+
       if (child && child.childrenList.length) {
-        child.childrenList.forEach((child: any) => {
-          const i = child.childrenList;
+        const temps: any = [];
+        child.childrenList.forEach((c: any) => {
+          const i = c.childrenList;
+          const childTemp: any = [];
+          // const i = c.childrenList;
           if (i && i.length > 0) {
-            i.forEach((j: any) => {
-              j.label = j.name;
-              j.value = j.id;
-            });
-
-            i.unshift({
+            childTemp.push({
               label: '全部',
-              value: child.id,
-              name: child.name,
-              id: child.id
+              value: c.id,
+              name: c.name,
+              id: c.id
+            });
+            i.forEach((j: any) => {
+              // j.label = j.name;
+              // j.value = j.id;
+              childTemp.push({
+                label: j.name,
+                value: j.id,
+                name: j.name,
+                id: j.id
+              });
             });
           }
-        });
 
+          temps.push({
+            ...c,
+            childrenList: childTemp
+          });
+        });
         return (
           [
             {
@@ -72,7 +86,7 @@ export default defineComponent({
               name: '全部',
               childrenList: []
             },
-            ...child.childrenList
+            ...temps
           ] || []
         );
       }

+ 1 - 0
src/views/prepare-lessons/components/directory-main/index.tsx

@@ -164,6 +164,7 @@ export default defineComponent({
         const subjectId = item.subjectList[0].id
           ? Number(item.subjectList[0].id)
           : '';
+        sessionStorage.removeItem('prepareLessonCourseWareSubjectIsNull');
         prepareStore.setSubjectId(subjectId);
       }
 

+ 23 - 38
src/views/prepare-lessons/components/lesson-main/courseware-presets/index.tsx

@@ -37,12 +37,6 @@ import PreviewWindow from '/src/views/preview-window';
 
 export default defineComponent({
   name: 'courseware-presets',
-  props: {
-    courseWareSubjectIsNull: {
-      type: Boolean,
-      default: false
-    }
-  },
   emits: ['change'],
   setup(props, { emit }) {
     const prepareStore = usePrepareStore();
@@ -179,20 +173,6 @@ export default defineComponent({
       }
     );
 
-    // 检测数据是否存在
-    // watch(
-    //   () => forms.tableList,
-    //   () => {
-    //     // fromChapterLessonCoursewareId;
-    //     forms.openTableList.forEach((item: any) => {
-    //       const index = forms.tableList.findIndex(
-    //         (i: any) => i.fromChapterLessonCoursewareId === item.id
-    //       );
-    //       item.isAdd = index !== -1 ? true : false;
-    //     });
-    //   }
-    // );
-
     watch(
       () => prepareStore.getSubjectList,
       () => {
@@ -205,6 +185,14 @@ export default defineComponent({
 
       // 并且没有声部时才会更新
       if (subjectList.length > 0) {
+        const prepareLessonCourseWareSubjectIsNull = sessionStorage.getItem(
+          'prepareLessonCourseWareSubjectIsNull'
+        );
+        if (prepareLessonCourseWareSubjectIsNull === 'true') {
+          prepareStore.setSubjectId('');
+          return;
+        }
+
         // 并且声部在列表中
         const localStorageSubjectId = localStorage.getItem(
           'prepareLessonSubjectId'
@@ -242,17 +230,13 @@ export default defineComponent({
           }
         }
         // 判断是否选择为空
-        if (props.courseWareSubjectIsNull) {
-          prepareStore.setSubjectId('');
+        if (subjectId && index >= 0) {
+          prepareStore.setSubjectId(subjectId);
+          // forms.subjectId = subjectId;
         } else {
-          if (subjectId && index >= 0) {
-            prepareStore.setSubjectId(subjectId);
-            // forms.subjectId = subjectId;
-          } else {
-            // 判断是否有缓存
-            prepareStore.setSubjectId(subjectList[0].id);
-            // forms.subjectId = subjectList[0].id;
-          }
+          // 判断是否有缓存
+          // prepareStore.setSubjectId(subjectList[0].id);
+          // forms.subjectId = subjectList[0].id;
         }
 
         // 保存
@@ -447,6 +431,13 @@ export default defineComponent({
                 prepareStore.setSubjectId(val);
                 // 保存
                 forms.subjectId = val;
+
+                if (!val) {
+                  sessionStorage.setItem(
+                    'prepareLessonCourseWareSubjectIsNull',
+                    val ? false : true
+                  );
+                }
               }}
             />
             <NButton
@@ -456,10 +447,7 @@ export default defineComponent({
                 eventGlobal.emit('teacher-slideshow', true);
                 emit('change', {
                   status: true,
-                  type: 'create',
-                  courseWareSubjectIsNull: prepareStore.getSubjectId
-                    ? false
-                    : true
+                  type: 'create'
                 });
               }}>
               <NImage
@@ -491,10 +479,7 @@ export default defineComponent({
                           emit('change', {
                             status: true,
                             type: 'update',
-                            groupItem: { id: item.id },
-                            courseWareSubjectIsNull: prepareStore.getSubjectId
-                              ? false
-                              : true
+                            groupItem: { id: item.id }
                           });
                         }}
                         onStartClass={() =>

+ 0 - 3
src/views/prepare-lessons/components/lesson-main/index.tsx

@@ -15,7 +15,6 @@ export default defineComponent({
     const state = reactive({
       editCoursewareShow: false, // 是否编辑课件
       coursewareType: 'create' as 'create' | 'edit',
-      courseWareSubjectIsNull: false, // 课件中是否使用全部声部
       editCourseware: {} as any, //
       editWorkShow: false, // 是否编辑预设
       editWork: {} as any // 预设模板编号
@@ -75,11 +74,9 @@ export default defineComponent({
                 />
               ) : (
                 <CoursewarePresets
-                  courseWareSubjectIsNull={state.courseWareSubjectIsNull}
                   onChange={(val: any) => {
                     state.coursewareType = val.type;
                     state.editCoursewareShow = val.status;
-                    state.courseWareSubjectIsNull = val.courseWareSubjectIsNull;
                     prepareStore.setIsEditResource(val.status);
                     state.editCourseware = val.groupItem;
                   }}

+ 1 - 0
src/views/prepare-lessons/index.tsx

@@ -100,6 +100,7 @@ export default defineComponent({
       prepareStore.setIsAddTrain(false);
       prepareStore.setIsEditResource(false);
       prepareStore.setIsEditTrain(false);
+      sessionStorage.removeItem('prepareLessonCourseWareSubjectIsNull');
     });
     onUnmounted(() => {
       prepareStore.setSubjectId('');

+ 25 - 13
src/views/prepare-lessons/model/source-music/components/list/search-group-resources.tsx

@@ -66,23 +66,35 @@ export default defineComponent({
         (item: any) => item.id === forms.wikiCategoryId
       );
       if (child && child.childrenList.length) {
-        child.childrenList.forEach((child: any) => {
-          const i = child.childrenList;
+        const temps: any = [];
+        child.childrenList.forEach((c: any) => {
+          const i = c.childrenList;
+          const childTemp: any = [];
+          // const i = c.childrenList;
           if (i && i.length > 0) {
-            i.forEach((j: any) => {
-              j.label = j.name;
-              j.value = j.id;
-            });
-
-            i.unshift({
+            childTemp.push({
               label: '全部',
-              value: child.id,
-              name: child.name,
-              id: child.id
+              value: c.id,
+              name: c.name,
+              id: c.id
+            });
+            i.forEach((j: any) => {
+              // j.label = j.name;
+              // j.value = j.id;
+              childTemp.push({
+                label: j.name,
+                value: j.id,
+                name: j.name,
+                id: j.id
+              });
             });
           }
-        });
 
+          temps.push({
+            ...c,
+            childrenList: childTemp
+          });
+        });
         return (
           [
             {
@@ -92,7 +104,7 @@ export default defineComponent({
               name: '全部',
               childrenList: []
             },
-            ...child.childrenList
+            ...temps
           ] || []
         );
       }