From 1b02b7e1915a6735322f1693d99b391afb736f78 Mon Sep 17 00:00:00 2001 From: dhb52 Date: Sat, 22 Jun 2024 15:59:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(sj=5F1.1.0):=20=E6=B7=BB=E5=8A=A0=E6=89=B9?= =?UTF-8?q?=E6=AC=A1=E6=90=9C=E7=B4=A2=E6=97=B6=E9=97=B4=E5=8C=BA=E9=97=B4?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/datetime-range.vue | 38 ++++-------------------- src/utils/common.ts | 29 ++++++++++++++++++ src/views/home/modules/task-tab.vue | 7 +---- src/views/job/batch/index.vue | 7 ++--- src/views/retry/dead-letter/index.vue | 4 +-- src/views/retry/log/index.vue | 4 +-- src/views/workflow/batch/index.vue | 4 ++- 7 files changed, 45 insertions(+), 48 deletions(-) diff --git a/src/components/common/datetime-range.vue b/src/components/common/datetime-range.vue index 706c2a9..c780241 100644 --- a/src/components/common/datetime-range.vue +++ b/src/components/common/datetime-range.vue @@ -1,60 +1,34 @@ diff --git a/src/utils/common.ts b/src/utils/common.ts index 6fc8aae..ab2388a 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -1,4 +1,5 @@ import { Md5 } from 'ts-md5'; +import dayjs from 'dayjs'; import { $t } from '@/locales'; /** @@ -117,3 +118,31 @@ export function toggleHtmlClass(className: string) { remove }; } + +/** + * 创建 `最近n个自然月` timestamp时间区间 + * + * @param months 月数 + * @param startOf 时间的开始类型 + * @returns timestamp时间区间 + */ +export function monthRange(months: number = 1, startOf: dayjs.OpUnitType = 'day') { + return [dayjs().subtract(months, 'month').startOf(startOf).valueOf(), dayjs().endOf('day').valueOf()] as [ + number, + number + ]; +} + +/** + * 创建 `最近n个自然月` 字符串时间区间 + * + * @param months 月数 + * @param startOf 时间的开始类型 + * @returns 字符串时间区间 + */ +export function monthRangeISO8601(months: number = 1, startOf: dayjs.OpUnitType = 'day') { + return [ + dayjs().subtract(months, 'month').startOf(startOf).format('YYYY-MM-DDTHH:mm:ss'), + dayjs().endOf('day').format('YYYY-MM-DDTHH:mm:ss') + ] as [string, string]; +} diff --git a/src/views/home/modules/task-tab.vue b/src/views/home/modules/task-tab.vue index 60f6759..403a282 100644 --- a/src/views/home/modules/task-tab.vue +++ b/src/views/home/modules/task-tab.vue @@ -204,12 +204,7 @@ getGroupNames(); - + diff --git a/src/views/job/batch/index.vue b/src/views/job/batch/index.vue index 4ed9111..053afd4 100644 --- a/src/views/job/batch/index.vue +++ b/src/views/job/batch/index.vue @@ -7,7 +7,7 @@ import { $t } from '@/locales'; import { useAppStore } from '@/store/modules/app'; import { useTable } from '@/hooks/common/table'; import { operationReasonRecord, taskBatchStatusRecord } from '@/constants/business'; -import { tagColor } from '@/utils/common'; +import { monthRangeISO8601, tagColor } from '@/utils/common'; import JobBatchSearch from './modules/job-batch-search.vue'; import JobBatchDetailDrawer from './modules/job-batch-detail-drawer.vue'; @@ -27,10 +27,7 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP groupName: null, jobName: null, taskBatchStatus: null, - datetimeRange: null - - // beginDate: null, - // endDate: null + datetimeRange: monthRangeISO8601() }, searchParams: { jobName, diff --git a/src/views/retry/dead-letter/index.vue b/src/views/retry/dead-letter/index.vue index c810836..fb45cf0 100644 --- a/src/views/retry/dead-letter/index.vue +++ b/src/views/retry/dead-letter/index.vue @@ -13,7 +13,7 @@ import { $t } from '@/locales'; import { useAppStore } from '@/store/modules/app'; import { useTable, useTableOperate } from '@/hooks/common/table'; import { retryTaskTypeRecord } from '@/constants/business'; -import { tagColor } from '@/utils/common'; +import { monthRangeISO8601, tagColor } from '@/utils/common'; import RetryDeadLetterSearch from './modules/dead-letter-search.vue'; import RetryDeadLetterDetailDrawer from './modules/retry-letter-detail-drawer.vue'; @@ -31,7 +31,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP size: 10, groupName: null, sceneName: null, - datetimeRange: null + datetimeRange: monthRangeISO8601() // if you want to use the searchParams in Form, you need to define the following properties, and the value is null // the value can not be undefined, otherwise the property in Form will not be reactive }, diff --git a/src/views/retry/log/index.vue b/src/views/retry/log/index.vue index df49819..80f37a7 100644 --- a/src/views/retry/log/index.vue +++ b/src/views/retry/log/index.vue @@ -7,7 +7,7 @@ import { $t } from '@/locales'; import { useAppStore } from '@/store/modules/app'; import { useTable, useTableOperate } from '@/hooks/common/table'; import { retryTaskStatusTypeRecord, retryTaskTypeRecord } from '@/constants/business'; -import { tagColor } from '@/utils/common'; +import { monthRangeISO8601, tagColor } from '@/utils/common'; import RetryLogSearch from './modules/retry-log-search.vue'; import RetryLogDetailDrawer from './modules/retry-log-detail-drawer.vue'; @@ -32,7 +32,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP idempotentId: null, bizNo: null, retryStatus: null, - datetimeRange: null + datetimeRange: monthRangeISO8601() }, searchParams: { retryStatus diff --git a/src/views/workflow/batch/index.vue b/src/views/workflow/batch/index.vue index 54096c9..c877943 100644 --- a/src/views/workflow/batch/index.vue +++ b/src/views/workflow/batch/index.vue @@ -6,7 +6,9 @@ import { $t } from '@/locales'; import { useAppStore } from '@/store/modules/app'; import { useTable, useTableOperate } from '@/hooks/common/table'; import { operationReasonRecord, taskBatchStatusRecord } from '@/constants/business'; +import { monthRangeISO8601 } from '@/utils/common'; import WorkflowBatchSearch from './modules/workflow-batch-search.vue'; + const router = useRouter(); const appStore = useAppStore(); @@ -23,7 +25,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP workflowId: null, groupName: null, taskBatchStatus: null, - datetimeRange: null + datetimeRange: monthRangeISO8601() }, searchParams: { workflowId,