kecheng-mulu.vue 1.9 KB

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