From 22271e641e4505ba906c3770905b7e84e3ad8d85 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期二, 02 四月 2024 17:05:57 +0800
Subject: [PATCH] mrshi
---
company/src/components/common/UploadAvatarImage.vue | 48 ++++++++++++++++++++++++++++--------------------
1 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/company/src/components/common/UploadAvatarImage.vue b/company/src/components/common/UploadAvatarImage.vue
index e0d737e..7d5ddae 100644
--- a/company/src/components/common/UploadAvatarImage.vue
+++ b/company/src/components/common/UploadAvatarImage.vue
@@ -3,16 +3,18 @@
<el-upload
class="avatar-uploader"
accept=".png,.jpg"
+ :style="customStyle"
:action="uploadImgUrl"
:data="uploadData"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:on-error="uploadError"
:before-upload="beforeAvatarUpload">
- <template v-if="file.imgurlfull">
- <img :src="file.imgurlfull" class="avatar">
- </template>
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+ <img v-if=" file.imgurlfull" style="width: 100%;" :src="file.imgurlfull" :style="customStyle" class="avatar">
+ <div v-else :style="customStyle">
+ <i class="el-icon-plus avatar-uploader-icon"></i>
+ <div class="tips-style">{{ tipsLabel }}</div>
+ </div>
</el-upload>
</div>
@@ -25,16 +27,16 @@
type: Object,
default: () => {}
},
+ tipsLabel: '',
+ customStyle: {
+ type: String,
+ default: 'width: 90px; height: 90px;'
+ },
uploadData: Object
},
data() {
return {
- uploadImgUrl: process.env.VUE_APP_API_PREFIX + '/public/uploadLocal',
- // uploadData: {
- // folder: 'upload',
- // type: 'image'
- // },
- imgurlfull: ''
+ uploadImgUrl: process.env.VUE_APP_API_PREFIX + '/public/upload'
}
},
@@ -42,10 +44,11 @@
// 涓婁紶鍥剧墖
handleAvatarSuccess(res, file) {
if (res.code == 200) {
- this.file.imgurl = res.data.imgaddr;
- this.file.imgurlfull = res.data.url;
- this.$tip.apiSuccess('涓婁紶鎴愬姛')
- this.$emit('uploadSuccess', { imgurl: res.data.imgaddr, imgurlfull: res.data.url })
+ let { data } = res
+ this.file.imgurl = data.imgaddr;
+ this.file.imgurlfull = data.url;
+ this.$message.success('涓婁紶鎴愬姛')
+ this.$emit('uploadSuccess', { imgurl: data.imgaddr, imgurlfull: data.url, name: data.originname })
} else {
this.$tip.apiFailed('涓婁紶澶辫触')
}
@@ -65,7 +68,7 @@
</script>
<style lang="scss" scoped>
-$image-width: 100px;
+$image-width: 90px;
.avatar-uploader {
width: $image-width;
height: $image-width;
@@ -75,26 +78,31 @@
border-radius: 6px;
cursor: pointer;
position: relative;
- width: $image-width;
- height: $image-width;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #409EFF;
}
.avatar-uploader-icon {
+ line-height: 90px;
font-size: 28px;
color: #8c939d;
width: $image-width;
height: $image-width;
- line-height: $image-width;
text-align: center;
}
.avatar {
- width: $image-width;
- height: $image-width;
+ width: 100% !important;
+ height: auto !important;
display: block;
}
+.tips-style {
+ height: 13px;
+ font-size: 13px;
+ font-weight: 400;
+ color: #999999;
+ line-height: 13px;
+}
</style>
<style lang="scss" scoped>
::v-deep .el-upload--picture-card{
--
Gitblit v1.9.3