Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
najiu-frontend
najiu-admin-template
Commits
a207cafe
Commit
a207cafe
authored
Oct 19, 2020
by
jq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(excel): update excel demo
parent
7101587b
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
202 additions
and
42 deletions
+202
-42
ExportExcelModel.vue
src/components/Excel/src/ExportExcelModel.vue
+2
-1
charts.ts
src/router/menus/modules/demo/charts.ts
+22
-0
comp.ts
src/router/menus/modules/demo/comp.ts
+0
-14
charts.ts
src/router/routes/modules/demo/charts.ts
+42
-0
comp.ts
src/router/routes/modules/demo/comp.ts
+0
-26
ArrayExport.vue
src/views/demo/echarts/excel/ArrayExport.vue
+36
-0
CustomExport.vue
src/views/demo/echarts/excel/CustomExport.vue
+43
-0
ImportExcel.vue
src/views/demo/echarts/excel/ImportExcel.vue
+1
-1
JsonExport.vue
src/views/demo/echarts/excel/JsonExport.vue
+56
-0
data.ts
src/views/demo/echarts/excel/data.ts
+0
-0
No files found.
src/components/Excel/src/ExportExcelModel.vue
View file @
a207cafe
...
...
@@ -12,6 +12,7 @@
import
{
defineComponent
}
from
'
vue
'
;
import
{
BasicModal
,
useModalInner
}
from
'
/@/components/Modal
'
;
import
{
BasicForm
,
FormSchema
,
useForm
}
from
'
/@/components/Form/index
'
;
import
{
ExportModalResult
}
from
'
./types
'
;
const
schemas
:
FormSchema
[]
=
[
{
...
...
@@ -59,7 +60,7 @@
const
[
registerModal
,
{
closeModal
}]
=
useModalInner
();
async
function
handleOk
()
{
const
res
=
await
validateFields
();
const
res
:
ExportModalResult
=
await
validateFields
();
const
{
filename
,
bookType
}
=
res
;
emit
(
'
success
'
,
{
...
...
src/router/menus/modules/demo/charts.ts
View file @
a207cafe
...
...
@@ -27,6 +27,28 @@ const menu: MenuModule = {
},
],
},
// {
// path: '/excel',
// name: 'excel',
// children: [
{
path
:
'
/customExport
'
,
name
:
'
选择导出格式
'
,
},
{
path
:
'
/jsonExport
'
,
name
:
'
JSON数据导出
'
,
},
{
path
:
'
/arrayExport
'
,
name
:
'
Array数据导出
'
,
},
{
path
:
'
/importExcel
'
,
name
:
'
导入
'
,
},
// ],
// },
],
},
};
...
...
src/router/menus/modules/demo/comp.ts
View file @
a207cafe
...
...
@@ -66,20 +66,6 @@ const menu: MenuModule = {
path
:
'
/strength-meter
'
,
name
:
'
密码强度组件
'
,
},
{
path
:
'
/excel
'
,
name
:
'
excel
'
,
children
:
[
{
path
:
'
/export
'
,
name
:
'
Export
'
,
},
{
path
:
'
/import
'
,
name
:
'
Import
'
,
},
],
},
],
},
};
...
...
src/router/routes/modules/demo/charts.ts
View file @
a207cafe
...
...
@@ -56,5 +56,47 @@ export default {
},
component
:
()
=>
import
(
'
/@/views/demo/echarts/apex/index.vue
'
),
},
// {
// path: '/excel',
// name: 'ExcelDemo',
// redirect: '/charts/excel/export',
// meta: {
// title: 'excel',
// },
// children: [
{
path
:
'
/customExport
'
,
name
:
'
CustomExport
'
,
component
:
()
=>
import
(
'
/@/views/demo/echarts/excel/CustomExport.vue
'
),
meta
:
{
title
:
'
选择导出格式
'
,
},
},
{
path
:
'
/jsonExport
'
,
name
:
'
JsonExport
'
,
component
:
()
=>
import
(
'
/@/views/demo/echarts/excel/JsonExport.vue
'
),
meta
:
{
title
:
'
JSON数据导出
'
,
},
},
{
path
:
'
/arrayExport
'
,
name
:
'
ArrayExport
'
,
component
:
()
=>
import
(
'
/@/views/demo/echarts/excel/ArrayExport.vue
'
),
meta
:
{
title
:
'
Array数据导出
'
,
},
},
{
path
:
'
/importExcel
'
,
name
:
'
ImportExcel
'
,
component
:
()
=>
import
(
'
/@/views/demo/echarts/excel/ImportExcel.vue
'
),
meta
:
{
title
:
'
导入
'
,
},
},
// ],
// },
],
}
as
AppRouteModule
;
src/router/routes/modules/demo/comp.ts
View file @
a207cafe
...
...
@@ -136,31 +136,5 @@ export default {
title
:
'
密码强度组件
'
,
},
},
{
path
:
'
/excel
'
,
name
:
'
ExcelDemo
'
,
redirect
:
'
/comp/excel/export
'
,
meta
:
{
title
:
'
excel
'
,
},
children
:
[
{
path
:
'
export
'
,
name
:
'
Export2Excel
'
,
component
:
()
=>
import
(
'
/@/views/demo/comp/excel/ExportToExcel.vue
'
),
meta
:
{
title
:
'
Export2Excel
'
,
},
},
{
path
:
'
import
'
,
name
:
'
ImportExcel
'
,
component
:
()
=>
import
(
'
/@/views/demo/comp/excel/ImportExcel.vue
'
),
meta
:
{
title
:
'
ImportExcel
'
,
},
},
],
},
],
}
as
AppRouteModule
;
src/views/demo/echarts/excel/ArrayExport.vue
0 → 100644
View file @
a207cafe
<
template
>
<div
class=
"m-4"
>
<BasicTable
title=
"基础表格"
:columns=
"columns"
:dataSource=
"data"
>
<template
#toolbar
>
<a-button
@
click=
"aoaToExcel"
>
导出
</a-button>
</
template
>
</BasicTable>
</div>
</template>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'
vue
'
;
import
{
BasicTable
}
from
'
/@/components/Table
'
;
import
{
aoaToSheetXlsx
,
ExportExcelModel
}
from
'
/@/components/Excel
'
;
import
{
arrHeader
,
arrData
,
columns
,
data
}
from
'
./data
'
;
export
default
defineComponent
({
components
:
{
BasicTable
,
ExportExcelModel
},
setup
()
{
function
aoaToExcel
()
{
// 保证data顺序与header一致
aoaToSheetXlsx
({
data
:
arrData
,
header
:
arrHeader
,
filename
:
'
二维数组方式导出excel.xlsx
'
,
});
}
return
{
aoaToExcel
,
columns
,
data
,
};
},
});
</
script
>
src/views/demo/echarts/excel/CustomExport.vue
0 → 100644
View file @
a207cafe
<
template
>
<div
class=
"m-4"
>
<BasicTable
title=
"基础表格"
:columns=
"columns"
:dataSource=
"data"
>
<template
#toolbar
>
<a-button
@
click=
"openModal"
>
导出
</a-button>
</
template
>
</BasicTable>
<ExportExcelModel
@
register=
"register"
@
success=
"defaultHeader"
/>
</div>
</template>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'
vue
'
;
import
{
BasicTable
}
from
'
/@/components/Table
'
;
import
{
jsonToSheetXlsx
,
ExportExcelModel
,
ExportModalResult
}
from
'
/@/components/Excel
'
;
import
{
columns
,
data
}
from
'
./data
'
;
import
{
useModal
}
from
'
/@/components/Modal
'
;
export
default
defineComponent
({
components
:
{
BasicTable
,
ExportExcelModel
},
setup
()
{
function
defaultHeader
({
filename
,
bookType
}:
ExportModalResult
)
{
// 默认Object.keys(data[0])作为header
jsonToSheetXlsx
({
data
,
filename
,
write2excelOpts
:
{
bookType
,
},
});
}
const
[
register
,
{
openModal
}]
=
useModal
();
return
{
defaultHeader
,
columns
,
data
,
register
,
openModal
,
};
},
});
</
script
>
src/views/demo/
comp
/excel/ImportExcel.vue
→
src/views/demo/
echarts
/excel/ImportExcel.vue
View file @
a207cafe
<
template
>
<div>
<div
class=
"m-4"
>
<ImportExcel
@
success=
"loadDataSuccess"
>
<a-button
class=
"m-3"
>
导入Excel
</a-button>
</ImportExcel>
...
...
src/views/demo/
comp/excel/ExportToExcel
.vue
→
src/views/demo/
echarts/excel/JsonExport
.vue
View file @
a207cafe
<
template
>
<div>
<div
class=
"m-4"
>
<BasicTable
title=
"基础表格"
:columns=
"columns"
:dataSource=
"data"
>
<template
#toolbar
>
<a-button
@
click=
"openModal"
>
JSON格式导出:默认头部
</a-button>
<a-button
@
click=
"customHeader"
>
JSON格式导出:自定义头部
</a-button>
<a-button
@
click=
"aoaToExcel"
>
二维数组格式导出
</a-button>
<a-button
@
click=
"defaultHeader"
>
导出:默认头部
</a-button>
<a-button
@
click=
"customHeader"
>
导出:自定义头部
</a-button>
</
template
>
</BasicTable>
<ExportExcelModel
@
register=
"register"
@
success=
"defaultHeader"
/>
</div>
</template>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'
vue
'
;
import
{
BasicTable
}
from
'
/@/components/Table
'
;
import
{
jsonToSheetXlsx
,
aoaToSheetXlsx
,
ExportExcelModel
,
ExportModalResult
,
}
from
'
/@/components/Excel
'
;
import
{
columns
,
data
,
arrHeader
,
arrData
}
from
'
./data
'
;
import
{
useModal
}
from
'
/@/components/Modal
'
;
import
{
jsonToSheetXlsx
,
ExportExcelModel
}
from
'
/@/components/Excel
'
;
import
{
columns
,
data
}
from
'
./data
'
;
export
default
defineComponent
({
components
:
{
BasicTable
,
ExportExcelModel
},
setup
()
{
function
defaultHeader
(
{
filename
,
bookType
}:
ExportModalResult
)
{
function
defaultHeader
()
{
// 默认Object.keys(data[0])作为header
jsonToSheetXlsx
({
data
,
filename
,
write2excelOpts
:
{
bookType
,
},
filename
:
'
使用key作为默认头部.xlsx
'
,
});
}
function
customHeader
()
{
...
...
@@ -48,31 +37,19 @@
beginTime
:
'
开始时间
'
,
endTime
:
'
结束时间
'
,
},
filename
:
'
文件名头部修改
.xlsx
'
,
filename
:
'
自定义头部
.xlsx
'
,
json2sheetOpts
:
{
// 指定顺序
header
:
[
'
name
'
,
'
id
'
],
},
});
}
function
aoaToExcel
()
{
// 保证data顺序与header一致
aoaToSheetXlsx
({
data
:
arrData
,
header
:
arrHeader
,
filename
:
'
数组方式导出excel.xlsx
'
,
});
}
const
[
register
,
{
openModal
}]
=
useModal
();
return
{
defaultHeader
,
customHeader
,
aoaToExcel
,
columns
,
data
,
register
,
openModal
,
};
},
});
...
...
src/views/demo/
comp
/excel/data.ts
→
src/views/demo/
echarts
/excel/data.ts
View file @
a207cafe
File moved
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