123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <template>
- <view class="kecheng-mulu">
- <myCollapseCardVue v-for="zhang in chapterArr" :title="zhang.name" @click.stop="handleZhangClick(zhang)"
- :open="zhang.open">
- <myCollapseCardVue v-for="jie in zhang.jieList" :title="jie.name" @click.stop="handleJieClick(jie, zhang)"
- :open="jie.open">
- <view class="kejian-item" v-for="item in jie.kejianList" @click.stop="handleKejianClick(item)">
- <text>{{item.name}}</text>
- <text v-if="isHasProgress">进度{{item.curProcess}}</text>
- </view>
- </myCollapseCardVue>
- </myCollapseCardVue>
- </view>
- </template>
- <script setup>
- import myCollapseCardVue from '../myCollapseCard/myCollapseCard.vue';
- import {
- ref
- } from 'vue';
- const props = defineProps({
- chapterArr: {
- type: Array
- },
- isHasProgress: {
- type: Boolean
- }
- })
- const emits = defineEmits(['play'])
- function handleZhangClick(item) {
- if (item.open) {
- // 展开 -》 关闭
- props.chapterArr.forEach(zhang => {
- zhang.open = false;
- zhang.jieList.forEach(jie => {
- jie.open = false;
- })
- })
- } else {
- // 关闭 -》 展开
- props.chapterArr.forEach(zhang => {
- zhang.open = false;
- zhang.jieList.forEach(jie => {
- jie.open = false;
- })
- })
- item.open = true;
- }
- }
- function handleJieClick(item, zhang) {
- if (item.open) {
- // 展开 -》 关闭
- zhang.jieList.forEach(jie => {
- jie.open = false;
- })
- } else {
- // 关闭 -》 展开
- zhang.jieList.forEach(jie => {
- jie.open = false;
- })
- item.open = true;
- }
- }
- function handleKejianClick(item) {
- emits('play', item)
- }
- </script>
- <style>
- .kejian-item {
- line-height: 50px;
- }
- </style>
|