|  | @@ -1,9 +1,10 @@
 | 
	
		
			
				|  |  | -import { defineComponent, onMounted, reactive, ref } from 'vue';
 | 
	
		
			
				|  |  | +import { defineComponent, nextTick, onMounted, reactive, ref } from 'vue';
 | 
	
		
			
				|  |  |  import styles from './index.module.less';
 | 
	
		
			
				|  |  | -import { NButton, NForm, NFormItem, NSpace } from 'naive-ui';
 | 
	
		
			
				|  |  | +import { NButton, NForm, NFormItem, NImage, NSpace } from 'naive-ui';
 | 
	
		
			
				|  |  |  import TheSearch from '/src/components/TheSearch';
 | 
	
		
			
				|  |  |  import { resourceTypeArray } from '/src/utils/searchArray';
 | 
	
		
			
				|  |  |  import { useCatchStore } from '/src/store/modules/catchData';
 | 
	
		
			
				|  |  | +import isCollaose from '../../images/isCollaose.png';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  export default defineComponent({
 | 
	
		
			
				|  |  |    name: 'search-group',
 | 
	
	
		
			
				|  | @@ -22,6 +23,45 @@ export default defineComponent({
 | 
	
		
			
				|  |  |        emit('search', forms);
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    const collapseWrapRef = ref();
 | 
	
		
			
				|  |  | +    const divDomList = ref([] as any);
 | 
	
		
			
				|  |  | +    const orginHeight = ref(0);
 | 
	
		
			
				|  |  | +    const hiddenHeight = ref(0);
 | 
	
		
			
				|  |  | +    const line = ref(0);
 | 
	
		
			
				|  |  | +    const isCollapse = ref(false);
 | 
	
		
			
				|  |  | +    const musicCateRef = (el: any) => {
 | 
	
		
			
				|  |  | +      if (el?.selfElRef) {
 | 
	
		
			
				|  |  | +        divDomList.value.push(el.selfElRef.parentNode);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +    const setCollapse = (flag: boolean) => {
 | 
	
		
			
				|  |  | +      isCollapse.value = flag;
 | 
	
		
			
				|  |  | +      getLive();
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +    const getLive = () => {
 | 
	
		
			
				|  |  | +      divDomList.value = [...new Set(divDomList.value)];
 | 
	
		
			
				|  |  | +      let offsetLeft = -1;
 | 
	
		
			
				|  |  | +      divDomList.value.forEach((item: any, index: number) => {
 | 
	
		
			
				|  |  | +        if (index === 0) {
 | 
	
		
			
				|  |  | +          line.value = 1;
 | 
	
		
			
				|  |  | +          offsetLeft = item.offsetLeft;
 | 
	
		
			
				|  |  | +        } else if (item.offsetLeft === offsetLeft && index != 0) {
 | 
	
		
			
				|  |  | +          // 如果某个标签的offsetLeft和第一个标签的offsetLeft相等  说明增加了一行
 | 
	
		
			
				|  |  | +          line.value++;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (!isCollapse.value) {
 | 
	
		
			
				|  |  | +          if (line.value > 1) {
 | 
	
		
			
				|  |  | +            //从第3行开始 隐藏标签
 | 
	
		
			
				|  |  | +            item.style.display = 'none';
 | 
	
		
			
				|  |  | +            // 显示展开按钮  class名chu是在前面动态添加的
 | 
	
		
			
				|  |  | +          } else {
 | 
	
		
			
				|  |  | +            item.style.display = 'block';
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +          item.style.display = 'block';
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  |      onMounted(async () => {
 | 
	
		
			
				|  |  |        resourceList.value = [
 | 
	
		
			
				|  |  |          {
 | 
	
	
		
			
				|  | @@ -35,6 +75,12 @@ export default defineComponent({
 | 
	
		
			
				|  |  |        await catchStore.getMusicSheetCategory();
 | 
	
		
			
				|  |  |        // 获取声部列表
 | 
	
		
			
				|  |  |        await catchStore.getSubjects();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      // // 这里开始
 | 
	
		
			
				|  |  | +      // orginHeight.value = collapseWrapRef.value.offsetHeight;
 | 
	
		
			
				|  |  | +      // hiddenHeight.value = collapseWrapRef.value.offsetHeight / line.value;
 | 
	
		
			
				|  |  | +      // // 默认隐藏
 | 
	
		
			
				|  |  | +      // getLive();
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |      return () => (
 | 
	
		
			
				|  |  |        <div class={styles.searchGroup}>
 | 
	
	
		
			
				|  | @@ -50,6 +96,17 @@ export default defineComponent({
 | 
	
		
			
				|  |  |                  onClick={() => {
 | 
	
		
			
				|  |  |                    forms.type = item.value;
 | 
	
		
			
				|  |  |                    onSearch();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                  nextTick(() => {
 | 
	
		
			
				|  |  | +                    if (forms.type === 'MUSIC') {
 | 
	
		
			
				|  |  | +                      // 这里开始
 | 
	
		
			
				|  |  | +                      orginHeight.value = collapseWrapRef.value.offsetHeight;
 | 
	
		
			
				|  |  | +                      hiddenHeight.value =
 | 
	
		
			
				|  |  | +                        collapseWrapRef.value.offsetHeight / line.value;
 | 
	
		
			
				|  |  | +                      // 默认隐藏
 | 
	
		
			
				|  |  | +                      getLive();
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                  });
 | 
	
		
			
				|  |  |                  }}>
 | 
	
		
			
				|  |  |                  {item.label}
 | 
	
		
			
				|  |  |                </NButton>
 | 
	
	
		
			
				|  | @@ -58,26 +115,78 @@ export default defineComponent({
 | 
	
		
			
				|  |  |          </div>
 | 
	
		
			
				|  |  |          <NForm labelAlign="left" labelPlacement="left">
 | 
	
		
			
				|  |  |            {forms.type === 'MUSIC' && (
 | 
	
		
			
				|  |  | -            <NFormItem label="教材:">
 | 
	
		
			
				|  |  | -              <NSpace class={styles.spaceSection}>
 | 
	
		
			
				|  |  | -                {catchStore.getAllMusicCategories.map((music: any) => (
 | 
	
		
			
				|  |  | -                  <NButton
 | 
	
		
			
				|  |  | -                    secondary={forms.bookVersionId === music.id}
 | 
	
		
			
				|  |  | -                    quaternary={forms.bookVersionId !== music.id}
 | 
	
		
			
				|  |  | -                    strong
 | 
	
		
			
				|  |  | -                    focusable={false}
 | 
	
		
			
				|  |  | -                    type={
 | 
	
		
			
				|  |  | -                      forms.bookVersionId === music.id ? 'primary' : 'default'
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    onClick={() => {
 | 
	
		
			
				|  |  | -                      forms.bookVersionId = music.id;
 | 
	
		
			
				|  |  | -                      onSearch();
 | 
	
		
			
				|  |  | -                    }}>
 | 
	
		
			
				|  |  | -                    {music.name}
 | 
	
		
			
				|  |  | -                  </NButton>
 | 
	
		
			
				|  |  | -                ))}
 | 
	
		
			
				|  |  | -              </NSpace>
 | 
	
		
			
				|  |  | -            </NFormItem>
 | 
	
		
			
				|  |  | +            <div class={[styles.collapsSection]}>
 | 
	
		
			
				|  |  | +              <NFormItem label="教材:">
 | 
	
		
			
				|  |  | +                <div
 | 
	
		
			
				|  |  | +                  class={[
 | 
	
		
			
				|  |  | +                    styles.collapseWrap,
 | 
	
		
			
				|  |  | +                    isCollapse.value ? '' : styles.isHidden
 | 
	
		
			
				|  |  | +                  ]}
 | 
	
		
			
				|  |  | +                  ref={collapseWrapRef}>
 | 
	
		
			
				|  |  | +                  <NSpace class={[styles.spaceSection]}>
 | 
	
		
			
				|  |  | +                    {catchStore.getAllMusicCategories.map((music: any) => (
 | 
	
		
			
				|  |  | +                      <NButton
 | 
	
		
			
				|  |  | +                        ref={musicCateRef}
 | 
	
		
			
				|  |  | +                        secondary={forms.bookVersionId === music.id}
 | 
	
		
			
				|  |  | +                        quaternary={forms.bookVersionId !== music.id}
 | 
	
		
			
				|  |  | +                        strong
 | 
	
		
			
				|  |  | +                        focusable={false}
 | 
	
		
			
				|  |  | +                        type={
 | 
	
		
			
				|  |  | +                          forms.bookVersionId === music.id
 | 
	
		
			
				|  |  | +                            ? 'primary'
 | 
	
		
			
				|  |  | +                            : 'default'
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        onClick={() => {
 | 
	
		
			
				|  |  | +                          forms.bookVersionId = music.id;
 | 
	
		
			
				|  |  | +                          onSearch();
 | 
	
		
			
				|  |  | +                        }}>
 | 
	
		
			
				|  |  | +                        {music.name}
 | 
	
		
			
				|  |  | +                      </NButton>
 | 
	
		
			
				|  |  | +                    ))}
 | 
	
		
			
				|  |  | +                    {line.value > 1 && (
 | 
	
		
			
				|  |  | +                      <div
 | 
	
		
			
				|  |  | +                        style={{
 | 
	
		
			
				|  |  | +                          height: 'var(--n-blank-height)',
 | 
	
		
			
				|  |  | +                          position: 'absolute',
 | 
	
		
			
				|  |  | +                          display: 'flex',
 | 
	
		
			
				|  |  | +                          alignItems: 'center'
 | 
	
		
			
				|  |  | +                        }}
 | 
	
		
			
				|  |  | +                        onClick={() => {
 | 
	
		
			
				|  |  | +                          setCollapse(!isCollapse.value);
 | 
	
		
			
				|  |  | +                        }}>
 | 
	
		
			
				|  |  | +                        <NImage
 | 
	
		
			
				|  |  | +                          previewDisabled
 | 
	
		
			
				|  |  | +                          src={isCollaose}
 | 
	
		
			
				|  |  | +                          class={[
 | 
	
		
			
				|  |  | +                            styles.collaoseBtn,
 | 
	
		
			
				|  |  | +                            isCollapse.value ? styles.isStart : ''
 | 
	
		
			
				|  |  | +                          ]}></NImage>
 | 
	
		
			
				|  |  | +                      </div>
 | 
	
		
			
				|  |  | +                    )}
 | 
	
		
			
				|  |  | +                  </NSpace>
 | 
	
		
			
				|  |  | +                </div>
 | 
	
		
			
				|  |  | +              </NFormItem>
 | 
	
		
			
				|  |  | +            </div>
 | 
	
		
			
				|  |  | +            // <NFormItem label="教材:">
 | 
	
		
			
				|  |  | +            //   <NSpace class={styles.spaceSection}>
 | 
	
		
			
				|  |  | +            //     {catchStore.getAllMusicCategories.map((music: any) => (
 | 
	
		
			
				|  |  | +            //       <NButton
 | 
	
		
			
				|  |  | +            //         secondary={forms.bookVersionId === music.id}
 | 
	
		
			
				|  |  | +            //         quaternary={forms.bookVersionId !== music.id}
 | 
	
		
			
				|  |  | +            //         strong
 | 
	
		
			
				|  |  | +            //         focusable={false}
 | 
	
		
			
				|  |  | +            //         type={
 | 
	
		
			
				|  |  | +            //           forms.bookVersionId === music.id ? 'primary' : 'default'
 | 
	
		
			
				|  |  | +            //         }
 | 
	
		
			
				|  |  | +            //         onClick={() => {
 | 
	
		
			
				|  |  | +            //           forms.bookVersionId = music.id;
 | 
	
		
			
				|  |  | +            //           onSearch();
 | 
	
		
			
				|  |  | +            //         }}>
 | 
	
		
			
				|  |  | +            //         {music.name}
 | 
	
		
			
				|  |  | +            //       </NButton>
 | 
	
		
			
				|  |  | +            //     ))}
 | 
	
		
			
				|  |  | +            //   </NSpace>
 | 
	
		
			
				|  |  | +            // </NFormItem>
 | 
	
		
			
				|  |  |            )}
 | 
	
		
			
				|  |  |            <NFormItem label="乐器:">
 | 
	
		
			
				|  |  |              <NSpace class={styles.spaceSection}>
 |