From d01a53ff85eb1243ec31ee261d21eac646929acf Mon Sep 17 00:00:00 2001
From: yujialong <479214531@qq.com>
Date: Fri, 8 Apr 2022 15:05:33 +0800
Subject: [PATCH] =?UTF-8?q?excel=E9=A2=84=E8=A7=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/index.js | 1 +
src/config/index.js | 2 +-
src/router/index.js | 7 +++
src/util/index.js | 10 ++++
src/views/Data.vue | 8 ++-
src/views/Preview.vue | 114 ++++++++++++++++++++++++++++++++++++++++++
6 files changed, 140 insertions(+), 2 deletions(-)
create mode 100644 src/views/Preview.vue
diff --git a/src/api/index.js b/src/api/index.js
index 2ae8013..dbb6d95 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -16,6 +16,7 @@ export default {
checkIsShowBySystemId: `nakadai/model/reference/checkIsShowBySystemId`,
fileUpload: `${config.host}nakadai/nakadai/oss/fileUpload`,
importData: `occupationlab/python/file/data/importData`,
+ lookExcel: `occupationlab/python/file/data/lookExcel`,
lookOver: `occupationlab/python/file/data/lookOver`,
batchDeletion: `occupationlab/python/file/data/batchDeletion`,
myData: `occupationlab/python/file/data/myData`
diff --git a/src/config/index.js b/src/config/index.js
index ede97dd..63b9fb1 100644
--- a/src/config/index.js
+++ b/src/config/index.js
@@ -4,7 +4,7 @@ const isHh = location.host.includes('10.196.131.73') //是否是河海版本
const isBeta = process.env.NODE_ENV === 'development' || location.host.includes('39.108.250.202') //是否是职站测试
let host = location.origin + ':9000/'
-if (process.env.NODE_ENV === 'development') host = 'http://39.108.250.202:9000/'
+if (process.env.NODE_ENV === 'development') host = 'http://192.168.31.151:9000/'
const systemId = util.getCookie('systemId')
/**
* python8个系统的id和名称
diff --git a/src/router/index.js b/src/router/index.js
index 53f3dde..166344c 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -16,6 +16,13 @@ const routes = [{
meta: {
title: '我的数据'
},
+ },
+ {
+ path: '/preview',
+ component: resolve => require(['../views/Preview'], resolve),
+ meta: {
+ title: 'excel预览'
+ },
}
];
diff --git a/src/util/index.js b/src/util/index.js
index 4a720bf..c9c0aec 100644
--- a/src/util/index.js
+++ b/src/util/index.js
@@ -44,6 +44,16 @@ export default {
if ("mp4,3gp,mov,m4v,avi,dat,mkv,flv,vob,rmvb,rm,qlv".includes(ext)) return true;
return false;
},
+ // 传入文件后缀判断是否是图片
+ isImg(ext) {
+ if ("jpg,jpeg,png,gif,svg,psd".includes(ext)) return true;
+ return false;
+ },
+ // 传入文件后缀判断是否是pdf以外的文档
+ isDoc(ext) {
+ if ("xls,xlsx,doc,docx,pdf,ppt,pptx".includes(ext)) return true;
+ return false;
+ },
// 下载文件
downloadFile(fileName,url) {
var x = new XMLHttpRequest()
diff --git a/src/views/Data.vue b/src/views/Data.vue
index 9c3eaa7..f0dbdd2 100644
--- a/src/views/Data.vue
+++ b/src/views/Data.vue
@@ -136,7 +136,13 @@ export default {
},
// 查看
show(row) {
- window.open(row.filePath)
+ // 如果是word,pdf,excel,就用预览插件打开,图片等就直接打开
+ const format = row.fileFormat
+ if ('xls,xlsx'.includes(format)) {
+ this.$router.push(`/preview?path=${row.filePath}`)
+ } else {
+ window.open((util.isDoc(format) ? 'https://view.officeapps.live.com/op/view.aspx?src=' : '') + row.filePath)
+ }
},
// 下载
download(row) {
diff --git a/src/views/Preview.vue b/src/views/Preview.vue
new file mode 100644
index 0000000..e69e4af
--- /dev/null
+++ b/src/views/Preview.vue
@@ -0,0 +1,114 @@
+
+
+
+
+
\ No newline at end of file