From 240573e3549395d2c620327c83ad75d71eb7dc9c Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Thu, 14 Nov 2024 14:58:42 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=BF=E6=8D=A2=E4=B8=BAcommonDownl?= =?UTF-8?q?oadExcel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/system/client/index.vue | 14 ++++----- .../src/views/system/dict/data/index.vue | 30 ++++--------------- .../src/views/system/dict/type/index.vue | 18 ++++++----- apps/web-antd/src/views/system/post/index.vue | 30 ++++--------------- .../src/views/system/tenant/index.vue | 15 +++++----- 5 files changed, 35 insertions(+), 72 deletions(-) diff --git a/apps/web-antd/src/views/system/client/index.vue b/apps/web-antd/src/views/system/client/index.vue index 2c76523b..c47a5a04 100644 --- a/apps/web-antd/src/views/system/client/index.vue +++ b/apps/web-antd/src/views/system/client/index.vue @@ -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(); @@ -124,13 +128,7 @@ const { hasAccessByCodes } = useAccess(); {{ $t('pages.common.export') }} diff --git a/apps/web-antd/src/views/system/dict/data/index.vue b/apps/web-antd/src/views/system/dict/data/index.vue index 4306fa29..b75d8156 100644 --- a/apps/web-antd/src/views/system/dict/data/index.vue +++ b/apps/web-antd/src/views/system/dict/data/index.vue @@ -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) => { {{ $t('pages.common.export') }} diff --git a/apps/web-antd/src/views/system/dict/type/index.vue b/apps/web-antd/src/views/system/dict/type/index.vue index c624bc9a..c8bf5089 100644 --- a/apps/web-antd/src/views/system/dict/type/index.vue +++ b/apps/web-antd/src/views/system/dict/type/index.vue @@ -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(() => { {{ $t('pages.common.export') }} diff --git a/apps/web-antd/src/views/system/post/index.vue b/apps/web-antd/src/views/system/post/index.vue index 4cd4c52c..11d1638f 100644 --- a/apps/web-antd/src/views/system/post/index.vue +++ b/apps/web-antd/src/views/system/post/index.vue @@ -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); +}