Browse Source

修改数据

lex 2 năm trước cách đây
mục cha
commit
4e8982304e

+ 27 - 0
src/views/courseList/index.tsx

@@ -96,6 +96,18 @@ export default defineComponent({
             state.platformApi + '/courseSchedule/myCoursewareDetail/' + route.query.id
           )
           if (Array.isArray(res?.data)) {
+            res.data.forEach((item: any) => {
+              const { knowledgePointList, ...res } = item
+              const tempK = knowledgePointList || []
+              tempK.forEach((child: any) => {
+                child.materialList = [
+                  ...(child.materialList || []),
+                  ...getKnowledgeMaterials(child.children || [])
+                ]
+                child.children = null
+              })
+            })
+
             const _list = await checkCoursewareCache(res.data)
             data.list = browserInfo.isApp
               ? res.data.map((item: any) => {
@@ -116,6 +128,21 @@ export default defineComponent({
       }
       data.loading = false
     }
+    // 获取子节点数据
+    const getKnowledgeMaterials = (list: any = []) => {
+      const tempList: any = []
+      list.forEach((item: any) => {
+        if (item.materialList && item.materialList.length > 0) {
+          tempList.push(...(item.materialList || []))
+        }
+
+        if (item.children && item.children.length > 0) {
+          tempList.push(...getKnowledgeMaterials(item.children || []))
+        }
+      })
+      return tempList
+    }
+
     onMounted(() => {
       getDetail()
       getList()

+ 8 - 0
src/views/coursewarePlay/component/point.module.less

@@ -40,6 +40,10 @@
     display: none;
     border-width: 0;
   }
+
+  .borderTop {
+    border-top: 1px solid rgba(255, 255, 255, 0.2);
+  }
   :global {
     .van-cell {
       background: transparent;
@@ -63,6 +67,10 @@
       padding: 0 0 6px;
     }
 
+    // .van-hairline--top:after {
+    //   border-color: var(--van-border-color) !important;
+    // }
+
     // .van-collapse-item {
     //   border-top: 1px solid rgba(255, 255, 255, 0.2);
     // }

+ 1 - 1
src/views/coursewarePlay/component/points.tsx

@@ -72,7 +72,7 @@ export default defineComponent({
                 <CollapseItem
                   center
                   border={false}
-                  class={index > 0 ? 'van-hairline--top' : ''}
+                  class={index > 0 ? styles.borderTop : ''}
                   isLink={false}
                   title={item.name}
                   name={item.id}