moduleRight.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <Transition class="module-right">
  3. <!-- 正常展示模块时 -->
  4. <div v-if="moduleShown" class="module-content">
  5. <div class="module-content__title__expand">
  6. <span class="action-btn close-btn" @click="closeModel"></span>
  7. {{ title }}
  8. </div>
  9. <div class="module-slot">
  10. <slot></slot>
  11. </div>
  12. </div>
  13. <!-- 隐藏模块时 -->
  14. <div v-else class="w-100%">
  15. <div class="module-content__title">
  16. <span class="action-btn show-btn" @click="showModel"></span>
  17. {{ title }}
  18. </div>
  19. </div>
  20. </Transition>
  21. </template>
  22. <script lang="ts" setup>
  23. import { ref } from 'vue';
  24. defineProps<{ title: string }>();
  25. const moduleShown = ref(true);
  26. function closeModel() {
  27. moduleShown.value = false;
  28. }
  29. function showModel() {
  30. moduleShown.value = true;
  31. }
  32. </script>
  33. <style lang="less" scoped>
  34. .module-right {
  35. --bg-height: 33px;
  36. color: #fff;
  37. box-sizing: border-box;
  38. .module-content {
  39. width: 100%;
  40. height: 100%;
  41. }
  42. .module-content__title__expand {
  43. width: 100%;
  44. height: var(--bg-height);
  45. background: url('../../../../../assets/images/home-container/configurable/model_right_title_bg_expand.png') no-repeat;
  46. background-size: 100% 100%;
  47. position: relative;
  48. text-align: left;
  49. padding: 4px 0 0 10%;
  50. }
  51. .module-content__title {
  52. width: 50%;
  53. height: var(--bg-height);
  54. background: url('../../../../../assets/images/home-container/configurable/model_right_title_bg.png') no-repeat;
  55. background-size: 100% 100%;
  56. position: relative;
  57. text-align: left;
  58. margin-left: 50%;
  59. padding: 4px 0 0 10%;
  60. }
  61. // 固定在父容器右上角的按钮图标
  62. .action-btn {
  63. width: 18px;
  64. height: 18px;
  65. background: url('../../../../../assets/images/home-container/configurable/expand.svg') no-repeat center;
  66. position: absolute;
  67. left: 0;
  68. top: 0;
  69. }
  70. .show-btn {
  71. transform: rotate(-90deg);
  72. }
  73. .module-slot {
  74. height: calc(100% - 33px);
  75. width: 100%;
  76. background-color: #259ccf22;
  77. }
  78. }
  79. // Transition动画相关
  80. .v-enter-active,
  81. .v-leave-active {
  82. transition: all 0.3s ease;
  83. }
  84. .v-enter-from,
  85. .v-leave-to {
  86. // opacity: 1;
  87. transform: translateX(100%);
  88. // transform: scaleY(0);
  89. // transform-origin: center top;
  90. }
  91. </style>