wujingjing
2024-09-25 ea53838c8ba303cea39b23732f245efde987822c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import List from './components/List.vue';
import Timestamp from './components/Timestamp.vue';
import TimeRange from './components/TimeRange.vue';
import { ChartTypeEnum } from '../../../types';
 
export const enum RecordSetParamsType {
    List = 'list',
    /** @description 后端格式 */
    StartTime = 'start_time',
    EndTime = 'end_time',
    /** @description start 和 end 合并为一个 range */
    TimeRange = 'time_range',
}
 
export type BaseParam = {
    id: string;
    title: string;
    hide?: boolean;
};
 
export type ListParamListItem = {
    title: string;
    value: string;
};
export type ListParam = {
    type: RecordSetParamsType.List;
    value: string;
    list: ListParamListItem[];
} & BaseParam;
 
//#region ====================== 后端数据格式 ======================
export type TimeRangeBackEndParamType = RecordSetParamsType.StartTime | RecordSetParamsType.EndTime;
export type TimeRangeBackEndParam = {
    type: TimeRangeBackEndParamType;
    value: string;
    // 属于同一个 group 配对
    group: string;
} & BaseParam;
//#endregion
//#region ====================== 整合 start 和 end,得到前端格式 ======================
export type TimeRangeParamValue = [string, string];
export type TimeRangeParam = {
    type: RecordSetParamsType.TimeRange;
    value: TimeRangeParamValue;
    // 属于同一个 group 配对
    group: string;
    range?: [TimeRangeBackEndParam, TimeRangeBackEndParam];
} & BaseParam;
//#endregion
 
export type RecordSetParamsItem = ListParam | TimeRangeParam | TimeRangeBackEndParam;
export type RecordSet = {
    params?: RecordSetParamsItem[];
    chartType?: ChartTypeEnum;
} & Record<string, any>;
 
export const recordSetMapCom = {
    [RecordSetParamsType.List]: List,
    [RecordSetParamsType.TimeRange]: TimeRange,
    [RecordSetParamsType.StartTime]: Timestamp,
    [RecordSetParamsType.EndTime]: Timestamp,
};