1
|
1
|
import { unref } from 'vue'
|
2
|
2
|
import dayjs from 'dayjs'
|
3
|
3
|
import { TableColumnFieldEnum } from './types'
|
4
|
|
-import { getListByDeviceProfileIds } from '@/api/device'
|
|
4
|
+import { getListByConfigurationId, getListByDeviceProfileIds } from '@/api/device'
|
5
|
5
|
import type { DeviceItemType } from '@/api/device/model'
|
6
|
6
|
import type { FormSchema } from '@/components/Form'
|
7
|
7
|
import { ComponentEnum } from '@/components/Form/src/enum'
|
...
|
...
|
@@ -9,8 +9,7 @@ import { useContentDataStoreWithOut } from '@/store/modules/contentData' |
9
|
9
|
import { DateFormatEnum } from '@/enums/timeEnum'
|
10
|
10
|
import type { BasicColumn } from '@/components/Table'
|
11
|
11
|
import { AlarmStatusEnum, type CodeTypeEnum, type ContentDataFieldsEnum } from '@/enums/datasource'
|
12
|
|
-
|
13
|
|
-const contentDataStore = useContentDataStoreWithOut()
|
|
12
|
+import { useParseParams } from '@/core/LoadData'
|
14
|
13
|
|
15
|
14
|
export const tableColumns: BasicColumn[] = [
|
16
|
15
|
{
|
...
|
...
|
@@ -73,88 +72,94 @@ const rangePresets = [ |
73
|
72
|
{ label: '360天之前', value: [dayjs().add(-360, 'd'), dayjs()] },
|
74
|
73
|
]
|
75
|
74
|
|
76
|
|
-export const formSchemas: FormSchema[] = [
|
77
|
|
- {
|
78
|
|
- field: AlarmListFieldsEnum.DEVICE_PROFILE_ID,
|
79
|
|
- label: AlarmListFieldsNameEnum.DEVICE_PROFILE_ID,
|
80
|
|
- component: ComponentEnum.INPUT,
|
81
|
|
- ifShow: false,
|
82
|
|
- },
|
83
|
|
- {
|
84
|
|
- field: AlarmListFieldsEnum.DEVICE_ID,
|
85
|
|
- label: AlarmListFieldsNameEnum.DEVICE_ID,
|
86
|
|
- component: ComponentEnum.API_SELECT,
|
87
|
|
- required: true,
|
88
|
|
- componentProps: ({ formModel }) => {
|
89
|
|
- const organizationId = window.useParseParams().organizationId
|
90
|
|
- if (!organizationId) return
|
91
|
|
- return {
|
92
|
|
- mode: 'multiple',
|
93
|
|
- showSearch: true,
|
94
|
|
- api: getListByDeviceProfileIds,
|
95
|
|
- params: {
|
96
|
|
- deviceProfileIds: unref(contentDataStore.getProductIds),
|
97
|
|
- organizationId,
|
98
|
|
- },
|
99
|
|
- aliasField: 'alias',
|
100
|
|
- fieldNames: { label: 'name', value: 'id' },
|
101
|
|
- maxTagCount: 4,
|
102
|
|
- onSelect(value: string, option: DeviceItemType) {
|
103
|
|
- formModel[AlarmListFieldsEnum.DEVICE_PROFILE_ID] = value ? option.deviceProfileId : null
|
104
|
|
- },
|
105
|
|
- filterOption: (inputValue: string, option: DeviceItemType) =>
|
106
|
|
- option.alias?.includes?.(inputValue) || option.name?.includes?.(inputValue),
|
107
|
|
- }
|
|
75
|
+export const getFormSchemas = (): FormSchema[] => {
|
|
76
|
+ const contentDataStore = useContentDataStoreWithOut()
|
|
77
|
+ const isTemplateLink = contentDataStore.getIsTemplateLink
|
|
78
|
+ return [
|
|
79
|
+ {
|
|
80
|
+ field: AlarmListFieldsEnum.DEVICE_PROFILE_ID,
|
|
81
|
+ label: AlarmListFieldsNameEnum.DEVICE_PROFILE_ID,
|
|
82
|
+ component: ComponentEnum.INPUT,
|
|
83
|
+ ifShow: false,
|
108
|
84
|
},
|
109
|
|
- },
|
110
|
|
- {
|
111
|
|
- field: AlarmListFieldsEnum.ALARM_LIST_QUERY_DATE,
|
112
|
|
- label: AlarmListFieldsNameEnum.ALARM_LIST_QUERY_DATE,
|
113
|
|
- component: ComponentEnum.RANGE_PICKER,
|
114
|
|
- required: true,
|
115
|
|
- componentProps: () => {
|
116
|
|
- return {
|
117
|
|
- showSearch: true,
|
118
|
|
- format: DateFormatEnum.YYYY_MM_DD_HH_MM_SS,
|
119
|
|
- presets: rangePresets,
|
120
|
|
- placement: 'topRight',
|
121
|
|
- showTime: true,
|
122
|
|
- }
|
|
85
|
+ {
|
|
86
|
+ field: AlarmListFieldsEnum.DEVICE_ID,
|
|
87
|
+ label: AlarmListFieldsNameEnum.DEVICE_ID,
|
|
88
|
+ component: ComponentEnum.API_SELECT,
|
|
89
|
+ required: true,
|
|
90
|
+ componentProps: ({ formModel }) => {
|
|
91
|
+ const { organizationId, configurationId } = useParseParams()
|
|
92
|
+ if (!organizationId) return
|
|
93
|
+ return {
|
|
94
|
+ mode: 'multiple',
|
|
95
|
+ showSearch: true,
|
|
96
|
+ api: async (params: Recordable) => {
|
|
97
|
+ return isTemplateLink ? await getListByConfigurationId(configurationId!) : await getListByDeviceProfileIds(params)
|
|
98
|
+ },
|
|
99
|
+ params: {
|
|
100
|
+ deviceProfileIds: unref(contentDataStore.getProductIds),
|
|
101
|
+ organizationId,
|
|
102
|
+ },
|
|
103
|
+ aliasField: 'alias',
|
|
104
|
+ fieldNames: { label: 'name', value: 'id' },
|
|
105
|
+ maxTagCount: 4,
|
|
106
|
+ onSelect(value: string, option: DeviceItemType) {
|
|
107
|
+ formModel[AlarmListFieldsEnum.DEVICE_PROFILE_ID] = value ? option.deviceProfileId : null
|
|
108
|
+ },
|
|
109
|
+ filterOption: (inputValue: string, option: DeviceItemType) =>
|
|
110
|
+ option.alias?.includes?.(inputValue) || option.name?.includes?.(inputValue),
|
|
111
|
+ }
|
|
112
|
+ },
|
123
|
113
|
},
|
124
|
|
- },
|
125
|
|
- {
|
126
|
|
- field: AlarmListFieldsEnum.ALARM_LIST_AUTO_PLAY,
|
127
|
|
- label: AlarmListFieldsNameEnum.ALARM_LIST_AUTO_PLAY,
|
128
|
|
- component: ComponentEnum.SWITCH,
|
129
|
|
- required: false,
|
130
|
|
- },
|
131
|
|
- {
|
132
|
|
- field: AlarmListFieldsEnum.ALARM_LIST_INTERVAL,
|
133
|
|
- label: AlarmListFieldsNameEnum.ALARM_LIST_INTERVAL,
|
134
|
|
- component: ComponentEnum.INPUT_NUMBER,
|
135
|
|
- required: false,
|
136
|
|
- componentProps: {
|
137
|
|
- min: 0,
|
|
114
|
+ {
|
|
115
|
+ field: AlarmListFieldsEnum.ALARM_LIST_QUERY_DATE,
|
|
116
|
+ label: AlarmListFieldsNameEnum.ALARM_LIST_QUERY_DATE,
|
|
117
|
+ component: ComponentEnum.RANGE_PICKER,
|
|
118
|
+ required: true,
|
|
119
|
+ componentProps: () => {
|
|
120
|
+ return {
|
|
121
|
+ showSearch: true,
|
|
122
|
+ format: DateFormatEnum.YYYY_MM_DD_HH_MM_SS,
|
|
123
|
+ presets: rangePresets,
|
|
124
|
+ placement: 'topRight',
|
|
125
|
+ showTime: true,
|
|
126
|
+ }
|
|
127
|
+ },
|
138
|
128
|
},
|
139
|
|
- renderComponentContent: () => {
|
140
|
|
- return {
|
141
|
|
- addonAfter: () => '秒',
|
142
|
|
- }
|
|
129
|
+ {
|
|
130
|
+ field: AlarmListFieldsEnum.ALARM_LIST_AUTO_PLAY,
|
|
131
|
+ label: AlarmListFieldsNameEnum.ALARM_LIST_AUTO_PLAY,
|
|
132
|
+ component: ComponentEnum.SWITCH,
|
|
133
|
+ required: false,
|
143
|
134
|
},
|
144
|
|
- },
|
145
|
|
- {
|
146
|
|
- field: AlarmListFieldsEnum.ALARM_LIST_POLLING,
|
147
|
|
- label: AlarmListFieldsNameEnum.ALARM_LIST_POLLING,
|
148
|
|
- component: ComponentEnum.INPUT_NUMBER,
|
149
|
|
- defaultValue: 30,
|
150
|
|
- required: false,
|
151
|
|
- componentProps: {
|
152
|
|
- min: 1,
|
|
135
|
+ {
|
|
136
|
+ field: AlarmListFieldsEnum.ALARM_LIST_INTERVAL,
|
|
137
|
+ label: AlarmListFieldsNameEnum.ALARM_LIST_INTERVAL,
|
|
138
|
+ component: ComponentEnum.INPUT_NUMBER,
|
|
139
|
+ required: false,
|
|
140
|
+ componentProps: {
|
|
141
|
+ min: 0,
|
|
142
|
+ },
|
|
143
|
+ renderComponentContent: () => {
|
|
144
|
+ return {
|
|
145
|
+ addonAfter: () => '秒',
|
|
146
|
+ }
|
|
147
|
+ },
|
153
|
148
|
},
|
154
|
|
- renderComponentContent: () => {
|
155
|
|
- return {
|
156
|
|
- addonAfter: () => '秒',
|
157
|
|
- }
|
|
149
|
+ {
|
|
150
|
+ field: AlarmListFieldsEnum.ALARM_LIST_POLLING,
|
|
151
|
+ label: AlarmListFieldsNameEnum.ALARM_LIST_POLLING,
|
|
152
|
+ component: ComponentEnum.INPUT_NUMBER,
|
|
153
|
+ defaultValue: 30,
|
|
154
|
+ required: false,
|
|
155
|
+ componentProps: {
|
|
156
|
+ min: 1,
|
|
157
|
+ },
|
|
158
|
+ renderComponentContent: () => {
|
|
159
|
+ return {
|
|
160
|
+ addonAfter: () => '秒',
|
|
161
|
+ }
|
|
162
|
+ },
|
158
|
163
|
},
|
159
|
|
- },
|
160
|
|
-] |
|
164
|
+ ]
|
|
165
|
+} |
...
|
...
|
|