|  | @@ -3,8 +3,11 @@ |  | @@ -3,8 +3,11 @@ | 
| 3 | import { useECharts } from '/@/hooks/web/useECharts'; | 3 | import { useECharts } from '/@/hooks/web/useECharts'; | 
| 4 | import { useAppStore } from '/@/store/modules/app'; | 4 | import { useAppStore } from '/@/store/modules/app'; | 
| 5 | import { useI18n } from '/@/hooks/web/useI18n'; | 5 | import { useI18n } from '/@/hooks/web/useI18n'; | 
| 6 | -  import { Empty } from 'ant-design-vue'; | 6 | +  import { Empty, DatePicker } from 'ant-design-vue'; | 
| 7 | import { EChartsOption, SeriesOption } from 'echarts'; | 7 | import { EChartsOption, SeriesOption } from 'echarts'; | 
|  |  | 8 | +  import { dateUtil } from '/@/utils/dateUtil'; | 
|  |  | 9 | +  import { RangePickerValue } from 'ant-design-vue/lib/date-picker/interface'; | 
|  |  | 10 | +  import moment from 'moment'; | 
| 8 |  | 11 |  | 
| 9 | const { t } = useI18n(); | 12 | const { t } = useI18n(); | 
| 10 |  | 13 |  | 
|  | @@ -26,8 +29,16 @@ |  | @@ -26,8 +29,16 @@ | 
| 26 | const timeRange = ref('week'); | 29 | const timeRange = ref('week'); | 
| 27 |  | 30 |  | 
| 28 | const timeRangeList = ref([ | 31 | const timeRangeList = ref([ | 
| 29 | -    { label: `1${t('home.index.timeUnit.hour')}`, value: 'hour', interval: 1000 * 60 * 5 }, |  |  | 
| 30 | -    { label: `1${t('home.index.timeUnit.day')}`, value: 'day', interval: 1000 * 60 * 60 * 1 }, | 32 | +    { | 
|  |  | 33 | +      label: `1${t('home.index.timeUnit.hour')}`, | 
|  |  | 34 | +      value: 'hour', | 
|  |  | 35 | +      interval: 1000 * 60 * 5, | 
|  |  | 36 | +    }, | 
|  |  | 37 | +    { | 
|  |  | 38 | +      label: `1${t('home.index.timeUnit.day')}`, | 
|  |  | 39 | +      value: 'day', | 
|  |  | 40 | +      interval: 1000 * 60 * 60 * 1, | 
|  |  | 41 | +    }, | 
| 31 | { | 42 | { | 
| 32 | label: `7${t('home.index.timeUnit.day')}`, | 43 | label: `7${t('home.index.timeUnit.day')}`, | 
| 33 | value: 'week', | 44 | value: 'week', | 
|  | @@ -52,6 +63,8 @@ |  | @@ -52,6 +63,8 @@ | 
| 52 |  | 63 |  | 
| 53 | const resizeStatus = ref(false); | 64 | const resizeStatus = ref(false); | 
| 54 |  | 65 |  | 
|  |  | 66 | +  const customDate = ref([]); | 
|  |  | 67 | + | 
| 55 | const { setOptions, resize } = useECharts(chartRef as Ref<HTMLDivElement>); | 68 | const { setOptions, resize } = useECharts(chartRef as Ref<HTMLDivElement>); | 
| 56 |  | 69 |  | 
| 57 | const getOptions = (): EChartsOption => { | 70 | const getOptions = (): EChartsOption => { | 
|  | @@ -110,15 +123,44 @@ |  | @@ -110,15 +123,44 @@ | 
| 110 | }); | 123 | }); | 
| 111 |  | 124 |  | 
| 112 | const handleTimeRangeChange = (e: any) => { | 125 | const handleTimeRangeChange = (e: any) => { | 
| 113 | -    const startTs = Date.now() - e.target.value; |  |  | 
| 114 | -    const endTs = Date.now(); |  |  | 
| 115 | -    emits('emitTimeRange', e.target.value, startTs, endTs); | 126 | +    emits('emitTimeRange', e.target.value, false, {}); | 
| 116 | watchClientWidth(); | 127 | watchClientWidth(); | 
| 117 | }; | 128 | }; | 
|  |  | 129 | + | 
|  |  | 130 | +  const handleCalendarChange = (val: RangePickerValue) => { | 
|  |  | 131 | +    customDate.value = val as unknown as any; | 
|  |  | 132 | +  }; | 
|  |  | 133 | + | 
|  |  | 134 | +  const handleDateOk = (range: RangePickerValue) => { | 
|  |  | 135 | +    if (!range.length) return; | 
|  |  | 136 | +    const [startTs, endTs] = range; | 
|  |  | 137 | +    const startTsTimeStamp = moment(startTs).valueOf(); | 
|  |  | 138 | +    const endTsTimeStamp = moment(endTs).valueOf(); | 
|  |  | 139 | +    const lessThanOneDay = moment(endTsTimeStamp).diff(moment(startTsTimeStamp), 'day'); | 
|  |  | 140 | +    emits('emitTimeRange', lessThanOneDay >= 1 ? 'month' : 'day', true, { | 
|  |  | 141 | +      startTs: startTsTimeStamp, | 
|  |  | 142 | +      endTs: endTsTimeStamp, | 
|  |  | 143 | +      type: lessThanOneDay >= 1 ? 'month' : 'day', | 
|  |  | 144 | +    }); | 
|  |  | 145 | +  }; | 
| 118 | </script> | 146 | </script> | 
| 119 | <template> | 147 | <template> | 
| 120 | <a-card :title="t('application.record.text.timeLineTitle')" class="w-full h-120"> | 148 | <a-card :title="t('application.record.text.timeLineTitle')" class="w-full h-120"> | 
| 121 | <template #extra> | 149 | <template #extra> | 
|  |  | 150 | +      <DatePicker.RangePicker | 
|  |  | 151 | +        style="width: 4.675rem" | 
|  |  | 152 | +        @calendarChange="handleCalendarChange" | 
|  |  | 153 | +        size="small" | 
|  |  | 154 | +        @ok="handleDateOk" | 
|  |  | 155 | +        v-model:value="customDate" | 
|  |  | 156 | +        :showTime="{ | 
|  |  | 157 | +          defaultValue: [dateUtil('00:00:00', 'HH:mm:ss'), dateUtil('23:59:59', 'HH:mm:ss')], | 
|  |  | 158 | +        }" | 
|  |  | 159 | +      > | 
|  |  | 160 | +        <a-radio-button :value="t('home.index.timeUnit.custom')"> | 
|  |  | 161 | +          {{ t('home.index.timeUnit.custom') }} | 
|  |  | 162 | +        </a-radio-button> | 
|  |  | 163 | +      </DatePicker.RangePicker> | 
| 122 | <a-radio-group @change="handleTimeRangeChange" v-model:value="timeRange" button-style="solid"> | 164 | <a-radio-group @change="handleTimeRangeChange" v-model:value="timeRange" button-style="solid"> | 
| 123 | <template v-for="(timeItem, index) in timeRangeList" :key="timeItem.value"> | 165 | <template v-for="(timeItem, index) in timeRangeList" :key="timeItem.value"> | 
| 124 | <div style="display: none">{{ index }}</div> | 166 | <div style="display: none">{{ index }}</div> |