优化报废图片展示问题

This commit is contained in:
BianLzhaoMin 2024-06-17 16:18:00 +08:00
parent 782d2c645a
commit 31a70c1178
3 changed files with 101 additions and 79 deletions

View File

@ -1,82 +1,88 @@
<template> <template>
<el-image <el-image
:src="`${realSrc}`" :src="`${realSrc}`"
fit="cover" fit="cover"
:style="`width:${realWidth};height:${realHeight};`" :style="`width:${realWidth};height:${realHeight};`"
:preview-src-list="realSrcList" :preview-src-list="realSrcList"
> >
<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>
</div> </div>
</el-image> </el-image>
</template> </template>
<script> <script>
export default { export default {
name: "ImagePreview", name: 'ImagePreview',
props: { props: {
src: { src: {
type: String, type: String,
default: "" default: '',
},
width: {
type: [Number, String],
default: '',
},
height: {
type: [Number, String],
default: '',
},
}, },
width: { computed: {
type: [Number, String], realSrc() {
default: "" if (!this.src) {
return
}
let real_src = this.src.split(',')[0]
console.log(this.src, '图片地址--')
return real_src
},
realSrcList() {
if (!this.src) {
return
}
let real_src_list = this.src.split(',')
let srcList = []
real_src_list.forEach((item) => {
return srcList.push(item)
})
return srcList
},
realWidth() {
return typeof this.width == 'string'
? this.width
: `${this.width}px`
},
realHeight() {
return typeof this.height == 'string'
? this.height
: `${this.height}px`
},
}, },
height: { }
type: [Number, String],
default: ""
}
},
computed: {
realSrc() {
if (!this.src) {
return;
}
let real_src = this.src.split(",")[0];
return real_src;
},
realSrcList() {
if (!this.src) {
return;
}
let real_src_list = this.src.split(",");
let srcList = [];
real_src_list.forEach(item => {
return srcList.push(item);
});
return srcList;
},
realWidth() {
return typeof this.width == "string" ? this.width : `${this.width}px`;
},
realHeight() {
return typeof this.height == "string" ? this.height : `${this.height}px`;
}
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.el-image { .el-image {
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 {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
color: #909399;
font-size: 30px;
} }
}
::v-deep .image-slot {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
color: #909399;
font-size: 30px;
}
} }
</style> </style>

View File

@ -510,7 +510,7 @@
</el-button> </el-button>
</el-col> </el-col>
</el-row> </el-row>
<el-table v-loading="loading" :data="numList" height="500"> <el-table v-loading="loading" :data="numList">
<el-table-column label="序号" align="center" type="index" /> <el-table-column label="序号" align="center" type="index" />
<el-table-column <el-table-column
label="类型名称" label="类型名称"
@ -539,7 +539,7 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-input <el-input
v-model.number="scope.row.qualifiedNum" v-model.number="scope.row.qualifiedNum"
placeholder="请输入合格数量" placeholder="合格数量"
type="number" type="number"
:min="0" :min="0"
clearable clearable
@ -557,7 +557,7 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-input <el-input
v-model.number="scope.row.serviceNum" v-model.number="scope.row.serviceNum"
placeholder="请输入待维修数量" placeholder="待维修数量"
type="number" type="number"
:min="0" :min="0"
clearable clearable
@ -574,7 +574,7 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-input <el-input
v-model.number="scope.row.scrapNum" v-model.number="scope.row.scrapNum"
placeholder="请输入待报废数量" placeholder="待报废数量"
type="number" type="number"
:min="0" :min="0"
clearable clearable
@ -583,6 +583,19 @@
/> />
</template> </template>
</el-table-column> </el-table-column>
<!-- 6.17新增 报废原因等填写 -->
<el-table-column label="报废信息" align="center">
<template slot-scope="{ row }">
<el-button
type="primary"
size="mini"
:disabled="row.scrapNum <= 0"
> </el-button
>
</template>
</el-table-column>
<!-- <el-table-column label="报废信息" align="center" prop="" :show-overflow-tooltip="true" /> --> <!-- <el-table-column label="报废信息" align="center" prop="" :show-overflow-tooltip="true" /> -->
</el-table> </el-table>
</div> </div>

View File

@ -11,7 +11,7 @@
<ImagePreview <ImagePreview
v-for="(item, index) in scrapImgList" v-for="(item, index) in scrapImgList"
:key="index" :key="index"
:src="item" :src="`${impViewUrl}${item}`"
:width="`20px`" :width="`20px`"
:height="`20px`" :height="`20px`"
class="img-box" class="img-box"
@ -22,7 +22,10 @@
<script> <script>
export default { export default {
props: { props: {
scrapImgUrl: {}, scrapImgUrl: {
type: String,
default: () => null,
},
}, },
data() { data() {
return { return {
@ -31,14 +34,14 @@ export default {
} }
}, },
mounted() { mounted() {
let imgList = [] // let imgList = []
if (this.scrapImgUrl) { if (this.scrapImgUrl) {
imgList = this.scrapImgUrl.split(',') this.scrapImgList = this.scrapImgUrl.split(',')
} }
this.scrapImgList = imgList.map( // this.scrapImgList = imgList.map(
(item) => (item = this.impViewUrl + item), // (item) => (item = this.impViewUrl + item),
) // )
}, },
} }
</script> </script>