HistoryTable.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div class="history-table">
  3. <BasicTable ref="historyTable" @register="registerTable" />
  4. </div>
  5. </template>
  6. <script lang="ts" name="system-user" setup>
  7. //ts语法
  8. import { watchEffect, ref, reactive } from 'vue';
  9. import { BasicTable } from '/@/components/Table';
  10. import { useListPage } from '/@/hooks/system/useListPage';
  11. import { getTableHeaderColumns } from '/@/hooks/web/useWebColumns';
  12. import { defHttp } from '/@/utils/http/axios';
  13. import dayjs from 'dayjs';
  14. const historyTable = ref();
  15. const list = (params) => defHttp.get({ url: '/ventanaly-device/safety/ventanalyMonitorData/list', params });
  16. const emit = defineEmits(['change']);
  17. const props = defineProps({
  18. columnsType: {
  19. type: String,
  20. required: true,
  21. },
  22. deviceType: {
  23. type: String,
  24. required: true,
  25. },
  26. deviceListApi: {
  27. type: Function,
  28. required: true,
  29. },
  30. designScope: {
  31. type: String,
  32. },
  33. });
  34. const columns = getTableHeaderColumns(props.columnsType);
  35. // 列表页面公共参数、方法
  36. const { tableContext } = useListPage({
  37. tableProps: {
  38. api: list,
  39. columns: columns,
  40. canResize: true,
  41. showTableSetting: false,
  42. showActionColumn: false,
  43. bordered: false,
  44. size: 'small',
  45. formConfig: {
  46. labelAlign: 'left',
  47. showAdvancedButton: false,
  48. // autoAdvancedCol: 2,
  49. baseColProps: {
  50. // offset: 0.5,
  51. xs: 24,
  52. sm: 24,
  53. md: 24,
  54. lg: 9,
  55. xl: 7,
  56. xxl: 4,
  57. },
  58. schemas: [
  59. {
  60. label: '查询日期',
  61. field: 'tData',
  62. component: 'DatePicker',
  63. defaultValue: dayjs(),
  64. componentProps: {
  65. valueFormat: 'YYYY-MM-DD',
  66. },
  67. },
  68. {
  69. label: '时间区间',
  70. field: 'tickectDate',
  71. component: 'TimeRangePicker',
  72. componentProps: {
  73. placeholder: ['开始时间', '结束时间'],
  74. valueFormat: 'HH:mm:ss',
  75. },
  76. },
  77. {
  78. label: '查询设备',
  79. field: 'gdeviceid',
  80. component: 'ApiSelect',
  81. componentProps: {
  82. api: props.deviceListApi,
  83. resultField: 'records',
  84. labelField: 'strname',
  85. valueField: 'id',
  86. },
  87. },
  88. {
  89. label: '间隔时间',
  90. field: 'skip',
  91. component: 'Select',
  92. componentProps: {
  93. options: [
  94. {
  95. label: '5秒',
  96. value: '1',
  97. },
  98. {
  99. label: '10秒',
  100. value: '2',
  101. },
  102. {
  103. label: '1分钟',
  104. value: '3',
  105. },
  106. {
  107. label: '5分钟',
  108. value: '4',
  109. },
  110. {
  111. label: '10分钟',
  112. value: '5',
  113. },
  114. ],
  115. },
  116. },
  117. ],
  118. fieldMapToTime: [['tickectDate', ['ttime_begin', 'ttime_end'], '']],
  119. },
  120. fetchSetting: {
  121. listField: 'datalist.records',
  122. },
  123. pagination: {
  124. current: 1,
  125. pageSize: 5,
  126. pageSizeOptions: ['5', '10', '20'],
  127. },
  128. beforeFetch(params) {
  129. params.gdevicetype = props.deviceType + '*';
  130. },
  131. afterFetch(resultItems) {
  132. resultItems.map((item) => {
  133. Object.assign(item, item['readData']);
  134. });
  135. return resultItems;
  136. },
  137. },
  138. });
  139. //注册table数据
  140. const [registerTable, { getDataSource }] = tableContext;
  141. watchEffect(() => {
  142. if (historyTable.value && getDataSource) {
  143. const data = getDataSource() || [];
  144. emit('change', data);
  145. console.log('[ data ] >', data);
  146. }
  147. });
  148. </script>
  149. <style scoped lang="less">
  150. @import '/@/design/vent/color.less';
  151. :deep(.ant-table-body) {
  152. height: auto !important;
  153. }
  154. .history-table {
  155. width: 100%;
  156. :deep(.jeecg-basic-table-form-container) {
  157. .ant-table-title {
  158. min-height: 0 !important;
  159. }
  160. }
  161. }
  162. </style>