config.ts
6.65 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
import { FormSchema, BasicColumn } from '/@/components/Table';
import { DescItem } from '/@/components/Description/index';
/**
* 所使用的枚举值
*/
export enum TriggerEnum {
IS_DEVICE_ACT = 'SIMPLE',
IS_TIME_ACT = 'DURATION',
IS_SCENE_ACT = 'REPEATING',
IS_CURRENT_CUSTOMER = 'CURRENT_CUSTOMER',
IS_CURRENT_DEVICE = 'CURRENT_DEVICE',
}
export const isCurrentCus = (type: string) => {
return type === TriggerEnum.IS_CURRENT_CUSTOMER;
};
export const isCurrentDev = (type: string) => {
return type === TriggerEnum.IS_CURRENT_DEVICE;
};
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 keyColumns: BasicColumn[] = [
{
title: '键名',
dataIndex: 'key1',
width: 200,
},
{
title: '键类型',
dataIndex: 'type',
width: 200,
},
];
export const columnsView: BasicColumn[] = [
{
title: '键名',
dataIndex: 'key1',
width: 200,
},
{
title: '操作',
dataIndex: 'operation',
width: 200,
format: (text: string, record: Recordable) => {
const findDay = [
{ label: '等于', value: 'EQUAL' },
{ label: '不等于', value: 'NOT_EQUAL' },
{ label: '开始于', value: 'STARTS_WITH' },
{ label: '结束于', value: 'ENDS_WITH' },
{ label: '包含', value: 'CONTAINS' },
{ label: '不包含', value: 'NOT_CONTAINS' },
{ label: '等于', value: 'EQUAL' },
{ label: '不等于', value: 'NOT_EQUAL' },
{ label: '大于', value: 'GREATER' },
{ label: '小于', value: 'LESS' },
{ label: '大于或等于', value: 'GREATER_OR_EQUAL' },
{ label: '小于或等于', value: 'LESS_OR_EQUAL' },
];
const findRuleByValue = findDay.find((f) => {
if (f.value == record.operation) {
return f.label;
}
});
if (findRuleByValue) {
return findRuleByValue.label;
}
},
},
{
title: '值',
dataIndex: 'value1',
width: 200,
},
];
export const DescDetailSchema: DescItem[] = [
{
field: 'key1',
label: '键名',
},
{
field: 'type',
label: '键类型',
},
];
export const formSchema: FormSchema[] = [
{
field: 'conditionType',
label: '条件类型',
colProps: { span: 24 },
component: 'Select',
componentProps: {
placeholder: '请选择报警日程表',
options: [
{ label: '简单', value: 'SIMPLE' },
{ label: '持续时间', value: 'DURATION' },
{ label: '重复', value: 'REPEATING' },
],
},
},
// {
// field: 'sourceType',
// label: '动态源类型',
// colProps: { span: 24 },
// component: 'Select',
// componentProps: {
// placeholder: '请选择动态源类型',
// options: [
// { label: '无动态值', value: '' },
// { label: '当前租户', value: 'CURRENT_TENANT' },
// { label: '当前客户', value: 'CURRENT_CUSTOMER' },
// { label: '当前设备', value: 'CURRENT_DEVICE' },
// ],
// },
// ifShow: ({ values }) => isWenDu(Reflect.get(values, 'conditionType')),
// show: ({ values }) => {
// return !!values.field5;
// },
// },
// {
// field: 'sourceAttribute',
// label: '源属性',
// colProps: { span: 24 },
// component: 'Input',
// componentProps: {
// placeholder: '源属性',
// },
// ifShow: ({ values }) => isWenDu(Reflect.get(values, 'conditionType')),
// show: ({ values }) => {
// return !!values.field5;
// },
// },
// {
// field: 'sourceType',
// label: '动态源类型',
// colProps: { span: 24 },
// component: 'Select',
// componentProps: {
// placeholder: '请选择动态源类型',
// options: [
// { label: '无动态值', value: '' },
// { label: '当前租户', value: 'CURRENT_TENANT' },
// { label: '当前客户', value: 'CURRENT_CUSTOMER' },
// { label: '当前设备', value: 'CURRENT_DEVICE' },
// ],
// },
// ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'conditionType')),
// show: ({ values }) => {
// return !!values.field6;
// },
// },
// {
// field: 'sourceAttribute',
// label: '源属性',
// colProps: { span: 24 },
// component: 'Input',
// componentProps: {
// placeholder: '源属性',
// },
// ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'conditionType')),
// show: ({ values }) => {
// return !!values.field6;
// },
// },
{
field: 'defaultValue',
label: '持续时间值',
colProps: { span: 24 },
component: 'Input',
componentProps: {
placeholder: '请输入持续时间值(请输入数字)',
},
ifShow: ({ values }) => isWenDu(Reflect.get(values, 'conditionType')),
show: ({ values }) => {
return !values.field5;
},
},
// {
// field: 'field5',
// component: 'Switch',
// label: '切换到动态值',
// colProps: {
// span: 8,
// },
// labelWidth: 200,
// ifShow: ({ values }) => isWenDu(Reflect.get(values, 'conditionType')),
// },
// {
// field: 'field6',
// component: 'Switch',
// label: '切换到动态值',
// colProps: {
// span: 8,
// },
// labelWidth: 200,
// ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'conditionType')),
// },
{
field: 'unit',
label: '时间单位',
colProps: { span: 24 },
component: 'Select',
componentProps: {
placeholder: '请选择时间单位',
options: [
{ label: '秒', value: 'SECONDS' },
{ label: '分钟', value: 'MINUTES' },
{ label: '小时', value: 'HOURS' },
{ label: '天', value: 'DAYS' },
],
},
ifShow: ({ values }) => isWenDu(Reflect.get(values, 'conditionType')),
},
{
field: 'defaultValue',
label: '事件计数值必填',
colProps: { span: 24 },
component: 'Input',
componentProps: {
placeholder: '请输入事件计数值(应在1到2147483637之间)',
},
rules: [{ message: '事件计数应在1到2147483637之间', trigger: 'blur' }],
ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'conditionType')),
show: ({ values }) => {
return !values.field6;
},
},
{
field: 'inherit',
label: '',
component: 'Checkbox',
renderComponentContent: 'Inherit from owner',
ifShow: ({ values }) =>
isCurrentCus(Reflect.get(values, 'sourceType')) ||
isCurrentDev(Reflect.get(values, 'sourceType')),
},
];