Pre Merge pull request !247 from lingdeng/dev

This commit is contained in:
lingdeng 2022-11-08 13:51:46 +00:00 committed by Gitee
commit 644618bc36
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -1,9 +1,9 @@
<template> <template>
<el-image <el-image
:src="`${realSrc}`"
fit="cover"
:style="`width:${realWidth};height:${realHeight};`"
:preview-src-list="realSrcList" :preview-src-list="realSrcList"
:src="`${realSrc}`"
:style="`width:${realWidth};height:${realHeight};`"
fit="cover"
> >
<div slot="error" class="image-slot"> <div slot="error" class="image-slot">
<i class="el-icon-picture-outline"></i> <i class="el-icon-picture-outline"></i>
@ -12,6 +12,7 @@
</template> </template>
<script> <script>
import {listByIds} from "@/api/system/oss";
export default { export default {
name: "ImagePreview", name: "ImagePreview",
@ -29,24 +30,38 @@ export default {
default: "" default: ""
} }
}, },
data() {
return {
fileList: []
}
},
watch: {
src: {
async handler(val) {
if (val) {
await listByIds(this.src).then(res => {
res.data.forEach(item => {
this.fileList.push(item.url);
});
})
}
},
deep: true,
immediate: true
}
},
computed: { computed: {
realSrc() { realSrc() {
if (!this.src) { if (!this.fileList) {
return; return;
} }
let real_src = this.src.split(",")[0]; return this.fileList[0];
return real_src;
}, },
realSrcList() { realSrcList() {
if (!this.src) { if (!this.fileList) {
return; return;
} }
let real_src_list = this.src.split(","); return this.fileList;
let srcList = [];
real_src_list.forEach(item => {
return srcList.push(item);
});
return srcList;
}, },
realWidth() { realWidth() {
return typeof this.width == "string" ? this.width : `${this.width}px`; return typeof this.width == "string" ? this.width : `${this.width}px`;
@ -63,13 +78,16 @@ export default {
border-radius: 5px; border-radius: 5px;
background-color: #ebeef5; background-color: #ebeef5;
box-shadow: 0 0 5px 1px #ccc; box-shadow: 0 0 5px 1px #ccc;
::v-deep .el-image__inner { ::v-deep .el-image__inner {
transition: all 0.3s; transition: all 0.3s;
cursor: pointer; cursor: pointer;
&:hover { &:hover {
transform: scale(1.2); transform: scale(1.2);
} }
} }
::v-deep .image-slot { ::v-deep .image-slot {
display: flex; display: flex;
justify-content: center; justify-content: center;