Showing
6 changed files
with
43 additions
and
10 deletions
1 | -import type { AlarmListRequestType } from './model' | |
1 | +import type { AlarmListRequestType, AlarmListResponseType } from './model' | |
2 | 2 | import { defHttp } from '@/utils/http' |
3 | 3 | |
4 | 4 | enum Api { |
... | ... | @@ -6,7 +6,7 @@ enum Api { |
6 | 6 | } |
7 | 7 | |
8 | 8 | export function fetchAlarmList(data: AlarmListRequestType) { |
9 | - return defHttp.post<AlarmListRequestType>({ | |
9 | + return defHttp.post<AlarmListResponseType>({ | |
10 | 10 | url: Api.POST_ALARM_PAGE, |
11 | 11 | data, |
12 | 12 | }) | ... | ... |
... | ... | @@ -11,5 +11,32 @@ export interface AlarmListRequestType { |
11 | 11 | |
12 | 12 | export interface AlarmListResponseType { |
13 | 13 | total: number |
14 | - items: any[] | |
14 | + items: AlarmListItemType[] | |
15 | 15 | } |
16 | + | |
17 | +export interface AlarmListItemType { | |
18 | + id: string | |
19 | + tenantId: string | |
20 | + creator: any | |
21 | + updater: any | |
22 | + createdTime: string | |
23 | + updatedTime: string | |
24 | + customerId: string | |
25 | + tbDeviceId: string | |
26 | + originatorType: number | |
27 | + deviceId: string | |
28 | + deviceName: string | |
29 | + type: string | |
30 | + severity: string | |
31 | + status: string | |
32 | + startTs: string | |
33 | + endTs: string | |
34 | + ackTs: string | |
35 | + clearTs: string | |
36 | + propagate: boolean | |
37 | + propagateRelationTypes: any | |
38 | + organizationId: string | |
39 | + organizationName: string | |
40 | + deviceAlias: string | |
41 | +} | |
42 | + | ... | ... |
... | ... | @@ -83,7 +83,10 @@ export function useFormValues({ |
83 | 83 | const [startTimeFormat, endTimeFormat]: DateFormatEnum[] = Array.isArray(format) ? format : [format, format] |
84 | 84 | |
85 | 85 | values[startTimeKey] = formatToDateTime(startTime, startTimeFormat) |
86 | - values[startTimeKey] = formatToDateTime(endTime, endTimeFormat) | |
86 | + values[endTimeKey] = formatToDateTime(endTime, endTimeFormat) | |
87 | + | |
88 | + if (startTimeFormat === DateFormatEnum.X) values[startTimeKey] = Number(values[startTimeKey]) | |
89 | + if (endTimeFormat === DateFormatEnum.X) values[endTimeKey] = Number(values[endTimeKey]) | |
87 | 90 | |
88 | 91 | Reflect.deleteProperty(values, field) |
89 | 92 | } | ... | ... |
... | ... | @@ -46,8 +46,8 @@ const setFieldsValue = (value: Recordable) => { |
46 | 46 | formActionType.setFieldsValue(value) |
47 | 47 | formActionType.setFieldsValue({ |
48 | 48 | alarmListQueryDate: [ |
49 | - dateUtil(Number(value?.startTime), DateFormatEnum.YYYY_MM_DD_HH_MM), | |
50 | - dateUtil(Number(value?.endTime), DateFormatEnum.YYYY_MM_DD_HH_MM), | |
49 | + dateUtil(Number(value?.startTime)), | |
50 | + dateUtil(Number(value?.endTime)), | |
51 | 51 | ], |
52 | 52 | }) |
53 | 53 | } | ... | ... |
... | ... | @@ -65,6 +65,7 @@ export const formSchemas: FormSchema[] = [ |
65 | 65 | params: unref(contentDataStore.getProductIds), |
66 | 66 | labelField: ['alias', 'name'], |
67 | 67 | valueField: 'id', |
68 | + maxTagCount: 4, | |
68 | 69 | onSelect(value: string, option: DeviceItemType) { |
69 | 70 | formModel[AlarmListFieldsEnum.DEVICE_PROFILE_ID] = value ? option.deviceProfileId : null |
70 | 71 | }, | ... | ... |
... | ... | @@ -6,7 +6,6 @@ import type { alarmListInterface } from './config' |
6 | 6 | import { options } from './config' |
7 | 7 | import { useAlarmList } from './useAlarmList.hook' |
8 | 8 | import { fetchAlarmList } from '@/api/alarm' |
9 | -import type { AlarmListResponseType } from '@/api/alarm/model' | |
10 | 9 | import type { CreateComponentType } from '@/core/Library/types' |
11 | 10 | import { useContentDataStore } from '@/store/modules/contentData' |
12 | 11 | import { isLightboxMode } from '@/utils/env' |
... | ... | @@ -36,25 +35,28 @@ const initOptions = reactive<{ |
36 | 35 | }) |
37 | 36 | |
38 | 37 | const fetchAlarmListConfig = computed(() => { |
39 | - return contentDataStore?.contentData.filter((item) => { | |
38 | + return contentDataStore?.contentData.find((item) => { | |
40 | 39 | return props.config.cellInfo?.id === item.id |
41 | 40 | }) |
42 | 41 | }) |
43 | 42 | |
44 | 43 | const initFetchAlarmList = async () => { |
45 | - const { dataSourceJson } = unref(fetchAlarmListConfig.value[0]) as Recordable | |
44 | + if (!unref(fetchAlarmListConfig)) return | |
45 | + const { dataSourceJson } = unref(fetchAlarmListConfig.value)! | |
46 | 46 | if (!dataSourceJson) return |
47 | 47 | const { alarmListOption } = dataSourceJson |
48 | 48 | if (!alarmListOption) return |
49 | 49 | const { startTime, endTime, deviceId, interval, autoPlay, polling } |
50 | 50 | = alarmListOption |
51 | + | |
51 | 52 | const resp = (await fetchAlarmList({ |
52 | 53 | startTime, |
53 | 54 | endTime, |
54 | 55 | deviceIds: deviceId, |
55 | 56 | page: 1, |
56 | 57 | pageSize: 30, |
57 | - })) as any as AlarmListResponseType | |
58 | + })) | |
59 | + | |
58 | 60 | initOptions.alarmList = resp.items || [] |
59 | 61 | initOptions.interval = interval || 0 |
60 | 62 | initOptions.scroll = autoPlay || false | ... | ... |