Showing
1 changed file
with
59 additions
and
5 deletions
1 | import { ref } from 'vue'; | 1 | import { ref } from 'vue'; |
2 | import { BasicColumn, FormSchema } from '/@/components/Table'; | 2 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
3 | import type { FormSchema as QFormSchema } from '/@/components/Form/index'; | 3 | import type { FormSchema as QFormSchema } from '/@/components/Form/index'; |
4 | -import moment from 'moment'; | ||
5 | import { getOrganizationList } from '/@/api/system/system'; | 4 | import { getOrganizationList } from '/@/api/system/system'; |
6 | import { copyTransFun } from '/@/utils/fnUtils'; | 5 | import { copyTransFun } from '/@/utils/fnUtils'; |
7 | import { findDictItemByCode } from '/@/api/system/dict'; | 6 | import { findDictItemByCode } from '/@/api/system/dict'; |
@@ -12,6 +11,7 @@ import { | @@ -12,6 +11,7 @@ import { | ||
12 | getPacketIntervalByValue, | 11 | getPacketIntervalByValue, |
13 | intervalOption, | 12 | intervalOption, |
14 | } from '../../device/localtion/cpns/TimePeriodForm/helper'; | 13 | } from '../../device/localtion/cpns/TimePeriodForm/helper'; |
14 | +import moment, { Moment } from 'moment'; | ||
15 | 15 | ||
16 | export enum QueryWay { | 16 | export enum QueryWay { |
17 | LATEST = 'latest', | 17 | LATEST = 'latest', |
@@ -433,16 +433,70 @@ export const formSchema: QFormSchema[] = [ | @@ -433,16 +433,70 @@ export const formSchema: QFormSchema[] = [ | ||
433 | ifShow({ values }) { | 433 | ifShow({ values }) { |
434 | return values[SchemaFiled.WAY] === QueryWay.TIME_PERIOD && !isFixedTime(values.executeWay); | 434 | return values[SchemaFiled.WAY] === QueryWay.TIME_PERIOD && !isFixedTime(values.executeWay); |
435 | }, | 435 | }, |
436 | - componentProps: { | ||
437 | - showTime: { | ||
438 | - defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')], | ||
439 | - }, | 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 | + }; | ||
440 | }, | 464 | }, |
441 | colProps: { | 465 | colProps: { |
442 | span: 10, | 466 | span: 10, |
443 | }, | 467 | }, |
444 | }, | 468 | }, |
445 | { | 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 | + { | ||
446 | field: SchemaFiled.START_TS, | 500 | field: SchemaFiled.START_TS, |
447 | label: '最近时间', | 501 | label: '最近时间', |
448 | component: 'Select', | 502 | component: 'Select', |