DetailDialog.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div>
  3. <el-dialog v-model="visible" title="问题详情" width="80%" align-center :close-on-click-modal="false">
  4. <div class="description-box">
  5. <div class="title">问题描述</div>
  6. <p>{{ description }}</p>
  7. </div>
  8. <div>
  9. <div class="title">问题图片/视频</div>
  10. <div class="media-box">
  11. <div class="img-box" v-for="(imagePath, index) in imagePaths" :key="index">
  12. <img :src="imagePath" alt="" style="object-fit:contain; width:200px; height:200px; border: solid 1px #CCC"
  13. @mouseenter="handleOpenPre(imagePath, index)">
  14. <div class="cover-box" v-if="isCoverVisible(index)" @mouseleave="handleClosePre(index)">
  15. <el-icon :size="40" color="#e6e6e6" style="cursor: pointer;" @click="handlePreview">
  16. <ZoomIn />
  17. </el-icon>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </el-dialog>
  23. <el-dialog v-model="dialogVisible">
  24. <img w-full :src="dialogImageUrl" alt="" />
  25. </el-dialog>
  26. </div>
  27. </template>
  28. <script setup lang="ts">
  29. import { ref, toRefs, watch } from 'vue';
  30. import { ZoomIn } from '@element-plus/icons-vue';
  31. const props = defineProps({
  32. showDrawer: Boolean,
  33. description: String,
  34. imagePaths: Array<string>,
  35. });
  36. const { showDrawer } = toRefs(props);
  37. const emits = defineEmits(['toggleStatus']);
  38. const visible = ref(false);
  39. const toggle = (newVal: boolean) => {
  40. visible.value = newVal;
  41. };
  42. watch(
  43. () => showDrawer.value,
  44. (newVal) => {
  45. toggle(newVal)
  46. }
  47. );
  48. watch(
  49. () => visible.value,
  50. (newVal) => {
  51. emits('toggleStatus', newVal)
  52. }
  53. );
  54. const showPreview = ref<boolean[]>(new Array(props.imagePaths?.values.length).fill(false));
  55. const dialogVisible = ref(false);
  56. const dialogImageUrl = ref('');
  57. const handleOpenPre = (val, index) => {
  58. dialogImageUrl.value = val;
  59. showPreview.value[index] = true;
  60. };
  61. const handleClosePre = (index) => {
  62. showPreview.value[index] = false;
  63. };
  64. const isCoverVisible = (index) => {
  65. return showPreview.value[index];
  66. };
  67. const handlePreview = () => {
  68. dialogVisible.value = true;
  69. };
  70. </script>
  71. <style scoped>
  72. :deep(.el-dialog) {
  73. padding: 0;
  74. background: #FFFFFF;
  75. box-shadow: 0px 9px 28px 8px rgba(0, 0, 0, 0.05), 0px 6px 16px 0px rgba(0, 0, 0, 0.08), 0px 3px 6px -4px rgba(0, 0, 0, 0.12);
  76. .el-dialog__header {
  77. display: flex;
  78. align-items: center;
  79. height: 56px;
  80. padding-left: 24px;
  81. padding-bottom: 0;
  82. border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  83. }
  84. .el-dialog__title {
  85. color: rgba(0, 0, 0, 0.88);
  86. font-size: 16px;
  87. font-weight: 500;
  88. }
  89. .el-dialog__headerbtn .el-dialog__close {
  90. color: #000;
  91. }
  92. .el-dialog__body {
  93. height: 564px;
  94. padding: 40px;
  95. overflow: scroll;
  96. }
  97. }
  98. .title {
  99. margin-bottom: 20px;
  100. color: #303133;
  101. font-size: 16px;
  102. font-weight: 500;
  103. }
  104. .title:before {
  105. margin-right: 8px;
  106. content: '';
  107. border-left: 3px solid #1777FF;
  108. }
  109. .description-box {
  110. margin-bottom: 20px;
  111. p {
  112. color: #606266;
  113. }
  114. }
  115. .media-box {
  116. display: flex;
  117. .img-box {
  118. position: relative;
  119. width: 200px;
  120. height: 200px;
  121. margin-right: 10px;
  122. }
  123. .cover-box {
  124. display: flex;
  125. align-items: center;
  126. justify-content: center;
  127. position: absolute;
  128. top: 0;
  129. width: 200px;
  130. height: 200px;
  131. background-color: rgba(0, 0, 0, 0.5);
  132. }
  133. }
  134. </style>