mo 1 year ago
parent
commit
580bb5d030

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

@@ -34,6 +34,7 @@ export default defineComponent({
       item: {} as any
     });
     const showGuide = ref(false);
+    const SearchGroupResourcesRef = ref()
     const getList = async () => {
       try {
         state.loading = true;
@@ -91,10 +92,10 @@ export default defineComponent({
     return () => (
       <>
         <SearchGroupResources
+        ref={SearchGroupResourcesRef}
           onSearch={(item: any) => onSearch(item)}
           onAdd={() => (state.teachingStatus = true)}
         />
-
         <NSpin v-model:show={state.loading} style={{ 'min-height': '50vh' }}>
           <div class={styles.list}>
             {state.tableList.map((item: any, index: number) => (

+ 18 - 4
src/views/natural-resources/components/share-resources/search-group-resources.tsx

@@ -9,6 +9,7 @@ import isCollaose from '../../images/isCollaose.png';
 export default defineComponent({
   name: 'search-group',
   emits: ['search', 'add'],
+  expose: ['init'],
   setup(props, { emit }) {
     const catchStore = useCatchStore();
     const forms = reactive({
@@ -19,8 +20,14 @@ export default defineComponent({
     });
 
     const onSearch = () => {
+      console.log('onSearch')
+      divDomList.value = []
+      setCollapse(true)
       emit('search', forms);
     };
+    const init = () => {
+      setCollapse(false)
+    }
     const collapseWrapRef = ref();
     const divDomList = ref([] as any);
     const orginHeight = ref(0);
@@ -28,7 +35,9 @@ export default defineComponent({
     const line = ref(0);
     const isCollapse = ref(false);
     const musicCateRef = (el: any) => {
-      if (el?.selfElRef) {
+      console.log('musicCateRef', musicCateRef)
+      // console.log(el?.selfElRef, 'el.selfElRef')
+      if (el?.selfElRef?.parentNode) {
         divDomList.value.push(el.selfElRef.parentNode);
       }
     };
@@ -37,8 +46,10 @@ export default defineComponent({
       getLive();
     };
     const getLive = () => {
+      console.log(divDomList.value.length)
       divDomList.value = [...new Set(divDomList.value)];
       let offsetLeft = -1;
+      console.log(divDomList.value, '  divDomList.value')
       divDomList.value.forEach((item: any, index: number) => {
         if (index === 0) {
           line.value = 1;
@@ -49,7 +60,7 @@ export default defineComponent({
         }
         if (!isCollapse.value) {
           if (line.value > 1) {
-            //从第3行开始 隐藏标签
+            //从第2行开始 隐藏标签
             item.style.display = 'none';
             // 显示展开按钮  class名chu是在前面动态添加的
           } else {
@@ -61,16 +72,19 @@ export default defineComponent({
       });
     };
     onMounted(async () => {
+      console.log('加载')
       // 获取教材分类列表
       await catchStore.getMusicSheetCategory();
       // 获取声部列表
       await catchStore.getSubjects();
 
-      // 这里开始
+
       orginHeight.value = collapseWrapRef.value.offsetHeight;
       hiddenHeight.value = collapseWrapRef.value.offsetHeight / line.value;
       // 默认隐藏
-      getLive();
+      setCollapse(false)
+      // 这里开始
+
     });
     return () => (
       <div class={styles.searchGroup}>