Commit 0011243e433c8c35d7f6ce2b3f3be15f022cbe06
Committed by
xp.Huang
1 parent
c572fab0
feat: 接口调用,新增自定义日期筛选
Showing
5 changed files
with
79 additions
and
11 deletions
| ... | ... | @@ -48,3 +48,9 @@ export const getApplicationRecordClassify = (type?: string) => { |
| 48 | 48 | url: `${ApplicationRecordManageApi.OPEN_API_RECORD}/getClassify${joinUrlParams}`, |
| 49 | 49 | }); |
| 50 | 50 | }; |
| 51 | + | |
| 52 | +export const getCustomApplicationRecordClassify = (params: Recordable) => { | |
| 53 | + return defHttp.get<ClassifyItemType[]>({ | |
| 54 | + url: `${ApplicationRecordManageApi.OPEN_API_RECORD}/getCustomClassify?type=${params.type}&endTime=${params.endTs}&startTime=${params.startTs}`, | |
| 55 | + }); | |
| 56 | +}; | ... | ... |
| ... | ... | @@ -174,5 +174,6 @@ export interface GetMeetTheConditionsDeviceParams { |
| 174 | 174 | transportType?: TransportTypeEnum; |
| 175 | 175 | isEdgeDistribution?: boolean; |
| 176 | 176 | edgeId?: string; |
| 177 | - isExcludeEdge?: boolean; | |
| 177 | + // isExcludeEdge?: boolean; | |
| 178 | + isExcludeCloud?: boolean; | |
| 178 | 179 | } | ... | ... |
| ... | ... | @@ -3,8 +3,11 @@ |
| 3 | 3 | import { useECharts } from '/@/hooks/web/useECharts'; |
| 4 | 4 | import { useAppStore } from '/@/store/modules/app'; |
| 5 | 5 | import { useI18n } from '/@/hooks/web/useI18n'; |
| 6 | - import { Empty } from 'ant-design-vue'; | |
| 6 | + import { Empty, DatePicker } from 'ant-design-vue'; | |
| 7 | 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 | 12 | const { t } = useI18n(); |
| 10 | 13 | |
| ... | ... | @@ -26,8 +29,16 @@ |
| 26 | 29 | const timeRange = ref('week'); |
| 27 | 30 | |
| 28 | 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 | 43 | label: `7${t('home.index.timeUnit.day')}`, |
| 33 | 44 | value: 'week', |
| ... | ... | @@ -52,6 +63,8 @@ |
| 52 | 63 | |
| 53 | 64 | const resizeStatus = ref(false); |
| 54 | 65 | |
| 66 | + const customDate = ref([]); | |
| 67 | + | |
| 55 | 68 | const { setOptions, resize } = useECharts(chartRef as Ref<HTMLDivElement>); |
| 56 | 69 | |
| 57 | 70 | const getOptions = (): EChartsOption => { |
| ... | ... | @@ -110,15 +123,44 @@ |
| 110 | 123 | }); |
| 111 | 124 | |
| 112 | 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 | 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 | 146 | </script> |
| 119 | 147 | <template> |
| 120 | 148 | <a-card :title="t('application.record.text.timeLineTitle')" class="w-full h-120"> |
| 121 | 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 | 164 | <a-radio-group @change="handleTimeRangeChange" v-model:value="timeRange" button-style="solid"> |
| 123 | 165 | <template v-for="(timeItem, index) in timeRangeList" :key="timeItem.value"> |
| 124 | 166 | <div style="display: none">{{ index }}</div> | ... | ... |
| ... | ... | @@ -7,7 +7,11 @@ |
| 7 | 7 | import TimeLineChart from './components/TimeLineChart.vue'; |
| 8 | 8 | import { useI18n } from '/@/hooks/web/useI18n'; |
| 9 | 9 | import { onMounted, reactive } from 'vue'; |
| 10 | - import { getApplicationRecordClassify, getApplicationRecordTop } from '/@/api/application/record'; | |
| 10 | + import { | |
| 11 | + getApplicationRecordClassify, | |
| 12 | + getApplicationRecordTop, | |
| 13 | + getCustomApplicationRecordClassify, | |
| 14 | + } from '/@/api/application/record'; | |
| 11 | 15 | import { ApplicationRecordTopItemType, TopItemType } from '/@/api/application/model/record'; |
| 12 | 16 | import { Empty } from 'ant-design-vue'; |
| 13 | 17 | import total1 from '/@/assets/images/total1.png'; |
| ... | ... | @@ -91,13 +95,27 @@ |
| 91 | 95 | const getClassify = async (type: DateInterval) => { |
| 92 | 96 | timeType.value = type; |
| 93 | 97 | const res = await getApplicationRecordClassify(type); |
| 98 | + const transformData = transformClassifyItem(res, type); | |
| 99 | + chartData.timeLineChartOptions = transformChartsOptionsByClassifyRecord(transformData, type); | |
| 100 | + }; | |
| 94 | 101 | |
| 102 | + // 自定义调用历史 | |
| 103 | + const getCustomClassify = async (type: DateInterval, dateValue: Recordable) => { | |
| 104 | + const res = await getCustomApplicationRecordClassify(dateValue); | |
| 95 | 105 | const transformData = transformClassifyItem(res, type); |
| 96 | 106 | chartData.timeLineChartOptions = transformChartsOptionsByClassifyRecord(transformData, type); |
| 97 | 107 | }; |
| 98 | 108 | |
| 99 | - const handleReceiveTimeRange = (value: DateInterval) => { | |
| 100 | - getClassify(value); | |
| 109 | + const handleReceiveTimeRange = ( | |
| 110 | + value: DateInterval, | |
| 111 | + isCustom: boolean, | |
| 112 | + dateValue: Recordable | |
| 113 | + ) => { | |
| 114 | + if (!isCustom) { | |
| 115 | + getClassify(value); | |
| 116 | + } else { | |
| 117 | + getCustomClassify(value, dateValue); | |
| 118 | + } | |
| 101 | 119 | }; |
| 102 | 120 | |
| 103 | 121 | onMounted(() => { | ... | ... |