1
0

history.data.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 isRedis = get(deviceOptions, '[0].stationtype', 'redis') === 'redis';
  15. return [
  16. {
  17. field: 'ttime_begin',
  18. label: '开始时间',
  19. component: 'DatePicker',
  20. defaultValue: dayjs().startOf('date'),
  21. required: true,
  22. componentProps: {
  23. showTime: true,
  24. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  25. getPopupContainer: getAutoScrollContainer,
  26. },
  27. colProps: {
  28. span: 4,
  29. },
  30. },
  31. {
  32. field: 'ttime_end',
  33. label: '结束时间',
  34. component: 'DatePicker',
  35. defaultValue: dayjs(),
  36. required: true,
  37. componentProps: {
  38. showTime: true,
  39. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  40. getPopupContainer: getAutoScrollContainer,
  41. },
  42. colProps: {
  43. span: 4,
  44. },
  45. },
  46. {
  47. label: '查询设备',
  48. field: 'gdeviceids',
  49. component: 'Select',
  50. required: true,
  51. defaultValue: isRedis ? device : [device],
  52. componentProps: {
  53. options: deviceOptions,
  54. // onChange: (e, option) => {
  55. mode: isRedis ? undefined : 'multiple',
  56. maxTagCount: 'responsive',
  57. // nextTick(async () => {
  58. // await getDataSource();
  59. // });
  60. // },
  61. },
  62. colProps: {
  63. span: 4,
  64. },
  65. },
  66. {
  67. label: '子设备',
  68. field: 'deviceNum',
  69. component: 'Select',
  70. required: Boolean(dictOptions.length),
  71. show: Boolean(dictOptions.length),
  72. defaultValue: dictOptions[0] ? dictOptions[0].value : '',
  73. componentProps: {
  74. options: dictOptions,
  75. // onChange: (e, option) => {
  76. // nextTick(async () => {
  77. // await getDataSource();
  78. // });
  79. // },
  80. },
  81. colProps: {
  82. span: 4,
  83. },
  84. },
  85. // {
  86. // label: '子设备',
  87. // field: 'deviceNum',
  88. // // component: 'JDictSelectTag',
  89. // // show: Boolean(dictCode),
  90. // componentProps: {
  91. // dictCode,
  92. // showChooseOption: false,
  93. // placeholder: '请选择',
  94. // },
  95. // colProps: {
  96. // span: 4,
  97. // },
  98. // },
  99. {
  100. label: '间隔时间',
  101. field: 'skip',
  102. component: 'Select',
  103. defaultValue: '8',
  104. componentProps: {
  105. options: [
  106. {
  107. label: '1秒',
  108. value: '1',
  109. },
  110. {
  111. label: '5秒',
  112. value: '2',
  113. },
  114. {
  115. label: '10秒',
  116. value: '3',
  117. },
  118. {
  119. label: '30秒',
  120. value: '4',
  121. },
  122. {
  123. label: '1分钟',
  124. value: '5',
  125. },
  126. {
  127. label: '10分钟',
  128. value: '6',
  129. },
  130. {
  131. label: '30分钟',
  132. value: '7',
  133. },
  134. {
  135. label: '1小时',
  136. value: '8',
  137. },
  138. ],
  139. },
  140. colProps: {
  141. span: 4,
  142. },
  143. },
  144. ];
  145. };
  146. /** 默认的表格props,参考 BasicTable 组件 */
  147. export const defaultTableProps: BasicTableProps = {
  148. columns: [
  149. {
  150. align: 'center',
  151. dataIndex: 'strinstallpos',
  152. defaultHidden: false,
  153. title: '安装位置',
  154. width: 80,
  155. },
  156. ],
  157. bordered: false,
  158. size: 'small',
  159. showIndexColumn: true,
  160. showActionColumn: false,
  161. };
  162. /** 默认的查询表单props,参考 BasicForm 组件 */
  163. export const defaultFormProps: FormProps = {
  164. labelAlign: 'left',
  165. labelCol: { span: 8 },
  166. showAdvancedButton: false,
  167. showSubmitButton: false,
  168. showResetButton: false,
  169. };
  170. /** 默认的表格分页props,参考 BasicTable 组件 */
  171. export const defaultPaginationProps: PaginationProps = {
  172. current: 1,
  173. pageSize: 10,
  174. pageSizeOptions: ['10', '30', '50', '100'],
  175. showQuickJumper: false,
  176. };