Showing
6 changed files
with
43 additions
and
10 deletions
| 1 | -import type { AlarmListRequestType } from './model' | 1 | +import type { AlarmListRequestType, AlarmListResponseType } from './model' |
| 2 | import { defHttp } from '@/utils/http' | 2 | import { defHttp } from '@/utils/http' |
| 3 | 3 | ||
| 4 | enum Api { | 4 | enum Api { |
| @@ -6,7 +6,7 @@ enum Api { | @@ -6,7 +6,7 @@ enum Api { | ||
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | export function fetchAlarmList(data: AlarmListRequestType) { | 8 | export function fetchAlarmList(data: AlarmListRequestType) { |
| 9 | - return defHttp.post<AlarmListRequestType>({ | 9 | + return defHttp.post<AlarmListResponseType>({ |
| 10 | url: Api.POST_ALARM_PAGE, | 10 | url: Api.POST_ALARM_PAGE, |
| 11 | data, | 11 | data, |
| 12 | }) | 12 | }) |
| @@ -11,5 +11,32 @@ export interface AlarmListRequestType { | @@ -11,5 +11,32 @@ export interface AlarmListRequestType { | ||
| 11 | 11 | ||
| 12 | export interface AlarmListResponseType { | 12 | export interface AlarmListResponseType { |
| 13 | total: number | 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,7 +83,10 @@ export function useFormValues({ | ||
| 83 | const [startTimeFormat, endTimeFormat]: DateFormatEnum[] = Array.isArray(format) ? format : [format, format] | 83 | const [startTimeFormat, endTimeFormat]: DateFormatEnum[] = Array.isArray(format) ? format : [format, format] |
| 84 | 84 | ||
| 85 | values[startTimeKey] = formatToDateTime(startTime, startTimeFormat) | 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 | Reflect.deleteProperty(values, field) | 91 | Reflect.deleteProperty(values, field) |
| 89 | } | 92 | } |
| @@ -46,8 +46,8 @@ const setFieldsValue = (value: Recordable) => { | @@ -46,8 +46,8 @@ const setFieldsValue = (value: Recordable) => { | ||
| 46 | formActionType.setFieldsValue(value) | 46 | formActionType.setFieldsValue(value) |
| 47 | formActionType.setFieldsValue({ | 47 | formActionType.setFieldsValue({ |
| 48 | alarmListQueryDate: [ | 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,6 +65,7 @@ export const formSchemas: FormSchema[] = [ | ||
| 65 | params: unref(contentDataStore.getProductIds), | 65 | params: unref(contentDataStore.getProductIds), |
| 66 | labelField: ['alias', 'name'], | 66 | labelField: ['alias', 'name'], |
| 67 | valueField: 'id', | 67 | valueField: 'id', |
| 68 | + maxTagCount: 4, | ||
| 68 | onSelect(value: string, option: DeviceItemType) { | 69 | onSelect(value: string, option: DeviceItemType) { |
| 69 | formModel[AlarmListFieldsEnum.DEVICE_PROFILE_ID] = value ? option.deviceProfileId : null | 70 | formModel[AlarmListFieldsEnum.DEVICE_PROFILE_ID] = value ? option.deviceProfileId : null |
| 70 | }, | 71 | }, |
| @@ -6,7 +6,6 @@ import type { alarmListInterface } from './config' | @@ -6,7 +6,6 @@ import type { alarmListInterface } from './config' | ||
| 6 | import { options } from './config' | 6 | import { options } from './config' |
| 7 | import { useAlarmList } from './useAlarmList.hook' | 7 | import { useAlarmList } from './useAlarmList.hook' |
| 8 | import { fetchAlarmList } from '@/api/alarm' | 8 | import { fetchAlarmList } from '@/api/alarm' |
| 9 | -import type { AlarmListResponseType } from '@/api/alarm/model' | ||
| 10 | import type { CreateComponentType } from '@/core/Library/types' | 9 | import type { CreateComponentType } from '@/core/Library/types' |
| 11 | import { useContentDataStore } from '@/store/modules/contentData' | 10 | import { useContentDataStore } from '@/store/modules/contentData' |
| 12 | import { isLightboxMode } from '@/utils/env' | 11 | import { isLightboxMode } from '@/utils/env' |
| @@ -36,25 +35,28 @@ const initOptions = reactive<{ | @@ -36,25 +35,28 @@ const initOptions = reactive<{ | ||
| 36 | }) | 35 | }) |
| 37 | 36 | ||
| 38 | const fetchAlarmListConfig = computed(() => { | 37 | const fetchAlarmListConfig = computed(() => { |
| 39 | - return contentDataStore?.contentData.filter((item) => { | 38 | + return contentDataStore?.contentData.find((item) => { |
| 40 | return props.config.cellInfo?.id === item.id | 39 | return props.config.cellInfo?.id === item.id |
| 41 | }) | 40 | }) |
| 42 | }) | 41 | }) |
| 43 | 42 | ||
| 44 | const initFetchAlarmList = async () => { | 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 | if (!dataSourceJson) return | 46 | if (!dataSourceJson) return |
| 47 | const { alarmListOption } = dataSourceJson | 47 | const { alarmListOption } = dataSourceJson |
| 48 | if (!alarmListOption) return | 48 | if (!alarmListOption) return |
| 49 | const { startTime, endTime, deviceId, interval, autoPlay, polling } | 49 | const { startTime, endTime, deviceId, interval, autoPlay, polling } |
| 50 | = alarmListOption | 50 | = alarmListOption |
| 51 | + | ||
| 51 | const resp = (await fetchAlarmList({ | 52 | const resp = (await fetchAlarmList({ |
| 52 | startTime, | 53 | startTime, |
| 53 | endTime, | 54 | endTime, |
| 54 | deviceIds: deviceId, | 55 | deviceIds: deviceId, |
| 55 | page: 1, | 56 | page: 1, |
| 56 | pageSize: 30, | 57 | pageSize: 30, |
| 57 | - })) as any as AlarmListResponseType | 58 | + })) |
| 59 | + | ||
| 58 | initOptions.alarmList = resp.items || [] | 60 | initOptions.alarmList = resp.items || [] |
| 59 | initOptions.interval = interval || 0 | 61 | initOptions.interval = interval || 0 |
| 60 | initOptions.scroll = autoPlay || false | 62 | initOptions.scroll = autoPlay || false |