Browse Source

修改搜索

lex 8 months ago
parent
commit
d23146afa6
26 changed files with 775 additions and 539 deletions
  1. 35 18
      src/components/CCascader/index.tsx
  2. 48 45
      src/components/card-preview/music-modal/index.tsx
  3. 253 199
      src/components/layout/modals/suggestion-list.tsx
  4. 3 0
      src/store/modules/catchData.ts
  5. 1 1
      src/views/attend-class/index.tsx
  6. 7 2
      src/views/natural-resources/components/my-collect/index.tsx
  7. 25 7
      src/views/natural-resources/components/my-collect/search-group-resources.tsx
  8. 8 2
      src/views/natural-resources/components/my-resources/index.tsx
  9. 24 12
      src/views/natural-resources/components/my-resources/search-group-resources.tsx
  10. 11 2
      src/views/natural-resources/components/share-resources/index.tsx
  11. 24 7
      src/views/natural-resources/components/share-resources/search-group-resources.tsx
  12. 39 5
      src/views/prepare-lessons/components/directory-main/index.tsx
  13. 28 25
      src/views/prepare-lessons/components/lesson-main/courseware-presets/index.tsx
  14. 108 154
      src/views/prepare-lessons/components/lesson-main/index.tsx
  15. 6 2
      src/views/prepare-lessons/components/resource-main/components/resource-item/index.tsx
  16. 1 0
      src/views/prepare-lessons/components/resource-main/components/resource-item/resource-search-group/index.tsx
  17. 5 1
      src/views/prepare-lessons/components/resource-main/components/select-music/index.tsx
  18. 1 1
      src/views/prepare-lessons/components/resource-main/components/select-music/resource-search-group/index.tsx
  19. 1 1
      src/views/prepare-lessons/index.tsx
  20. 7 3
      src/views/prepare-lessons/model/select-music/select-item/index.tsx
  21. 17 1
      src/views/prepare-lessons/model/select-music/select-item/search-group.tsx
  22. 24 4
      src/views/prepare-lessons/model/select-resources/index.tsx
  23. 47 17
      src/views/prepare-lessons/model/select-resources/select-item/class-search-group/index.tsx
  24. 23 7
      src/views/prepare-lessons/model/select-resources/select-item/index.tsx
  25. 26 23
      src/views/prepare-lessons/model/select-resources/select-item/resource-search-group/index.tsx
  26. 3 0
      src/views/xiaoku-music/index.tsx

+ 35 - 18
src/components/CCascader/index.tsx

