diff --git a/src/hooks/useRangePicker.ts b/src/hooks/useRangePicker.ts new file mode 100644 index 00000000..61190722 --- /dev/null +++ b/src/hooks/useRangePicker.ts @@ -0,0 +1,47 @@ +import dayjs from 'dayjs'; + +/**日期快捷选择 */ +export function dayjsRanges() { + return [ + { + label: 'Today', + value: [dayjs().startOf('day'), dayjs()], + }, + { + label: 'Last 1 hour', + value: [ + dayjs().subtract(1, 'hour').startOf('hour'), + dayjs().subtract(1, 'hour').endOf('hour'), + ], + }, + // { + // label: 'Last 3 hour', + // value: [dayjs().subtract(3, 'hours'), dayjs()], + // }, + // { + // label: 'Last 6 hour', + // value: [dayjs().subtract(6, 'hours'), dayjs()], + // }, + { + label: 'Last 1 day', + value: [ + dayjs().subtract(1, 'day').startOf('day'), + dayjs().subtract(1, 'day').endOf('day'), + ], + }, + { + label: 'Last 7 day', + value: [ + dayjs().subtract(7, 'day').startOf('day'), + dayjs().subtract(1, 'day').endOf('day'), + ], + }, + { + label: 'Last 15 day', + value: [ + dayjs().subtract(15, 'day').startOf('day'), + dayjs().subtract(1, 'day').endOf('day'), + ], + }, + ]; +} diff --git a/src/views/dashboard/imsCDR/index.vue b/src/views/dashboard/imsCDR/index.vue index 12230357..6b7b9a0c 100644 --- a/src/views/dashboard/imsCDR/index.vue +++ b/src/views/dashboard/imsCDR/index.vue @@ -24,6 +24,7 @@ import PQueue from 'p-queue'; import { listTenant } from '@/api/system/tenant'; import { useClipboard } from '@vueuse/core'; import dayjs, { type Dayjs } from 'dayjs'; +import { dayjsRanges } from '@/hooks/useRangePicker'; const { copy } = useClipboard({ legacy: true }); const { t } = useI18n(); const { getDict } = useDictStore(); @@ -52,21 +53,6 @@ let queryRangePicker = ref<[Dayjs, Dayjs] | undefined>([ dayjs().startOf('hour'), dayjs().endOf('hour'), ]); -/**时间范围 */ -let rangePickerPresets = ref([ - { - label: 'Now hour', - value: [dayjs().startOf('hour'), dayjs().endOf('hour')], - }, - { label: 'Today', value: [dayjs().startOf('day'), dayjs().endOf('day')] }, - { - label: 'Yesterday', - value: [ - dayjs().subtract(1, 'day').startOf('day'), - dayjs().subtract(1, 'day').endOf('day'), - ], - }, -]); /**查询参数 */ let queryParams = reactive({ @@ -648,7 +634,7 @@ onBeforeUnmount(() => { > ([ dayjs().startOf('hour'), dayjs().endOf('hour'), ]); -/**时间范围 */ -let rangePickerPresets = ref([ - { - label: 'Now hour', - value: [dayjs().startOf('hour'), dayjs().endOf('hour')], - }, - { label: 'Today', value: [dayjs().startOf('day'), dayjs().endOf('day')] }, - { - label: 'Yesterday', - value: [ - dayjs().subtract(1, 'day').startOf('day'), - dayjs().subtract(1, 'day').endOf('day'), - ], - }, -]); /**查询参数 */ let queryParams = reactive({ @@ -579,7 +565,7 @@ onBeforeUnmount(() => { > ([ dayjs().startOf('hour'), dayjs().endOf('hour'), ]); -/**时间范围 */ -let rangePickerPresets = ref([ - { - label: 'Now hour', - value: [dayjs().startOf('hour'), dayjs().endOf('hour')], - }, - { label: 'Today', value: [dayjs().startOf('day'), dayjs().endOf('day')] }, - { - label: 'Yesterday', - value: [ - dayjs().subtract(1, 'day').startOf('day'), - dayjs().subtract(1, 'day').endOf('day'), - ], - }, -]); /**查询参数 */ let queryParams = reactive({ @@ -612,7 +598,7 @@ onBeforeUnmount(() => { > {
{{ t('views.dashboard.cdr.time') }}: - {{ parseDateToStr(record.cdrJSON.invocationTimestamp) }} + {{ + parseDateToStr(record.cdrJSON.invocationTimestamp) + }}
{{ t('views.dashboard.cdr.rowInfo') }} @@ -858,15 +846,21 @@ onBeforeUnmount(() => {
Data Volume Uplink: - {{ parseSizeFromByte(udata.dataVolumeUplink, 'MB') }} + {{ + parseSizeFromByte(udata.dataVolumeUplink, 'MB') + }}
Data Volume Downlink: - {{ parseSizeFromByte(udata.dataVolumeDownlink, 'MB') }} + {{ + parseSizeFromByte(udata.dataVolumeDownlink, 'MB') + }}
Data Total Volume: - {{ parseSizeFromByte(udata.dataTotalVolume, 'MB') }} + {{ + parseSizeFromByte(udata.dataTotalVolume, 'MB') + }}