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
25aa6dc3
Commit
25aa6dc3
authored
Jan 11, 2025
by
何远江
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加导出数据格式.csv、.txt
parent
23405537
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
9 deletions
+20
-9
export-excel.ts
src/utils/export-excel.ts
+3
-3
Variables.vue
src/views/var/variables/Variables.vue
+3
-2
TemplateVariable.vue
src/views/var/variables/components/TemplateVariable.vue
+14
-4
No files found.
src/utils/export-excel.ts
View file @
25aa6dc3
import
*
as
XLSX
from
'xlsx'
import
*
as
XLSX
from
'xlsx'
import
{
saveAs
}
from
'file-saver'
import
{
saveAs
}
from
'file-saver'
export
function
exportExcel
(
data
:
any
[],
filename
?:
string
)
{
export
function
exportExcel
(
data
:
any
[],
bookType
:
XLSX
.
BookType
=
'xlsx'
,
filename
?:
string
,
)
{
data
.
forEach
(
row
=>
{
data
.
forEach
(
(
row
)
=>
{
delete
row
[
'_X_ROW_KEY'
]
delete
row
[
'_X_ROW_KEY'
]
})
})
const
worksheet
=
XLSX
.
utils
.
json_to_sheet
(
data
)
const
worksheet
=
XLSX
.
utils
.
json_to_sheet
(
data
)
...
@@ -11,7 +11,7 @@ export function exportExcel(data: any[], filename?: string) {
...
@@ -11,7 +11,7 @@ export function exportExcel(data: any[], filename?: string) {
XLSX
.
utils
.
book_append_sheet
(
workbook
,
worksheet
,
'Sheet1'
)
XLSX
.
utils
.
book_append_sheet
(
workbook
,
worksheet
,
'Sheet1'
)
const
excelBuffer
=
XLSX
.
write
(
workbook
,
{
bookType
:
'xlsx'
,
type
:
'array'
})
const
excelBuffer
=
XLSX
.
write
(
workbook
,
{
bookType
:
bookType
,
type
:
'array'
})
const
blob
=
new
Blob
([
excelBuffer
],
{
type
:
'application/octet-stream'
})
const
blob
=
new
Blob
([
excelBuffer
],
{
type
:
'application/octet-stream'
})
...
...
src/views/var/variables/Variables.vue
View file @
25aa6dc3
...
@@ -132,6 +132,7 @@ import { filterVarData } from '@/utils/excel'
...
@@ -132,6 +132,7 @@ import { filterVarData } from '@/utils/excel'
import
{
uploadFile
}
from
'@/api/excel'
import
{
uploadFile
}
from
'@/api/excel'
import
{
ElLoading
,
ElMessage
}
from
'element-plus'
import
{
ElLoading
,
ElMessage
}
from
'element-plus'
import
{
exportExcel
}
from
'@/utils/export-excel'
import
{
exportExcel
}
from
'@/utils/export-excel'
import
type
{
BookType
}
from
'xlsx'
const
loading
=
ref
(
false
)
const
loading
=
ref
(
false
)
const
formState
=
reactive
({
const
formState
=
reactive
({
...
@@ -248,8 +249,8 @@ const submitImport = async () => {
...
@@ -248,8 +249,8 @@ const submitImport = async () => {
}
}
}
}
const
download
=
()
=>
{
const
download
=
(
type
:
BookType
=
'xlsx'
)
=>
{
exportExcel
(
detailVariable
.
value
.
data
,
`
${
currentRow
.
value
.
orderNo
}
.xlsx
`
)
exportExcel
(
detailVariable
.
value
.
data
,
type
,
`
${
currentRow
.
value
.
orderNo
}
.
${
type
}
`
)
}
}
const
onReset
=
()
=>
{
const
onReset
=
()
=>
{
...
...
src/views/var/variables/components/TemplateVariable.vue
View file @
25aa6dc3
...
@@ -11,7 +11,17 @@
...
@@ -11,7 +11,17 @@
>
>
<template
#
default
>
<template
#
default
>
<el-button
type=
"primary"
@
click=
"download"
>
导出
</el-button>
<el-dropdown
placement=
"bottom-start"
@
command=
"handleExport"
>
<el-button
type=
"primary"
>
导出数据
</el-button>
<template
#
dropdown
>
<el-dropdown-menu>
<el-dropdown-item
command=
"xlsx"
>
*.xlsx
</el-dropdown-item>
<el-dropdown-item
command=
"txt"
>
*.txt
</el-dropdown-item>
<el-dropdown-item
command=
"csv"
>
*.csv
</el-dropdown-item>
</el-dropdown-menu>
</
template
>
</el-dropdown>
<vxe-table
ref=
"xTable"
border
:data=
"data"
size=
"small"
height=
"400"
>
<vxe-table
ref=
"xTable"
border
:data=
"data"
size=
"small"
height=
"400"
>
<vxe-column
v-for=
"column in titles"
:key=
"item"
:field=
"column"
:title=
"column"
></vxe-column>
<vxe-column
v-for=
"column in titles"
:key=
"item"
:field=
"column"
:title=
"column"
></vxe-column>
...
@@ -67,8 +77,8 @@
...
@@ -67,8 +77,8 @@
emit
(
'update:visible'
,
false
)
emit
(
'update:visible'
,
false
)
}
}
const
download
=
(
)
=>
{
const
handleExport
=
(
type
:
any
)
=>
{
emit
(
'download'
)
emit
(
'download'
,
type
)
}
}
return
{
return
{
...
@@ -76,7 +86,7 @@
...
@@ -76,7 +86,7 @@
xTable
,
xTable
,
tableData
,
tableData
,
onHide
,
onHide
,
download
handleExport
}
}
}
}
})
})
...
...
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