Commit 476a5a374db17b786bfd2f46b39d5f0ab7737ddb
Merge branch 'fix/front/10-28/2024' into 'main_dev'
feat: 接口调用,新增自定义日期筛选 See merge request yunteng/thingskit-front!1519
Showing
5 changed files
with
79 additions
and
11 deletions
@@ -48,3 +48,9 @@ export const getApplicationRecordClassify = (type?: string) => { | @@ -48,3 +48,9 @@ export const getApplicationRecordClassify = (type?: string) => { | ||
48 | url: `${ApplicationRecordManageApi.OPEN_API_RECORD}/getClassify${joinUrlParams}`, | 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,5 +174,6 @@ export interface GetMeetTheConditionsDeviceParams { | ||
174 | transportType?: TransportTypeEnum; | 174 | transportType?: TransportTypeEnum; |
175 | isEdgeDistribution?: boolean; | 175 | isEdgeDistribution?: boolean; |
176 | edgeId?: string; | 176 | edgeId?: string; |
177 | - isExcludeEdge?: boolean; | 177 | + // isExcludeEdge?: boolean; |
178 | + isExcludeCloud?: boolean; | ||
178 | } | 179 | } |
@@ -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> |
@@ -7,7 +7,11 @@ | @@ -7,7 +7,11 @@ | ||
7 | import TimeLineChart from './components/TimeLineChart.vue'; | 7 | import TimeLineChart from './components/TimeLineChart.vue'; |
8 | import { useI18n } from '/@/hooks/web/useI18n'; | 8 | import { useI18n } from '/@/hooks/web/useI18n'; |
9 | import { onMounted, reactive } from 'vue'; | 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 | import { ApplicationRecordTopItemType, TopItemType } from '/@/api/application/model/record'; | 15 | import { ApplicationRecordTopItemType, TopItemType } from '/@/api/application/model/record'; |
12 | import { Empty } from 'ant-design-vue'; | 16 | import { Empty } from 'ant-design-vue'; |
13 | import total1 from '/@/assets/images/total1.png'; | 17 | import total1 from '/@/assets/images/total1.png'; |
@@ -91,13 +95,27 @@ | @@ -91,13 +95,27 @@ | ||
91 | const getClassify = async (type: DateInterval) => { | 95 | const getClassify = async (type: DateInterval) => { |
92 | timeType.value = type; | 96 | timeType.value = type; |
93 | const res = await getApplicationRecordClassify(type); | 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 | const transformData = transformClassifyItem(res, type); | 105 | const transformData = transformClassifyItem(res, type); |
96 | chartData.timeLineChartOptions = transformChartsOptionsByClassifyRecord(transformData, type); | 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 | onMounted(() => { | 121 | onMounted(() => { |
@@ -113,7 +113,8 @@ | @@ -113,7 +113,8 @@ | ||
113 | organizationId, | 113 | organizationId, |
114 | isEdgeDistribution: true, | 114 | isEdgeDistribution: true, |
115 | edgeId: props.edgeId, | 115 | edgeId: props.edgeId, |
116 | - isExcludeEdge: true, | 116 | + // isExcludeEdge: true, |
117 | + isExcludeCloud: true, | ||
117 | }); | 118 | }); |
118 | return result.map((item) => ({ | 119 | return result.map((item) => ({ |
119 | ...item, | 120 | ...item, |