@@ -24,6 +24,11 @@ export default defineComponent({
       type: Boolean,
       default: false
     },
+    /** 子选项是否显示全部类型 */
+    childShowAllCheck: {
+      type: Boolean,
+      default: true
+    },
     value: {
       type: String,
       default: ''
@@ -87,20 +92,23 @@ export default defineComponent({
       let children: any;
       let columnName = '';
       if (subject.children) {
-        children = [
-          {
+        children = [...subject.children];
+        let activeIndex = children.length > 0 ? children[0].id : '';
+        if (props.childShowAllCheck) {
+          children.unshift({
             columnName: subject.children[0].columnName,
             name: '全部' + subject.children[0].columnName || '',
             id: ''
-          },
-          ...subject.children
-        ];
+          });
+          activeIndex = '';
+        }
         columnName = subject.children[0].columnName;
 
+        state.childSelectId = activeIndex;
         state.selectParents = {
           ...subject,
           columnName,
-          activeIndex: '',
+          activeIndex,
           children
         };
       } else {
@@ -146,7 +154,6 @@ export default defineComponent({
         });
       }
 
-      console.log(values, names, 'names', props.value);
       if (props.showPath) {
         return names.join(' / ');
       } else {
@@ -361,6 +368,7 @@ export default defineComponent({
                         ))}
                       </div>
                       <ChildNodeSearch
+                        childShowAllCheck={props.childShowAllCheck}
                         activeRow={state.selectParents}
                         onSelectChildTag={(val: any) => {
                           state.childSelectId = val;
@@ -391,6 +399,11 @@ export default defineComponent({
 const ChildNodeSearch = defineComponent({
   name: 'ChildNodeSearch',
   props: {
+    /** 子选项是否显示全部类型 */
+    childShowAllCheck: {
+      type: Boolean,
+      default: true
+    },
     activeRow: {
       type: Object,
       default: () => ({})
@@ -425,14 +438,14 @@ const ChildNodeSearch = defineComponent({
             let children: any;
             let columnName = '';
             if (subject.children) {
-              children = [
-                {
+              children = [...subject.children];
+              if (props.childShowAllCheck) {
+                children.unshift({
                   columnName: subject.children[0].columnName,
                   name: '全部' + subject.children[0].columnName || '',
                   id: ''
-                },
-                ...subject.children
-              ];
+                });
+              }
               columnName = subject.children[0].columnName;
 
               selectItem.value = {
@@ -441,6 +454,7 @@ const ChildNodeSearch = defineComponent({
                 activeIndex: subject.activeIndex || '',
                 children
               };
+              emit('selectChildTag', subject.activeIndex || '');
             }
           }
         });
@@ -473,20 +487,23 @@ const ChildNodeSearch = defineComponent({
                     let children: any;
                     let columnName = '';
                     if (subject.children) {
-                      children = [
-                        {
+                      children = [...subject.children];
+                      let activeIndex =
+                        children.length > 0 ? children[0].id : '';
+                      if (props.childShowAllCheck) {
+                        children.unshift({
                           columnName: subject.children[0].columnName,
                           name: '全部' + subject.children[0].columnName || '',
                           id: ''
-                        },
-                        ...subject.children
-                      ];
+                        });
+                        activeIndex = '';
+                      }
                       columnName = subject.children[0].columnName;
 
                       selectItem.value = {
                         ...subject,
                         columnName,
-                        activeIndex: '',
+                        activeIndex,
                         children
                       };
                     } else {

+ 48 - 45
src/components/card-preview/music-modal/index.tsx

@@ -1,45 +1,48 @@
-import { defineComponent, ref } from 'vue';
-import styles from './index.module.less';
-import { useUserStore } from '/src/store/modules/users';
-import { vaildMusicScoreUrl } from '/src/utils/urlUtils';
-import { iframeDislableKeyboard } from '/src/utils';
-
-export default defineComponent({
-  name: 'song-modal',
-  props: {
-    item: {
-      type: Object,
-      default: () => ({})
-    },
-    /** 从哪里使用 */
-    from: {
-      type: String,
-      default: ''
-    }
-  },
-  setup(props) {
-    const userStore = useUserStore();
-    const iframeRef = ref();
-    const isLoaded = ref(false);
-    // const origin = /(localhost|192)/.test(location.host)
-    //   ? 'https://test.lexiaoya.cn'
-    //   : location.origin;
-    const src = `${vaildMusicScoreUrl()}/instrument?v=${+new Date()}&modelType=practise&id=${
-      props.item.content
-    }&Authorization=${userStore.getToken}&platform=pc&zoom=0.8`;
-    return () => (
-      <div class={styles.musicScore}>
-        <iframe
-          ref={iframeRef}
-          onLoad={(val: any) => {
-            // emit('setIframe', iframeRef.value);
-            isLoaded.value = true;
-            iframeDislableKeyboard(val.target);
-          }}
-          class={[styles.container, 'musicIframe']}
-          frameborder="0"
-          src={src}></iframe>
-      </div>
-    );
-  }
-});
+import { defineComponent, ref } from 'vue';
+import styles from './index.module.less';
+import { useUserStore } from '/src/store/modules/users';
+import { vaildMusicScoreUrl } from '/src/utils/urlUtils';
+import { iframeDislableKeyboard } from '/src/utils';
+
+export default defineComponent({
+  name: 'song-modal',
+  props: {
+    item: {
+      type: Object,
+      default: () => ({})
+    },
+    /** 从哪里使用 */
+    from: {
+      type: String,
+      default: ''
+    }
+  },
+  setup(props) {
+    const userStore = useUserStore();
+    const iframeRef = ref();
+    const isLoaded = ref(false);
+    // const origin = /(localhost|192)/.test(location.host)
+    //   ? 'https://test.lexiaoya.cn'
+    //   : location.origin;
+    let src = `${vaildMusicScoreUrl()}/instrument?v=${+new Date()}&modelType=practise&id=${
+      props.item.content
+    }&Authorization=${userStore.getToken}&platform=pc&zoom=0.8`;
+    if (props.item.instrumentId) {
+      src += '&instrumentId=' + props.item.instrumentId;
+    }
+    return () => (
+      <div class={styles.musicScore}>
+        <iframe
+          ref={iframeRef}
+          onLoad={(val: any) => {
+            // emit('setIframe', iframeRef.value);
+            isLoaded.value = true;
+            iframeDislableKeyboard(val.target);
+          }}
+          class={[styles.container, 'musicIframe']}
+          frameborder="0"
+          src={src}></iframe>
+      </div>
+    );
+  }
+});

+ 253 - 199
src/components/layout/modals/suggestion-list.tsx

@@ -1,199 +1,253 @@
-import { PropType, defineComponent, onMounted, reactive, ref } from 'vue';
-import styles from './suggestion-list.module.less';
-import {
-  NInput,
-  NSelect,
-  NScrollbar,
-  NSpin,
-  NThing,
-  NImageGroup,
-  NSpace,
-  NImage,
-  NButton
-} from 'naive-ui';
-import { batchSetRead, getSysSuggestionList } from './api';
-import CDatePicker from '../../CDatePicker';
-import TheEmpty from '../../TheEmpty';
-import { useDebounceFn, useThrottleFn } from '@vueuse/core';
-import { eventGlobal, getTimes } from '/src/utils';
-
-export default defineComponent({
-  name: 'suggestion-list',
-  props: {
-    typeList: {
-      type: Array as PropType<any[]>,
-      default: () => []
-    }
-  },
-  setup(props) {
-    const state = reactive({
-      suggestionTypeList: [] as any,
-      loading: false,
-      finshed: false, // 是否加载完
-      pagination: {
-        page: 1,
-        rows: 20
-      },
-      searchGroup: {
-        suggestionTypeId: null,
-        timer: null as any
-      },
-      tableList: [] as any,
-      show: false,
-      item: {} as any
-    });
-
-    const getList = async () => {
-      try {
-        if (state.pagination.page === 1) {
-          state.loading = true;
-        }
-        const { timer, ...res } = state.searchGroup;
-        const { data } = await getSysSuggestionList({
-          ...state.searchGroup,
-          ...res,
-          ...getTimes(timer, ['startTime', 'endTime'])
-        });
-        state.loading = false;
-        const tempRows = data.rows || [];
-        tempRows.forEach((row: any) => {
-          const imgList =
-            (row.attachmentUrls && row.attachmentUrls.split(',')) || [];
-          row.imgList = imgList;
-        });
-        if (state.pagination.page === 1) {
-          state.tableList = tempRows;
-        } else {
-          state.tableList.push(...tempRows);
-        }
-        state.finshed = data.pages <= data.current ? true : false;
-      } catch {
-        state.loading = false;
-      }
-    };
-
-    const throttledFnSearch = useDebounceFn(item => {
-      state.pagination.page = state.pagination.page + 1;
-      state.pagination.page = 1;
-      state.tableList = [];
-      state.searchGroup = Object.assign(state.searchGroup, item);
-      getList();
-    }, 100);
-
-    const throttledFn = useThrottleFn(() => {
-      state.pagination.page = state.pagination.page + 1;
-      getList();
-    }, 500);
-
-    const getBatchSetRead = async () => {
-      try {
-        await batchSetRead({ messageType: 'SYS_SUGGEST_FEEDBACK_TEACHER' });
-
-        eventGlobal.emit('onSuggestionRead');
-      } catch {
-        //
-      }
-    };
-    onMounted(() => {
-      props.typeList.forEach((item: any) => {
-        state.suggestionTypeList.push({
-          label: item.name,
-          value: item.id
-        });
-      });
-      getBatchSetRead();
-      getList();
-    });
-    return () => (
-      <div class={styles.suggestionList}>
-        <div class={styles.attendClassSearch}>
-          <NSelect
-            placeholder="反馈类型"
-            clearable
-            options={
-              [
-                { label: '反馈类型', value: null },
-                ...state.suggestionTypeList
-              ] as any
-            }
-            v-model:value={state.searchGroup.suggestionTypeId}
-          />
-          <CDatePicker
-            v-model:value={state.searchGroup.timer}
-            separator={'至'}
-            start-placeholder="反馈开始日期"
-            end-placeholder="反馈结束日期"
-            type="daterange"
-            clearable={true}
-            timerValue={state.searchGroup.timer}></CDatePicker>
-
-          <NButton type="primary" class="searchBtn" onClick={throttledFnSearch}>
-            搜索
-          </NButton>
-        </div>
-        <NScrollbar
-          class={styles.classList}
-          onScroll={(e: any) => {
-            const clientHeight = e.target?.clientHeight;
-            const scrollTop = e.target?.scrollTop;
-            const scrollHeight = e.target?.scrollHeight;
-            // 是否到底,是否加载完
-            if (
-              clientHeight + scrollTop + 20 >= scrollHeight &&
-              !state.finshed &&
-              !state.loading
-            ) {
-              throttledFn();
-            }
-          }}>
-          <NSpin show={state.loading}>
-            <div
-              class={[
-                styles.listSection,
-                !state.loading && state.tableList.length <= 0
-                  ? styles.emptySection
-                  : ''
-              ]}>
-              {state.tableList.map((item: any) => (
-                <div>
-                  <NThing class={[styles.thingItem, 'isFull']}>
-                    <div class={styles.item}>
-                      <span>反馈类型:</span>
-                      {item.suggestionTypeName}
-                    </div>
-                    <div class={styles.item}>
-                      <span>反馈内容:</span>
-                      {item.content}
-                    </div>
-                    {item.imgList && item.imgList.length > 0 && (
-                      <div class={styles.item}>
-                        <NImageGroup class={styles.IMageWraps}>
-                          {item.imgList?.map((item: any, index: number) => (
-                            <NImage
-                              class={[styles.ShowImg]}
-                              src={item}
-                              objectFit="cover"></NImage>
-                          ))}
-                        </NImageGroup>
-                      </div>
-                    )}
-
-                    {item.handleStatus && (
-                      <div class={styles.itemResult}>
-                        <span>处理结果:</span>
-                        {item.handleAttitude === 'NO'
-                          ? '感谢你对音乐数字课堂的关注与支持,我们会认真处理您的反馈,尽快修复和完善相关功能!'
-                          : item.feedbackContent}
-                      </div>
-                    )}
-                  </NThing>
-                </div>
-              ))}
-              {!state.loading && state.tableList.length <= 0 && <TheEmpty />}
-            </div>
-          </NSpin>
-        </NScrollbar>
-      </div>
-    );
-  }
-});
+import { PropType, defineComponent, onMounted, reactive, ref } from 'vue';
+
+import styles from './suggestion-list.module.less';
+
+import {
+  NInput,
+  NSelect,
+  NScrollbar,
+  NSpin,
+  NThing,
+  NImageGroup,
+  NSpace,
+  NImage,
+  NButton
+} from 'naive-ui';
+
+import { batchSetRead, getSysSuggestionList } from './api';
+
+import CDatePicker from '../../CDatePicker';
+
+import TheEmpty from '../../TheEmpty';
+
+import { useDebounceFn, useThrottleFn } from '@vueuse/core';
+
+import { eventGlobal, getTimes } from '/src/utils';
+
+export default defineComponent({
+  name: 'suggestion-list',
+
+  props: {
+    typeList: {
+      type: Array as PropType<any[]>,
+
+      default: () => []
+    }
+  },
+
+  setup(props) {
+    const state = reactive({
+      suggestionTypeList: [] as any,
+
+      loading: false,
+
+      finshed: false, // 是否加载完
+
+      pagination: {
+        page: 1,
+
+        rows: 20
+      },
+
+      searchGroup: {
+        suggestionTypeId: null,
+
+        timer: null as any
+      },
+
+      tableList: [] as any,
+
+      show: false,
+
+      item: {} as any
+    });
+
+    const getList = async () => {
+      try {
+        if (state.pagination.page === 1) {
+          state.loading = true;
+        }
+
+        const { timer, ...res } = state.searchGroup;
+
+        const { data } = await getSysSuggestionList({
+          ...state.searchGroup,
+
+          ...res,
+
+          ...getTimes(timer, ['startTime', 'endTime'])
+        });
+
+        state.loading = false;
+
+        const tempRows = data.rows || [];
+
+        tempRows.forEach((row: any) => {
+          const imgList =
+            (row.attachmentUrls && row.attachmentUrls.split(',')) || [];
+
+          row.imgList = imgList;
+        });
+
+        if (state.pagination.page === 1) {
+          state.tableList = tempRows;
+        } else {
+          state.tableList.push(...tempRows);
+        }
+
+        state.finshed = data.pages <= data.current ? true : false;
+      } catch {
+        state.loading = false;
+      }
+    };
+
+    const throttledFnSearch = useDebounceFn(item => {
+      state.pagination.page = state.pagination.page + 1;
+
+      state.pagination.page = 1;
+
+      state.tableList = [];
+
+      state.searchGroup = Object.assign(state.searchGroup, item);
+
+      getList();
+    }, 100);
+
+    const throttledFn = useThrottleFn(() => {
+      state.pagination.page = state.pagination.page + 1;
+
+      getList();
+    }, 300);
+
+    const getBatchSetRead = async () => {
+      try {
+        await batchSetRead({ messageType: 'SYS_SUGGEST_FEEDBACK_TEACHER' });
+
+        eventGlobal.emit('onSuggestionRead');
+      } catch {
+        //
+      }
+    };
+
+    onMounted(() => {
+      props.typeList.forEach((item: any) => {
+        state.suggestionTypeList.push({
+          label: item.name,
+
+          value: item.id
+        });
+      });
+
+      getBatchSetRead();
+
+      getList();
+    });
+
+    return () => (
+      <div class={styles.suggestionList}>
+        <div class={styles.attendClassSearch}>
+          <NSelect
+            placeholder="反馈类型"
+            clearable
+            options={
+              [
+                { label: '反馈类型', value: null },
+
+                ...state.suggestionTypeList
+              ] as any
+            }
+            v-model:value={state.searchGroup.suggestionTypeId}
+          />
+
+          <CDatePicker
+            v-model:value={state.searchGroup.timer}
+            separator={'至'}
+            start-placeholder="反馈开始日期"
+            end-placeholder="反馈结束日期"
+            type="daterange"
+            clearable={true}
+            timerValue={state.searchGroup.timer}></CDatePicker>
+
+          <NButton type="primary" class="searchBtn" onClick={throttledFnSearch}>
+            搜索
+          </NButton>
+        </div>
+
+        <NScrollbar
+          class={styles.classList}
+          onScroll={(e: any) => {
+            const clientHeight = e.target?.clientHeight;
+
+            const scrollTop = e.target?.scrollTop;
+
+            const scrollHeight = e.target?.scrollHeight;
+
+            // 是否到底,是否加载完
+
+            if (
+              clientHeight + scrollTop + 20 >= scrollHeight &&
+              !state.finshed &&
+              !state.loading
+            ) {
+              throttledFn();
+            }
+          }}>
+          <NSpin show={state.loading}>
+            <div
+              class={[
+                styles.listSection,
+
+                !state.loading && state.tableList.length <= 0
+                  ? styles.emptySection
+                  : ''
+              ]}>
+              {state.tableList.map((item: any) => (
+                <div>
+                  <NThing class={[styles.thingItem, 'isFull']}>
+                    <div class={styles.item}>
+                      <span>反馈类型:</span>
+
+                      {item.suggestionTypeName}
+                    </div>
+
+                    <div class={styles.item}>
+                      <span>反馈内容:</span>
+
+                      {item.content}
+                    </div>
+
+                    {item.imgList && item.imgList.length > 0 && (
+                      <div class={styles.item}>
+                        <NImageGroup class={styles.IMageWraps}>
+                          {item.imgList?.map((item: any, index: number) => (
+                            <NImage
+                              class={[styles.ShowImg]}
+                              src={item}
+                              objectFit="cover"></NImage>
+                          ))}
+                        </NImageGroup>
+                      </div>
+                    )}
+
+                    {item.handleStatus && (
+                      <div class={styles.itemResult}>
+                        <span>处理结果:</span>
+
+                        {item.handleAttitude === 'NO'
+                          ? '感谢你对音乐数字课堂的关注与支持,我们会认真处理您的反馈,尽快修复和完善相关功能!'
+                          : item.feedbackContent}
+                      </div>
+                    )}
+                  </NThing>
+                </div>
+              ))}
+
+              {!state.loading && state.tableList.length <= 0 && <TheEmpty />}
+            </div>
+          </NSpin>
+        </NScrollbar>
+      </div>
+    );
+  }
+});
+

+ 3 - 0
src/store/modules/catchData.ts

@@ -85,6 +85,9 @@ export const useCatchStore = defineStore('catch-store', {
         ...this.subjectInstruemnts
       ];
     },
+    getSubjectInstrumentOnly(): any[] {
+      return this.subjectInstruemnts;
+    },
     getMusicTagTree(): any[] {
       return this.musicTagTree;
     }

+ 1 - 1
src/views/attend-class/index.tsx

@@ -2375,7 +2375,7 @@ export default defineComponent({
           style={selResourDragData.styleDrag.value}
           preset="card"
           title={'选择资源'}>
-          <SelectResources from="class" />
+          <SelectResources from="class" instrumentId={data.instrumentId} />
           <Dragbom></Dragbom>
         </NModal>
         <NModal

+ 7 - 2
src/views/natural-resources/components/my-collect/index.tsx

@@ -33,6 +33,7 @@ export default defineComponent({
         type: 'MUSIC', //
         name: '',
         bookVersionId: null,
+        musicalInstrumentId: null,
         subjectId: null,
         sourceType: 4
       },
@@ -127,7 +128,7 @@ export default defineComponent({
     };
 
     onMounted(() => {
-      getList();
+      // getList();
     });
     return () => (
       <>
@@ -149,7 +150,11 @@ export default defineComponent({
                     onClick={(val: any) => {
                       if (val.type === 'IMG' || !item.enableFlag) return;
                       state.show = true;
-                      state.item = val;
+                      state.item = {
+                        instrumentId:
+                          state.searchGroup.musicalInstrumentId || null,
+                        ...val
+                      };
                     }}
                     onCollect={(item: any) => onCollect(item)}
                   />

+ 25 - 7
src/views/natural-resources/components/my-collect/search-group-resources.tsx

@@ -37,6 +37,7 @@ export default defineComponent({
     const onSearch = () => {
       emit('search', {
         ...forms,
+        subjectId: forms.audioPlayTypes !== 'SING' ? forms.subjectId : null,
         audioPlayTypes: forms.audioPlayTypes
           ? forms.audioPlayTypes === 'PLAY_SING'
             ? ['PLAY', 'SING']
@@ -101,6 +102,20 @@ export default defineComponent({
       return obj;
     };
 
+    /** 默认选中第一个声部 */
+    const formatFirstSubject = () => {
+      const tempSubjects = catchStore.getSubjectInstrumentOnly;
+      if (tempSubjects.length > 0) {
+        const firstSubject = tempSubjects[0];
+        if (firstSubject.instruments && firstSubject.instruments.length > 1) {
+          state.tempSubjectId = firstSubject.instruments[0]?.value;
+          forms.subjectId = firstSubject.instruments[0]?.value;
+        } else {
+          forms.subjectId = firstSubject.value;
+        }
+      }
+    };
+
     onMounted(async () => {
       // 场景
       const tempAudio = Object.keys(audioPlayType).map(key => {
@@ -129,6 +144,8 @@ export default defineComponent({
       //   // 默认隐藏
       //   getLive();
       // }
+      formatFirstSubject();
+      onSearch();
     });
     return () => (
       <div class={styles.searchGroup}>
@@ -143,9 +160,8 @@ export default defineComponent({
                 focusable={false}
                 onClick={() => {
                   forms.type = item.value;
-                  forms.subjectId = null;
-                  state.tempSubjectId = null;
                   forms.audioPlayTypes = '';
+                  formatFirstSubject();
                   onSearch();
 
                   nextTick(() => {
@@ -230,10 +246,12 @@ export default defineComponent({
                   ]}
                   onClick={() => {
                     forms.audioPlayTypes = subject.value;
-                    if (subject.value === 'SING') {
-                      state.tempSubjectId = null;
-                      forms.subjectId = null;
-                    }
+                    // if (subject.value === 'SING') {
+                    //   state.tempSubjectId = null;
+                    //   forms.subjectId = null;
+                    // } else {
+                    //   formatFirstSubject();
+                    // }
                     onSearch();
                   }}>
                   {subject.name}
@@ -244,7 +262,7 @@ export default defineComponent({
           {forms.audioPlayTypes !== 'SING' && (
             <NFormItem label="乐器:">
               <NSpace class={styles.spaceSection2}>
-                {catchStore.getSubjectInstruments.map((subject: any) =>
+                {catchStore.getSubjectInstrumentOnly.map((subject: any) =>
                   subject.instruments && subject.instruments.length > 1 ? (
                     <NPopselect
                       options={subject.instruments}

+ 8 - 2
src/views/natural-resources/components/my-resources/index.tsx

@@ -46,6 +46,7 @@ export default defineComponent({
         type: 'MUSIC', //
         name: '',
         bookVersionId: null,
+        musicalInstrumentId: null,
         subjectId: null,
         sourceType: 3
       },
@@ -179,7 +180,7 @@ export default defineComponent({
     };
     const searchGroupResourcesRef = ref();
     onMounted(() => {
-      getList();
+      // getList();
     });
     return () => (
       <>
@@ -306,7 +307,12 @@ export default defineComponent({
                         onClick={(val: any) => {
                           if (val.type === 'IMG' || !item.enableFlag) return;
                           state.show = true;
-                          state.item = val;
+                          state.item = {
+                            instrumentId:
+                              state.searchGroup.musicalInstrumentId || null,
+                            ...val
+                          };
+                          console.log(state.item, 'item');
                         }}
                         onCollect={(item: any) => onCollect(item)}
                       />

+ 24 - 12
src/views/natural-resources/components/my-resources/search-group-resources.tsx

@@ -43,17 +43,26 @@ export default defineComponent({
       emit('search', forms);
     };
 
+    /** 默认选中第一个声部 */
+    const formatFirstSubject = () => {
+      const tempSubjects = catchStore.getSubjectInstrumentOnly;
+      if (tempSubjects.length > 0) {
+        const firstSubject = tempSubjects[0];
+        if (firstSubject.instruments && firstSubject.instruments.length > 1) {
+          state.tempSubjectId = firstSubject.instruments[0]?.value;
+          forms.subjectId = firstSubject.instruments[0]?.value;
+        } else {
+          forms.subjectId = firstSubject.value;
+        }
+      }
+
+      onSearch();
+    };
+
     onMounted(async () => {
-      resourceList.value = [
-        // {
-        //   label: '全部',
-        //   value: ''
-        // }
-      ];
+      resourceList.value = [];
       resourceTypeArray.forEach((item: any) => {
-        // if (item.value !== 'MUSIC') {
         resourceList.value.push(item);
-        // }
       });
 
       // 获取声部列表
@@ -62,6 +71,8 @@ export default defineComponent({
       if (forms.subjectId) {
         state.tempSubjectId = forms.subjectId;
       }
+
+      formatFirstSubject();
     });
 
     const selectChildObj = (item: any) => {
@@ -100,10 +111,11 @@ export default defineComponent({
                   }
                   forms.audioPlayTypes = item.value === 'MUSIC' ? ['PLAY'] : [];
                   forms.type = item.value;
-                  forms.subjectId = null;
-                  state.tempSubjectId = null;
+                  // forms.subjectId = null;
+                  // state.tempSubjectId = null;
 
-                  onSearch();
+                  // onSearch();
+                  formatFirstSubject();
                 }}>
                 {item.label}
               </NButton>
@@ -208,7 +220,7 @@ export default defineComponent({
         <NForm labelAlign="left" labelPlacement="left">
           <NFormItem label="乐器:">
             <NSpace class={styles.spaceSection2}>
-              {catchStore.getSubjectInstruments.map((subject: any) =>
+              {catchStore.getSubjectInstrumentOnly.map((subject: any) =>
                 subject.instruments && subject.instruments.length > 1 ? (
                   <NPopselect
                     options={subject.instruments}

+ 11 - 2
src/views/natural-resources/components/share-resources/index.tsx

@@ -26,6 +26,7 @@ export default defineComponent({
         type: 'MUSIC', //
         name: '',
         audioPlayTypes: [] as any,
+        musicalInstrumentId: null,
         bookVersionId: null,
         subjectId: null,
         sourceType: 2
@@ -124,7 +125,11 @@ export default defineComponent({
                       onClick={(val: any) => {
                         if (val.type === 'IMG') return;
                         state.show = true;
-                        state.item = val;
+                        state.item = {
+                          instrumentId:
+                            state.searchGroup.musicalInstrumentId || null,
+                          ...val
+                        };
                       }}
                       onCollect={(item: any) => onCollect(item)}
                     />
@@ -135,7 +140,11 @@ export default defineComponent({
                       onClick={(val: any) => {
                         if (val.type === 'IMG') return;
                         state.show = true;
-                        state.item = val;
+                        state.item = {
+                          instrumentId:
+                            state.searchGroup.musicalInstrumentId || null,
+                          ...val
+                        };
                       }}
                       onCollect={(item: any) => onCollect(item)}
                     />

+ 24 - 7
src/views/natural-resources/components/share-resources/search-group-resources.tsx

@@ -139,6 +139,7 @@ export default defineComponent({
     const onSearch = () => {
       emit('search', {
         ...forms,
+        subjectId: forms.audioPlayTypes !== 'SING' ? forms.subjectId : null,
         audioPlayTypes: forms.audioPlayTypes
           ? forms.audioPlayTypes === 'PLAY_SING'
             ? ['PLAY', 'SING']
@@ -244,6 +245,19 @@ export default defineComponent({
       onSearch();
     };
 
+    /** 默认选中第一个声部 */
+    const formatFirstSubject = () => {
+      const tempSubjects = catchStore.getSubjectInstrumentOnly;
+      if (tempSubjects.length > 0) {
+        const firstSubject = tempSubjects[0];
+        if (firstSubject.instruments && firstSubject.instruments.length > 1) {
+          state.tempSubjectId = firstSubject.instruments[0]?.value;
+          forms.subjectId = firstSubject.instruments[0]?.value;
+        } else {
+          forms.subjectId = firstSubject.value;
+        }
+      }
+    };
     onMounted(async () => {
       // 场景
       const tempAudio = Object.keys(audioPlayType).map(key => {
@@ -263,6 +277,7 @@ export default defineComponent({
       // 获取声部列表
       await catchStore.getSubjects();
 
+      formatFirstSubject();
       if (forms.type === 'MUSIC') {
         orginHeight.value = collapseWrapRef.value?.offsetHeight;
         // hiddenHeight.value = collapseWrapRef.value.offsetHeight / line.value;
@@ -285,13 +300,13 @@ export default defineComponent({
                 focusable={false}
                 onClick={() => {
                   forms.type = item.value;
-                  forms.subjectId = null;
                   forms.audioPlayTypes = '';
-                  state.tempSubjectId = null;
                   data.tagActiveId = '';
                   data.childSelectId = null;
                   data.selectParents = {};
 
+                  formatFirstSubject();
+
                   onSearch();
 
                   nextTick(() => {
@@ -366,10 +381,12 @@ export default defineComponent({
                   ]}
                   onClick={() => {
                     forms.audioPlayTypes = subject.value;
-                    if (subject.value === 'SING') {
-                      state.tempSubjectId = null;
-                      forms.subjectId = null;
-                    }
+                    // if (subject.value === 'SING') {
+                    //   state.tempSubjectId = null;
+                    //   forms.subjectId = null;
+                    // } else {
+                    //   formatFirstSubject();
+                    // }
                     onSearch();
                   }}>
                   {subject.name}
@@ -381,7 +398,7 @@ export default defineComponent({
           {forms.audioPlayTypes !== 'SING' && (
             <NFormItem label="乐器:">
               <NSpace class={styles.spaceSection}>
-                {catchStore.getSubjectInstruments.map((subject: any) =>
+                {catchStore.getSubjectInstrumentOnly.map((subject: any) =>
                   subject.instruments && subject.instruments.length > 1 ? (
                     <NPopselect
                       options={subject.instruments}

+ 39 - 5
src/views/prepare-lessons/components/directory-main/index.tsx

@@ -119,11 +119,48 @@ export default defineComponent({
           }
         });
         prepareStore.setTreeList(tempList);
+
+        const tempInstrumentId = prepareStore.getInstrumentId;
+        if (tempInstrumentId) {
+          const instrumentList = prepareStore.getFormatInstrumentList;
+          let status = false;
+          instrumentList.forEach((item: any) => {
+            if (item.instruments?.length > 0) {
+              item.instruments.forEach((child: any) => {
+                if (child.value == tempInstrumentId) {
+                  status = true;
+                }
+              });
+            }
+            if (item.value == tempInstrumentId) {
+              status = true;
+            }
+          });
+          if (!status) {
+            onShowDefaultInstrument();
+          }
+        } else {
+          onShowDefaultInstrument();
+        }
       } catch {
         //
       }
     };
 
+    const onShowDefaultInstrument = () => {
+      // 默认选中第一个声部
+      const instrumentList = prepareStore.getFormatInstrumentList;
+      if (instrumentList.length > 0) {
+        const tempList = instrumentList[0];
+        if (tempList.instruments.length > 1) {
+          const childTempList = tempList.instruments[0];
+          prepareStore.setInstrumentId(childTempList.value);
+        } else {
+          prepareStore.setInstrumentId(tempList.value);
+        }
+      }
+    };
+
     const formatParentId = (id: any, list: any, ids = [] as any) => {
       for (const item of list) {
         if (item.knowledgeList && item.knowledgeList.length > 0) {
@@ -169,7 +206,6 @@ export default defineComponent({
     const changeCourseware = async (item: any) => {
       prepareStore.setBaseCourseware(item);
       // prepareStore.setSubjectList(item.subjectList);
-
       if (item.instrumentIds) {
         const { data } = await getSubjectList2({
           instrumentIds: item.instrumentIds
@@ -192,14 +228,12 @@ export default defineComponent({
         });
         await getLessonCoursewareDetail();
         // 判断教材里面是否有当前选择的声部,如果没有则默认选择第一个
-        console.log(status, 'status');
+
         if (status) {
           const instrumentId = tempInstrumentId;
-          sessionStorage.removeItem('prepareLessonCourseWareSubjectIsNull');
           prepareStore.setInstrumentId(instrumentId);
         } else {
-          sessionStorage.removeItem('prepareLessonCourseWareSubjectIsNull');
-          prepareStore.setInstrumentId('');
+          onShowDefaultInstrument();
         }
       }
 

+ 28 - 25
src/views/prepare-lessons/components/lesson-main/courseware-presets/index.tsx

@@ -172,16 +172,15 @@ export default defineComponent({
 
     const checkInstrumentIds = () => {
       const instrumentsList = prepareStore.getSingleInstrumentList;
-
       // 并且没有声部时才会更新
       if (instrumentsList.length > 0) {
-        const prepareLessonCourseWareSubjectIsNull = sessionStorage.getItem(
-          'prepareLessonCourseWareSubjectIsNull'
-        );
-        if (prepareLessonCourseWareSubjectIsNull === 'true') {
-          prepareStore.setInstrumentId('');
-          return;
-        }
+        // const prepareLessonCourseWareSubjectIsNull = sessionStorage.getItem(
+        //   'prepareLessonCourseWareSubjectIsNull'
+        // );
+        // if (prepareLessonCourseWareSubjectIsNull === 'true') {
+        //   prepareStore.setInstrumentId('');
+        //   return;
+        // }
 
         // 并且声部在列表中
         const localStorageSubjectId = localStorage.getItem(
@@ -236,6 +235,10 @@ export default defineComponent({
         );
 
         subjectRef.value?.syncBarPosition();
+      } else {
+        if (forms.instrumentId) {
+          prepareStore.setInstrumentId(forms.instrumentId + '');
+        }
       }
     };
 
@@ -464,16 +467,16 @@ export default defineComponent({
                 }
               });
 
-              if (!val) {
-                prepareStore.setInstrumentId(val);
-                // 保存
-                forms.instrumentId = val;
-                forms.wikiCategoryIdChild = null;
-                sessionStorage.setItem(
-                  'prepareLessonCourseWareSubjectIsNull',
-                  val ? 'false' : 'true'
-                );
-              }
+              // if (!val) {
+              //   prepareStore.setInstrumentId(val);
+              //   // 保存
+              //   forms.instrumentId = val;
+              //   forms.wikiCategoryIdChild = null;
+              //   sessionStorage.setItem(
+              //     'prepareLessonCourseWareSubjectIsNull',
+              //     val ? 'false' : 'true'
+              //   );
+              // }
             }}
             v-slots={{
               suffix: () => (
@@ -497,7 +500,7 @@ export default defineComponent({
               )
             }}>
             {[
-              { name: '全部乐器', id: '', label: '全部乐器', value: '' },
+              // { name: '全部乐器', id: '', label: '全部乐器', value: '' },
               ...prepareStore.getFormatInstrumentList
             ].map((item: any, index: number) => (
               <NTabPane
@@ -518,12 +521,12 @@ export default defineComponent({
                           // 保存
                           forms.instrumentId = val;
 
-                          if (!val) {
-                            sessionStorage.setItem(
-                              'prepareLessonCourseWareSubjectIsNull',
-                              val ? 'false' : 'true'
-                            );
-                          }
+                          // if (!val) {
+                          //   sessionStorage.setItem(
+                          //     'prepareLessonCourseWareSubjectIsNull',
+                          //     val ? 'false' : 'true'
+                          //   );
+                          // }
                         }}
                         key={item.id}
                         class={styles.popSelect}>

+ 108 - 154
src/views/prepare-lessons/components/lesson-main/index.tsx

@@ -1,154 +1,108 @@
-import { defineComponent, nextTick, reactive, ref, watch } from 'vue';
-import styles from './index.module.less';
-// import { NTabPane, NTabs } from 'naive-ui';
-import Courseware from './courseware/addCourseware';
-// import Train from './train';
-import { usePrepareStore } from '/src/store/modules/prepareLessons';
-// import TrainPresets from './train-presets';
-import { eventGlobal } from '/src/utils';
-import CoursewarePresets from './courseware-presets';
-import CoursewareHead from './courseware-head';
-import { NButton, NSpace } from 'naive-ui';
-
-export default defineComponent({
-  name: 'lesson-main',
-  setup() {
-    const prepareStore = usePrepareStore();
-    const state = reactive({
-      editCoursewareShow: false, // 是否编辑课件
-      coursewareType: 'create' as 'create' | 'edit',
-      addParam: {
-        isAdd: false, // 是否添加
-        id: null,
-        addName: '' // 添加的名称
-      },
-      editCourseware: {} as any, //
-      // editWorkShow: false, // 是否编辑预设
-      editWork: {} as any // 预设模板编号
-    });
-    const coursewareHeadRef = ref();
-
-    // 取消
-    const onCancelCourseware = () => {
-      eventGlobal.emit('coursewareClosed', coursewareHeadRef.value?.getForms());
-    };
-
-    const onSaveCourseware = () => {
-      // console.log(
-      //   coursewareHeadRef.value,
-      //   coursewareHeadRef.value?.getForms(),
-      //   '12'
-      // );
-      eventGlobal.emit('coursewareSave', coursewareHeadRef.value?.getForms());
-    };
-
-    return () => (
-      <div
-        class={[state.editCoursewareShow && styles.coursewareSection]}
-        style={{ height: '100%' }}>
-        {/* 编辑作业头部标题 */}
-        {state.editCoursewareShow && (
-          <div class={styles.coursewareHeader}>
-            <CoursewareHead ref={coursewareHeadRef} />
-          </div>
-        )}
-
-        <div class={styles['lesson-main']}>
-          {state.editCoursewareShow ? (
-            // <NTabs
-            //   ref={lessonMainRef}
-            //   defaultValue="courseware"
-            //   paneClass={styles.paneTitle}
-            //   justifyContent="center"
-            //   paneWrapperClass={styles.paneWrapperContainer}
-            //   value={prepareStore.getTabType}
-            //   onUpdate:value={(val: string) => {
-            //     prepareStore.setTabType(val);
-            //     // 重置编辑状态
-            //     prepareStore.setIsEditResource(false);
-            //     prepareStore.setIsEditTrain(false);
-
-            //     eventGlobal.emit('teacher-slideshow', false);
-            //     if (val !== 'train') {
-            //       state.editWorkShow = false;
-            //     }
-            //   }}>
-            //   {!state.editWorkShow && (
-            //     <NTabPane
-            //       name="courseware"
-            //       tab={
-            //         state.editCoursewareShow
-            //           ? state.coursewareType === 'create'
-            //             ? '创建课件'
-            //             : '编辑课件'
-            //           : '课件'
-            //       }
-            //       displayDirective="if">
-            //       <Courseware
-            //         groupItem={state.editCourseware}
-            //         onChange={(val: any) => {
-            //           if (val.addParam) {
-            //             state.addParam = val.addParam;
-            //           }
-            //           state.editCoursewareShow = val.status;
-            //           prepareStore.setIsEditResource(val.status);
-            //           if (!val.status) {
-            //             eventGlobal.emit('teacher-slideshow', false);
-            //           }
-            //         }}
-            //       />
-            //     </NTabPane>
-            //   )}
-            // </NTabs>
-
-            <Courseware
-              groupItem={state.editCourseware}
-              onChange={(val: any) => {
-                if (val.addParam) {
-                  state.addParam = val.addParam;
-                }
-                state.editCoursewareShow = val.status;
-                prepareStore.setIsEditResource(val.status);
-                if (!val.status) {
-                  eventGlobal.emit('teacher-slideshow', false);
-                }
-              }}
-            />
-          ) : (
-            <CoursewarePresets
-              addParam={state.addParam}
-              onChange={(val: any) => {
-                state.coursewareType = val.type;
-                state.editCoursewareShow = val.status;
-                prepareStore.setIsEditResource(val.status);
-                state.editCourseware = val.groupItem;
-                state.addParam = {
-                  isAdd: false, // 是否添加
-                  id: null,
-                  addName: '' // 添加的名称
-                };
-              }}
-            />
-          )}
-        </div>
-
-        {/* 编辑作业底部操作 */}
-        {state.editCoursewareShow && (
-          <div class={styles.coursewareFooter}>
-            <NSpace>
-              <NButton
-                bordered={false}
-                type="error"
-                onClick={onCancelCourseware}>
-                取消
-              </NButton>
-              <NButton type="primary" onClick={onSaveCourseware}>
-                保存课件
-              </NButton>
-            </NSpace>
-          </div>
-        )}
-      </div>
-    );
-  }
-});
+import { defineComponent, nextTick, reactive, ref, watch } from 'vue';
+import styles from './index.module.less';
+// import { NTabPane, NTabs } from 'naive-ui';
+import Courseware from './courseware/addCourseware';
+// import Train from './train';
+import { usePrepareStore } from '/src/store/modules/prepareLessons';
+// import TrainPresets from './train-presets';
+import { eventGlobal } from '/src/utils';
+import CoursewarePresets from './courseware-presets';
+import CoursewareHead from './courseware-head';
+import { NButton, NSpace } from 'naive-ui';
+
+export default defineComponent({
+  name: 'lesson-main',
+  setup() {
+    const prepareStore = usePrepareStore();
+    const state = reactive({
+      editCoursewareShow: false, // 是否编辑课件
+      coursewareType: 'create' as 'create' | 'edit',
+      addParam: {
+        isAdd: false, // 是否添加
+        id: null,
+        addName: '' // 添加的名称
+      },
+      editCourseware: {} as any, //
+      // editWorkShow: false, // 是否编辑预设
+      editWork: {} as any // 预设模板编号
+    });
+    const coursewareHeadRef = ref();
+
+    // 取消
+    const onCancelCourseware = () => {
+      eventGlobal.emit('coursewareClosed', coursewareHeadRef.value?.getForms());
+    };
+
+    const onSaveCourseware = () => {
+      // console.log(
+      //   coursewareHeadRef.value,
+      //   coursewareHeadRef.value?.getForms(),
+      //   '12'
+      // );
+      eventGlobal.emit('coursewareSave', coursewareHeadRef.value?.getForms());
+    };
+
+    return () => (
+      <div
+        class={[state.editCoursewareShow && styles.coursewareSection]}
+        style={{ height: '100%' }}>
+        {/* 编辑作业头部标题 */}
+        {state.editCoursewareShow && (
+          <div class={styles.coursewareHeader}>
+            <CoursewareHead ref={coursewareHeadRef} />
+          </div>
+        )}
+
+        <div class={styles['lesson-main']}>
+          {state.editCoursewareShow ? (
+            <Courseware
+              groupItem={state.editCourseware}
+              onChange={(val: any) => {
+                if (val.addParam) {
+                  state.addParam = val.addParam;
+                }
+                state.editCoursewareShow = val.status;
+                prepareStore.setIsEditResource(val.status);
+                if (!val.status) {
+                  eventGlobal.emit('teacher-slideshow', false);
+                }
+              }}
+            />
+          ) : (
+            <CoursewarePresets
+              addParam={state.addParam}
+              onChange={(val: any) => {
+                state.coursewareType = val.type;
+                state.editCoursewareShow = val.status;
+                prepareStore.setIsEditResource(val.status);
+                state.editCourseware = val.groupItem;
+                state.addParam = {
+                  isAdd: false, // 是否添加
+                  id: null,
+                  addName: '' // 添加的名称
+                };
+              }}
+            />
+          )}
+        </div>
+
+        {/* 编辑作业底部操作 */}
+        {state.editCoursewareShow && (
+          <div class={styles.coursewareFooter}>
+            <NSpace>
+              <NButton
+                bordered={false}
+                type="error"
+                onClick={onCancelCourseware}>
+                取消
+              </NButton>
+              <NButton type="primary" onClick={onSaveCourseware}>
+                保存课件
+              </NButton>
+            </NSpace>
+          </div>
+        )}
+      </div>
+    );
+  }
+});

+ 6 - 2
src/views/prepare-lessons/components/resource-main/components/resource-item/index.tsx

@@ -128,7 +128,7 @@ export default defineComponent({
       state.tableList = [];
       state.searchGroup = Object.assign(state.searchGroup, item);
       getList();
-    }, 500);
+    }, 300);
 
     // 声部变化时
     watch(
@@ -259,7 +259,11 @@ export default defineComponent({
                       onClick={() => {
                         if (item.type === 'IMG') return;
                         state.show = true;
-                        state.item = item;
+                        state.item = {
+                          instrumentId:
+                            state.searchGroup.musicalInstrumentId || null,
+                          ...item
+                        };
                       }}
                       onCollect={(item: any) => onCollect(item)}
                       // isShowAddDisabled={!prepareStore.getIsEditResource}

+ 1 - 0
src/views/prepare-lessons/components/resource-main/components/resource-item/resource-search-group/index.tsx

@@ -146,6 +146,7 @@ export default defineComponent({
             )}
             <CCascader
               placeholder="全部声部"
+              childShowAllCheck={false}
               showPath
               showAudioPlayType={props.type === 'myResources' ? false : true}
               v-model:value={subjects.value}

+ 5 - 1
src/views/prepare-lessons/components/resource-main/components/select-music/index.tsx

@@ -305,7 +305,11 @@ export default defineComponent({
                       onClick={() => {
                         if (item.type === 'IMG') return;
                         state.show = true;
-                        state.item = item;
+                        state.item = {
+                          instrumentId:
+                            state.searchGroup.musicalInstrumentId || null,
+                          ...item
+                        };
                       }}
                       onAdd={(child: any) => onAdd(child)}
                       onCollect={(item: any) => onCollect(item)}

+ 1 - 1
src/views/prepare-lessons/components/resource-main/components/select-music/resource-search-group/index.tsx

@@ -117,7 +117,6 @@ export default defineComponent({
                 v-model:value={musics.value}
                 options={tagList.value}
                 onUpdate:value={(value: any) => {
-                  console.log(value, 'value');
                   forms.bookVersionId = value || '';
                   onSearch();
                 }}
@@ -125,6 +124,7 @@ export default defineComponent({
             )}
             <CCascader
               v-model:value={subjects.value}
+              childShowAllCheck={false}
               placement="bottom-end"
               placeholder="全部声部"
               options={tagSubjectList.value}

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

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

+ 7 - 3
src/views/prepare-lessons/model/select-music/select-item/index.tsx

@@ -134,12 +134,12 @@ export default defineComponent({
     };
     const throttledFnSearch = useDebounceFn(item => {
       onSearch(item);
-    }, 500);
+    }, 300);
 
     const throttledFn = useThrottleFn(() => {
       state.pagination.page = state.pagination.page + 1;
       getList();
-    }, 500);
+    }, 300);
 
     // 收藏
     const onCollect = async (item: any) => {
@@ -225,7 +225,11 @@ export default defineComponent({
                       onClick={() => {
                         if (item.type === 'IMG') return;
                         state.show = true;
-                        state.item = item;
+                        state.item = {
+                          instrumentId:
+                            state.searchGroup.musicalInstrumentId || null,
+                          ...item
+                        };
                       }}
                       onCollect={(item: any) => onCollect(item)}
                     />

+ 17 - 1
src/views/prepare-lessons/model/select-music/select-item/search-group.tsx

@@ -241,6 +241,20 @@ export default defineComponent({
       onSearch();
     };
 
+    /** 默认选中第一个声部 */
+    const formatFirstSubject = () => {
+      const tempSubjects = catchStore.getSubjectInstrumentOnly;
+      if (tempSubjects.length > 0) {
+        const firstSubject = tempSubjects[0];
+        if (firstSubject.instruments && firstSubject.instruments.length > 1) {
+          state.tempSubjectId = firstSubject.instruments[0]?.value;
+          forms.musicalInstrumentId = firstSubject.instruments[0]?.value;
+        } else {
+          forms.musicalInstrumentId = firstSubject.value;
+        }
+      }
+    };
+
     onMounted(async () => {
       // 获取教材分类列表
       // await catchStore.getMusicSheetCategory();
@@ -268,6 +282,8 @@ export default defineComponent({
       // }
       // console.log(state.musicCategory, 'state.musicCategory');
 
+      formatFirstSubject();
+
       onSearch('timer');
     });
     return () => (
@@ -380,7 +396,7 @@ export default defineComponent({
 
           <NFormItem label="乐器:">
             <NSpace class={styles.spaceSection2}>
-              {catchStore.getSubjectInstruments.map((subject: any) =>
+              {catchStore.getSubjectInstrumentOnly.map((subject: any) =>
                 subject.instruments && subject.instruments.length > 1 ? (
                   <NPopselect
                     options={subject.instruments}

+ 24 - 4
src/views/prepare-lessons/model/select-resources/index.tsx

@@ -16,6 +16,10 @@ export default defineComponent({
     from: {
       type: String,
       default: ''
+    },
+    instrumentId: {
+      type: String,
+      default: ''
     }
   },
   emits: ['select'],
@@ -57,22 +61,38 @@ export default defineComponent({
           }}>
           {props.from !== 'class' && (
             <NTabPane name="relateResources" tab={'相关资源'}>
-              <SelectItem type="relateResources" from={props.from} />
+              <SelectItem
+                type="relateResources"
+                from={props.from}
+                instrumentId={props.instrumentId}
+              />
             </NTabPane>
           )}
           <NTabPane
             name="shareResources"
             tab={props.from === 'class' ? '共享曲目' : '共享资源'}>
-            <SelectItem type="shareResources" from={props.from} />
+            <SelectItem
+              type="shareResources"
+              from={props.from}
+              instrumentId={props.instrumentId}
+            />
           </NTabPane>
           <NTabPane
             name="myResources"
             tab={props.from === 'class' ? '我的曲目' : '我的资源'}>
-            <SelectItem type="myResources" from={props.from} />
+            <SelectItem
+              type="myResources"
+              from={props.from}
+              instrumentId={props.instrumentId}
+            />
           </NTabPane>
 
           <NTabPane name="myCollect" tab="我的收藏">
-            <SelectItem type="myCollect" from={props.from} />
+            <SelectItem
+              type="myCollect"
+              from={props.from}
+              instrumentId={props.instrumentId}
+            />
           </NTabPane>
         </NTabs>
       </div>

+ 47 - 17
src/views/prepare-lessons/model/select-resources/select-item/class-search-group/index.tsx

@@ -57,15 +57,20 @@ export default defineComponent({
     const resourceType = ref([] as any);
     const audioPlayTypeList = ref([] as any);
 
-    const onSearch = () => {
-      emit('search', {
-        ...forms,
-        audioPlayTypes: forms.audioPlayTypes
-          ? forms.audioPlayTypes === 'PLAY_SING'
-            ? ['PLAY', 'SING']
-            : [forms.audioPlayTypes]
-          : []
-      });
+    const onSearch = (type?: string) => {
+      emit(
+        'search',
+        {
+          ...forms,
+          subjectId: forms.audioPlayTypes !== 'SING' ? forms.subjectId : null,
+          audioPlayTypes: forms.audioPlayTypes
+            ? forms.audioPlayTypes === 'PLAY_SING'
+              ? ['PLAY', 'SING']
+              : [forms.audioPlayTypes]
+            : []
+        },
+        type
+      );
     };
 
     const throttleFn = useThrottleFn(() => onSearch(), 500);
@@ -80,6 +85,19 @@ export default defineComponent({
       });
       return obj;
     };
+
+    /** 默认选中第一个声部 */
+    const formatFirstSubject = () => {
+      const tempSubjects = catchStore.getSubjectInstrumentOnly;
+      if (tempSubjects.length > 0) {
+        const firstSubject = tempSubjects[0];
+        if (firstSubject.instruments && firstSubject.instruments.length > 1) {
+          forms.subjectId = firstSubject.instruments[0]?.value;
+        } else {
+          forms.subjectId = firstSubject.value;
+        }
+      }
+    };
     onMounted(async () => {
       // 场景
       const tempAudio = Object.keys(audioPlayType).map(key => {
@@ -97,15 +115,25 @@ export default defineComponent({
       await catchStore.getMusicSheetCategory();
       // 获取声部
       await catchStore.getSubjects();
+
+      if (!props.subjectId) {
+        formatFirstSubject();
+      }
+
       catchStore.getSubjectInstruments.forEach((item: any) => {
-        if (item.id == props.subjectId) {
-          if (item.instruments.length > 0) {
-            forms.subjectId = item.instruments[0].value;
-          } else {
+        if (item.instruments?.length > 0) {
+          item.instruments.forEach((child: any) => {
+            if (child.id == props.subjectId) {
+              forms.subjectId = child.value;
+            }
+          });
+        } else {
+          if (item.id == props.subjectId) {
             forms.subjectId = item.value;
           }
         }
       });
+      onSearch('timer');
     });
     return () => (
       <div class={styles.searchGroup}>
@@ -128,9 +156,11 @@ export default defineComponent({
                     ]}
                     onClick={() => {
                       forms.audioPlayTypes = subject.value;
-                      if (subject.value === 'SING') {
-                        forms.subjectId = null;
-                      }
+                      // if (subject.value === 'SING') {
+                      //   forms.subjectId = null;
+                      // } else {
+                      //   formatFirstSubject();
+                      // }
                       onSearch();
                     }}>
                     {subject.name}
@@ -147,7 +177,7 @@ export default defineComponent({
                   styles.spaceSection2,
                   'spaceSectionBox'
                 ]}>
-                {catchStore.getSubjectInstruments.map((subject: any) =>
+                {catchStore.getSubjectInstrumentOnly.map((subject: any) =>
                   subject.instruments && subject.instruments.length > 1 ? (
                     <NPopselect
                       options={subject.instruments}

+ 23 - 7
src/views/prepare-lessons/model/select-resources/select-item/index.tsx

@@ -44,6 +44,10 @@ export default defineComponent({
     from: {
       type: String,
       default: ''
+    },
+    instrumentId: {
+      type: String,
+      default: ''
     }
   },
   setup(props) {
@@ -131,7 +135,7 @@ export default defineComponent({
     };
     const throttledFnSearch = useDebounceFn(item => {
       onSearch(item);
-    }, 500);
+    }, 300);
 
     // 添加资源
     const onAdd = async (item: any) => {
@@ -208,9 +212,9 @@ export default defineComponent({
         }
       );
 
-      if (props.type !== 'shareResources' || props.from === 'class') {
-        getList();
-      }
+      // if (props.type !== 'shareResources' || props.from === 'class') {
+      //   getList();
+      // }
 
       if (props.type === 'relateResources') {
         eventGlobal.on('onCoursewareUpdate', onUpdate);
@@ -260,8 +264,16 @@ export default defineComponent({
               <ClassSearchGroup
                 from={props.from}
                 type={props.type}
-                subjectId={prepareStore.getSubjectId as any}
-                onSearch={(item: any) => throttledFnSearch(item)}
+                subjectId={
+                  (prepareStore.getSubjectId as any) || props.instrumentId
+                }
+                onSearch={(item: any, type: any) => {
+                  if (type) {
+                    onSearch(item);
+                    return;
+                  }
+                  throttledFnSearch(item);
+                }}
               />
             ) : (
               <ResourceSearchGroup
@@ -303,7 +315,11 @@ export default defineComponent({
                           onClick={() => {
                             if (item.type === 'IMG') return;
                             state.show = true;
-                            state.item = item;
+                            state.item = {
+                              instrumentId:
+                                state.searchGroup.musicalInstrumentId,
+                              ...item
+                            };
                           }}
                         />
                       </div>

+ 26 - 23
src/views/prepare-lessons/model/select-resources/select-item/resource-search-group/index.tsx

@@ -155,6 +155,7 @@ export default defineComponent({
         'search',
         {
           ...forms,
+          subjectId: forms.audioPlayTypes !== 'SING' ? forms.subjectId : null,
           audioPlayTypes: forms.audioPlayTypes
             ? forms.audioPlayTypes === 'PLAY_SING'
               ? ['PLAY', 'SING']
@@ -267,6 +268,20 @@ export default defineComponent({
       onSearch();
     };
 
+    /** 默认选中第一个声部 */
+    const formatFirstSubject = () => {
+      const tempSubjects = catchStore.getSubjectInstrumentOnly;
+      if (tempSubjects.length > 0) {
+        const firstSubject = tempSubjects[0];
+        if (firstSubject.instruments && firstSubject.instruments.length > 1) {
+          state.tempSubjectId = firstSubject.instruments[0]?.value;
+          forms.subjectId = firstSubject.instruments[0]?.value;
+        } else {
+          forms.subjectId = firstSubject.value;
+        }
+      }
+    };
+
     onMounted(async () => {
       // 场景
       const tempAudio = Object.keys(audioPlayType).map(key => {
@@ -298,9 +313,8 @@ export default defineComponent({
         getLive();
       }
 
-      if (props.type === 'shareResources') {
-        onSearch('timer');
-      }
+      formatFirstSubject();
+      onSearch('timer');
     });
     return () => (
       <div class={styles.searchGroup}>
@@ -316,12 +330,13 @@ export default defineComponent({
                 onClick={() => {
                   forms.type = item.value;
                   forms.subjectId = null;
-
                   data.tagActiveId = '';
                   data.childSelectId = null;
                   data.selectParents = {};
                   forms.audioPlayTypes =
                     props.type === 'myResources' ? 'PLAY' : '';
+
+                  formatFirstSubject();
                   onSearch();
 
                   try {
@@ -400,10 +415,12 @@ export default defineComponent({
                     ]}
                     onClick={() => {
                       forms.audioPlayTypes = subject.value;
-                      if (subject.value === 'SING') {
-                        state.tempSubjectId = null;
-                        forms.subjectId = null;
-                      }
+                      // if (subject.value === 'SING') {
+                      //   state.tempSubjectId = null;
+                      //   forms.subjectId = null;
+                      // } else {
+                      //   formatFirstSubject();
+                      // }
                       onSearch();
                     }}>
                     {subject.name}
@@ -416,21 +433,7 @@ export default defineComponent({
           {forms.audioPlayTypes !== 'SING' && (
             <NFormItem label="乐器:">
               <NSpace class={styles.spaceSection2}>
-                {/* {catchStore.getSubjectAllList.map((music: any) => (
-                <NButton
-                  secondary={forms.subjectId === music.id}
-                  quaternary={forms.subjectId !== music.id}
-                  strong
-                  focusable={false}
-                  type={forms.subjectId === music.id ? 'primary' : 'default'}
-                  onClick={() => {
-                    forms.subjectId = music.id;
-                    onSearch();
-                  }}>
-                  {music.name}
-                </NButton>
-              ))} */}
-                {catchStore.getSubjectInstruments.map((subject: any) =>
+                {catchStore.getSubjectInstrumentOnly.map((subject: any) =>
                   subject.instruments && subject.instruments.length > 1 ? (
                     <NPopselect
                       options={subject.instruments}

+ 3 - 0
src/views/xiaoku-music/index.tsx

@@ -446,12 +446,14 @@ export default defineComponent({
         }
       ];
       // 首调 固定调 并且 不显示可转谱 则不显示五线谱
+      console.log(scoreType, isConvertibleScore, 'isConvertibleScore');
       if (
         !(
           ['JIAN', 'FIRST'].includes(scoreType) && isConvertibleScore === false
         ) &&
         !(isConvertibleScore === undefined || isConvertibleScore === null)
       ) {
+        console.log('true ----- inin in in ');
         action.unshift({
           value: 'staff',
           label: '五线谱'
@@ -797,6 +799,7 @@ export default defineComponent({
                     <CCascader
                       placeholder="全部乐器"
                       arrowType="small"
+                      childShowAllCheck={false}
                       class={styles.instrumentSection}
                       v-model:value={subjects.value}
                       options={data.tags}