kecheng-mulu.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <view class="kecheng-mulu">
  3. <myCollapseCardVue v-for="zhang in chapterArr" :title="zhang.name" @click.stop="handleZhangClick(zhang)"
  4. :open="zhang.open">
  5. <myCollapseCardVue v-for="jie in zhang.jieList" :title="jie.name" @click.stop="handleJieClick(jie, zhang)"
  6. :open="jie.open">
  7. <view class="kejian-item" v-for="item in jie.kejianList" @click.stop="handleKejianClick(item)">
  8. <text>{{item.name}}</text>
  9. <text v-if="isHasProgress">进度{{item.curProcess}}</text>
  10. </view>
  11. </myCollapseCardVue>
  12. </myCollapseCardVue>
  13. </view>
  14. </template>
  15. <script setup>
  16. import myCollapseCardVue from '../myCollapseCard/myCollapseCard.vue';
  17. import {
  18. ref
  19. } from 'vue';
  20. const props = defineProps({
  21. chapterArr: {
  22. type: Array
  23. },
  24. isHasProgress: {
  25. type: Boolean
  26. }
  27. })
  28. const emits = defineEmits(['play'])
  29. function handleZhangClick(item) {
  30. if (item.open) {
  31. // 展开 -》 关闭
  32. props.chapterArr.forEach(zhang => {
  33. zhang.open = false;
  34. zhang.jieList.forEach(jie => {
  35. jie.open = false;
  36. })
  37. })
  38. } else {
  39. // 关闭 -》 展开
  40. props.chapterArr.forEach(zhang => {
  41. zhang.open = false;
  42. zhang.jieList.forEach(jie => {
  43. jie.open = false;
  44. })
  45. })
  46. item.open = true;
  47. }
  48. }
  49. function handleJieClick(item, zhang) {
  50. if (item.open) {
  51. // 展开 -》 关闭
  52. zhang.jieList.forEach(jie => {
  53. jie.open = false;
  54. })
  55. } else {
  56. // 关闭 -》 展开
  57. zhang.jieList.forEach(jie => {
  58. jie.open = false;
  59. })
  60. item.open = true;
  61. }
  62. }
  63. function handleKejianClick(item) {
  64. emits('play', item)
  65. }
  66. </script>
  67. <style>
  68. .kejian-item {
  69. line-height: 50px;
  70. }
  71. </style>