|
25 | 25 | <template #file="{ file }">
|
26 | 26 | <img :src="file.url" class="upload-image" />
|
27 | 27 | <div class="upload-handle" @click.stop>
|
28 |
| - <div class="handle-icon" @click="handlePictureCardPreview(file)"> |
| 28 | + <div class="handle-icon" @click="imagePreview(file.url!)"> |
29 | 29 | <Icon icon="ep:zoom-in" />
|
30 | 30 | <span>查看</span>
|
31 | 31 | </div>
|
|
39 | 39 | <div class="el-upload__tip">
|
40 | 40 | <slot name="tip"></slot>
|
41 | 41 | </div>
|
42 |
| - <el-image-viewer |
43 |
| - v-if="imgViewVisible" |
44 |
| - :url-list="[viewImageUrl]" |
45 |
| - @close="imgViewVisible = false" |
46 |
| - /> |
47 | 42 | </div>
|
48 | 43 | </template>
|
49 | 44 | <script lang="ts" setup>
|
50 | 45 | import type { UploadFile, UploadProps, UploadUserFile } from 'element-plus'
|
51 | 46 | import { ElNotification } from 'element-plus'
|
| 47 | +import { createImageViewer } from '@/components/ImageViewer' |
52 | 48 |
|
53 | 49 | import { propTypes } from '@/utils/propTypes'
|
54 | 50 | import { useUpload } from '@/components/UploadFile/src/useUpload'
|
55 | 51 |
|
56 | 52 | defineOptions({ name: 'UploadImgs' })
|
57 | 53 |
|
58 | 54 | const message = useMessage() // 消息弹窗
|
| 55 | +// 查看图片 |
| 56 | +const imagePreview = (imgUrl: string) => { |
| 57 | + createImageViewer({ |
| 58 | + zIndex: 9999999, |
| 59 | + urlList: [imgUrl] |
| 60 | + }) |
| 61 | +} |
59 | 62 |
|
60 | 63 | type FileTypes =
|
61 | 64 | | 'image/apng'
|
@@ -178,14 +181,6 @@ const handleExceed = () => {
|
178 | 181 | type: 'warning'
|
179 | 182 | })
|
180 | 183 | }
|
181 |
| -
|
182 |
| -// 图片预览 |
183 |
| -const viewImageUrl = ref('') |
184 |
| -const imgViewVisible = ref(false) |
185 |
| -const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => { |
186 |
| - viewImageUrl.value = uploadFile.url! |
187 |
| - imgViewVisible.value = true |
188 |
| -} |
189 | 184 | </script>
|
190 | 185 |
|
191 | 186 | <style lang="scss" scoped>
|
|
0 commit comments