From 9c4c2f1f2860dee1482860c0042aee5fed0cca8c Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Wed, 12 Nov 2025 18:11:21 +0800 Subject: [PATCH] =?UTF-8?q?excel=20=E9=A2=84=E8=A7=88=E9=9B=86=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 7 +- src/main.js | 4 + src/views/common/DocumentExcel.vue | 392 +++++++++++++++++- .../technical/components/child/FileInfo.vue | 2 +- vue.config.js | 38 ++ 5 files changed, 438 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 99c2817..c75e8f2 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "dependencies": { "@riophae/vue-treeselect": "0.4.0", "@vue-office/docx": "^1.6.3", + "@vue-office/excel": "^1.7.14", "@vue/composition-api": "^1.7.2", "axios": "0.28.1", "clipboard": "2.0.8", @@ -40,8 +41,11 @@ "js-beautify": "1.13.0", "js-cookie": "3.0.1", "jsencrypt": "3.0.0-rc.1", + "jquery": "^3.6.0", + "jquery-mousewheel": "^3.1.13", "jszip": "^3.10.1", "lodash": "^4.17.21", + "luckysheet": "^2.1.13", "mammoth": "^1.11.0", "nprogress": "0.2.0", "pdfjs-dist": "^2.16.105", @@ -58,7 +62,8 @@ "vue-pdf": "^4.3.0", "vue-router": "3.4.9", "vuedraggable": "2.24.3", - "vuex": "3.6.0" + "vuex": "3.6.0", + "xlsx": "^0.18.5" }, "devDependencies": { "@vue/cli-plugin-babel": "4.4.6", diff --git a/src/main.js b/src/main.js index acce779..efd0133 100644 --- a/src/main.js +++ b/src/main.js @@ -2,6 +2,10 @@ import Vue from 'vue' import Cookies from 'js-cookie' +// 全局引入 jQuery,Luckysheet 需要它 +import $ from 'jquery' +window.$ = window.jQuery = $ + import Element from 'element-ui' import './assets/styles/element-variables.scss' diff --git a/src/views/common/DocumentExcel.vue b/src/views/common/DocumentExcel.vue index 4020307..c2afdb2 100644 --- a/src/views/common/DocumentExcel.vue +++ b/src/views/common/DocumentExcel.vue @@ -1,13 +1,399 @@ - \ No newline at end of file diff --git a/src/views/enterpriseLibrary/technical/components/child/FileInfo.vue b/src/views/enterpriseLibrary/technical/components/child/FileInfo.vue index 4191cdc..771ae55 100644 --- a/src/views/enterpriseLibrary/technical/components/child/FileInfo.vue +++ b/src/views/enterpriseLibrary/technical/components/child/FileInfo.vue @@ -19,7 +19,7 @@ // 默认参数 const defaultParams = { fileType: 'technical_solution', - uploadType: 'pdf、doc、docx', + uploadType: 'pdf、doc、docx、xls、xlsx', maxFileTips: '500MB', fileUploadRule: { fileUploadType: 'technical_solution', diff --git a/vue.config.js b/vue.config.js index 2045dab..3848aa4 100644 --- a/vue.config.js +++ b/vue.config.js @@ -107,6 +107,44 @@ module.exports = { config.plugins.delete('preload') // TODO: need test config.plugins.delete('prefetch') // TODO: need test + // 处理 .ico 文件 - 必须在 CSS 规则之前 + config.module + .rule('ico') + .test(/\.ico$/) + .use('file-loader') + .loader('file-loader') + .options({ + name: 'static/[name].[hash:8].[ext]', + esModule: false + }) + .end() + + // 配置 CSS loader 忽略 .ico 文件的 url 处理 + const cssRule = config.module.rule('css') + if (cssRule && cssRule.oneOfs) { + cssRule.oneOfs.store.forEach((oneOf) => { + oneOf.uses.store.forEach((use, useKey) => { + if (use.name && use.name.includes('css-loader')) { + oneOf.use(useKey).tap(options => { + if (!options) options = {} + const originalUrl = options.url + options.url = (url, resourcePath) => { + // 忽略 .ico 文件的 url,避免 webpack 处理 + if (url && typeof url === 'string' && (url.endsWith('.ico') || url.includes('.ico'))) { + return false + } + if (typeof originalUrl === 'function') { + return originalUrl(url, resourcePath) + } + return originalUrl !== false + } + return options + }) + } + }) + }) + } + // set svg-sprite-loader config.module .rule('svg')