chore: 替换为commonDownloadExcel

This commit is contained in:
dap 2024-11-14 14:58:42 +08:00
parent 36c6a65d22
commit 240573e354
5 changed files with 35 additions and 72 deletions

View File

@ -21,7 +21,7 @@ import {
clientRemove,
} from '#/api/system/client';
import { TableSwitch } from '#/components/table';
import { downloadExcel } from '#/utils/file/download';
import { commonDownloadExcel } from '#/utils/file/download';
import clientDrawer from './client-drawer.vue';
import { columns, querySchema } from './data';
@ -114,6 +114,10 @@ function handleMultiDelete() {
});
}
function handleDownloadExcel() {
commonDownloadExcel(clientExport, '客户端数据', tableApi.formApi.form.values);
}
const { hasAccessByCodes } = useAccess();
</script>
@ -124,13 +128,7 @@ const { hasAccessByCodes } = useAccess();
<Space>
<a-button
v-access:code="['system:client:export']"
@click="
downloadExcel(
clientExport,
'客户端数据',
tableApi.formApi.form.values,
)
"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>

View File

@ -7,7 +7,6 @@ import { useVbenDrawer, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import dayjs from 'dayjs';
import {
tableCheckboxEvent,
@ -19,7 +18,7 @@ import {
dictDataList,
dictDataRemove,
} from '#/api/system/dict/dict-data';
import { downloadExcel } from '#/utils/file/download';
import { commonDownloadExcel } from '#/utils/file/download';
import { emitter } from '../mitt';
import { columns, querySchema } from './data';
@ -54,21 +53,6 @@ const gridOptions: VxeGridProps = {
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
//
if (formValues?.createTime) {
formValues.params = {
beginTime: dayjs(formValues.createTime[0]).format(
'YYYY-MM-DD 00:00:00',
),
endTime: dayjs(formValues.createTime[1]).format(
'YYYY-MM-DD 23:59:59',
),
};
Reflect.deleteProperty(formValues, 'createTime');
} else {
Reflect.deleteProperty(formValues, 'params');
}
const params: any = {
pageNum: page.currentPage,
pageSize: page.pageSize,
@ -136,6 +120,10 @@ function handleMultiDelete() {
});
}
function handleDownloadExcel() {
commonDownloadExcel(dictDataExport, '字典数据', tableApi.formApi.form.values);
}
emitter.on('rowClick', async (value) => {
dictType.value = value;
await tableApi.query();
@ -149,13 +137,7 @@ emitter.on('rowClick', async (value) => {
<Space>
<a-button
v-access:code="['system:dict:export']"
@click="
downloadExcel(
dictDataExport,
'字典数据',
tableApi.formApi.form.values,
)
"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>

View File

@ -31,7 +31,7 @@ import {
} from '#/api/system/dict/dict-type';
import { dictSyncTenant } from '#/api/system/tenant';
import { useTenantStore } from '#/store/tenant';
import { downloadExcel } from '#/utils/file/download';
import { commonDownloadExcel } from '#/utils/file/download';
import { emitter } from '../mitt';
import { columns, querySchema } from './data';
@ -176,6 +176,14 @@ function handleSyncTenantDict() {
});
}
function handleDownloadExcel() {
commonDownloadExcel(
dictTypeExport,
'字典类型数据',
tableApi.formApi.form.values,
);
}
const { hasAccessByRoles } = useAccess();
const tenantStore = useTenantStore();
/**
@ -206,13 +214,7 @@ const couldSyncTenantDict = computed(() => {
</Dropdown>
<a-button
v-access:code="['system:dict:export']"
@click="
downloadExcel(
dictTypeExport,
'字典类型数据',
tableApi.formApi.form.values,
)
"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>

View File

@ -7,7 +7,6 @@ import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import dayjs from 'dayjs';
import {
tableCheckboxEvent,
@ -15,7 +14,7 @@ import {
type VxeGridProps,
} from '#/adapter/vxe-table';
import { postExport, postList, postRemove } from '#/api/system/post';
import { downloadExcel } from '#/utils/file/download';
import { commonDownloadExcel } from '#/utils/file/download';
import DeptTree from '#/views/system/user/dept-tree.vue';
import { columns, querySchema } from './data';
@ -58,21 +57,6 @@ const gridOptions: VxeGridProps = {
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
//
if (formValues?.createTime) {
formValues.params = {
beginTime: dayjs(formValues.createTime[0]).format(
'YYYY-MM-DD 00:00:00',
),
endTime: dayjs(formValues.createTime[1]).format(
'YYYY-MM-DD 23:59:59',
),
};
Reflect.deleteProperty(formValues, 'createTime');
} else {
Reflect.deleteProperty(formValues, 'params');
}
//
if (selectDeptId.value.length === 1) {
formValues.belongDeptId = selectDeptId.value[0];
@ -138,6 +122,10 @@ function handleMultiDelete() {
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(postExport, '岗位信息', tableApi.formApi.form.values);
}
</script>
<template>
@ -152,13 +140,7 @@ function handleMultiDelete() {
<Space>
<a-button
v-access:code="['system:post:export']"
@click="
downloadExcel(
postExport,
'岗位信息数据',
tableApi.formApi.form.values,
)
"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>

View File

@ -25,7 +25,7 @@ import {
} from '#/api/system/tenant';
import { TableSwitch } from '#/components/table';
import { useTenantStore } from '#/store/tenant';
import { downloadExcel } from '#/utils/file/download';
import { commonDownloadExcel } from '#/utils/file/download';
import { columns, querySchema } from './data';
import tenantDrawer from './tenant-drawer.vue';
@ -142,6 +142,11 @@ function handleMultiDelete() {
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(tenantExport, '租户数据', tableApi.formApi.form.values);
}
/**
* 与后台逻辑相同
* 只有超级管理员能访问租户相关
@ -160,13 +165,7 @@ const isSuperAdmin = computed(() => {
<Space>
<a-button
v-access:code="['system:tenant:export']"
@click="
downloadExcel(
tenantExport,
'租户数据',
tableApi.formApi.form.values,
)
"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>