history.data.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import dayjs from 'dayjs';
  2. import { BasicTableProps, PaginationProps, FormProps, 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[]) => FormSchema[] = (dictOptions: any[], deviceOptions: any[]) => {
  13. const device = get(deviceOptions, '[0].value', '');
  14. const dictcode = get(dictOptions, '[0].value', '');
  15. const isRedis = get(deviceOptions, '[0].stationtype', 'redis') === 'redis';
  16. return [
  17. {
  18. field: 'ttime_begin',
  19. label: '开始时间',
  20. component: 'DatePicker',
  21. defaultValue: dayjs().startOf('date'),
  22. required: true,
  23. componentProps: {
  24. showTime: true,
  25. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  26. getPopupContainer: getAutoScrollContainer,
  27. },
  28. colProps: {
  29. span: 4,
  30. },
  31. },
  32. {
  33. field: 'ttime_end',
  34. label: '结束时间',
  35. component: 'DatePicker',
  36. defaultValue: dayjs(),
  37. required: true,
  38. componentProps: {
  39. showTime: true,
  40. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  41. getPopupContainer: getAutoScrollContainer,
  42. },
  43. colProps: {
  44. span: 4,
  45. },
  46. },
  47. {
  48. label: '查询设备',
  49. field: 'gdeviceids',
  50. component: 'Select',
  51. required: true,
  52. defaultValue: isRedis ? device : [device],
  53. componentProps: {
  54. options: deviceOptions,
  55. // onChange: (e, option) => {
  56. mode: isRedis ? undefined : 'multiple',
  57. maxTagCount: 'responsive',
  58. // nextTick(async () => {
  59. // await getDataSource();
  60. // });
  61. // },
  62. },
  63. colProps: {
  64. span: 4,
  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: 4,
  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: 4,
  143. },
  144. },
  145. ];
  146. };
  147. /** 默认的表格props,参考 BasicTable 组件 */
  148. export const defaultTableProps: BasicTableProps = {
  149. columns: [
  150. {
  151. align: 'center',
  152. dataIndex: 'strinstallpos',
  153. defaultHidden: false,
  154. title: '安装位置',
  155. width: 80,
  156. },
  157. ],
  158. bordered: false,
  159. size: 'small',
  160. showIndexColumn: true,
  161. showActionColumn: false,
  162. };
  163. /** 默认的查询表单props,参考 BasicForm 组件 */
  164. export const defaultFormProps: FormProps = {
  165. labelAlign: 'left',
  166. labelCol: { span: 8 },
  167. showAdvancedButton: false,
  168. showSubmitButton: false,
  169. showResetButton: false,
  170. };
  171. /** 默认的表格分页props,参考 BasicTable 组件 */
  172. export const defaultPaginationProps: PaginationProps = {
  173. current: 1,
  174. pageSize: 10,
  175. pageSizeOptions: ['10', '30', '50', '100'],
  176. showQuickJumper: false,
  177. };