data.ts
10.1 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
import { FormSchema } from '/@/components/Form';
// import { getOrganizationList } from '/@/api/system/system';
// import { copyTransFun } from '/@/utils/fnUtils';
import { deviceConfigGetRuleChain } from '/@/api/device/deviceConfigApi';
import { ref } from 'vue';
import { findDictItemByCode } from '/@/api/system/dict';
import { alarmContactGetPage } from '/@/api/device/deviceConfigApi';
export const step1Schemas: FormSchema[] = [
{
field: 'name',
label: '配置名称',
required: true,
component: 'Input',
componentProps: {
maxLength: 30,
},
},
//规则链(string)
{
field: 'defaultRuleChainId',
label: '请选择规则链',
component: 'ApiSelect',
componentProps: {
api: async () => {
const data = await deviceConfigGetRuleChain();
const returnData = data.map((m) => {
return {
getValueField: m.name,
getKeyField: m.id.id,
};
});
return returnData;
},
labelField: 'getValueField',
valueField: 'getKeyField',
immediate: true,
},
},
// {
// field: 'icon',
// component: 'Upload',
// label: '请上传图片',
// colProps: {
// span: 8,
// },
// componentProps: {
// // api: uploadApi,
// },
// },
{
field: 'defaultQueueName',
label: '处理队列',
component: 'ApiSelect',
componentProps: {
api: findDictItemByCode,
params: {
dictCode: 'queen_execute_sequence',
},
labelField: 'itemText',
valueField: 'itemValue',
},
},
{
label: '描述',
field: 'description',
component: 'InputTextArea',
},
];
export const step2Schemas: FormSchema[] = [
{
field: 'transportType',
component: 'Select',
label: '传输方式',
defaultValue: 'DEFAULT',
componentProps: {
options: [
{ label: 'DEFAULT', value: 'DEFAULT' },
{ label: 'MQTT', value: 'MQTT' },
{ label: 'TCP', value: 'TCP' },
{ label: 'CoAP', value: 'CoAP' },
{ label: 'LWM2M', value: 'LWM2M' },
{ label: 'SNMP', value: 'SNMP' },
],
},
},
];
export const step3Schemas: FormSchema[] = [
{
field: 'alarmType',
component: 'Input',
label: '报警类型',
colProps: {
span: 12,
},
componentProps: {
placeholder: '请输入报警类型',
},
},
];
export const step3ViewHighSetting: FormSchema[] = [
{
field: 'propagate',
component: 'Checkbox',
label: '传递报警',
// renderComponentContent: '忽略大小写',
},
{
field: 'propagateRelationTypes',
component: 'Input',
label: '关联类型',
colProps: {
span: 11,
},
componentProps: {
placeholder: '要传递的关联类型',
},
},
];
export const step3HighSetting: FormSchema[] = [
{
field: 'propagate',
component: 'Checkbox',
label: '',
slot: 'checkBox',
},
{
field: 'propagateRelationTypes',
component: 'Input',
label: '关联类型',
colProps: {
span: 11,
},
componentProps: {
placeholder: '要传递的关联类型',
},
ifShow: ({ values }) => !!values.propagate,
},
];
export const isWhereType = ref(null);
export const step3CreateAlarm: FormSchema[] = [
{
field: 'WARNING',
component: 'Select',
label: '严重程度',
colProps: {
span: 16,
},
componentProps: {
placeholder: '请选择严重程度',
options: [
{
value: 'CRITICAL',
label: '危险',
},
{
value: 'MAJOR',
label: '重要',
},
{
value: 'MINOR',
label: '次要',
},
{
value: 'WARNING',
label: '警告',
},
{
value: 'INDETERMINATE',
label: '不确定',
},
],
onChange: (v) => {
isWhereType.value = v ? v : 'INDETERMINATE';
},
},
},
];
export const step3ClearAlarm: FormSchema[] = [
// {
// field: 'associationType',
// component: 'Input',
// label: '关联类型',
// componentProps: {
// placeholder: '要传递的关联类型',
// },
// },
];
export const dashboardFormScheme: FormSchema[] = [
{
field: 'dashboardId',
component: 'Select',
label: 'Mobile dashboard:',
colProps: {
span: 15,
},
componentProps: {
placeholder: '请选择Mobile dashboard',
options: [{ label: 'DASHBOARD', value: 'DASHBOARD' }],
},
},
];
export const alertContactsSchemas: FormSchema[] = [
{
field: 'alarmContactId',
label: '告警通知联系人',
component: 'ApiSelect',
componentProps: {
api: alarmContactGetPage,
labelField: 'username',
valueField: 'id',
resultField: 'items',
},
},
{
field: 'messageMode',
label: '告警通知方式',
required: true,
component: 'ApiSelect',
componentProps: {
api: findDictItemByCode,
params: {
dictCode: 'message_type',
},
labelField: 'itemText',
valueField: 'itemValue',
},
},
];
/**
* 所使用的枚举值
*/
export enum TriggerEnum {
IS_DEVICE_ACT = '属性',
IS_TIME_ACT = 'TIME_SERIES',
IS_SCENE_ACT = '常量',
IS_STRING = 'STRING',
IS_NUMERIC = 'NUMERIC',
IS_BOOLEAN = 'BOOLEAN',
IS_COMPLEX = 'COMPLEX',
}
export const isShiDu = (type: string) => {
return type === TriggerEnum.IS_DEVICE_ACT;
};
export const isWenDu = (type: string) => {
return type === TriggerEnum.IS_TIME_ACT;
};
export const isTimeAll = (type: string) => {
return type === TriggerEnum.IS_SCENE_ACT;
};
export const isString = (type: string) => {
return type === TriggerEnum.IS_STRING;
};
export const isNumeric = (type: string) => {
return type === TriggerEnum.IS_NUMERIC;
};
export const isBoolean = (type: string) => {
return type === TriggerEnum.IS_BOOLEAN;
};
export const isComplex = (type: string) => {
return type === TriggerEnum.IS_COMPLEX;
};
export const echoFormSchema: FormSchema[] = [
{
field: 'type',
label: '键类型',
colProps: { span: 24 },
component: 'Select',
componentProps: {
placeholder: '请选择键类型',
options: [
{ label: '属性', value: '属性' },
{ label: 'Timeseries', value: 'TIME_SERIES' },
{ label: '常量', value: '常量' },
],
},
},
{
field: 'key',
label: '键名',
colProps: { span: 24 },
component: 'Select',
componentProps: {
placeholder: '请选择键名',
options: [
{ label: 'active', value: 'active' },
{ label: 'inactivityAlarmTime', value: 'inactivityAlarmTime' },
{ label: 'lastActivityTime', value: 'lastActivityTime' },
{ label: 'lastConnectTime', value: 'lastConnectTime' },
{ label: 'lastDisconnectTime', value: 'lastDisconnectTime' },
],
},
ifShow: ({ values }) => isShiDu(Reflect.get(values, 'type')),
},
{
field: 'key',
label: '键名',
colProps: { span: 24 },
component: 'Select',
componentProps: {
placeholder: '请选择键名',
options: [
{ label: 'CO2', value: 'CO2' },
{ label: 'temp', value: 'temp' },
{ label: 'wet', value: 'wet' },
],
},
ifShow: ({ values }) => isWenDu(Reflect.get(values, 'type')),
},
{
field: 'key',
label: '键名',
colProps: { span: 24 },
component: 'Input',
componentProps: {
placeholder: '请输入键名',
},
ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
},
{
field: 'type1',
label: '值类型',
colProps: { span: 24 },
component: 'Select',
componentProps: {
placeholder: '请选择值类型',
options: [
{ label: '字符串', value: 'STRING' },
{ label: '数字', value: 'NUMERIC' },
{ label: '布尔值', value: 'BOOLEAN' },
{ label: '日期时间', value: 'COMPLEX' },
],
},
},
{
field: 'operation',
label: '操作',
colProps: { span: 24 },
component: 'Select',
componentProps: {
placeholder: '请选择操作',
options: [
{ label: '等于', value: 'EQUAL' },
{ label: '不等于', value: 'NOT_EQUAL' },
{ label: '开始于', value: 'STARTS_WITH' },
{ label: '结束于', value: 'ENDS_WITH' },
{ label: '包含', value: 'CONTAINS' },
{ label: '不包含', value: 'NOT_CONTAINS' },
],
},
ifShow: ({ values }) => isString(Reflect.get(values, 'type1')),
},
{
field: 'operation',
label: '操作',
colProps: { span: 24 },
component: 'Select',
componentProps: {
placeholder: '请选择操作',
options: [
{ label: '等于', value: 'EQUAL' },
{ label: '不等于', value: 'NOT_EQUAL' },
{ label: '大于', value: 'GREATER' },
{ label: '小于', value: 'LESS' },
{ label: '大于或等于', value: 'GREATER_OR_EQUAL' },
{ label: '小于或等于', value: 'LESS_OR_EQUAL' },
],
},
ifShow: ({ values }) => isNumeric(Reflect.get(values, 'type1')),
},
{
field: 'operation',
label: '操作',
colProps: { span: 24 },
component: 'Select',
componentProps: {
placeholder: '请选择操作',
options: [
{ label: '等于', value: 'EQUAL' },
{ label: '不等于', value: 'NOT_EQUAL' },
],
},
ifShow: ({ values }) => isBoolean(Reflect.get(values, 'type1')),
},
{
field: 'operation',
label: '操作',
colProps: { span: 24 },
component: 'Select',
componentProps: {
placeholder: '请选择操作',
options: [
{ label: '等于', value: 'EQUAL' },
{ label: '不等于', value: 'NOT_EQUAL' },
{ label: '大于', value: 'GREATER' },
{ label: '小于', value: 'LESS' },
{ label: '大于或等于', value: 'GREATER_OR_EQUAL' },
{ label: '小于或等于', value: 'LESS_OR_EQUAL' },
],
},
ifShow: ({ values }) => isComplex(Reflect.get(values, 'type1')),
},
{
field: 'value1',
label: '默认值',
colProps: { span: 24 },
component: 'Input',
componentProps: {
placeholder: '请输入默认值(数字)',
},
},
];