courseCollapse.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <!--
  2. * @FileDescription: 折叠菜单
  3. * @Author: 黄琪勇
  4. * @Date:2024-04-01 18:40:50
  5. -->
  6. <template>
  7. <el-collapse class="courseCollapse" accordion>
  8. <el-collapse-item v-for="item in props.courseList" :key="item.id" :name="item.id">
  9. <template #title>
  10. <div class="courseCollapseHead">
  11. <div class="courseCollapseHeadTit">
  12. <template v-if="props.titleType === 'round'">
  13. <div class="roundCon">
  14. <img src="@/img/curriculum/yuan.png" />
  15. <div class="ellipsisBox">
  16. <ellipsisScroll :title="item.name" />
  17. </div>
  18. </div>
  19. </template>
  20. <ellipsisScroll v-else :title="item.name" />
  21. </div>
  22. <div class="courseCollapseHeadArrow">
  23. <div class="headArrow">
  24. <div>展开</div>
  25. <img src="@/img/curriculum/xiangxia.png" />
  26. </div>
  27. <div class="headArrowActive">
  28. <div>收起</div>
  29. <img src="@/img/curriculum/xiangshang.png" />
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <div class="courseCollapseCon">
  35. <template v-if="item.materialList">
  36. <div class="courseList" v-for="i in item.materialList" :key="i.id">
  37. <div class="courseTitleCon">
  38. <img :src="require(`@/img/curriculum/${i.type}.png`)" />
  39. <div class="ellipsisBox">
  40. <ellipsisScroll :title="i.name" />
  41. </div>
  42. </div>
  43. <img class="iconArrow" src="@/img/curriculum/zkai.png" />
  44. </div>
  45. </template>
  46. <courseCollapse v-else :courseList="item.children!" :titleType="'round'" />
  47. </div>
  48. </el-collapse-item>
  49. </el-collapse>
  50. </template>
  51. <script setup lang="ts">
  52. import ellipsisScroll from "@/components/ellipsisScroll"
  53. type materialListType = {
  54. id: string
  55. type: string
  56. name: string
  57. }
  58. type courseListType = {
  59. id: string
  60. name: string
  61. materialList: materialListType[] | null
  62. children: courseListType | null
  63. }[]
  64. const props = withDefaults(
  65. defineProps<{
  66. courseList: courseListType
  67. titleType: "default" | "round"
  68. }>(),
  69. {
  70. titleType: "default"
  71. }
  72. )
  73. </script>
  74. <style lang="scss" scoped>
  75. .courseCollapse.el-collapse {
  76. --el-collapse-border-color: #f2f2f2;
  77. --el-collapse-header-height: 62px;
  78. border: none;
  79. & > :deep(.el-collapse-item) {
  80. > .el-collapse-item__wrap > .el-collapse-item__content {
  81. padding-bottom: 2px;
  82. }
  83. &:last-child {
  84. > .el-collapse-item__wrap {
  85. border-bottom: none;
  86. }
  87. > .el-collapse-item__header {
  88. border-bottom: none;
  89. }
  90. }
  91. .el-collapse-item__arrow {
  92. display: none;
  93. }
  94. &.is-active > .el-collapse-item__header {
  95. > .courseCollapseHead .courseCollapseHeadArrow {
  96. > .headArrow {
  97. display: none;
  98. }
  99. > .headArrowActive {
  100. display: flex;
  101. }
  102. }
  103. }
  104. }
  105. .courseCollapseHead {
  106. width: 100%;
  107. height: 100%;
  108. display: flex;
  109. justify-content: space-between;
  110. align-items: center;
  111. .courseCollapseHeadTit {
  112. text-align: left;
  113. margin-right: 8px;
  114. flex-grow: 1;
  115. font-weight: 500;
  116. font-size: 18px;
  117. color: #333333;
  118. overflow: hidden;
  119. .roundCon {
  120. display: flex;
  121. align-items: center;
  122. color: #f67146;
  123. > .ellipsisBox {
  124. flex-grow: 1;
  125. overflow: hidden;
  126. }
  127. > img {
  128. flex-shrink: 0;
  129. width: 8px;
  130. height: 8px;
  131. margin-right: 10px;
  132. }
  133. }
  134. }
  135. .courseCollapseHeadArrow {
  136. flex-shrink: 0;
  137. .headArrow,
  138. .headArrowActive {
  139. display: flex;
  140. align-items: center;
  141. font-weight: 400;
  142. font-size: 17px;
  143. color: #999999;
  144. > img {
  145. margin-left: 5px;
  146. width: 12px;
  147. height: 8px;
  148. }
  149. }
  150. .headArrowActive {
  151. display: none;
  152. color: #ff8057;
  153. }
  154. }
  155. }
  156. .courseCollapseCon {
  157. padding-left: 20px;
  158. .courseList {
  159. display: flex;
  160. justify-content: space-between;
  161. align-items: center;
  162. height: 68px;
  163. border-bottom: 1px solid #f2f2f2;
  164. cursor: pointer;
  165. &:hover {
  166. .iconArrow,
  167. .courseTitleCon > img {
  168. opacity: $opacity-hover;
  169. }
  170. }
  171. &:last-child {
  172. border-bottom: initial;
  173. }
  174. .courseTitleCon {
  175. flex-grow: 1;
  176. overflow: hidden;
  177. margin-right: 8px;
  178. display: flex;
  179. align-items: center;
  180. font-weight: 400;
  181. font-size: 18px;
  182. color: #333333;
  183. > .ellipsisBox {
  184. flex-grow: 1;
  185. overflow: hidden;
  186. }
  187. > img {
  188. flex-shrink: 0;
  189. width: 33px;
  190. height: 33px;
  191. margin-right: 10px;
  192. }
  193. }
  194. .iconArrow {
  195. flex-shrink: 0;
  196. width: 8px;
  197. height: 15px;
  198. }
  199. }
  200. }
  201. }
  202. </style>