From 65d46fec51054fa75b7dc8eec4da9800658704fa Mon Sep 17 00:00:00 2001 From: xlsea Date: Sat, 30 Mar 2024 17:55:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=9B=BE=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/typings/components.d.ts | 1 + src/views/home/index.vue | 46 +++++++++++++++++++-- src/views/home/modules/line-retry-chart.vue | 7 ++++ src/views/home/modules/retry-tab.vue | 12 ++++-- 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/src/typings/components.d.ts b/src/typings/components.d.ts index 5fc771c..7fd15c4 100644 --- a/src/typings/components.d.ts +++ b/src/typings/components.d.ts @@ -43,6 +43,7 @@ declare module 'vue' { NCheckbox: typeof import('naive-ui')['NCheckbox'] NColorPicker: typeof import('naive-ui')['NColorPicker'] NDataTable: typeof import('naive-ui')['NDataTable'] + NDatePicker: typeof import('naive-ui')['NDatePicker'] NDescriptions: typeof import('naive-ui')['NDescriptions'] NDescriptionsItem: typeof import('naive-ui')['NDescriptionsItem'] NDialogProvider: typeof import('naive-ui')['NDialogProvider'] diff --git a/src/views/home/index.vue b/src/views/home/index.vue index 491f94e..625ed83 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -16,6 +16,10 @@ const cardCount = ref(); const tabParams = ref({ type: 'WEEK' }); +const dateRange = ref<[number, number] | null>(); +const formattedValue = ref<[string, string] | null>( + tabParams.value.startTime && tabParams.value.endTime ? [tabParams.value.startTime, tabParams.value.endTime] : null +); const getCardData = async () => { const { data: cardData, error } = await fetchCardCount(); @@ -25,6 +29,29 @@ const getCardData = async () => { }; getCardData(); + +const onUpdateDate = (value: [string, string]) => { + if (value) { + tabParams.value.type = 'OTHERS'; + tabParams.value.startTime = value[0]; + tabParams.value.endTime = value[1]; + } +}; + +const onClearDate = () => { + tabParams.value.type = 'WEEK'; + tabParams.value.startTime = undefined; + tabParams.value.endTime = undefined; +}; + +const onUpdateType = (value: string) => { + if (value !== 'OTHERS') { + dateRange.value = null; + formattedValue.value = null; + tabParams.value.startTime = undefined; + tabParams.value.endTime = undefined; + } +};