Browse Source

Merge branch 'iteration-20240607-small' into jenkins

lex 9 months ago
parent
commit
c12f71bd92

+ 1 - 0
src/views/attend-class/index.module.less

@@ -895,6 +895,7 @@
   .resourceMain {
     flex: 0 0 360px;
     height: 55vh;
+    width: 360px;
     box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);
   }
 }

+ 1 - 0
src/views/attend-class/model/class-work/index.module.less

@@ -158,6 +158,7 @@
 
   .resourceMain {
     flex: 0 0 360px;
+    width: 360px;
     height: 75vh;
     box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);
   }

+ 1 - 0
src/views/homework-record/index.module.less

@@ -108,6 +108,7 @@
 
   .resourceMain {
     flex: 0 0 360px;
+    width: 360px;
     height: 75vh;
     box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);
   }

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

@@ -83,7 +83,7 @@ const ChildNodeSearch = defineComponent({
                       } else {
                         selectItem.value = {};
                       }
-                      emit('selectChildTag', subject);
+                      emit('selectChildTag', activeRow.value.activeIndex);
                     }}>
                     {subject.name}
                   </span>
@@ -94,7 +94,11 @@ const ChildNodeSearch = defineComponent({
             <ChildNodeSearch
               activeRow={selectItem.value}
               onSelectChildTag={(item: any) => {
-                emit('selectChildTag', item);
+                // console.log(
+                //   activeRow.value.activeIndex,
+                //   'activeRow.value.activeIndex'
+                // );
+                emit('selectChildTag', item || activeRow.value.activeIndex);
               }}
             />
           </>
@@ -337,7 +341,7 @@ export default defineComponent({
               <ChildNodeSearch
                 activeRow={data.selectParents}
                 onSelectChildTag={(val: any) => {
-                  data.childSelectId = val.id;
+                  data.childSelectId = val;
                   onSearch();
                 }}
               />

+ 1 - 0
src/views/prepare-lessons/components/lesson-main/courseware-presets/index.module.less

@@ -379,6 +379,7 @@
 
   .resourceMain {
     flex: 0 0 360px;
+    width: 360px;
     height: 75vh;
     box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);
   }

+ 77 - 76
src/views/prepare-lessons/index.module.less

@@ -1,77 +1,78 @@
-.prepareLessons {
-  display: flex;
-  // padding: 32px;
-  // padding-bottom: 32px;
-  height: calc(100vh - 118px);
-  overflow: hidden;
-  border-radius: 20px;
-
-  .directoryMain,
-  .resourceMain {
-    flex: 0 0 360px;
-    background-color: #fff;
-    border-radius: 20px;
-  }
-
-
-  .directoryMain {
-    margin-right: 20px;
-  }
-
-
-  .lessonMain {
-    margin: 0 20px 0 0;
-    flex: 1;
-    // background-color: #fff;
-    border-radius: 20px;
-    transition: all .2s ease;
-  }
-
-  .resourceMain {
-
-    transition: all .2s ease;
-
-    &.resourceClose {
-      transition: all .2s ease;
-      width: 0;
-      transform: translateX(100%);
-      opacity: 0;
-    }
-  }
-
-  &.showSideBar {
-    .directoryMain {
-      width: 360px;
-      transition: all .2s ease;
-      opacity: 0;
-      position: absolute;
-      right: 0;
-      transform: translateX(100%);
-    }
-
-    .lessonMain {
-      transition: all .2s ease;
-      margin-left: 0;
-    }
-  }
-
-  &.hideSideBar {
-    position: relative;
-    overflow: hidden;
-
-    .resourceMain {
-      width: 360px;
-      transition: all .2s ease;
-      opacity: 0;
-      position: absolute;
-      right: 0;
-      transform: translateX(100%);
-    }
-
-
-    .lessonMain {
-      transition: all .2s ease;
-      margin-right: 0;
-    }
-  }
+.prepareLessons {
+  display: flex;
+  // padding: 32px;
+  // padding-bottom: 32px;
+  height: calc(100vh - 118px);
+  overflow: hidden;
+  border-radius: 20px;
+
+  .directoryMain,
+  .resourceMain {
+    flex: 0 0 360px;
+    width: 360px;
+    background-color: #fff;
+    border-radius: 20px;
+  }
+
+
+  .directoryMain {
+    margin-right: 20px;
+  }
+
+
+  .lessonMain {
+    margin: 0 20px 0 0;
+    flex: 1;
+    // background-color: #fff;
+    border-radius: 20px;
+    transition: all .2s ease;
+  }
+
+  .resourceMain {
+
+    transition: all .2s ease;
+
+    &.resourceClose {
+      transition: all .2s ease;
+      width: 0;
+      transform: translateX(100%);
+      opacity: 0;
+    }
+  }
+
+  &.showSideBar {
+    .directoryMain {
+      width: 360px;
+      transition: all .2s ease;
+      opacity: 0;
+      position: absolute;
+      right: 0;
+      transform: translateX(100%);
+    }
+
+    .lessonMain {
+      transition: all .2s ease;
+      margin-left: 0;
+    }
+  }
+
+  &.hideSideBar {
+    position: relative;
+    overflow: hidden;
+
+    .resourceMain {
+      width: 360px;
+      transition: all .2s ease;
+      opacity: 0;
+      position: absolute;
+      right: 0;
+      transform: translateX(100%);
+    }
+
+
+    .lessonMain {
+      transition: all .2s ease;
+      margin-right: 0;
+    }
+  }
 }

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

@@ -74,7 +74,7 @@ const ChildNodeSearch = defineComponent({
                       } else {
                         selectItem.value = {};
                       }
-                      emit('selectChildTag', subject);
+                      emit('selectChildTag', activeRow.value.activeIndex);
                     }}>
                     {subject.name}
                   </span>
@@ -85,7 +85,7 @@ const ChildNodeSearch = defineComponent({
             <ChildNodeSearch
               activeRow={selectItem.value}
               onSelectChildTag={(item: any) => {
-                emit('selectChildTag', item);
+                emit('selectChildTag', item || activeRow.value.activeIndex);
               }}
             />
           </>
@@ -298,7 +298,7 @@ export default defineComponent({
             <ChildNodeSearch
               activeRow={data.selectParents}
               onSelectChildTag={(val: any) => {
-                data.childSelectId = val.id;
+                data.childSelectId = val;
                 onSearch();
               }}
             />

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

@@ -85,7 +85,7 @@ const ChildNodeSearch = defineComponent({
                       } else {
                         selectItem.value = {};
                       }
-                      emit('selectChildTag', subject);
+                      emit('selectChildTag', activeRow.value.activeIndex);
                     }}>
                     {subject.name}
                   </span>
@@ -96,7 +96,7 @@ const ChildNodeSearch = defineComponent({
             <ChildNodeSearch
               activeRow={selectItem.value}
               onSelectChildTag={(item: any) => {
-                emit('selectChildTag', item);
+                emit('selectChildTag', item || activeRow.value.activeIndex);
               }}
             />
           </>
@@ -394,7 +394,7 @@ export default defineComponent({
               <ChildNodeSearch
                 activeRow={data.selectParents}
                 onSelectChildTag={(val: any) => {
-                  data.childSelectId = val.id;
+                  data.childSelectId = val;
                   onSearch();
                 }}
               />

+ 1 - 1
src/views/xiaoku-ai/index.module.less

@@ -31,7 +31,7 @@
 
   .tagWrap {
     flex: 1;
-    margin-right: 20px;
+    margin-right: 28px;
   }
 
   .tags {

+ 121 - 20
src/views/xiaoku-ai/index.tsx

@@ -17,6 +17,10 @@ const ChildNodeSearch = defineComponent({
     list: {
       type: Array,
       default: () => []
+    },
+    loading: {
+      type: Boolean,
+      default: false
     }
   },
   emits: ['selectChildTag'],
@@ -28,9 +32,43 @@ const ChildNodeSearch = defineComponent({
       () => props.activeRow,
       () => {
         activeRow.value = props.activeRow;
-        selectItem.value = {};
+        initActiveRow();
       }
     );
+
+    const initActiveRow = () => {
+      if (activeRow.value.activeIndex) {
+        const childList = activeRow.value.children || [];
+        childList.forEach((subject: any) => {
+          if (subject.id === activeRow.value.activeIndex) {
+            let children: any;
+            let columnName = '';
+            if (subject.children) {
+              children = [
+                {
+                  columnName: subject.children[0].columnName,
+                  name: '全部',
+                  id: ''
+                },
+                ...subject.children
+              ];
+              columnName = subject.children[0].columnName;
+
+              selectItem.value = {
+                ...subject,
+                columnName,
+                activeIndex: subject.activeIndex,
+                children
+              };
+            }
+          }
+        });
+      }
+    };
+
+    onMounted(() => {
+      initActiveRow();
+    });
     return () => (
       <>
         {activeRow.value?.id && (
@@ -57,6 +95,7 @@ const ChildNodeSearch = defineComponent({
                             : 'default'
                         }
                         onClick={() => {
+                          if (props.loading) return;
                           activeRow.value.activeIndex = subject.id;
                           let children: any;
                           let columnName = '';
@@ -80,7 +119,7 @@ const ChildNodeSearch = defineComponent({
                           } else {
                             selectItem.value = {};
                           }
-                          emit('selectChildTag', subject);
+                          emit('selectChildTag', activeRow.value.activeIndex);
                         }}>
                         {subject.name}
                       </NButton>
@@ -93,7 +132,7 @@ const ChildNodeSearch = defineComponent({
             <ChildNodeSearch
               activeRow={selectItem.value}
               onSelectChildTag={(item: any) => {
-                emit('selectChildTag', item);
+                emit('selectChildTag', item || activeRow.value.activeIndex);
               }}
             />
           </>
@@ -134,20 +173,46 @@ export default defineComponent({
       // tagActive: {} as any,
       childSelectId: xiaokuAi.childSelectId || (null as any)
     });
-    // const _initTags = () => {
-    //   const tags = catchStore.getMusicTagTree;
-    //   data.tags = [
-    //     {
-    //       columnName: tags[0].columnName,
-    //       name: '全部',
-    //       id: ''
-    //     },
-    //     ...tags
-    //   ];
-    //   data.tagActiveId = data.tags[0].id;
-    // };
+
+    const formatParentId = (id: any, list: any, ids = [] as any) => {
+      for (const item of list) {
+        if (item.children && item.children.length > 0) {
+          const cIds: any = formatParentId(id, item.children, [
+            ...ids,
+            item.id
+          ]);
+          if (cIds.includes(id)) {
+            return cIds;
+          }
+        }
+        if (item.id === id) {
+          return [...ids, id];
+        }
+      }
+      return ids;
+    };
+
+    const formatParentCurrentValue = (ids: any, list: any) => {
+      for (const item of list) {
+        if (ids.includes(item.id)) {
+          if (item.children && item.children.length > 0) {
+            let lastId: any;
+            item.children.forEach((child: any) => {
+              if (ids.includes(child.id)) {
+                lastId = child.id;
+              }
+            });
+            item.activeIndex = lastId;
+          }
+        }
+        if (item.children && item.children.length > 0) {
+          formatParentCurrentValue(ids, item.children);
+        }
+      }
+    };
 
     const changeTag = (item: any) => {
+      if (data.loading) return;
       data.tagActiveId = item.id;
       data.childSelectId = null;
       let children: any;
@@ -195,9 +260,45 @@ export default defineComponent({
           },
           ...tags
         ];
-        // if (!data.tagActiveId) {
-        // }
-        data.tagActiveId = data.tags[0].id;
+        if (!data.tagActiveId) {
+          data.tagActiveId = data.tags[0].id;
+        } else {
+          const ids = formatParentId(xiaokuAi.childSelectId, data.tags);
+          formatParentCurrentValue(ids, data.tags);
+          data.tags.forEach((item: any) => {
+            if (item.id === data.tagActiveId) {
+              let children: any;
+              let columnName = '';
+              if (item.children) {
+                children = [
+                  {
+                    columnName: item.children[0].columnName,
+                    name: '全部',
+                    id: ''
+                  },
+                  ...item.children
+                ];
+                columnName = item.children[0].columnName;
+
+                let id: any;
+                item.children.forEach((item: any) => {
+                  if (ids.includes(item.id)) {
+                    id = item.id;
+                  }
+                });
+
+                data.selectParents = {
+                  ...item,
+                  columnName,
+                  activeIndex: id || '',
+                  children
+                };
+              } else {
+                data.selectParents = {};
+              }
+            }
+          });
+        }
       }
     };
 
@@ -248,7 +349,6 @@ export default defineComponent({
             }
           });
 
-          console.log(childInstruments, 'childInstruments');
           if (childInstruments.length > 0) {
             selectChildObj(childInstruments);
           }
@@ -300,8 +400,9 @@ export default defineComponent({
 
             <ChildNodeSearch
               activeRow={data.selectParents}
+              loading={data.loading}
               onSelectChildTag={(val: any) => {
-                data.childSelectId = val.id;
+                data.childSelectId = val;
                 localStorage.setItem(
                   'xiaoku-ai-search',
                   JSON.stringify({

+ 2 - 2
vite.config.ts

@@ -23,8 +23,8 @@ function resolve(dir: string) {
 }
 // https://vitejs.dev/config/
 // https://github.com/vitejs/vite/issues/1930 .env
-const proxyUrl = 'https://dev.kt.colexiu.com/';
-// const proxyUrl = 'https://test.kt.colexiu.com';
+// const proxyUrl = 'https://dev.kt.colexiu.com/';
+const proxyUrl = 'https://test.kt.colexiu.com';
 // const proxyUrl = 'http://192.168.3.14:7989';
 const now = new Date().getTime();
 export default defineConfig(() => {