Showing
2 changed files
with
351 additions
and
53 deletions
| ... | ... | @@ -6,31 +6,20 @@ import { copyTransFun } from '/@/utils/fnUtils'; |
| 6 | 6 | import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; |
| 7 | 7 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; |
| 8 | 8 | import { findDictItemByCode } from '/@/api/system/dict'; |
| 9 | - | |
| 10 | -export enum TypeEnum { | |
| 11 | - IS_TIMING = 'TIMING', | |
| 12 | - IS_WEEK = 'week', | |
| 13 | - IS_MONTH = 'month', | |
| 14 | -} | |
| 15 | -export const isTiming = (type: string) => { | |
| 16 | - return type === TypeEnum.IS_TIMING; | |
| 17 | -}; | |
| 18 | -export const isWeek = (type: string) => { | |
| 19 | - return type === TypeEnum.IS_WEEK; | |
| 20 | -}; | |
| 21 | - | |
| 22 | -export const isMonth = (type: string) => { | |
| 23 | - return type === TypeEnum.IS_MONTH; | |
| 24 | -}; | |
| 25 | - | |
| 26 | -export enum AggregateDataEnum { | |
| 27 | - MIN = 'MIN', | |
| 28 | - MAX = 'MAX', | |
| 29 | - AVG = 'AVG', | |
| 30 | - SUM = 'SUM', | |
| 31 | - COUNT = 'COUNT', | |
| 32 | - NONE = 'NONE', | |
| 33 | -} | |
| 9 | +import { | |
| 10 | + optionsConfig, | |
| 11 | + isTiming, | |
| 12 | + isWeek, | |
| 13 | + isMonth, | |
| 14 | + isEmpty, | |
| 15 | + isDefultWeek, | |
| 16 | + isMin, | |
| 17 | + isMax, | |
| 18 | + isAvg, | |
| 19 | + isSum, | |
| 20 | + isCountAll, | |
| 21 | + AggregateDataEnum, | |
| 22 | +} from './timeConfig'; | |
| 34 | 23 | |
| 35 | 24 | // 表格配置 |
| 36 | 25 | export const columns: BasicColumn[] = [ |
| ... | ... | @@ -366,7 +355,7 @@ export const formSchema: QFormSchema[] = [ |
| 366 | 355 | colProps: { span: 24 }, |
| 367 | 356 | }, |
| 368 | 357 | { |
| 369 | - field: '10', | |
| 358 | + field: 'condition', | |
| 370 | 359 | label: '聚合条件', |
| 371 | 360 | required: true, |
| 372 | 361 | component: 'Select', |
| ... | ... | @@ -389,56 +378,229 @@ export const formSchema: QFormSchema[] = [ |
| 389 | 378 | label: '最小值', |
| 390 | 379 | value: AggregateDataEnum.MIN, |
| 391 | 380 | }, |
| 381 | + { | |
| 382 | + label: '计数', | |
| 383 | + value: AggregateDataEnum.COUNTALL, | |
| 384 | + }, | |
| 385 | + { | |
| 386 | + label: '空', | |
| 387 | + value: AggregateDataEnum.EMPTY, | |
| 388 | + }, | |
| 392 | 389 | ], |
| 393 | 390 | }, |
| 394 | 391 | colProps: { span: 24 }, |
| 395 | 392 | }, |
| 396 | 393 | { |
| 397 | - field: '91112', | |
| 394 | + field: 'maxNumber', | |
| 395 | + component: 'InputNumber', | |
| 396 | + label: '最大值', | |
| 397 | + required: true, | |
| 398 | + defaultValue: 200, | |
| 399 | + colProps: { span: 22 }, | |
| 400 | + componentProps: { | |
| 401 | + min: 7, | |
| 402 | + max: 50000, | |
| 403 | + }, | |
| 404 | + ifShow: ({ values }) => isEmpty(values.condition), | |
| 405 | + }, | |
| 406 | + { | |
| 407 | + field: 'defaultWeek', | |
| 408 | + component: 'ApiRadioGroup', | |
| 398 | 409 | label: '查询周期', |
| 399 | 410 | required: true, |
| 400 | - component: 'Select', | |
| 411 | + colProps: { | |
| 412 | + span: 24, | |
| 413 | + }, | |
| 414 | + defaultValue: '2', | |
| 401 | 415 | componentProps: { |
| 402 | 416 | placeholder: '请选择查询周期', |
| 403 | 417 | options: [ |
| 404 | - { label: '1秒', value: '1000' }, | |
| 405 | - { label: '5秒', value: '5000' }, | |
| 406 | - { label: '10秒', value: '10000' }, | |
| 407 | - { label: '15秒', value: '15000' }, | |
| 408 | - { label: '30秒', value: '30000' }, | |
| 409 | - { label: '1分', value: '60000' }, | |
| 410 | - { label: '2分', value: '120000' }, | |
| 411 | - { label: '5分', value: '300000' }, | |
| 412 | - { label: '10分', value: '600000' }, | |
| 413 | - { label: '15分', value: '900000' }, | |
| 414 | - { label: '30分', value: '1800000' }, | |
| 415 | - { label: '1小时', value: '3600000' }, | |
| 416 | - { label: '2小时', value: '7200000' }, | |
| 417 | - { label: '5小时', value: '18000000' }, | |
| 418 | - { label: '10小时', value: '36000000' }, | |
| 419 | - { label: '12小时', value: '43200000' }, | |
| 420 | - { label: '1天', value: '86400000' }, | |
| 421 | - { label: '7天', value: '604800000' }, | |
| 422 | - { label: '30天', value: '2592000000' }, | |
| 418 | + { | |
| 419 | + label: '自定义周期', | |
| 420 | + value: 'defaultIsWeek', | |
| 421 | + }, | |
| 422 | + { | |
| 423 | + label: '固定周期', | |
| 424 | + value: '2', | |
| 425 | + }, | |
| 423 | 426 | ], |
| 424 | 427 | }, |
| 428 | + }, | |
| 429 | + { | |
| 430 | + field: '3ddsadds', | |
| 431 | + label: '时间段', | |
| 432 | + required: true, | |
| 433 | + component: 'RangePicker', | |
| 434 | + componentProps: { | |
| 435 | + showTime: { | |
| 436 | + defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')], | |
| 437 | + }, | |
| 438 | + placeholder: '请选择时间段', | |
| 439 | + }, | |
| 440 | + colProps: { span: 6 }, | |
| 441 | + ifShow: ({ values }) => isDefultWeek(values.defaultWeek), | |
| 442 | + }, | |
| 443 | + { | |
| 444 | + field: '91112', | |
| 445 | + label: '时间周期', | |
| 446 | + required: true, | |
| 447 | + component: 'ApiSelect', | |
| 448 | + defaultValue: '1000', | |
| 449 | + componentProps: ({ formActionType }) => { | |
| 450 | + const { updateSchema } = formActionType; | |
| 451 | + return { | |
| 452 | + api: async () => { | |
| 453 | + const data: any = await findDictItemByCode({ dictCode: 'query_week' }); | |
| 454 | + const option = data.map((item) => { | |
| 455 | + return { | |
| 456 | + label: item.itemText, | |
| 457 | + value: item.itemValue, | |
| 458 | + }; | |
| 459 | + }); | |
| 460 | + return option; | |
| 461 | + }, | |
| 462 | + async onChange(e) { | |
| 463 | + if (Number(e) <= 30000) { | |
| 464 | + //30秒以内 -> 1秒 | |
| 465 | + updateSchema({ | |
| 466 | + field: '102121', | |
| 467 | + componentProps: { | |
| 468 | + options: optionsConfig.slice(0, 1), | |
| 469 | + }, | |
| 470 | + }); | |
| 471 | + } else if (Number(e) == 60000) { | |
| 472 | + //1分钟以内 -> 1秒 5秒 | |
| 473 | + updateSchema({ | |
| 474 | + field: '102121', | |
| 475 | + componentProps: { | |
| 476 | + options: optionsConfig.slice(0, 2), | |
| 477 | + }, | |
| 478 | + }); | |
| 479 | + } else if (Number(e) == 120000) { | |
| 480 | + //2分钟以内 -> 1秒 5秒 10 15 | |
| 481 | + updateSchema({ | |
| 482 | + field: '102121', | |
| 483 | + componentProps: { | |
| 484 | + options: optionsConfig.slice(0, 4), | |
| 485 | + }, | |
| 486 | + }); | |
| 487 | + } else if (Number(e) == 300000) { | |
| 488 | + //5分钟以内 -> 1秒 5秒 10 15 30 | |
| 489 | + updateSchema({ | |
| 490 | + field: '102121', | |
| 491 | + componentProps: { | |
| 492 | + options: optionsConfig.slice(0, 5), | |
| 493 | + }, | |
| 494 | + }); | |
| 495 | + } else if (Number(e) == 600000) { | |
| 496 | + //10分钟以内 -> 5秒 10 15 30 1分钟 | |
| 497 | + updateSchema({ | |
| 498 | + field: '102121', | |
| 499 | + componentProps: { | |
| 500 | + options: optionsConfig.slice(1, 2).concat(optionsConfig.slice(2, 6)), | |
| 501 | + }, | |
| 502 | + }); | |
| 503 | + } else if (Number(e) == 900000 || Number(e) == 1800000) { | |
| 504 | + //15 30 分钟以内 -> 5秒 10 15 30 1分钟 2分钟 | |
| 505 | + updateSchema({ | |
| 506 | + field: '102121', | |
| 507 | + componentProps: { | |
| 508 | + options: optionsConfig.slice(1, 2).concat(optionsConfig.slice(2, 7)), | |
| 509 | + }, | |
| 510 | + }); | |
| 511 | + } else if (Number(e) == 3600000) { | |
| 512 | + //1小时以内 -> 10秒 15 30 1分钟 2分钟 5分钟 | |
| 513 | + updateSchema({ | |
| 514 | + field: '102121', | |
| 515 | + componentProps: { | |
| 516 | + options: optionsConfig.slice(2, 8), | |
| 517 | + }, | |
| 518 | + }); | |
| 519 | + } else if (Number(e) == 7200000) { | |
| 520 | + //2小时以内 -> 15秒 30 1分钟 2分钟 5分钟 10 15 | |
| 521 | + updateSchema({ | |
| 522 | + field: '102121', | |
| 523 | + componentProps: { | |
| 524 | + options: optionsConfig.slice(3, 10), | |
| 525 | + }, | |
| 526 | + }); | |
| 527 | + } else if (Number(e) == 18000000) { | |
| 528 | + //5小时以内 -> 1分钟 2分钟 5分钟 10 15 30 | |
| 529 | + updateSchema({ | |
| 530 | + field: '102121', | |
| 531 | + componentProps: { | |
| 532 | + options: optionsConfig.slice(5, 11), | |
| 533 | + }, | |
| 534 | + }); | |
| 535 | + } else if (Number(e) == 36000000 || Number(e) == 43200000) { | |
| 536 | + //10 12小时以内 -> 2分钟 5分钟 10 15 30 1小时 | |
| 537 | + updateSchema({ | |
| 538 | + field: '102121', | |
| 539 | + componentProps: { | |
| 540 | + options: optionsConfig.slice(6, 12), | |
| 541 | + }, | |
| 542 | + }); | |
| 543 | + } else if (Number(e) == 86400000) { | |
| 544 | + //1天以内 -> 5分钟 10 15 30 1小时 2 | |
| 545 | + updateSchema({ | |
| 546 | + field: '102121', | |
| 547 | + componentProps: { | |
| 548 | + options: optionsConfig.slice(7, 13), | |
| 549 | + }, | |
| 550 | + }); | |
| 551 | + } else if (Number(e) == 604800000) { | |
| 552 | + //7天以内 -> 30分钟 1小时 2 5 10 12 1天 | |
| 553 | + updateSchema({ | |
| 554 | + field: '102121', | |
| 555 | + componentProps: { | |
| 556 | + options: optionsConfig.slice(10, 17), | |
| 557 | + }, | |
| 558 | + }); | |
| 559 | + } else if (Number(e) == 2592000000) { | |
| 560 | + //30天以内 -> 2小时 5 10 12 1天 | |
| 561 | + updateSchema({ | |
| 562 | + field: '102121', | |
| 563 | + componentProps: { | |
| 564 | + options: optionsConfig.slice(12, 17), | |
| 565 | + }, | |
| 566 | + }); | |
| 567 | + } | |
| 568 | + }, | |
| 569 | + maxLength: 250, | |
| 570 | + placeholder: '请选择查询周期', | |
| 571 | + }; | |
| 572 | + }, | |
| 425 | 573 | colProps: { span: 24 }, |
| 574 | + ifShow: ({ values }) => | |
| 575 | + (!isEmpty(values.condition) && !isDefultWeek(values.defaultWeek)) || | |
| 576 | + isMin(values.condition) || | |
| 577 | + isMax(values.condition) || | |
| 578 | + isAvg(values.condition) || | |
| 579 | + isSum(values.condition) || | |
| 580 | + isCountAll(values.condition), | |
| 426 | 581 | }, |
| 427 | 582 | { |
| 428 | 583 | field: '102121', |
| 429 | 584 | label: '间隔时间', |
| 430 | 585 | required: true, |
| 431 | 586 | component: 'Select', |
| 587 | + colProps: { span: 24 }, | |
| 588 | + defaultValue: '1000', | |
| 432 | 589 | componentProps: { |
| 433 | 590 | placeholder: '请选择间隔时间', |
| 434 | 591 | options: [ |
| 435 | - { label: '2小时', value: '7200000' }, | |
| 436 | - { label: '5小时', value: '18000000' }, | |
| 437 | - { label: '10小时', value: '36000000' }, | |
| 438 | - { label: '12小时', value: '43200000' }, | |
| 439 | - { label: '1天', value: '86400000' }, | |
| 592 | + { | |
| 593 | + label: '1秒', | |
| 594 | + value: '1000', | |
| 595 | + }, | |
| 440 | 596 | ], |
| 441 | 597 | }, |
| 442 | - colProps: { span: 24 }, | |
| 598 | + ifShow: ({ values }) => | |
| 599 | + (!isEmpty(values.condition) && !isDefultWeek(values.defaultWeek)) || | |
| 600 | + isMin(values.condition) || | |
| 601 | + isMax(values.condition) || | |
| 602 | + isAvg(values.condition) || | |
| 603 | + isSum(values.condition) || | |
| 604 | + isCountAll(values.condition), | |
| 443 | 605 | }, |
| 444 | 606 | ]; | ... | ... |
src/views/report/config/timeConfig.ts
0 → 100644
| 1 | +interface IOptionConfig { | |
| 2 | + label: string; | |
| 3 | + value: string; | |
| 4 | +} | |
| 5 | + | |
| 6 | +export const optionsConfig: IOptionConfig[] = [ | |
| 7 | + { | |
| 8 | + label: '1秒', | |
| 9 | + value: '1000', | |
| 10 | + }, | |
| 11 | + { | |
| 12 | + label: '5秒', | |
| 13 | + value: '5000', | |
| 14 | + }, | |
| 15 | + { | |
| 16 | + label: '10秒', | |
| 17 | + value: '10000', | |
| 18 | + }, | |
| 19 | + { | |
| 20 | + label: '15秒', | |
| 21 | + value: '15000', | |
| 22 | + }, | |
| 23 | + { | |
| 24 | + label: '30秒', | |
| 25 | + value: '30000', | |
| 26 | + }, | |
| 27 | + { | |
| 28 | + label: '1分钟', | |
| 29 | + value: '60000', | |
| 30 | + }, | |
| 31 | + { | |
| 32 | + label: '2分钟', | |
| 33 | + value: '120000', | |
| 34 | + }, | |
| 35 | + { | |
| 36 | + label: '5分钟', | |
| 37 | + value: '300000', | |
| 38 | + }, | |
| 39 | + { | |
| 40 | + label: '10分钟', | |
| 41 | + value: '600000', | |
| 42 | + }, | |
| 43 | + { | |
| 44 | + label: '15分钟', | |
| 45 | + value: '900000', | |
| 46 | + }, | |
| 47 | + { | |
| 48 | + label: '30分钟', | |
| 49 | + value: '1800000', | |
| 50 | + }, | |
| 51 | + { | |
| 52 | + label: '1小时', | |
| 53 | + value: '3600000', | |
| 54 | + }, | |
| 55 | + { | |
| 56 | + label: '2小时', | |
| 57 | + value: '7200000', | |
| 58 | + }, | |
| 59 | + { | |
| 60 | + label: '5小时', | |
| 61 | + value: '18000000', | |
| 62 | + }, | |
| 63 | + { | |
| 64 | + label: '10小时', | |
| 65 | + value: '36000000', | |
| 66 | + }, | |
| 67 | + { | |
| 68 | + label: '12小时', | |
| 69 | + value: '43200000', | |
| 70 | + }, | |
| 71 | + { | |
| 72 | + label: '1天', | |
| 73 | + value: '86400000', | |
| 74 | + }, | |
| 75 | +]; | |
| 76 | + | |
| 77 | +export enum TypeEnum { | |
| 78 | + IS_TIMING = 'TIMING', | |
| 79 | + IS_WEEK = 'week', | |
| 80 | + IS_MONTH = 'month', | |
| 81 | + IS_EMPTY = 'EMPTY', | |
| 82 | + IS_DEFAULT_WEEK = 'defaultIsWeek', | |
| 83 | + IS_MIN = 'MIN', | |
| 84 | + IS_MAX = 'MAX', | |
| 85 | + IS_AVG = 'AVG', | |
| 86 | + IS_SUM = 'SUM', | |
| 87 | + COUNTALL = 'COUNTALL', | |
| 88 | +} | |
| 89 | + | |
| 90 | +export enum AggregateDataEnum { | |
| 91 | + MIN = 'MIN', | |
| 92 | + MAX = 'MAX', | |
| 93 | + AVG = 'AVG', | |
| 94 | + SUM = 'SUM', | |
| 95 | + COUNTALL = 'COUNTALL', | |
| 96 | + EMPTY = 'EMPTY', | |
| 97 | +} | |
| 98 | + | |
| 99 | +export const isTiming = (type: string) => { | |
| 100 | + return type === TypeEnum.IS_TIMING; | |
| 101 | +}; | |
| 102 | + | |
| 103 | +export const isWeek = (type: string) => { | |
| 104 | + return type === TypeEnum.IS_WEEK; | |
| 105 | +}; | |
| 106 | + | |
| 107 | +export const isMonth = (type: string) => { | |
| 108 | + return type === TypeEnum.IS_MONTH; | |
| 109 | +}; | |
| 110 | + | |
| 111 | +export const isEmpty = (type: string) => { | |
| 112 | + return type === TypeEnum.IS_EMPTY; | |
| 113 | +}; | |
| 114 | + | |
| 115 | +export const isDefultWeek = (type: string) => { | |
| 116 | + return type === TypeEnum.IS_DEFAULT_WEEK; | |
| 117 | +}; | |
| 118 | + | |
| 119 | +export const isMin = (type: string) => { | |
| 120 | + return type === TypeEnum.IS_MIN; | |
| 121 | +}; | |
| 122 | + | |
| 123 | +export const isMax = (type: string) => { | |
| 124 | + return type === TypeEnum.IS_MAX; | |
| 125 | +}; | |
| 126 | + | |
| 127 | +export const isAvg = (type: string) => { | |
| 128 | + return type === TypeEnum.IS_AVG; | |
| 129 | +}; | |
| 130 | +export const isSum = (type: string) => { | |
| 131 | + return type === TypeEnum.IS_SUM; | |
| 132 | +}; | |
| 133 | + | |
| 134 | +export const isCountAll = (type: string) => { | |
| 135 | + return type === TypeEnum.COUNTALL; | |
| 136 | +}; | ... | ... |