|
|
@@ -52,11 +52,13 @@
|
|
|
<el-table-column prop="versionNumber" header-align="center" align="center" min-width="140"
|
|
|
:show-tooltip-when-overflow="true" label="版本号">
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="attachList2" header-align="center" align="center" min-width="140"
|
|
|
+ <el-table-column prop="attachList2" header-align="center" align="center" min-width="100"
|
|
|
:show-tooltip-when-overflow="true" label="简图">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button :disabled="!scope.row.attachList2 || scope.row.attachList2.length === 0" type="text" size="small"
|
|
|
- @click="attachDetail(scope.row.attachList2)">查看</el-button>
|
|
|
+ <div class="thumb-list" v-if="getImageList(scope.row.attachList2).length">
|
|
|
+ <img v-for="(img, idx) in getImageList(scope.row.attachList2)" :key="(img.url || '') + idx" class="thumb"
|
|
|
+ :src="downloadUrl + img.url" :alt="img.fileName" @click="previewFile(img.fileName, img.url)" />
|
|
|
+ </div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="productSpec" header-align="center" align="center" min-width="140"
|
|
|
@@ -105,15 +107,18 @@
|
|
|
</span>
|
|
|
|
|
|
<attach-detail-dialog ref="attachDetail" />
|
|
|
+ <preview-component v-if="previewVisible" ref="preview" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import UserComponent from '../common/user-component'
|
|
|
import AttachDetailDialog from '../common/attach-detail-dialog'
|
|
|
+import PreviewComponent from '../common/preview-component'
|
|
|
+import { downloadUrl } from '@/api/file'
|
|
|
export default {
|
|
|
name: 'project-product-detail',
|
|
|
- components: { UserComponent, AttachDetailDialog },
|
|
|
+ components: { UserComponent, AttachDetailDialog, PreviewComponent },
|
|
|
computed: {},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -125,6 +130,8 @@ export default {
|
|
|
dataRule: {},
|
|
|
dataList: [],
|
|
|
dataListLoading: false,
|
|
|
+ previewVisible: false,
|
|
|
+ downloadUrl: downloadUrl
|
|
|
|
|
|
}
|
|
|
},
|
|
|
@@ -162,6 +169,23 @@ export default {
|
|
|
this.$refs.attachDetail.init(attachList)
|
|
|
})
|
|
|
},
|
|
|
+ // 过滤图片附件
|
|
|
+ getImageList(attachList) {
|
|
|
+ if (!attachList || !Array.isArray(attachList)) return []
|
|
|
+ return attachList.filter(item => this.isImage(item && item.fileName))
|
|
|
+ },
|
|
|
+ isImage(fileName) {
|
|
|
+ if (!fileName || typeof fileName !== 'string') return false
|
|
|
+ const ext = fileName.split('.').pop().toLowerCase()
|
|
|
+ return ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'].includes(ext)
|
|
|
+ },
|
|
|
+ // 预览大图
|
|
|
+ previewFile(fileName, url) {
|
|
|
+ this.previewVisible = true
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.preview && this.$refs.preview.init(fileName, url)
|
|
|
+ })
|
|
|
+ },
|
|
|
// 表单提交
|
|
|
dataFormSubmit() {
|
|
|
this.$refs['dataForm'].validate((valid) => {
|
|
|
@@ -221,4 +245,21 @@ export default {
|
|
|
cursor: pointer;
|
|
|
color: #3e8ef7;
|
|
|
}
|
|
|
+
|
|
|
+/* 缩略图样式 */
|
|
|
+.thumb-list {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ gap: 6px;
|
|
|
+ justify-content: center;
|
|
|
+}
|
|
|
+
|
|
|
+.thumb {
|
|
|
+ width: 48px;
|
|
|
+ height: 48px;
|
|
|
+ object-fit: cover;
|
|
|
+ border: 1px solid #ebeef5;
|
|
|
+ border-radius: 4px;
|
|
|
+ cursor: pointer;
|
|
|
+}
|
|
|
</style>
|