From 050078c08237238a2706c8bd7c5ea3382f3c01f7 Mon Sep 17 00:00:00 2001
From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com>
Date: Tue, 16 Sep 2025 13:25:36 +0800
Subject: [PATCH] =?UTF-8?q?=E7=A6=85=E9=81=93bug=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/UploadFileFormData/index.vue | 32 ++++----
src/views/dataManage/pro-materials/index.vue | 77 ++++++++++++++++++-
src/views/dataManage/product-center/index.vue | 1 +
src/views/publicService/components/navBar.vue | 4 +-
src/views/publicService/index.vue | 12 +--
5 files changed, 102 insertions(+), 24 deletions(-)
diff --git a/src/components/UploadFileFormData/index.vue b/src/components/UploadFileFormData/index.vue
index 272d282..e3c3b7a 100644
--- a/src/components/UploadFileFormData/index.vue
+++ b/src/components/UploadFileFormData/index.vue
@@ -40,7 +40,7 @@ export default {
// 文件类型
fileType: {
type: Array,
- default: ['png', 'jpg', 'jpeg'],
+ default: [],
},
// 文件大小
fileSize: {
@@ -185,20 +185,24 @@ export default {
handleChange(file, fileList) {
// console.log(file, fileList, 'file, fileList')
- // const isFormat = this.fileType.some((e) => file.name.endsWith(e))
- // if (!isFormat) {
- // this.$modal.msgError(
- // `文件格式不正确, 请上传${this.fileType.join(
- // '、',
- // )}格式的文件!`,
- // )
+ if (this.fileType.length > 0) {
+ const isFormat = this.fileType.some((e) =>
+ file.name.endsWith(e),
+ )
+ if (!isFormat) {
+ this.$modal.msgError(
+ `文件格式不正确, 请上传${this.fileType.join(
+ '、',
+ )}格式的文件!`,
+ )
- // this.$emit(
- // 'update:fileList',
- // fileList.filter((item) => item.uid !== file.uid),
- // )
- // return false
- // }
+ this.$emit(
+ 'update:fileList',
+ fileList.filter((item) => item.uid !== file.uid),
+ )
+ return false
+ }
+ }
// 判断文件大小
const isLt = file.size / 1024 / 1024 < this.fileSize
diff --git a/src/views/dataManage/pro-materials/index.vue b/src/views/dataManage/pro-materials/index.vue
index 3b41c84..a6221d3 100644
--- a/src/views/dataManage/pro-materials/index.vue
+++ b/src/views/dataManage/pro-materials/index.vue
@@ -107,7 +107,12 @@
- {{ scope.row.files[0].originalName }}
+
+ {{ scope.row.files[0].originalName }}
+
/
@@ -117,6 +122,15 @@
+
+
+
+
{{ scope.row[column.prop] }}
@@ -153,7 +167,6 @@
/>
-
+
+
+
+
+
+
+
+
@@ -174,6 +198,8 @@ import {
getProMaterialsListAPI,
deleteProductCenterAPI,
} from '@/api/dataManage/pro-materials'
+import { encryptCBCTime } from '@/utils/aes'
+import useBase64 from '@/utils/base64Utils.js'
import DialogModel from '@/components/DialogModel'
import AddAndEditForm from './components/addAndEditForm.vue'
export default {
@@ -212,6 +238,10 @@ export default {
prop: 'file',
label: '附件',
},
+ {
+ prop: 'cover',
+ label: '封面',
+ },
{
prop: 'fileType',
label: '附件类型',
@@ -237,6 +267,15 @@ export default {
minHeight: '50vh',
maxHeight: '90vh',
},
+ previewDialogConfig: {
+ outerTitle: '预览',
+ outerVisible: false,
+ // minHeight: '90vh',
+ // maxHeight: '90vh',
+ },
+ iframeUrl: '',
+ lookFile: 'http://192.168.0.14:8012/onlinePreview?url=',
+ filePreviewPath: 'http://218.21.27.6:18013/onlinePreview?url=',
}
},
created() {
@@ -298,6 +337,10 @@ export default {
handleCloseDialogOuter() {
this.dialogConfig.outerVisible = false
},
+ // 关闭弹框
+ handleClosePreviewDialogOuter() {
+ this.previewDialogConfig.outerVisible = false
+ },
// 关闭弹框 由子组件调用
closeDialog(isSuccess) {
this.dialogConfig.outerVisible = false
@@ -305,6 +348,32 @@ export default {
this.onHandleQuery()
}
},
+
+ // 预览附件
+ onHandlePreviewFile(files) {
+ if (!files || files.length === 0) return
+ const { originalName, filePath } = files[0]
+ let filePreviewPath = ''
+ let time = encryptCBCTime(Math.floor(Date.now()).toString())
+ const encodedPath = filePath.includes('http')
+ ? encodeURIComponent(useBase64.encode64(`${filePath}`))
+ : encodeURIComponent(
+ useBase64.encode64(`${this.lookFile}/${filePath}`),
+ )
+ filePreviewPath = `${this.lookFile}${encodedPath}&token=${time}`
+
+ const isEdgeOrOther = /Edg|Chrome|Firefox|Safari/.test(
+ navigator.userAgent,
+ )
+ if (isEdgeOrOther) {
+ const url = new URL(filePreviewPath)
+ url.searchParams.append('preventDownload', 'true')
+ filePreviewPath = url.toString()
+ }
+
+ this.iframeUrl = filePreviewPath
+ this.previewDialogConfig.outerVisible = true
+ },
},
}
@@ -318,4 +387,8 @@ export default {
color: #409eff;
text-decoration: underline;
}
+
+.preview-docs {
+ height: 79vh;
+}
diff --git a/src/views/dataManage/product-center/index.vue b/src/views/dataManage/product-center/index.vue
index 1763bde..f8025eb 100644
--- a/src/views/dataManage/product-center/index.vue
+++ b/src/views/dataManage/product-center/index.vue
@@ -106,6 +106,7 @@
diff --git a/src/views/publicService/components/navBar.vue b/src/views/publicService/components/navBar.vue
index 37be96e..5438076 100644
--- a/src/views/publicService/components/navBar.vue
+++ b/src/views/publicService/components/navBar.vue
@@ -1,5 +1,5 @@
-