1
1
<template >
2
2
<div class =" upload-box" >
3
3
<el-upload
4
- :action =" updateUrl"
5
4
:id =" uuid"
5
+ :accept =" fileType.join(',')"
6
+ :action =" updateUrl"
7
+ :before-upload =" beforeUpload"
6
8
:class =" ['upload', drag ? 'no-border' : '']"
7
- :multiple =" false"
8
- :show-file-list =" false"
9
+ :drag =" drag"
9
10
:headers =" uploadHeaders"
10
- :before-upload =" beforeUpload"
11
- :on-success =" uploadSuccess"
11
+ :multiple =" false"
12
12
:on-error =" uploadError"
13
- :drag = " drag "
14
- :accept = " fileType.join(',') "
13
+ :on-success = " uploadSuccess "
14
+ :show-file-list = " false "
15
15
>
16
16
<template v-if =" modelValue " >
17
17
<img :src =" modelValue" class =" upload-image" />
20
20
<Icon icon =" ep:edit" />
21
21
<span v-if =" showBtnText" >{{ t('action.edit') }}</span >
22
22
</div >
23
- <div class =" handle-icon" @click =" imgViewVisible = true " >
23
+ <div class =" handle-icon" @click =" imagePreview(modelValue) " >
24
24
<Icon icon =" ep:zoom-in" />
25
25
<span v-if =" showBtnText" >{{ t('action.detail') }}</span >
26
26
</div >
27
- <div class =" handle-icon" @click =" deleteImg" v-if = " showDelete " >
27
+ <div v-if = " showDelete " class =" handle-icon" @click =" deleteImg" >
28
28
<Icon icon =" ep:delete" />
29
29
<span v-if =" showBtnText" >{{ t('action.del') }}</span >
30
30
</div >
42
42
<div class =" el-upload__tip" >
43
43
<slot name =" tip" ></slot >
44
44
</div >
45
- <el-image-viewer
46
- v-if =" imgViewVisible"
47
- @close =" imgViewVisible = false"
48
- :url-list =" [modelValue]"
49
- />
50
45
</div >
51
46
</template >
52
47
@@ -56,6 +51,7 @@ import type { UploadProps } from 'element-plus'
56
51
import { generateUUID } from ' @/utils'
57
52
import { propTypes } from ' @/utils/propTypes'
58
53
import { getAccessToken , getTenantId } from ' @/utils/auth'
54
+ import { createImageViewer } from ' @/components/ImageViewer'
59
55
60
56
defineOptions ({ name: ' UploadImg' })
61
57
@@ -92,7 +88,12 @@ const message = useMessage() // 消息弹窗
92
88
// 生成组件唯一id
93
89
const uuid = ref (' id-' + generateUUID ())
94
90
// 查看图片
95
- const imgViewVisible = ref (false )
91
+ const imagePreview = (imgUrl : string ) => {
92
+ createImageViewer ({
93
+ zIndex: 9999999 ,
94
+ urlList: [imgUrl ]
95
+ })
96
+ }
96
97
97
98
const emit = defineEmits ([' update:modelValue' ])
98
99
@@ -130,7 +131,7 @@ const uploadError = () => {
130
131
message .notifyError (' 图片上传失败,请您重新上传!' )
131
132
}
132
133
</script >
133
- <style scoped lang="scss">
134
+ <style lang="scss" scoped >
134
135
.is-error {
135
136
.upload {
136
137
:deep (.el-upload ),
0 commit comments