From 0ec7a17e8d9e52f9e34622e0319dca70c8d7ddee Mon Sep 17 00:00:00 2001
From: dsh <15569653818@163.com>
Date: Fri, 26 Apr 2024 09:09:58 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/AllTypeFile/update.vue | 45 ++++++++++++++++++++++++---
1 file changed, 40 insertions(+), 5 deletions(-)
diff --git a/src/components/AllTypeFile/update.vue b/src/components/AllTypeFile/update.vue
index 20c4916..ac21a14 100644
--- a/src/components/AllTypeFile/update.vue
+++ b/src/components/AllTypeFile/update.vue
@@ -22,7 +22,7 @@
{{ getFileName(scope.row.fileName) }}
-
+
@@ -35,10 +35,10 @@
- 下载
- 通过
- 不通过
- 删除
+ 下载
+ 通过
+ 不通过
+ 删除
@@ -190,6 +190,41 @@ export default {
return name;
}
},
+ previewFile(file) {
+ debugger
+ const fileType = this.getFileType(file.name);
+ switch (fileType) {
+ case 'image':
+ this.$router.push(`${this.baseUrl}/${file.url}`);
+ break;
+ case 'pdf':
+ this.$router.push(`/preview/pdf/${file.url}`);
+ break;
+ case 'excel':
+ this.$router.push(`/preview/excel/${file.url}`);
+ break;
+ case 'word':
+ this.$router.push(`/preview/word/${file.url}`);
+ break;
+ default:
+ // 默认处理
+ break;
+ }
+ },
+ getFileType(fileName) {
+ const extension = fileName.split('.').pop().toLowerCase();
+ if (['jpg', 'jpeg', 'png', 'gif'].includes(extension)) {
+ return 'image';
+ } else if (['pdf'].includes(extension)) {
+ return 'pdf';
+ } else if (['xlsx', 'xls'].includes(extension)) {
+ return 'excel';
+ } else if (['doc', 'docx'].includes(extension)) {
+ return 'word';
+ } else {
+ return 'unknown';
+ }
+ },
// 对象转成指定字符串分隔
listToString(list, separator) {
let strs = "";