planDialog.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div class="plan-dialog-container" v-if="visible">
  3. <div class="plan-title">
  4. <span class="title-text">防汛预案</span>
  5. <img src="@/assets/image/common/close.png" style="cursor: pointer" alt="" @click="closeDialog" />
  6. </div>
  7. <div class="plan-content">
  8. <el-tabs tab-position="left" style="height: 5.85rem">
  9. <el-tab-pane :label="item.label" v-for="(item, index) in this.planItems" :key="index">
  10. <el-carousel :ref="'mainCarousel' + index" :interval="5000" :autoplay="false" arrow="always" indicator-position="none">
  11. <el-carousel-item v-for="(image,i) in item.imageList" :key="i">
  12. <div class="image-wrapper">
  13. <el-image :src="image" :preview-src-list="item.imageList" fit="cover" class="main-image" />
  14. <!-- <div class="fullscreen-btn" @click="openFullscreen(index)">
  15. <img src="@/assets/image/smart-early-warning/fullScreen.png" alt="" />
  16. </div> -->
  17. </div>
  18. </el-carousel-item>
  19. </el-carousel>
  20. </el-tab-pane>
  21. </el-tabs>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. visible: false,
  30. planList: [],
  31. imgsOne: [],
  32. imgsTwo: [],
  33. imgsThree: [],
  34. imgsFour: []
  35. }
  36. },
  37. created() {
  38. this.loadImages()
  39. },
  40. mounted() {
  41. this.$globalEventBus.$on('showPlanDialog', (data) => {
  42. this.planList = data.list
  43. this.visible = data.list.length > 0 ? true : false
  44. })
  45. },
  46. computed: {
  47. planItems() {
  48. return this.planList.map((item) => {
  49. if (item.id == '12') {
  50. return { ...item, imageList: this.imgsOne }
  51. } else if (item.id == '13') {
  52. return { ...item, imageList: this.imgsTwo }
  53. } else if (item.id == '14') {
  54. return { ...item, imageList: this.imgsThree }
  55. } else if (item.id == '15') {
  56. return { ...item, imageList: this.imgsFour }
  57. }
  58. console.info(item)
  59. return item
  60. })
  61. }
  62. },
  63. methods: {
  64. loadImages() {
  65. const imagesRequireContext1 = require.context('@/assets/image/planOne', false, /\.png$|\.jpg$/)
  66. this.imgsOne = imagesRequireContext1.keys().map((imagePath) => imagesRequireContext1(imagePath))
  67. const imagesRequireContext2 = require.context('@/assets/image/planTwo', false, /\.png$|\.jpg$/)
  68. this.imgsTwo = imagesRequireContext2.keys().map((imagePath2) => imagesRequireContext2(imagePath2))
  69. const imagesRequireContext3 = require.context('@/assets/image/planThree', false, /\.png$|\.jpg$/)
  70. this.imgsThree = imagesRequireContext3.keys().map((imagePath3) => imagesRequireContext3(imagePath3))
  71. const imagesRequireContext4 = require.context('@/assets/image/planFour', false, /\.png$|\.jpg$/)
  72. this.imgsFour = imagesRequireContext4.keys().map((imagePath4) => imagesRequireContext4(imagePath4))
  73. },
  74. openFullscreen(index) {
  75. const img = this.$el.querySelectorAll('.main-image')[index].querySelector('img')
  76. img.click()
  77. },
  78. closeDialog(){
  79. this.visible = false
  80. this.$globalEventBus.$emit('closePlanDialog',this.planList)
  81. }
  82. },
  83. destroyed() {
  84. this.$globalEventBus.$off('showPlanDialog')
  85. }
  86. }
  87. </script>
  88. <style lang="scss" scoped>
  89. .plan-dialog-container {
  90. position: absolute;
  91. top: px-to-rem(270);
  92. right: calc(50% - px-to-rem(590));
  93. width: px-to-rem(1180);
  94. z-index: 1001;
  95. .plan-title {
  96. background: url('@/assets/image/common/planTitleBg.png') no-repeat;
  97. background-size: 100% 100%;
  98. height: px-to-rem(39);
  99. display: flex;
  100. justify-content: space-between;
  101. align-items: center;
  102. padding: 0 px-to-rem(20);
  103. font-size: px-to-rem(16);
  104. color: #fff;
  105. .title-text {
  106. font-weight: bold;
  107. margin-left: px-to-rem(20);
  108. }
  109. }
  110. .plan-content {
  111. background-color: rgba(35, 61, 108, 0.8);
  112. :deep(.el-tabs__content) {
  113. padding: px-to-rem(10);
  114. padding-left: 0;
  115. }
  116. :deep(.el-tabs__item) {
  117. background-color: transparent;
  118. color: #fff;
  119. width: px-to-rem(170);
  120. white-space: nowrap;
  121. overflow: hidden;
  122. text-overflow: ellipsis;
  123. height: px-to-rem(36);
  124. line-height: px-to-rem(36);
  125. font-weight: 400;
  126. font-size: px-to-rem(16);
  127. }
  128. :deep(.el-tabs__item.is-active) {
  129. background: #498ee3;
  130. font-weight: 400;
  131. font-size: px-to-rem(16);
  132. color: #f5f5f5;
  133. }
  134. :deep(.el-tabs__nav-wrap::after) {
  135. background-color: #4d628b;
  136. }
  137. :deep(.el-carousel__container) {
  138. height: px-to-rem(563);
  139. }
  140. .image-wrapper {
  141. height: px-to-rem(563); // 与 carousel 容器高度一致
  142. display: flex;
  143. align-items: center;
  144. justify-content: center;
  145. .main-image {
  146. height: 100%;
  147. width: auto;
  148. max-width: 100%;
  149. object-fit: contain; // 保持图片比例,完整显示图片
  150. }
  151. }
  152. }
  153. .fullscreen-btn {
  154. position: absolute;
  155. bottom: px-to-rem(10);
  156. right: px-to-rem(10);
  157. width: px-to-rem(40);
  158. height: px-to-rem(40);
  159. display: flex;
  160. align-items: center;
  161. justify-content: center;
  162. cursor: pointer;
  163. z-index: 10;
  164. transition: all 0.3s;
  165. }
  166. .fullscreen-btn:hover {
  167. transform: scale(1.1);
  168. }
  169. }
  170. </style>