mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-22 11:36:37 +08:00
optimize(projects): optimize page code: plugin_excel
This commit is contained in:
parent
c425822b3a
commit
fa4367a7b9
@ -1,7 +1,6 @@
|
|||||||
<script setup lang="tsx">
|
<script setup lang="tsx">
|
||||||
import { NButton, NTag } from 'naive-ui';
|
import { NButton, NTag } from 'naive-ui';
|
||||||
import { utils, writeFile } from 'xlsx';
|
import { utils, writeFile } from 'xlsx';
|
||||||
import type { DataTableBaseColumn } from 'naive-ui';
|
|
||||||
import { useAppStore } from '@/store/modules/app';
|
import { useAppStore } from '@/store/modules/app';
|
||||||
import { useTable } from '@/hooks/common/table';
|
import { useTable } from '@/hooks/common/table';
|
||||||
import { fetchGetUserList } from '@/service/api';
|
import { fetchGetUserList } from '@/service/api';
|
||||||
@ -104,7 +103,6 @@ const { columns, data, loading } = useTable({
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
const tableTitleList = columns.value.slice(2) as DataTableBaseColumn[];
|
|
||||||
function exportExcel() {
|
function exportExcel() {
|
||||||
const exportColumns = columns.value.slice(2);
|
const exportColumns = columns.value.slice(2);
|
||||||
|
|
||||||
@ -118,7 +116,7 @@ function exportExcel() {
|
|||||||
|
|
||||||
const workSheet = utils.aoa_to_sheet(excelList);
|
const workSheet = utils.aoa_to_sheet(excelList);
|
||||||
|
|
||||||
workSheet['!cols'] = tableTitleList.map(item => ({
|
workSheet['!cols'] = exportColumns.map(item => ({
|
||||||
width: Math.round(Number(item.width) / 10 || 20)
|
width: Math.round(Number(item.width) / 10 || 20)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user