kecheng-mulu.vue 1.9 KB

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