refactor: 重构下载excel及区间选择器字段逻辑处理
This commit is contained in:
@@ -7,7 +7,6 @@ import { Page, useVbenModal, 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,
|
||||
@@ -20,7 +19,7 @@ import {
|
||||
configRefreshCache,
|
||||
configRemove,
|
||||
} from '#/api/system/config';
|
||||
import { downloadExcel } from '#/utils/file/download';
|
||||
import { commonDownloadExcel } from '#/utils/file/download';
|
||||
|
||||
import configModal from './config-modal.vue';
|
||||
import { columns, querySchema } from './data';
|
||||
@@ -34,6 +33,14 @@ const formOptions: VbenFormProps = {
|
||||
},
|
||||
schema: querySchema(),
|
||||
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
|
||||
// 日期选择格式化
|
||||
fieldMappingTime: [
|
||||
[
|
||||
'createTime',
|
||||
['params[beginTime]', 'params[endTime]'],
|
||||
['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'],
|
||||
],
|
||||
],
|
||||
};
|
||||
|
||||
const gridOptions: VxeGridProps = {
|
||||
@@ -50,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');
|
||||
}
|
||||
|
||||
return await configList({
|
||||
pageNum: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
@@ -123,6 +115,12 @@ function handleMultiDelete() {
|
||||
});
|
||||
}
|
||||
|
||||
function handleDownloadExcel() {
|
||||
commonDownloadExcel(configExport, '参数配置', tableApi.formApi.form.values, {
|
||||
fieldMappingTime: formOptions.fieldMappingTime,
|
||||
});
|
||||
}
|
||||
|
||||
async function handleRefreshCache() {
|
||||
await configRefreshCache();
|
||||
await tableApi.query();
|
||||
@@ -137,13 +135,7 @@ async function handleRefreshCache() {
|
||||
<a-button @click="handleRefreshCache"> 刷新缓存 </a-button>
|
||||
<a-button
|
||||
v-access:code="['system:config:export']"
|
||||
@click="
|
||||
downloadExcel(
|
||||
configExport,
|
||||
'参数配置',
|
||||
tableApi.formApi.form.values,
|
||||
)
|
||||
"
|
||||
@click="handleDownloadExcel"
|
||||
>
|
||||
{{ $t('pages.common.export') }}
|
||||
</a-button>
|
||||
|
Reference in New Issue
Block a user