history.data.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. * @returns
  11. */
  12. export const getDefaultSchemas: (dictOptions: any[], deviceOptions: any[], onDeviceChange?: Function) => FormSchema[] = (
  13. dictOptions: any[],
  14. deviceOptions: any[],
  15. onDeviceChange?: Function
  16. ) => {
  17. const device = get(deviceOptions, '[0].value', '');
  18. const dictcode = get(dictOptions, '[0].value', '');
  19. const isRedis = get(deviceOptions, '[0].stationtype', 'redis') === 'redis';
  20. return [
  21. {
  22. field: 'ttime_begin',
  23. label: '开始时间',
  24. component: 'DatePicker',
  25. defaultValue: dayjs().startOf('date'),
  26. required: true,
  27. componentProps: {
  28. showTime: true,
  29. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  30. getPopupContainer: getAutoScrollContainer,
  31. },
  32. colProps: {
  33. span: 4,
  34. },
  35. },
  36. {
  37. field: 'ttime_end',
  38. label: '结束时间',
  39. component: 'DatePicker',
  40. defaultValue: dayjs(),
  41. required: true,
  42. componentProps: {
  43. showTime: true,
  44. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  45. getPopupContainer: getAutoScrollContainer,
  46. },
  47. colProps: {
  48. span: 4,
  49. },
  50. },
  51. {
  52. label: '查询设备',
  53. field: 'gdeviceids',
  54. component: 'Select',
  55. required: true,
  56. defaultValue: VENT_PARAM.historyIsMultiple ? [device] : device,
  57. componentProps: {
  58. options: deviceOptions,
  59. mode: VENT_PARAM.historyIsMultiple ? 'multiple' : undefined,
  60. maxTagCount: 'responsive',
  61. onChange: onDeviceChange,
  62. },
  63. colProps: {
  64. span: 6,
  65. },
  66. },
  67. {
  68. label: '子设备',
  69. field: 'deviceNum',
  70. component: 'Select',
  71. required: isRedis ? false : Boolean(dictOptions.length),
  72. show: isRedis ? false : Boolean(dictOptions.length),
  73. defaultValue: isRedis ? '' : dictcode,
  74. componentProps: {
  75. options: dictOptions,
  76. // onChange: (e, option) => {
  77. // nextTick(async () => {
  78. // await getDataSource();
  79. // });
  80. // },
  81. },
  82. colProps: {
  83. span: 3,
  84. },
  85. },
  86. // {
  87. // label: '子设备',
  88. // field: 'deviceNum',
  89. // // component: 'JDictSelectTag',
  90. // // show: Boolean(dictCode),
  91. // componentProps: {
  92. // dictCode,
  93. // showChooseOption: false,
  94. // placeholder: '请选择',
  95. // },
  96. // colProps: {
  97. // span: 4,
  98. // },
  99. // },
  100. {
  101. label: '间隔时间',
  102. field: 'skip',
  103. component: 'Select',
  104. defaultValue: '8',
  105. componentProps: {
  106. options: [
  107. {
  108. label: '1秒',
  109. value: '1',
  110. },
  111. {
  112. label: '5秒',
  113. value: '2',
  114. },
  115. {
  116. label: '10秒',
  117. value: '3',
  118. },
  119. {
  120. label: '30秒',
  121. value: '4',
  122. },
  123. {
  124. label: '1分钟',
  125. value: '5',
  126. },
  127. {
  128. label: '10分钟',
  129. value: '6',
  130. },
  131. {
  132. label: '30分钟',
  133. value: '7',
  134. },
  135. {
  136. label: '1小时',
  137. value: '8',
  138. },
  139. ],
  140. },
  141. colProps: {
  142. span: 3,
  143. },
  144. },
  145. ];
  146. };