HistoryTable.vue 4.3 KB

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