Showing
6 changed files
with
47 additions
and
6 deletions
@@ -2,6 +2,7 @@ import { DeviceProfileModel } from '../../device/model/deviceModel'; | @@ -2,6 +2,7 @@ import { DeviceProfileModel } from '../../device/model/deviceModel'; | ||
2 | import { HistoryData } from './model'; | 2 | import { HistoryData } from './model'; |
3 | import { defHttp } from '/@/utils/http/axios'; | 3 | import { defHttp } from '/@/utils/http/axios'; |
4 | import { isString } from '/@/utils/is'; | 4 | import { isString } from '/@/utils/is'; |
5 | +import { OrderByEnum } from '/@/views/device/localtion/cpns/TimePeriodForm/config'; | ||
5 | 6 | ||
6 | // 获取设备配置 | 7 | // 获取设备配置 |
7 | export const getDeviceProfile = (deviceType?: string) => { | 8 | export const getDeviceProfile = (deviceType?: string) => { |
@@ -12,11 +13,11 @@ export const getDeviceProfile = (deviceType?: string) => { | @@ -12,11 +13,11 @@ export const getDeviceProfile = (deviceType?: string) => { | ||
12 | }; | 13 | }; |
13 | 14 | ||
14 | // 获取历史数据 | 15 | // 获取历史数据 |
15 | -export const getDeviceHistoryInfo = (params: Recordable, orderBy?: string) => { | 16 | +export const getDeviceHistoryInfo = (params: Recordable, orderBy = OrderByEnum.DESC) => { |
16 | return defHttp.get<HistoryData>( | 17 | return defHttp.get<HistoryData>( |
17 | { | 18 | { |
18 | url: `/plugins/telemetry/DEVICE/${params.entityId}/values/timeseries`, | 19 | url: `/plugins/telemetry/DEVICE/${params.entityId}/values/timeseries`, |
19 | - params: { ...params, entityId: null, orderBy: orderBy || 'DESC' }, | 20 | + params: { orderBy, ...params, entityId: null }, |
20 | }, | 21 | }, |
21 | { | 22 | { |
22 | joinPrefix: false, | 23 | joinPrefix: false, |
@@ -5,7 +5,10 @@ | @@ -5,7 +5,10 @@ | ||
5 | import { useECharts } from '/@/hooks/web/useECharts'; | 5 | import { useECharts } from '/@/hooks/web/useECharts'; |
6 | import { AggregateDataEnum, selectDeviceAttrSchema } from '/@/views/device/localtion/config.data'; | 6 | import { AggregateDataEnum, selectDeviceAttrSchema } from '/@/views/device/localtion/config.data'; |
7 | import { useTimePeriodForm } from '/@/views/device/localtion/cpns/TimePeriodForm'; | 7 | import { useTimePeriodForm } from '/@/views/device/localtion/cpns/TimePeriodForm'; |
8 | - import { defaultSchemas } from '/@/views/device/localtion/cpns/TimePeriodForm/config'; | 8 | + import { |
9 | + defaultSchemas, | ||
10 | + OrderByEnum, | ||
11 | + } from '/@/views/device/localtion/cpns/TimePeriodForm/config'; | ||
9 | import TimePeriodForm from '/@/views/device/localtion/cpns/TimePeriodForm/TimePeriodForm.vue'; | 12 | import TimePeriodForm from '/@/views/device/localtion/cpns/TimePeriodForm/TimePeriodForm.vue'; |
10 | import { useGridLayout } from '/@/hooks/component/useGridLayout'; | 13 | import { useGridLayout } from '/@/hooks/component/useGridLayout'; |
11 | import { ColEx } from '/@/components/Form/src/types'; | 14 | import { ColEx } from '/@/components/Form/src/types'; |
@@ -184,7 +187,6 @@ | @@ -184,7 +187,6 @@ | ||
184 | if (props.attr) { | 187 | if (props.attr) { |
185 | method.setFieldsValue({ keys: props.attr }); | 188 | method.setFieldsValue({ keys: props.attr }); |
186 | const attrInfo = unref(deviceAttrs).find((item) => item.identifier === props.attr); | 189 | const attrInfo = unref(deviceAttrs).find((item) => item.identifier === props.attr); |
187 | - console.log({ attrInfo }); | ||
188 | if ( | 190 | if ( |
189 | [DataTypeEnum.IS_STRING, DataTypeEnum.IS_STRUCT].includes( | 191 | [DataTypeEnum.IS_STRING, DataTypeEnum.IS_STRUCT].includes( |
190 | attrInfo?.detail.dataType.type as unknown as DataTypeEnum | 192 | attrInfo?.detail.dataType.type as unknown as DataTypeEnum |
@@ -198,7 +200,7 @@ | @@ -198,7 +200,7 @@ | ||
198 | } catch (error) {} | 200 | } catch (error) {} |
199 | }; | 201 | }; |
200 | 202 | ||
201 | - const openHistoryPanel = async (orderBy?: string) => { | 203 | + const openHistoryPanel = async (orderBy = OrderByEnum.ASC) => { |
202 | await nextTick(); | 204 | await nextTick(); |
203 | method.updateSchema({ | 205 | method.updateSchema({ |
204 | field: 'keys', | 206 | field: 'keys', |
@@ -32,13 +32,14 @@ export function useHistoryData() { | @@ -32,13 +32,14 @@ export function useHistoryData() { | ||
32 | }; | 32 | }; |
33 | 33 | ||
34 | function getSearchParams(value: Partial<Record<SchemaFiled, string>>) { | 34 | function getSearchParams(value: Partial<Record<SchemaFiled, string>>) { |
35 | - const { startTs, endTs, interval, agg, limit, keys, way, deviceId } = value; | 35 | + const { startTs, endTs, interval, agg, limit, keys, way, deviceId, orderBy } = value; |
36 | const basicRecord = { | 36 | const basicRecord = { |
37 | entityId: deviceId, | 37 | entityId: deviceId, |
38 | keys: keys ? keys : unref(getDeviceKeys).join(), | 38 | keys: keys ? keys : unref(getDeviceKeys).join(), |
39 | interval, | 39 | interval, |
40 | agg, | 40 | agg, |
41 | limit, | 41 | limit, |
42 | + orderBy, | ||
42 | }; | 43 | }; |
43 | if (way === QueryWay.LATEST) { | 44 | if (way === QueryWay.LATEST) { |
44 | return Object.assign(basicRecord, { | 45 | return Object.assign(basicRecord, { |
@@ -21,6 +21,16 @@ export enum SchemaFiled { | @@ -21,6 +21,16 @@ export enum SchemaFiled { | ||
21 | ORDER_BY = 'orderBy', | 21 | ORDER_BY = 'orderBy', |
22 | } | 22 | } |
23 | 23 | ||
24 | +export enum OrderByEnum { | ||
25 | + DESC = 'DESC', | ||
26 | + ASC = 'ASC', | ||
27 | +} | ||
28 | + | ||
29 | +export enum OrderByNameEnum { | ||
30 | + DESC = '降序', | ||
31 | + ASC = '升序', | ||
32 | +} | ||
33 | + | ||
24 | export enum AggregateDataEnum { | 34 | export enum AggregateDataEnum { |
25 | MIN = 'MIN', | 35 | MIN = 'MIN', |
26 | MAX = 'MAX', | 36 | MAX = 'MAX', |
@@ -31,6 +41,18 @@ export enum AggregateDataEnum { | @@ -31,6 +41,18 @@ export enum AggregateDataEnum { | ||
31 | } | 41 | } |
32 | export const defaultSchemas: FormSchema[] = [ | 42 | export const defaultSchemas: FormSchema[] = [ |
33 | { | 43 | { |
44 | + field: SchemaFiled.ORDER_BY, | ||
45 | + label: '数据排序', | ||
46 | + component: 'Select', | ||
47 | + defaultValue: OrderByEnum.ASC, | ||
48 | + componentProps: { | ||
49 | + options: Object.values(OrderByEnum).map((value) => ({ | ||
50 | + value, | ||
51 | + label: OrderByNameEnum[value], | ||
52 | + })), | ||
53 | + }, | ||
54 | + }, | ||
55 | + { | ||
34 | field: SchemaFiled.WAY, | 56 | field: SchemaFiled.WAY, |
35 | label: '查询方式', | 57 | label: '查询方式', |
36 | component: 'RadioGroup', | 58 | component: 'RadioGroup', |
@@ -8,6 +8,7 @@ import { | @@ -8,6 +8,7 @@ import { | ||
8 | getPacketIntervalByValue, | 8 | getPacketIntervalByValue, |
9 | intervalOption, | 9 | intervalOption, |
10 | } from '/@/views/device/localtion/cpns/TimePeriodForm/helper'; | 10 | } from '/@/views/device/localtion/cpns/TimePeriodForm/helper'; |
11 | +import { OrderByEnum, OrderByNameEnum } from '/@/views/device/localtion/cpns/TimePeriodForm/config'; | ||
11 | export enum QueryWay { | 12 | export enum QueryWay { |
12 | LATEST = 'latest', | 13 | LATEST = 'latest', |
13 | TIME_PERIOD = 'timePeriod', | 14 | TIME_PERIOD = 'timePeriod', |
@@ -38,6 +39,18 @@ export enum AggregateDataEnum { | @@ -38,6 +39,18 @@ export enum AggregateDataEnum { | ||
38 | export const formSchema = (): FormSchema[] => { | 39 | export const formSchema = (): FormSchema[] => { |
39 | return [ | 40 | return [ |
40 | { | 41 | { |
42 | + field: SchemaFiled.ORDER_BY, | ||
43 | + label: '数据排序', | ||
44 | + component: 'Select', | ||
45 | + defaultValue: OrderByEnum.ASC, | ||
46 | + componentProps: { | ||
47 | + options: Object.values(OrderByEnum).map((value) => ({ | ||
48 | + value, | ||
49 | + label: OrderByNameEnum[value], | ||
50 | + })), | ||
51 | + }, | ||
52 | + }, | ||
53 | + { | ||
41 | field: SchemaFiled.DEVICE_ID, | 54 | field: SchemaFiled.DEVICE_ID, |
42 | label: '设备名称', | 55 | label: '设备名称', |
43 | component: 'Select', | 56 | component: 'Select', |
@@ -22,6 +22,7 @@ | @@ -22,6 +22,7 @@ | ||
22 | import { ModalParamsType } from '/#/utils'; | 22 | import { ModalParamsType } from '/#/utils'; |
23 | import { WidgetDataType } from '../../hooks/useDataSource'; | 23 | import { WidgetDataType } from '../../hooks/useDataSource'; |
24 | import { ExtraDataSource } from '../../types'; | 24 | import { ExtraDataSource } from '../../types'; |
25 | + import { OrderByEnum } from '/@/views/device/localtion/cpns/TimePeriodForm/config'; | ||
25 | 26 | ||
26 | type DeviceOption = Record<'label' | 'value' | 'organizationId', string>; | 27 | type DeviceOption = Record<'label' | 'value' | 'organizationId', string>; |
27 | 28 | ||
@@ -211,6 +212,7 @@ | @@ -211,6 +212,7 @@ | ||
211 | endTs: Date.now(), | 212 | endTs: Date.now(), |
212 | agg: AggregateDataEnum.NONE, | 213 | agg: AggregateDataEnum.NONE, |
213 | limit: 7, | 214 | limit: 7, |
215 | + orderBy: OrderByEnum.ASC, | ||
214 | }); | 216 | }); |
215 | historyData.value = getTableHistoryData(res); | 217 | historyData.value = getTableHistoryData(res); |
216 | // 判断对象是否为空 | 218 | // 判断对象是否为空 |