refactor:优化 date 范围查找的函数
parent
72dd0bcbde
commit
cf434f0ed1
|
@ -1,7 +1,10 @@
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
// TODO @芋艿:后续整理下
|
||||||
|
|
||||||
|
// TODO @puhui999:转成 function 方式哈
|
||||||
/** 时间段选择器拓展 */
|
/** 时间段选择器拓展 */
|
||||||
export const rangePickerExtend = () => {
|
export const getRangePickerDefaultProps = () => {
|
||||||
return {
|
return {
|
||||||
showTime: {
|
showTime: {
|
||||||
format: 'HH:mm:ss',
|
format: 'HH:mm:ss',
|
||||||
|
@ -10,28 +13,22 @@ export const rangePickerExtend = () => {
|
||||||
dayjs('23:59:59', 'HH:mm:ss'),
|
dayjs('23:59:59', 'HH:mm:ss'),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
// 如果需要10位时间戳(秒级)可以使用 valueFormat: 'X'
|
|
||||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||||
format: 'YYYY-MM-DD HH:mm:ss', // 显示格式
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
placeholder: ['开始时间', '结束时间'],
|
placeholder: ['开始时间', '结束时间'],
|
||||||
ranges: {
|
ranges: {
|
||||||
今天: [dayjs().startOf('day'), dayjs().endOf('day')],
|
'今天': [dayjs().startOf('day'), dayjs().endOf('day')],
|
||||||
|
'昨天': [
|
||||||
昨天: [
|
|
||||||
dayjs().subtract(1, 'day').startOf('day'),
|
dayjs().subtract(1, 'day').startOf('day'),
|
||||||
dayjs().subtract(1, 'day').endOf('day'),
|
dayjs().subtract(1, 'day').endOf('day'),
|
||||||
],
|
],
|
||||||
|
'本周': [dayjs().startOf('week'), dayjs().endOf('day')],
|
||||||
本周: [dayjs().startOf('week'), dayjs().endOf('day')],
|
'本月': [dayjs().startOf('month'), dayjs().endOf('day')],
|
||||||
|
'最近 7 天': [
|
||||||
本月: [dayjs().startOf('month'), dayjs().endOf('day')],
|
|
||||||
|
|
||||||
最近7天: [
|
|
||||||
dayjs().subtract(7, 'day').startOf('day'),
|
dayjs().subtract(7, 'day').startOf('day'),
|
||||||
dayjs().endOf('day'),
|
dayjs().endOf('day'),
|
||||||
],
|
],
|
||||||
|
'最近 30 天': [
|
||||||
最近30天: [
|
|
||||||
dayjs().subtract(30, 'day').startOf('day'),
|
dayjs().subtract(30, 'day').startOf('day'),
|
||||||
dayjs().endOf('day'),
|
dayjs().endOf('day'),
|
||||||
],
|
],
|
|
@ -4,6 +4,7 @@ import type { SystemMailLogApi } from '#/api/system/mail/log';
|
||||||
|
|
||||||
import { getSimpleMailAccountList } from '#/api/system/mail/account';
|
import { getSimpleMailAccountList } from '#/api/system/mail/account';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
/** 列表的搜索表单 */
|
||||||
export function useGridFormSchema(): VbenFormSchema[] {
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
@ -13,6 +14,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '发送时间',
|
label: '发送时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { z } from '#/adapter/form';
|
||||||
import { getSimpleMailAccountList } from '#/api/system/mail/account';
|
import { getSimpleMailAccountList } from '#/api/system/mail/account';
|
||||||
import { CommonStatusEnum } from '#/utils/constants';
|
import { CommonStatusEnum } from '#/utils/constants';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
@ -179,6 +180,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,6 +3,7 @@ import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||||
|
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
/** 列表的搜索表单 */
|
||||||
export function useGridFormSchema(): VbenFormSchema[] {
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
@ -40,11 +41,11 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '模版类型',
|
label: '模版类型',
|
||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
allowClear: true,
|
|
||||||
options: getDictOptions(
|
options: getDictOptions(
|
||||||
DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE,
|
DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE,
|
||||||
'number',
|
'number',
|
||||||
),
|
),
|
||||||
|
allowClear: true,
|
||||||
placeholder: '请选择模版类型',
|
placeholder: '请选择模版类型',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -53,6 +54,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,7 @@ import type { SystemNotifyTemplateApi } from '#/api/system/notify/template';
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
import { CommonStatusEnum } from '#/utils/constants';
|
import { CommonStatusEnum } from '#/utils/constants';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
import { rangePickerExtend } from '#/utils/TimeUtils';
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
@ -139,8 +139,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
...rangePickerExtend(),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -5,7 +5,7 @@ import type { SystemRoleApi } from '#/api/system/role';
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
import { CommonStatusEnum, SystemDataScopeEnum } from '#/utils/constants';
|
import { CommonStatusEnum, SystemDataScopeEnum } from '#/utils/constants';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
import { rangePickerExtend } from '#/utils/TimeUtils';
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
@ -175,8 +175,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
...rangePickerExtend(),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -5,7 +5,7 @@ import type { SystemSmsChannelApi } from '#/api/system/sms/channel';
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
import { CommonStatusEnum } from '#/utils/constants';
|
import { CommonStatusEnum } from '#/utils/constants';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
import { rangePickerExtend } from '#/utils/TimeUtils';
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
@ -121,8 +121,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
...rangePickerExtend(),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -4,7 +4,7 @@ import type { SystemSmsLogApi } from '#/api/system/sms/log';
|
||||||
|
|
||||||
import { getSimpleSmsChannelList } from '#/api/system/sms/channel';
|
import { getSimpleSmsChannelList } from '#/api/system/sms/channel';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
import { rangePickerExtend } from '#/utils/TimeUtils';
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
/** 列表的搜索表单 */
|
||||||
export function useGridFormSchema(): VbenFormSchema[] {
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
@ -54,8 +54,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '发送时间',
|
label: '发送时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
...rangePickerExtend(),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -73,8 +73,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '接收时间',
|
label: '接收时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
...rangePickerExtend(),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { z } from '#/adapter/form';
|
||||||
import { getSimpleSmsChannelList } from '#/api/system/sms/channel';
|
import { getSimpleSmsChannelList } from '#/api/system/sms/channel';
|
||||||
import { CommonStatusEnum } from '#/utils/constants';
|
import { CommonStatusEnum } from '#/utils/constants';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
@ -153,12 +154,12 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
placeholder: '请选择短信渠道',
|
placeholder: '请选择短信渠道',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// TODO @芋艿:范围检索的处理
|
|
||||||
{
|
{
|
||||||
fieldName: 'createTime',
|
fieldName: 'createTime',
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { z } from '#/adapter/form';
|
||||||
import { getTenantPackageList } from '#/api/system/tenant-package';
|
import { getTenantPackageList } from '#/api/system/tenant-package';
|
||||||
import { CommonStatusEnum } from '#/utils/constants';
|
import { CommonStatusEnum } from '#/utils/constants';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
@ -169,6 +170,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,6 +5,7 @@ import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
import { CommonStatusEnum } from '#/utils/constants';
|
import { CommonStatusEnum } from '#/utils/constants';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
@ -81,6 +82,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { getDeptList } from '#/api/system/dept';
|
||||||
import { getSimplePostList } from '#/api/system/post';
|
import { getSimplePostList } from '#/api/system/post';
|
||||||
import { getSimpleRoleList } from '#/api/system/role';
|
import { getSimpleRoleList } from '#/api/system/role';
|
||||||
import { handleTree } from '#/utils/tree';
|
import { handleTree } from '#/utils/tree';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
@ -245,10 +246,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
showTime: true,
|
|
||||||
format: 'YYYY-MM-DD HH:mm:ss',
|
|
||||||
placeholder: ['开始日期', '结束日期'],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue