history.data.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import dayjs from 'dayjs';
  2. import { FormSchema } from '/@/components/Table';
  3. import { getAutoScrollContainer } from '/@/utils/common/compUtils';
  4. import { get } from 'lodash-es';
  5. /**
  6. * 默认的查询表单项props
  7. *
  8. * @param dictOptions 用于初始化子设备下拉框
  9. * @param deviceOptions 用于初始化设备下拉框
  10. * @param onDeviceChange 设备下拉框选择内容后的回调函数
  11. * @returns
  12. */
  13. export const getDefaultSchemas: (dictOptions: any[], deviceOptions: any[], onDeviceChange?: Function) => FormSchema[] = (
  14. dictOptions: any[],
  15. deviceOptions: any[],
  16. onDeviceChange?: Function
  17. ) => {
  18. const device = get(deviceOptions, '[0].value', '');
  19. const isRedis = get(deviceOptions, '[0].stationtype', 'redis') === 'redis';
  20. const dictcode = get(dictOptions, '[0].value', '');
  21. return [
  22. {
  23. field: 'ttime_begin',
  24. label: '开始时间',
  25. component: 'DatePicker',
  26. defaultValue: dayjs().startOf('date'),
  27. required: true,
  28. componentProps: {
  29. showTime: true,
  30. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  31. getPopupContainer: getAutoScrollContainer,
  32. },
  33. colProps: {
  34. span: 5,
  35. },
  36. },
  37. {
  38. field: 'ttime_end',
  39. label: '结束时间',
  40. component: 'DatePicker',
  41. defaultValue: dayjs(),
  42. required: true,
  43. componentProps: {
  44. showTime: true,
  45. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  46. getPopupContainer: getAutoScrollContainer,
  47. },
  48. colProps: {
  49. span: 5,
  50. },
  51. },
  52. {
  53. label: '查询设备',
  54. field: 'deviceId',
  55. component: 'Select',
  56. required: true,
  57. defaultValue: VENT_PARAM.historyIsMultiple ? [device] : device,
  58. componentProps: {
  59. options: deviceOptions,
  60. mode: VENT_PARAM.historyIsMultiple ? 'multiple' : undefined,
  61. maxTagCount: 'responsive',
  62. onChange: onDeviceChange,
  63. },
  64. colProps: {
  65. span: 5,
  66. },
  67. },
  68. {
  69. label: '子设备',
  70. field: 'deviceNum',
  71. component: 'Select',
  72. required: isRedis ? false : Boolean(dictOptions.length),
  73. show: isRedis ? false : Boolean(dictOptions.length),
  74. defaultValue: isRedis ? '' : dictcode,
  75. componentProps: {
  76. options: dictOptions,
  77. // onChange: (e, option) => {
  78. // },
  79. },
  80. colProps: {
  81. span: 4,
  82. },
  83. },
  84. ];
  85. };