|
|
|
@ -11,9 +11,28 @@
|
|
|
|
|
:headers="headers"
|
|
|
|
|
style="display: inline-block; vertical-align: top"
|
|
|
|
|
>
|
|
|
|
|
<img v-if="value" :src="value" class="avatar" />
|
|
|
|
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
|
|
|
<el-image v-if="!value" :src="value">
|
|
|
|
|
<div slot="error" class="image-slot">
|
|
|
|
|
<i class="el-icon-plus" />
|
|
|
|
|
</div>
|
|
|
|
|
</el-image>
|
|
|
|
|
<div v-else class="image">
|
|
|
|
|
<el-image :src="value" :style="`width:150px;height:150px;`" fit="fill"/>
|
|
|
|
|
<div class="mask">
|
|
|
|
|
<div class="actions">
|
|
|
|
|
<span title="预览" @click.stop="dialogVisible = true">
|
|
|
|
|
<i class="el-icon-zoom-in" />
|
|
|
|
|
</span>
|
|
|
|
|
<span title="移除" @click.stop="removeImage">
|
|
|
|
|
<i class="el-icon-delete" />
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-upload>
|
|
|
|
|
<el-dialog :visible.sync="dialogVisible" title="预览" width="800" append-to-body>
|
|
|
|
|
<img :src="value" style="display: block; max-width: 100%; margin: 0 auto;">
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
@ -21,10 +40,10 @@
|
|
|
|
|
import { getToken } from "@/utils/auth";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: {},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
uploadImgUrl: process.env.VUE_APP_BASE_API + "/file/upload", // 上传的图片服务器地址
|
|
|
|
|
dialogVisible: false,
|
|
|
|
|
uploadImgUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
|
|
|
|
|
headers: {
|
|
|
|
|
Authorization: "Bearer " + getToken(),
|
|
|
|
|
},
|
|
|
|
@ -37,8 +56,11 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
removeImage() {
|
|
|
|
|
this.$emit("input", "");
|
|
|
|
|
},
|
|
|
|
|
handleUploadSuccess(res) {
|
|
|
|
|
this.$emit("input", res.data.url);
|
|
|
|
|
this.$emit("input", res.url);
|
|
|
|
|
this.loading.close();
|
|
|
|
|
},
|
|
|
|
|
handleBeforeUpload() {
|
|
|
|
@ -61,8 +83,18 @@ export default {
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.avatar {
|
|
|
|
|
.image {
|
|
|
|
|
position: relative;
|
|
|
|
|
.mask {
|
|
|
|
|
opacity: 0;
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
background-color: rgba(0, 0, 0, 0.5);
|
|
|
|
|
transition: all 0.3s;
|
|
|
|
|
}
|
|
|
|
|
&:hover .mask {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|