Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
topsun-baoshen-excel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
何远江
topsun-baoshen-excel
Commits
1d57f3ea
Commit
1d57f3ea
authored
Mar 15, 2024
by
何远江
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
excel浏览添加下载
parent
442f3b3a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
index.vue
src/components/PreviewExcel/index.vue
+18
-4
No files found.
src/components/PreviewExcel/index.vue
View file @
1d57f3ea
<
template
>
<div
id=
"preview-excel"
></div>
<el-button
class=
"download-file"
@
click
.
stop=
"downloadFile"
size=
"large"
circle
type=
"primary"
>
<el-icon><Download
/></el-icon>
</el-button>
</
template
>
<
script
lang=
"ts"
setup
>
import
{
Download
}
from
'@element-plus/icons-vue'
import
{
onMounted
,
onUnmounted
,
ref
,
watch
}
from
'vue'
import
LuckyExcel
from
'luckyexcel'
import
{
getOrderFileById
}
from
'@/api/order'
...
...
@@ -15,6 +20,7 @@ import {
import
{
useRoute
}
from
'vue-router'
import
{
isFunction
}
from
'@/utils/is'
const
filePath
=
ref
(
''
)
const
props
=
defineProps
([
'fileId'
])
const
luckysheet
=
(
window
as
any
).
luckysheet
const
loading
=
ref
(
false
)
...
...
@@ -22,6 +28,8 @@ const route = useRoute()
/**生成excel */
const
generateExcel
=
(
path
:
string
)
=>
{
// 保存浏览文件的地址
filePath
.
value
=
path
LuckyExcel
.
transformExcelToLuckyByUrl
(
'/api/sys/static/'
+
path
,
new
Date
().
getTime
()
+
'.xlsx'
,
...
...
@@ -43,6 +51,10 @@ const generateExcel = (path: string) => {
)
}
const
downloadFile
=
()
=>
{
window
.
open
(
'/api/sys/static/'
+
filePath
.
value
,
'_blank'
)
}
/**获取文件路径 */
const
getFilePath
=
async
()
=>
{
try
{
...
...
@@ -71,10 +83,6 @@ watch(
)
onMounted
(()
=>
{
// luckysheet.create({
// container: 'preview-excel'
// })
getFilePath
()
})
onUnmounted
(()
=>
{
...
...
@@ -86,4 +94,10 @@ onUnmounted(() => {
width
:
100%
;
height
:
100%
;
}
.download-file
{
position
:
fixed
;
bottom
:
30px
;
right
:
20px
;
z-index
:
3000
;
}
</
style
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment