1
|
-import { ref } from 'vue';
|
|
|
2
|
-import { BasicColumn, FormSchema } from '/@/components/Table';
|
|
|
3
|
-import type { FormSchema as QFormSchema } from '/@/components/Form/index';
|
|
|
4
|
-import { getOrganizationList } from '/@/api/system/system';
|
|
|
5
|
-import { copyTransFun } from '/@/utils/fnUtils';
|
|
|
6
|
-import { findDictItemByCode } from '/@/api/system/dict';
|
|
|
7
|
-import { isTiming, isWeek, isMonth, isFixedTime } from './timeConfig';
|
|
|
8
|
-import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config';
|
|
|
9
|
-import {
|
|
|
10
|
- getPacketIntervalByRange,
|
|
|
11
|
- getPacketIntervalByValue,
|
|
|
12
|
- intervalOption,
|
|
|
13
|
-} from '../../device/localtion/cpns/TimePeriodForm/helper';
|
|
|
14
|
-import moment, { Moment } from 'moment';
|
|
|
15
|
-
|
|
|
16
|
-export enum QueryWay {
|
|
|
17
|
- LATEST = 'latest',
|
|
|
18
|
- TIME_PERIOD = 'timePeriod',
|
|
|
19
|
-}
|
|
|
20
|
-export enum SchemaFiled {
|
|
|
21
|
- WAY = 'queryMode',
|
|
|
22
|
- TIME_PERIOD = 'timePeriod',
|
|
|
23
|
- KEYS = 'keys',
|
|
|
24
|
- DATE_RANGE = 'dataRange',
|
|
|
25
|
- START_TS = 'startTs',
|
|
|
26
|
- END_TS = 'endTs',
|
|
|
27
|
- INTERVAL = 'interval',
|
|
|
28
|
- LIMIT = 'limit',
|
|
|
29
|
- AGG = 'agg',
|
|
|
30
|
- ORDER_BY = 'orderBy',
|
|
|
31
|
-}
|
|
|
32
|
-export const organizationId = ref('');
|
|
|
33
|
-
|
|
|
34
|
-// 表格配置
|
|
|
35
|
-export const columns: BasicColumn[] = [
|
|
|
36
|
- {
|
|
|
37
|
- title: '配置名称',
|
|
|
38
|
- dataIndex: 'name',
|
|
|
39
|
- width: 120,
|
|
|
40
|
- },
|
|
|
41
|
- {
|
|
|
42
|
- title: '所属组织',
|
|
|
43
|
- dataIndex: 'organizationDTO.name',
|
|
|
44
|
- width: 120,
|
|
|
45
|
- },
|
|
|
46
|
- {
|
|
|
47
|
- title: '数据类型',
|
|
|
48
|
- dataIndex: 'dataType',
|
|
|
49
|
- width: 120,
|
|
|
50
|
- format: (_text: string, record: Recordable) => {
|
|
|
51
|
- return record.dataType === 0 ? '原始数据' : '聚合数据';
|
|
|
52
|
- },
|
|
|
53
|
- },
|
|
|
54
|
- {
|
|
|
55
|
- title: '配置状态',
|
|
|
56
|
- dataIndex: 'status',
|
|
|
57
|
- width: 120,
|
|
|
58
|
- slots: { customRender: 'configStatus' },
|
|
|
59
|
- },
|
|
|
60
|
- {
|
|
|
61
|
- title: '执行方式',
|
|
|
62
|
- dataIndex: 'executeWay',
|
|
|
63
|
- width: 160,
|
|
|
64
|
- format: (_text: string, record: Recordable) => {
|
|
|
65
|
- return record.executeWay === 0 ? '立即执行' : '定时执行';
|
|
|
66
|
- },
|
|
|
67
|
- },
|
|
|
68
|
- {
|
|
|
69
|
- title: '执行设备',
|
|
|
70
|
- dataIndex: 'devices',
|
|
|
71
|
- width: 160,
|
|
|
72
|
- slots: { customRender: 'doDeviceSlot' },
|
|
|
73
|
- },
|
|
|
74
|
- {
|
|
|
75
|
- title: '创建人',
|
|
|
76
|
- dataIndex: 'createUserName',
|
|
|
77
|
- width: 180,
|
|
|
78
|
- },
|
|
|
79
|
- {
|
|
|
80
|
- title: '创建时间',
|
|
|
81
|
- dataIndex: 'createTime',
|
|
|
82
|
- width: 180,
|
|
|
83
|
- },
|
|
|
84
|
-];
|
|
|
85
|
-export const viewDeviceColumn: BasicColumn[] = [
|
|
|
86
|
- {
|
|
|
87
|
- title: '设备',
|
|
|
88
|
- dataIndex: 'device',
|
|
|
89
|
- width: 80,
|
|
|
90
|
- },
|
|
|
91
|
- {
|
|
|
92
|
- title: '属性',
|
|
|
93
|
- dataIndex: 'attribute',
|
|
|
94
|
- width: 120,
|
|
|
95
|
- },
|
|
|
96
|
-];
|
|
|
97
|
-
|
|
|
98
|
-// 查询配置
|
|
|
99
|
-export const searchFormSchema: FormSchema[] = [
|
|
|
100
|
- {
|
|
|
101
|
- field: 'name',
|
|
|
102
|
- label: '配置名称',
|
|
|
103
|
- component: 'Input',
|
|
|
104
|
- colProps: { span: 6 },
|
|
|
105
|
- componentProps: {
|
|
|
106
|
- maxLength: 36,
|
|
|
107
|
- placeholder: '请输入配置名称',
|
|
|
108
|
- },
|
|
|
109
|
- },
|
|
|
110
|
- {
|
|
|
111
|
- field: 'status',
|
|
|
112
|
- label: '配置状态',
|
|
|
113
|
- component: 'Select',
|
|
|
114
|
- colProps: { span: 6 },
|
|
|
115
|
- componentProps: {
|
|
|
116
|
- options: [
|
|
|
117
|
- {
|
|
|
118
|
- label: '启用',
|
|
|
119
|
- value: 1,
|
|
|
120
|
- },
|
|
|
121
|
- {
|
|
|
122
|
- label: '禁用',
|
|
|
123
|
- value: 0,
|
|
|
124
|
- },
|
|
|
125
|
- ],
|
|
|
126
|
- placeholder: '请选择配置状态',
|
|
|
127
|
- },
|
|
|
128
|
- },
|
|
|
129
|
- {
|
|
|
130
|
- field: 'sendTime',
|
|
|
131
|
- label: '创建时间',
|
|
|
132
|
- component: 'RangePicker',
|
|
|
133
|
- componentProps: {
|
|
|
134
|
- showTime: {
|
|
|
135
|
- defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
|
|
|
136
|
- },
|
|
|
137
|
- },
|
|
|
138
|
- colProps: { span: 6 },
|
|
|
139
|
- },
|
|
|
140
|
-];
|
|
|
141
|
-
|
|
|
142
|
-// 新增编辑配置
|
|
|
143
|
-export const formSchema: QFormSchema[] = [
|
|
|
144
|
- {
|
|
|
145
|
- field: 'name',
|
|
|
146
|
- label: '报表名称',
|
|
|
147
|
- colProps: { span: 24 },
|
|
|
148
|
- required: true,
|
|
|
149
|
- component: 'Input',
|
|
|
150
|
- componentProps: {
|
|
|
151
|
- maxLength: 64,
|
|
|
152
|
- placeholder: '请输入报表名称',
|
|
|
153
|
- },
|
|
|
154
|
- },
|
|
|
155
|
- {
|
|
|
156
|
- field: 'organizationId',
|
|
|
157
|
- label: '所属组织',
|
|
|
158
|
- colProps: { span: 24 },
|
|
|
159
|
- component: 'ApiTreeSelect',
|
|
|
160
|
- required: true,
|
|
|
161
|
- componentProps: () => {
|
|
|
162
|
- return {
|
|
|
163
|
- maxLength: 250,
|
|
|
164
|
- placeholder: '请选择所属组织',
|
|
|
165
|
- api: async () => {
|
|
|
166
|
- const data = await getOrganizationList();
|
|
|
167
|
- copyTransFun(data as any as any[]);
|
|
|
168
|
- return data;
|
|
|
169
|
- },
|
|
|
170
|
- async onChange(e) {
|
|
|
171
|
- organizationId.value = e;
|
|
|
172
|
- },
|
|
|
173
|
- };
|
|
|
174
|
- },
|
|
|
175
|
- },
|
|
|
176
|
- {
|
|
|
177
|
- field: 'remark',
|
|
|
178
|
- label: '描述',
|
|
|
179
|
- colProps: { span: 24 },
|
|
|
180
|
- component: 'InputTextArea',
|
|
|
181
|
- componentProps: {
|
|
|
182
|
- maxLength: 255,
|
|
|
183
|
- placeholder: '请输入描述',
|
|
|
184
|
- },
|
|
|
185
|
- },
|
|
|
186
|
- {
|
|
|
187
|
- field: 'executeWay',
|
|
|
188
|
- component: 'RadioGroup',
|
|
|
189
|
- helpMessage: [
|
|
|
190
|
- `立即执行,在创建完报表配置后,启用配置即执行。
|
|
|
191
|
- 定时执行,用户定义执行时间,启用后,
|
|
|
192
|
- 在满足执行时间条件后,自动执行。`,
|
|
|
193
|
- ],
|
|
|
194
|
- label: '执行方式',
|
|
|
195
|
- colProps: {
|
|
|
196
|
- span: 24,
|
|
|
197
|
- },
|
|
|
198
|
- defaultValue: 0,
|
|
|
199
|
- componentProps: ({ formActionType }) => {
|
|
|
200
|
- const { updateSchema, setFieldsValue } = formActionType;
|
|
|
201
|
- const options = [
|
|
|
202
|
- {
|
|
|
203
|
- label: '立即执行',
|
|
|
204
|
- value: 0,
|
|
|
205
|
- },
|
|
|
206
|
- {
|
|
|
207
|
- label: '定时执行',
|
|
|
208
|
- value: 1,
|
|
|
209
|
- },
|
|
|
210
|
- ];
|
|
|
211
|
- return {
|
|
|
212
|
- options,
|
|
|
213
|
- placeholder: '请选择执行方式',
|
|
|
214
|
- onChange(e) {
|
|
|
215
|
- let dataCompareOpions: any = [];
|
|
|
216
|
- setFieldsValue({
|
|
|
217
|
- startTs: 1000,
|
|
|
218
|
- interval: 1000,
|
|
|
219
|
- });
|
|
|
220
|
- if (e.target.value == 0) {
|
|
|
221
|
- setFieldsValue({ queryMode: QueryWay.LATEST });
|
|
|
222
|
- dataCompareOpions = [
|
|
|
223
|
- { label: '固定周期', value: QueryWay.LATEST },
|
|
|
224
|
- { label: '自定义周期', value: QueryWay.TIME_PERIOD },
|
|
|
225
|
- ];
|
|
|
226
|
- updateSchema({
|
|
|
227
|
- field: SchemaFiled.WAY,
|
|
|
228
|
- componentProps: {
|
|
|
229
|
- options: dataCompareOpions,
|
|
|
230
|
- },
|
|
|
231
|
- });
|
|
|
232
|
- } else {
|
|
|
233
|
- setFieldsValue({ queryMode: QueryWay.LATEST });
|
|
|
234
|
- setFieldsValue({ startTs: 5000 });
|
|
|
235
|
- setFieldsValue({ interval: 1000 });
|
|
|
236
|
- dataCompareOpions = [{ label: '固定周期', value: QueryWay.LATEST }];
|
|
|
237
|
- updateSchema({
|
|
|
238
|
- defaultValue: QueryWay.LATEST,
|
|
|
239
|
- field: SchemaFiled.WAY,
|
|
|
240
|
- componentProps: {
|
|
|
241
|
- options: dataCompareOpions,
|
|
|
242
|
- },
|
|
|
243
|
- });
|
|
|
244
|
- }
|
|
|
245
|
- },
|
|
|
246
|
- maxLength: 250,
|
|
|
247
|
- };
|
|
|
248
|
- },
|
|
|
249
|
- },
|
|
|
250
|
- {
|
|
|
251
|
- field: 'cycleType',
|
|
|
252
|
- component: 'Select',
|
|
|
253
|
- label: '周期',
|
|
|
254
|
- required: true,
|
|
|
255
|
- colProps: { span: 24 },
|
|
|
256
|
- defaultValue: 0,
|
|
|
257
|
- componentProps: {
|
|
|
258
|
- placeholder: '请选择周期',
|
|
|
259
|
- options: [
|
|
|
260
|
- { label: '每日', value: 0 },
|
|
|
261
|
- { label: '每周', value: 1 },
|
|
|
262
|
- { label: '每月', value: 2 },
|
|
|
263
|
- ],
|
|
|
264
|
- },
|
|
|
265
|
- ifShow: ({ values }) => isTiming(values.executeWay),
|
|
|
266
|
- },
|
|
|
267
|
- {
|
|
|
268
|
- field: 'currentCycle',
|
|
|
269
|
- component: 'ApiSelect',
|
|
|
270
|
- label: '每周',
|
|
|
271
|
- required: true,
|
|
|
272
|
- colProps: { span: 24 },
|
|
|
273
|
- defaultValue: '0 0 0 ? * MON',
|
|
|
274
|
- componentProps: {
|
|
|
275
|
- placeholder: '请选择周期',
|
|
|
276
|
- api: findDictItemByCode,
|
|
|
277
|
- params: {
|
|
|
278
|
- dictCode: 'every_week',
|
|
|
279
|
- },
|
|
|
280
|
- labelField: 'itemText',
|
|
|
281
|
- valueField: 'itemValue',
|
|
|
282
|
- },
|
|
|
283
|
- ifShow: ({ values }) => isWeek(values.cycleType),
|
|
|
284
|
- },
|
|
|
285
|
- {
|
|
|
286
|
- field: 'cycleTime',
|
|
|
287
|
- component: 'ApiSelect',
|
|
|
288
|
- label: '每月',
|
|
|
289
|
- required: true,
|
|
|
290
|
- colProps: { span: 24 },
|
|
|
291
|
- defaultValue: '0 0 0 1 * ? *',
|
|
|
292
|
- componentProps: {
|
|
|
293
|
- placeholder: '请选择月份',
|
|
|
294
|
- api: findDictItemByCode,
|
|
|
295
|
- params: {
|
|
|
296
|
- dictCode: 'every_month',
|
|
|
297
|
- },
|
|
|
298
|
- labelField: 'itemText',
|
|
|
299
|
- valueField: 'itemValue',
|
|
|
300
|
- },
|
|
|
301
|
- ifShow: ({ values }) => isMonth(values.cycleType),
|
|
|
302
|
- },
|
|
|
303
|
- {
|
|
|
304
|
- field: 'cronTime',
|
|
|
305
|
- component: 'ApiSelect',
|
|
|
306
|
- label: '时间',
|
|
|
307
|
- required: true,
|
|
|
308
|
- colProps: { span: 24 },
|
|
|
309
|
- defaultValue: '0 0 0 * * ?',
|
|
|
310
|
- componentProps: {
|
|
|
311
|
- placeholder: '请选择时间',
|
|
|
312
|
- api: findDictItemByCode,
|
|
|
313
|
- params: {
|
|
|
314
|
- dictCode: 'every_day',
|
|
|
315
|
- },
|
|
|
316
|
- labelField: 'itemText',
|
|
|
317
|
- valueField: 'itemValue',
|
|
|
318
|
- },
|
|
|
319
|
- ifShow: ({ values }) => isTiming(values.executeWay),
|
|
|
320
|
- },
|
|
|
321
|
- {
|
|
|
322
|
- field: 'devices',
|
|
|
323
|
- label: '设备',
|
|
|
324
|
- component: 'Select',
|
|
|
325
|
- slot: 'devices',
|
|
|
326
|
- colProps: { span: 24 },
|
|
|
327
|
- },
|
|
|
328
|
- {
|
|
|
329
|
- field: 'dataType',
|
|
|
330
|
- label: '数据类型',
|
|
|
331
|
- required: true,
|
|
|
332
|
- component: 'Select',
|
|
|
333
|
- componentProps: ({ formActionType }) => {
|
|
|
334
|
- const { updateSchema, setFieldsValue } = formActionType;
|
|
|
335
|
- const options = [
|
|
|
336
|
- { label: '原始数据', value: 0 },
|
|
|
337
|
- { label: '聚合数据', value: 1 },
|
|
|
338
|
- ];
|
|
|
339
|
- return {
|
|
|
340
|
- options,
|
|
|
341
|
- onSelect(e) {
|
|
|
342
|
- let dataCompareOpions: any = [];
|
|
|
343
|
- if (e == 0) {
|
|
|
344
|
- setFieldsValue({ agg: 'NONE' });
|
|
|
345
|
- dataCompareOpions = [{ label: '空', value: AggregateDataEnum.NONE }];
|
|
|
346
|
- updateSchema({
|
|
|
347
|
- field: SchemaFiled.AGG,
|
|
|
348
|
- componentProps: {
|
|
|
349
|
- options: dataCompareOpions,
|
|
|
350
|
- },
|
|
|
351
|
- });
|
|
|
352
|
- } else {
|
|
|
353
|
- setFieldsValue({ agg: '' });
|
|
|
354
|
- dataCompareOpions = [
|
|
|
355
|
- { label: '最小值', value: AggregateDataEnum.MIN },
|
|
|
356
|
- { label: '最大值', value: AggregateDataEnum.MAX },
|
|
|
357
|
- { label: '平均值', value: AggregateDataEnum.AVG },
|
|
|
358
|
- { label: '求和', value: AggregateDataEnum.SUM },
|
|
|
359
|
- { label: '计数', value: AggregateDataEnum.COUNT },
|
|
|
360
|
- ];
|
|
|
361
|
- updateSchema({
|
|
|
362
|
- field: SchemaFiled.AGG,
|
|
|
363
|
- componentProps: {
|
|
|
364
|
- options: dataCompareOpions,
|
|
|
365
|
- },
|
|
|
366
|
- });
|
|
|
367
|
- }
|
|
|
368
|
- },
|
|
|
369
|
- maxLength: 250,
|
|
|
370
|
- placeholder: '请选择属性性质',
|
|
|
371
|
- };
|
|
|
372
|
- },
|
|
|
373
|
- colProps: { span: 24 },
|
|
|
374
|
- },
|
|
|
375
|
- {
|
|
|
376
|
- field: SchemaFiled.AGG,
|
|
|
377
|
- label: '聚合条件',
|
|
|
378
|
- component: 'Select',
|
|
|
379
|
- required: true,
|
|
|
380
|
- componentProps: {
|
|
|
381
|
- placeholder: '请选择聚合条件',
|
|
|
382
|
- getPopupContainer: () => document.body,
|
|
|
383
|
- },
|
|
|
384
|
- },
|
|
|
385
|
- {
|
|
|
386
|
- field: 'limit',
|
|
|
387
|
- required: true,
|
|
|
388
|
- label: '最大条数',
|
|
|
389
|
- component: 'InputNumber',
|
|
|
390
|
- defaultValue: 100,
|
|
|
391
|
- ifShow({ values }) {
|
|
|
392
|
- return values[SchemaFiled.AGG] === AggregateDataEnum.NONE;
|
|
|
393
|
- },
|
|
|
394
|
- colProps: { span: 12 },
|
|
|
395
|
- componentProps: {
|
|
|
396
|
- placeholder: '请输入最大条数',
|
|
|
397
|
- min: 7,
|
|
|
398
|
- max: 50000,
|
|
|
399
|
- },
|
|
|
400
|
- },
|
|
|
401
|
- {
|
|
|
402
|
- field: SchemaFiled.WAY,
|
|
|
403
|
- label: '查询周期',
|
|
|
404
|
- component: 'RadioGroup',
|
|
|
405
|
- defaultValue: QueryWay.LATEST,
|
|
|
406
|
- required: true,
|
|
|
407
|
- componentProps({ formActionType }) {
|
|
|
408
|
- const { setFieldsValue } = formActionType;
|
|
|
409
|
- return {
|
|
|
410
|
- placeholder: '请选择查询周期',
|
|
|
411
|
- options: [
|
|
|
412
|
- { label: '固定周期', value: QueryWay.LATEST },
|
|
|
413
|
- { label: '自定义周期', value: QueryWay.TIME_PERIOD },
|
|
|
414
|
- ],
|
|
|
415
|
- onChange(value) {
|
|
|
416
|
- console.log(value);
|
|
|
417
|
- value === QueryWay.LATEST
|
|
|
418
|
- ? setFieldsValue({
|
|
|
419
|
- [SchemaFiled.DATE_RANGE]: [],
|
|
|
420
|
- [SchemaFiled.START_TS]: null,
|
|
|
421
|
- [SchemaFiled.END_TS]: null,
|
|
|
422
|
- })
|
|
|
423
|
- : setFieldsValue({ [SchemaFiled.START_TS]: null });
|
|
|
424
|
- },
|
|
|
425
|
- };
|
|
|
426
|
- },
|
|
|
427
|
- },
|
|
|
428
|
- {
|
|
|
429
|
- field: SchemaFiled.DATE_RANGE,
|
|
|
430
|
- label: '时间段',
|
|
|
431
|
- component: 'RangePicker',
|
|
|
432
|
- required: true,
|
|
|
433
|
- ifShow({ values }) {
|
|
|
434
|
- return values[SchemaFiled.WAY] === QueryWay.TIME_PERIOD && !isFixedTime(values.executeWay);
|
|
|
435
|
- },
|
|
|
436
|
- // componentProps: {
|
|
|
437
|
- // showTime: {
|
|
|
438
|
- // defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
|
|
|
439
|
- // },
|
|
|
440
|
- // },
|
|
|
441
|
- componentProps({ formActionType }) {
|
|
|
442
|
- const { setFieldsValue } = formActionType;
|
|
|
443
|
- let dates: Moment[] = [];
|
|
|
444
|
- return {
|
|
|
445
|
- showTime: {
|
|
|
446
|
- defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
|
|
|
447
|
- },
|
|
|
448
|
- onCalendarChange(value: Moment[]) {
|
|
|
449
|
- dates = value;
|
|
|
450
|
- },
|
|
|
451
|
- disabledDate(current: Moment) {
|
|
|
452
|
- if (!dates || dates.length === 0 || !current) {
|
|
|
453
|
- return false;
|
|
|
454
|
- }
|
|
|
455
|
- const diffDate = current.diff(dates[0], 'years', true);
|
|
|
456
|
- return Math.abs(diffDate) > 1;
|
|
|
457
|
- },
|
|
|
458
|
- onChange() {
|
|
|
459
|
- dates = [];
|
|
|
460
|
- setFieldsValue({ dateGroupGap: null });
|
|
|
461
|
- },
|
|
|
462
|
- getPopupContainer: () => document.body,
|
|
|
463
|
- };
|
|
|
464
|
- },
|
|
|
465
|
- colProps: {
|
|
|
466
|
- span: 10,
|
|
|
467
|
- },
|
|
|
468
|
- },
|
|
|
469
|
- {
|
|
|
470
|
- field: 'dateGroupGap',
|
|
|
471
|
- label: '分组间隔',
|
|
|
472
|
- component: 'Select',
|
|
|
473
|
- dynamicRules: ({ model }) => {
|
|
|
474
|
- return [
|
|
|
475
|
- {
|
|
|
476
|
- required: model[SchemaFiled.AGG] !== AggregateDataEnum.NONE,
|
|
|
477
|
- message: '分组间隔为必填项',
|
|
|
478
|
- type: 'number',
|
|
|
479
|
- },
|
|
|
480
|
- ];
|
|
|
481
|
- },
|
|
|
482
|
- ifShow({ values }) {
|
|
|
483
|
- return values[SchemaFiled.WAY] === QueryWay.TIME_PERIOD && !isFixedTime(values.executeWay);
|
|
|
484
|
- },
|
|
|
485
|
- componentProps({ formModel, formActionType }) {
|
|
|
486
|
- const options =
|
|
|
487
|
- formModel[SchemaFiled.WAY] === QueryWay.LATEST
|
|
|
488
|
- ? getPacketIntervalByValue(formModel[SchemaFiled.START_TS])
|
|
|
489
|
- : getPacketIntervalByRange(formModel[SchemaFiled.DATE_RANGE]);
|
|
|
490
|
- if (formModel[SchemaFiled.AGG] !== AggregateDataEnum.NONE) {
|
|
|
491
|
- formActionType.setFieldsValue({ [SchemaFiled.LIMIT]: null });
|
|
|
492
|
- }
|
|
|
493
|
- return {
|
|
|
494
|
- options,
|
|
|
495
|
- getPopupContainer: () => document.body,
|
|
|
496
|
- };
|
|
|
497
|
- },
|
|
|
498
|
- },
|
|
|
499
|
- {
|
|
|
500
|
- field: SchemaFiled.START_TS,
|
|
|
501
|
- label: '最近时间',
|
|
|
502
|
- component: 'Select',
|
|
|
503
|
- required: true,
|
|
|
504
|
- ifShow({ values }) {
|
|
|
505
|
- return values[SchemaFiled.WAY] == QueryWay.LATEST;
|
|
|
506
|
- },
|
|
|
507
|
- componentProps({ formActionType }) {
|
|
|
508
|
- const { setFieldsValue } = formActionType;
|
|
|
509
|
- return {
|
|
|
510
|
- defaultValue: 1000,
|
|
|
511
|
- placeholder: '请选择近期时间',
|
|
|
512
|
- options: intervalOption,
|
|
|
513
|
- onChange() {
|
|
|
514
|
- setFieldsValue({ [SchemaFiled.INTERVAL]: null });
|
|
|
515
|
- },
|
|
|
516
|
- };
|
|
|
517
|
- },
|
|
|
518
|
- },
|
|
|
519
|
- {
|
|
|
520
|
- field: SchemaFiled.INTERVAL,
|
|
|
521
|
- label: '间隔时间',
|
|
|
522
|
- component: 'Select',
|
|
|
523
|
- required: true,
|
|
|
524
|
- ifShow({ values }) {
|
|
|
525
|
- return values[SchemaFiled.WAY] == QueryWay.LATEST;
|
|
|
526
|
- },
|
|
|
527
|
- componentProps({ formModel, formActionType }) {
|
|
|
528
|
- const options =
|
|
|
529
|
- formModel[SchemaFiled.WAY] === QueryWay.LATEST
|
|
|
530
|
- ? getPacketIntervalByValue(formModel[SchemaFiled.START_TS])
|
|
|
531
|
- : getPacketIntervalByRange(formModel[SchemaFiled.DATE_RANGE]);
|
|
|
532
|
- if (formModel[SchemaFiled.AGG] !== AggregateDataEnum.NONE) {
|
|
|
533
|
- formActionType.setFieldsValue({ [SchemaFiled.LIMIT]: null });
|
|
|
534
|
- }
|
|
|
535
|
- return {
|
|
|
536
|
- placeholder: '请选择间隔时间',
|
|
|
537
|
- options,
|
|
|
538
|
- };
|
|
|
539
|
- },
|
|
|
540
|
- },
|
|
|
541
|
-]; |
1
|
+import { ref } from 'vue';
|
|
|
2
|
+import { BasicColumn, FormSchema } from '/@/components/Table';
|
|
|
3
|
+import { FormSchema as QFormSchema, useComponentRegister } from '/@/components/Form/index';
|
|
|
4
|
+import { findDictItemByCode } from '/@/api/system/dict';
|
|
|
5
|
+import { isTiming, isWeek, isMonth, isFixedTime } from './timeConfig';
|
|
|
6
|
+import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config';
|
|
|
7
|
+import {
|
|
|
8
|
+ getPacketIntervalByRange,
|
|
|
9
|
+ getPacketIntervalByValue,
|
|
|
10
|
+ intervalOption,
|
|
|
11
|
+} from '../../device/localtion/cpns/TimePeriodForm/helper';
|
|
|
12
|
+import moment, { Moment } from 'moment';
|
|
|
13
|
+import { OrgTreeSelect } from '../../common/OrgTreeSelect';
|
|
|
14
|
+useComponentRegister('OrgTreeSelect', OrgTreeSelect);
|
|
|
15
|
+export enum QueryWay {
|
|
|
16
|
+ LATEST = 'latest',
|
|
|
17
|
+ TIME_PERIOD = 'timePeriod',
|
|
|
18
|
+}
|
|
|
19
|
+export enum SchemaFiled {
|
|
|
20
|
+ WAY = 'queryMode',
|
|
|
21
|
+ TIME_PERIOD = 'timePeriod',
|
|
|
22
|
+ KEYS = 'keys',
|
|
|
23
|
+ DATE_RANGE = 'dataRange',
|
|
|
24
|
+ START_TS = 'startTs',
|
|
|
25
|
+ END_TS = 'endTs',
|
|
|
26
|
+ INTERVAL = 'interval',
|
|
|
27
|
+ LIMIT = 'limit',
|
|
|
28
|
+ AGG = 'agg',
|
|
|
29
|
+ ORDER_BY = 'orderBy',
|
|
|
30
|
+}
|
|
|
31
|
+export const organizationId = ref('');
|
|
|
32
|
+
|
|
|
33
|
+// 表格配置
|
|
|
34
|
+export const columns: BasicColumn[] = [
|
|
|
35
|
+ {
|
|
|
36
|
+ title: '配置名称',
|
|
|
37
|
+ dataIndex: 'name',
|
|
|
38
|
+ width: 120,
|
|
|
39
|
+ },
|
|
|
40
|
+ {
|
|
|
41
|
+ title: '所属组织',
|
|
|
42
|
+ dataIndex: 'organizationDTO.name',
|
|
|
43
|
+ width: 120,
|
|
|
44
|
+ },
|
|
|
45
|
+ {
|
|
|
46
|
+ title: '数据类型',
|
|
|
47
|
+ dataIndex: 'dataType',
|
|
|
48
|
+ width: 120,
|
|
|
49
|
+ format: (_text: string, record: Recordable) => {
|
|
|
50
|
+ return record.dataType === 0 ? '原始数据' : '聚合数据';
|
|
|
51
|
+ },
|
|
|
52
|
+ },
|
|
|
53
|
+ {
|
|
|
54
|
+ title: '配置状态',
|
|
|
55
|
+ dataIndex: 'status',
|
|
|
56
|
+ width: 120,
|
|
|
57
|
+ slots: { customRender: 'configStatus' },
|
|
|
58
|
+ },
|
|
|
59
|
+ {
|
|
|
60
|
+ title: '执行方式',
|
|
|
61
|
+ dataIndex: 'executeWay',
|
|
|
62
|
+ width: 160,
|
|
|
63
|
+ format: (_text: string, record: Recordable) => {
|
|
|
64
|
+ return record.executeWay === 0 ? '立即执行' : '定时执行';
|
|
|
65
|
+ },
|
|
|
66
|
+ },
|
|
|
67
|
+ {
|
|
|
68
|
+ title: '执行设备',
|
|
|
69
|
+ dataIndex: 'devices',
|
|
|
70
|
+ width: 160,
|
|
|
71
|
+ slots: { customRender: 'doDeviceSlot' },
|
|
|
72
|
+ },
|
|
|
73
|
+ {
|
|
|
74
|
+ title: '创建人',
|
|
|
75
|
+ dataIndex: 'createUserName',
|
|
|
76
|
+ width: 180,
|
|
|
77
|
+ },
|
|
|
78
|
+ {
|
|
|
79
|
+ title: '创建时间',
|
|
|
80
|
+ dataIndex: 'createTime',
|
|
|
81
|
+ width: 180,
|
|
|
82
|
+ },
|
|
|
83
|
+];
|
|
|
84
|
+export const viewDeviceColumn: BasicColumn[] = [
|
|
|
85
|
+ {
|
|
|
86
|
+ title: '设备',
|
|
|
87
|
+ dataIndex: 'device',
|
|
|
88
|
+ width: 80,
|
|
|
89
|
+ },
|
|
|
90
|
+ {
|
|
|
91
|
+ title: '属性',
|
|
|
92
|
+ dataIndex: 'attribute',
|
|
|
93
|
+ width: 120,
|
|
|
94
|
+ },
|
|
|
95
|
+];
|
|
|
96
|
+
|
|
|
97
|
+// 查询配置
|
|
|
98
|
+export const searchFormSchema: FormSchema[] = [
|
|
|
99
|
+ {
|
|
|
100
|
+ field: 'name',
|
|
|
101
|
+ label: '配置名称',
|
|
|
102
|
+ component: 'Input',
|
|
|
103
|
+ colProps: { span: 6 },
|
|
|
104
|
+ componentProps: {
|
|
|
105
|
+ maxLength: 36,
|
|
|
106
|
+ placeholder: '请输入配置名称',
|
|
|
107
|
+ },
|
|
|
108
|
+ },
|
|
|
109
|
+ {
|
|
|
110
|
+ field: 'status',
|
|
|
111
|
+ label: '配置状态',
|
|
|
112
|
+ component: 'Select',
|
|
|
113
|
+ colProps: { span: 6 },
|
|
|
114
|
+ componentProps: {
|
|
|
115
|
+ options: [
|
|
|
116
|
+ {
|
|
|
117
|
+ label: '启用',
|
|
|
118
|
+ value: 1,
|
|
|
119
|
+ },
|
|
|
120
|
+ {
|
|
|
121
|
+ label: '禁用',
|
|
|
122
|
+ value: 0,
|
|
|
123
|
+ },
|
|
|
124
|
+ ],
|
|
|
125
|
+ placeholder: '请选择配置状态',
|
|
|
126
|
+ },
|
|
|
127
|
+ },
|
|
|
128
|
+ {
|
|
|
129
|
+ field: 'sendTime',
|
|
|
130
|
+ label: '创建时间',
|
|
|
131
|
+ component: 'RangePicker',
|
|
|
132
|
+ componentProps: {
|
|
|
133
|
+ showTime: {
|
|
|
134
|
+ defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
|
|
|
135
|
+ },
|
|
|
136
|
+ },
|
|
|
137
|
+ colProps: { span: 6 },
|
|
|
138
|
+ },
|
|
|
139
|
+];
|
|
|
140
|
+
|
|
|
141
|
+// 新增编辑配置
|
|
|
142
|
+export const formSchema: QFormSchema[] = [
|
|
|
143
|
+ {
|
|
|
144
|
+ field: 'name',
|
|
|
145
|
+ label: '报表名称',
|
|
|
146
|
+ colProps: { span: 24 },
|
|
|
147
|
+ required: true,
|
|
|
148
|
+ component: 'Input',
|
|
|
149
|
+ componentProps: {
|
|
|
150
|
+ maxLength: 64,
|
|
|
151
|
+ placeholder: '请输入报表名称',
|
|
|
152
|
+ },
|
|
|
153
|
+ },
|
|
|
154
|
+ {
|
|
|
155
|
+ field: 'organizationId',
|
|
|
156
|
+ label: '所属组织',
|
|
|
157
|
+ colProps: { span: 24 },
|
|
|
158
|
+ component: 'OrgTreeSelect',
|
|
|
159
|
+ required: true,
|
|
|
160
|
+ componentProps: () => {
|
|
|
161
|
+ return {
|
|
|
162
|
+ async onChange(e) {
|
|
|
163
|
+ organizationId.value = e;
|
|
|
164
|
+ },
|
|
|
165
|
+ };
|
|
|
166
|
+ },
|
|
|
167
|
+ },
|
|
|
168
|
+ {
|
|
|
169
|
+ field: 'remark',
|
|
|
170
|
+ label: '描述',
|
|
|
171
|
+ colProps: { span: 24 },
|
|
|
172
|
+ component: 'InputTextArea',
|
|
|
173
|
+ componentProps: {
|
|
|
174
|
+ maxLength: 255,
|
|
|
175
|
+ placeholder: '请输入描述',
|
|
|
176
|
+ },
|
|
|
177
|
+ },
|
|
|
178
|
+ {
|
|
|
179
|
+ field: 'executeWay',
|
|
|
180
|
+ component: 'RadioGroup',
|
|
|
181
|
+ helpMessage: [
|
|
|
182
|
+ `立即执行,在创建完报表配置后,启用配置即执行。
|
|
|
183
|
+ 定时执行,用户定义执行时间,启用后,
|
|
|
184
|
+ 在满足执行时间条件后,自动执行。`,
|
|
|
185
|
+ ],
|
|
|
186
|
+ label: '执行方式',
|
|
|
187
|
+ colProps: {
|
|
|
188
|
+ span: 24,
|
|
|
189
|
+ },
|
|
|
190
|
+ defaultValue: 0,
|
|
|
191
|
+ componentProps: ({ formActionType }) => {
|
|
|
192
|
+ const { updateSchema, setFieldsValue } = formActionType;
|
|
|
193
|
+ const options = [
|
|
|
194
|
+ {
|
|
|
195
|
+ label: '立即执行',
|
|
|
196
|
+ value: 0,
|
|
|
197
|
+ },
|
|
|
198
|
+ {
|
|
|
199
|
+ label: '定时执行',
|
|
|
200
|
+ value: 1,
|
|
|
201
|
+ },
|
|
|
202
|
+ ];
|
|
|
203
|
+ return {
|
|
|
204
|
+ options,
|
|
|
205
|
+ placeholder: '请选择执行方式',
|
|
|
206
|
+ onChange(e) {
|
|
|
207
|
+ let dataCompareOpions: any = [];
|
|
|
208
|
+ setFieldsValue({
|
|
|
209
|
+ startTs: 1000,
|
|
|
210
|
+ interval: 1000,
|
|
|
211
|
+ });
|
|
|
212
|
+ if (e.target.value == 0) {
|
|
|
213
|
+ setFieldsValue({ queryMode: QueryWay.LATEST });
|
|
|
214
|
+ dataCompareOpions = [
|
|
|
215
|
+ { label: '固定周期', value: QueryWay.LATEST },
|
|
|
216
|
+ { label: '自定义周期', value: QueryWay.TIME_PERIOD },
|
|
|
217
|
+ ];
|
|
|
218
|
+ updateSchema({
|
|
|
219
|
+ field: SchemaFiled.WAY,
|
|
|
220
|
+ componentProps: {
|
|
|
221
|
+ options: dataCompareOpions,
|
|
|
222
|
+ },
|
|
|
223
|
+ });
|
|
|
224
|
+ } else {
|
|
|
225
|
+ setFieldsValue({ queryMode: QueryWay.LATEST });
|
|
|
226
|
+ setFieldsValue({ startTs: 5000 });
|
|
|
227
|
+ setFieldsValue({ interval: 1000 });
|
|
|
228
|
+ dataCompareOpions = [{ label: '固定周期', value: QueryWay.LATEST }];
|
|
|
229
|
+ updateSchema({
|
|
|
230
|
+ defaultValue: QueryWay.LATEST,
|
|
|
231
|
+ field: SchemaFiled.WAY,
|
|
|
232
|
+ componentProps: {
|
|
|
233
|
+ options: dataCompareOpions,
|
|
|
234
|
+ },
|
|
|
235
|
+ });
|
|
|
236
|
+ }
|
|
|
237
|
+ },
|
|
|
238
|
+ maxLength: 250,
|
|
|
239
|
+ };
|
|
|
240
|
+ },
|
|
|
241
|
+ },
|
|
|
242
|
+ {
|
|
|
243
|
+ field: 'cycleType',
|
|
|
244
|
+ component: 'Select',
|
|
|
245
|
+ label: '周期',
|
|
|
246
|
+ required: true,
|
|
|
247
|
+ colProps: { span: 24 },
|
|
|
248
|
+ defaultValue: 0,
|
|
|
249
|
+ componentProps: {
|
|
|
250
|
+ placeholder: '请选择周期',
|
|
|
251
|
+ options: [
|
|
|
252
|
+ { label: '每日', value: 0 },
|
|
|
253
|
+ { label: '每周', value: 1 },
|
|
|
254
|
+ { label: '每月', value: 2 },
|
|
|
255
|
+ ],
|
|
|
256
|
+ },
|
|
|
257
|
+ ifShow: ({ values }) => isTiming(values.executeWay),
|
|
|
258
|
+ },
|
|
|
259
|
+ {
|
|
|
260
|
+ field: 'currentCycle',
|
|
|
261
|
+ component: 'ApiSelect',
|
|
|
262
|
+ label: '每周',
|
|
|
263
|
+ required: true,
|
|
|
264
|
+ colProps: { span: 24 },
|
|
|
265
|
+ defaultValue: '0 0 0 ? * MON',
|
|
|
266
|
+ componentProps: {
|
|
|
267
|
+ placeholder: '请选择周期',
|
|
|
268
|
+ api: findDictItemByCode,
|
|
|
269
|
+ params: {
|
|
|
270
|
+ dictCode: 'every_week',
|
|
|
271
|
+ },
|
|
|
272
|
+ labelField: 'itemText',
|
|
|
273
|
+ valueField: 'itemValue',
|
|
|
274
|
+ },
|
|
|
275
|
+ ifShow: ({ values }) => isWeek(values.cycleType),
|
|
|
276
|
+ },
|
|
|
277
|
+ {
|
|
|
278
|
+ field: 'cycleTime',
|
|
|
279
|
+ component: 'ApiSelect',
|
|
|
280
|
+ label: '每月',
|
|
|
281
|
+ required: true,
|
|
|
282
|
+ colProps: { span: 24 },
|
|
|
283
|
+ defaultValue: '0 0 0 1 * ? *',
|
|
|
284
|
+ componentProps: {
|
|
|
285
|
+ placeholder: '请选择月份',
|
|
|
286
|
+ api: findDictItemByCode,
|
|
|
287
|
+ params: {
|
|
|
288
|
+ dictCode: 'every_month',
|
|
|
289
|
+ },
|
|
|
290
|
+ labelField: 'itemText',
|
|
|
291
|
+ valueField: 'itemValue',
|
|
|
292
|
+ },
|
|
|
293
|
+ ifShow: ({ values }) => isMonth(values.cycleType),
|
|
|
294
|
+ },
|
|
|
295
|
+ {
|
|
|
296
|
+ field: 'cronTime',
|
|
|
297
|
+ component: 'ApiSelect',
|
|
|
298
|
+ label: '时间',
|
|
|
299
|
+ required: true,
|
|
|
300
|
+ colProps: { span: 24 },
|
|
|
301
|
+ defaultValue: '0 0 0 * * ?',
|
|
|
302
|
+ componentProps: {
|
|
|
303
|
+ placeholder: '请选择时间',
|
|
|
304
|
+ api: findDictItemByCode,
|
|
|
305
|
+ params: {
|
|
|
306
|
+ dictCode: 'every_day',
|
|
|
307
|
+ },
|
|
|
308
|
+ labelField: 'itemText',
|
|
|
309
|
+ valueField: 'itemValue',
|
|
|
310
|
+ },
|
|
|
311
|
+ ifShow: ({ values }) => isTiming(values.executeWay),
|
|
|
312
|
+ },
|
|
|
313
|
+ {
|
|
|
314
|
+ field: 'devices',
|
|
|
315
|
+ label: '设备',
|
|
|
316
|
+ component: 'Select',
|
|
|
317
|
+ slot: 'devices',
|
|
|
318
|
+ colProps: { span: 24 },
|
|
|
319
|
+ },
|
|
|
320
|
+ {
|
|
|
321
|
+ field: 'dataType',
|
|
|
322
|
+ label: '数据类型',
|
|
|
323
|
+ required: true,
|
|
|
324
|
+ component: 'Select',
|
|
|
325
|
+ componentProps: ({ formActionType }) => {
|
|
|
326
|
+ const { updateSchema, setFieldsValue } = formActionType;
|
|
|
327
|
+ const options = [
|
|
|
328
|
+ { label: '原始数据', value: 0 },
|
|
|
329
|
+ { label: '聚合数据', value: 1 },
|
|
|
330
|
+ ];
|
|
|
331
|
+ return {
|
|
|
332
|
+ options,
|
|
|
333
|
+ onSelect(e) {
|
|
|
334
|
+ let dataCompareOpions: any = [];
|
|
|
335
|
+ if (e == 0) {
|
|
|
336
|
+ setFieldsValue({ agg: 'NONE' });
|
|
|
337
|
+ dataCompareOpions = [{ label: '空', value: AggregateDataEnum.NONE }];
|
|
|
338
|
+ updateSchema({
|
|
|
339
|
+ field: SchemaFiled.AGG,
|
|
|
340
|
+ componentProps: {
|
|
|
341
|
+ options: dataCompareOpions,
|
|
|
342
|
+ },
|
|
|
343
|
+ });
|
|
|
344
|
+ } else {
|
|
|
345
|
+ setFieldsValue({ agg: '' });
|
|
|
346
|
+ dataCompareOpions = [
|
|
|
347
|
+ { label: '最小值', value: AggregateDataEnum.MIN },
|
|
|
348
|
+ { label: '最大值', value: AggregateDataEnum.MAX },
|
|
|
349
|
+ { label: '平均值', value: AggregateDataEnum.AVG },
|
|
|
350
|
+ { label: '求和', value: AggregateDataEnum.SUM },
|
|
|
351
|
+ { label: '计数', value: AggregateDataEnum.COUNT },
|
|
|
352
|
+ ];
|
|
|
353
|
+ updateSchema({
|
|
|
354
|
+ field: SchemaFiled.AGG,
|
|
|
355
|
+ componentProps: {
|
|
|
356
|
+ options: dataCompareOpions,
|
|
|
357
|
+ },
|
|
|
358
|
+ });
|
|
|
359
|
+ }
|
|
|
360
|
+ },
|
|
|
361
|
+ maxLength: 250,
|
|
|
362
|
+ placeholder: '请选择属性性质',
|
|
|
363
|
+ };
|
|
|
364
|
+ },
|
|
|
365
|
+ colProps: { span: 24 },
|
|
|
366
|
+ },
|
|
|
367
|
+ {
|
|
|
368
|
+ field: SchemaFiled.AGG,
|
|
|
369
|
+ label: '聚合条件',
|
|
|
370
|
+ component: 'Select',
|
|
|
371
|
+ required: true,
|
|
|
372
|
+ componentProps: {
|
|
|
373
|
+ placeholder: '请选择聚合条件',
|
|
|
374
|
+ getPopupContainer: () => document.body,
|
|
|
375
|
+ },
|
|
|
376
|
+ },
|
|
|
377
|
+ {
|
|
|
378
|
+ field: 'limit',
|
|
|
379
|
+ required: true,
|
|
|
380
|
+ label: '最大条数',
|
|
|
381
|
+ component: 'InputNumber',
|
|
|
382
|
+ defaultValue: 100,
|
|
|
383
|
+ ifShow({ values }) {
|
|
|
384
|
+ return values[SchemaFiled.AGG] === AggregateDataEnum.NONE;
|
|
|
385
|
+ },
|
|
|
386
|
+ colProps: { span: 12 },
|
|
|
387
|
+ componentProps: {
|
|
|
388
|
+ placeholder: '请输入最大条数',
|
|
|
389
|
+ min: 7,
|
|
|
390
|
+ max: 50000,
|
|
|
391
|
+ },
|
|
|
392
|
+ },
|
|
|
393
|
+ {
|
|
|
394
|
+ field: SchemaFiled.WAY,
|
|
|
395
|
+ label: '查询周期',
|
|
|
396
|
+ component: 'RadioGroup',
|
|
|
397
|
+ defaultValue: QueryWay.LATEST,
|
|
|
398
|
+ required: true,
|
|
|
399
|
+ componentProps({ formActionType }) {
|
|
|
400
|
+ const { setFieldsValue } = formActionType;
|
|
|
401
|
+ return {
|
|
|
402
|
+ placeholder: '请选择查询周期',
|
|
|
403
|
+ options: [
|
|
|
404
|
+ { label: '固定周期', value: QueryWay.LATEST },
|
|
|
405
|
+ { label: '自定义周期', value: QueryWay.TIME_PERIOD },
|
|
|
406
|
+ ],
|
|
|
407
|
+ onChange(value) {
|
|
|
408
|
+ console.log(value);
|
|
|
409
|
+ value === QueryWay.LATEST
|
|
|
410
|
+ ? setFieldsValue({
|
|
|
411
|
+ [SchemaFiled.DATE_RANGE]: [],
|
|
|
412
|
+ [SchemaFiled.START_TS]: null,
|
|
|
413
|
+ [SchemaFiled.END_TS]: null,
|
|
|
414
|
+ })
|
|
|
415
|
+ : setFieldsValue({ [SchemaFiled.START_TS]: null });
|
|
|
416
|
+ },
|
|
|
417
|
+ };
|
|
|
418
|
+ },
|
|
|
419
|
+ },
|
|
|
420
|
+ {
|
|
|
421
|
+ field: SchemaFiled.DATE_RANGE,
|
|
|
422
|
+ label: '时间段',
|
|
|
423
|
+ component: 'RangePicker',
|
|
|
424
|
+ required: true,
|
|
|
425
|
+ ifShow({ values }) {
|
|
|
426
|
+ return values[SchemaFiled.WAY] === QueryWay.TIME_PERIOD && !isFixedTime(values.executeWay);
|
|
|
427
|
+ },
|
|
|
428
|
+ // componentProps: {
|
|
|
429
|
+ // showTime: {
|
|
|
430
|
+ // defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
|
|
|
431
|
+ // },
|
|
|
432
|
+ // },
|
|
|
433
|
+ componentProps({ formActionType }) {
|
|
|
434
|
+ const { setFieldsValue } = formActionType;
|
|
|
435
|
+ let dates: Moment[] = [];
|
|
|
436
|
+ return {
|
|
|
437
|
+ showTime: {
|
|
|
438
|
+ defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
|
|
|
439
|
+ },
|
|
|
440
|
+ onCalendarChange(value: Moment[]) {
|
|
|
441
|
+ dates = value;
|
|
|
442
|
+ },
|
|
|
443
|
+ disabledDate(current: Moment) {
|
|
|
444
|
+ if (!dates || dates.length === 0 || !current) {
|
|
|
445
|
+ return false;
|
|
|
446
|
+ }
|
|
|
447
|
+ const diffDate = current.diff(dates[0], 'years', true);
|
|
|
448
|
+ return Math.abs(diffDate) > 1;
|
|
|
449
|
+ },
|
|
|
450
|
+ onChange() {
|
|
|
451
|
+ dates = [];
|
|
|
452
|
+ setFieldsValue({ dateGroupGap: null });
|
|
|
453
|
+ },
|
|
|
454
|
+ getPopupContainer: () => document.body,
|
|
|
455
|
+ };
|
|
|
456
|
+ },
|
|
|
457
|
+ colProps: {
|
|
|
458
|
+ span: 10,
|
|
|
459
|
+ },
|
|
|
460
|
+ },
|
|
|
461
|
+ {
|
|
|
462
|
+ field: 'dateGroupGap',
|
|
|
463
|
+ label: '分组间隔',
|
|
|
464
|
+ component: 'Select',
|
|
|
465
|
+ dynamicRules: ({ model }) => {
|
|
|
466
|
+ return [
|
|
|
467
|
+ {
|
|
|
468
|
+ required: model[SchemaFiled.AGG] !== AggregateDataEnum.NONE,
|
|
|
469
|
+ message: '分组间隔为必填项',
|
|
|
470
|
+ type: 'number',
|
|
|
471
|
+ },
|
|
|
472
|
+ ];
|
|
|
473
|
+ },
|
|
|
474
|
+ ifShow({ values }) {
|
|
|
475
|
+ return values[SchemaFiled.WAY] === QueryWay.TIME_PERIOD && !isFixedTime(values.executeWay);
|
|
|
476
|
+ },
|
|
|
477
|
+ componentProps({ formModel, formActionType }) {
|
|
|
478
|
+ const options =
|
|
|
479
|
+ formModel[SchemaFiled.WAY] === QueryWay.LATEST
|
|
|
480
|
+ ? getPacketIntervalByValue(formModel[SchemaFiled.START_TS])
|
|
|
481
|
+ : getPacketIntervalByRange(formModel[SchemaFiled.DATE_RANGE]);
|
|
|
482
|
+ if (formModel[SchemaFiled.AGG] !== AggregateDataEnum.NONE) {
|
|
|
483
|
+ formActionType.setFieldsValue({ [SchemaFiled.LIMIT]: null });
|
|
|
484
|
+ }
|
|
|
485
|
+ return {
|
|
|
486
|
+ options,
|
|
|
487
|
+ getPopupContainer: () => document.body,
|
|
|
488
|
+ };
|
|
|
489
|
+ },
|
|
|
490
|
+ },
|
|
|
491
|
+ {
|
|
|
492
|
+ field: SchemaFiled.START_TS,
|
|
|
493
|
+ label: '最近时间',
|
|
|
494
|
+ component: 'Select',
|
|
|
495
|
+ required: true,
|
|
|
496
|
+ ifShow({ values }) {
|
|
|
497
|
+ return values[SchemaFiled.WAY] == QueryWay.LATEST;
|
|
|
498
|
+ },
|
|
|
499
|
+ componentProps({ formActionType }) {
|
|
|
500
|
+ const { setFieldsValue } = formActionType;
|
|
|
501
|
+ return {
|
|
|
502
|
+ defaultValue: 1000,
|
|
|
503
|
+ placeholder: '请选择近期时间',
|
|
|
504
|
+ options: intervalOption,
|
|
|
505
|
+ onChange() {
|
|
|
506
|
+ setFieldsValue({ [SchemaFiled.INTERVAL]: null });
|
|
|
507
|
+ },
|
|
|
508
|
+ };
|
|
|
509
|
+ },
|
|
|
510
|
+ },
|
|
|
511
|
+ {
|
|
|
512
|
+ field: SchemaFiled.INTERVAL,
|
|
|
513
|
+ label: '间隔时间',
|
|
|
514
|
+ component: 'Select',
|
|
|
515
|
+ required: true,
|
|
|
516
|
+ ifShow({ values }) {
|
|
|
517
|
+ return values[SchemaFiled.WAY] == QueryWay.LATEST;
|
|
|
518
|
+ },
|
|
|
519
|
+ componentProps({ formModel, formActionType }) {
|
|
|
520
|
+ const options =
|
|
|
521
|
+ formModel[SchemaFiled.WAY] === QueryWay.LATEST
|
|
|
522
|
+ ? getPacketIntervalByValue(formModel[SchemaFiled.START_TS])
|
|
|
523
|
+ : getPacketIntervalByRange(formModel[SchemaFiled.DATE_RANGE]);
|
|
|
524
|
+ if (formModel[SchemaFiled.AGG] !== AggregateDataEnum.NONE) {
|
|
|
525
|
+ formActionType.setFieldsValue({ [SchemaFiled.LIMIT]: null });
|
|
|
526
|
+ }
|
|
|
527
|
+ return {
|
|
|
528
|
+ placeholder: '请选择间隔时间',
|
|
|
529
|
+ options,
|
|
|
530
|
+ };
|
|
|
531
|
+ },
|
|
|
532
|
+ },
|
|
|
533
|
+]; |