HistoryTable.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 } 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. scroll: {
  38. type: Object,
  39. default: () => { }
  40. }
  41. });
  42. const columns = getTableHeaderColumns(props.columnsType);
  43. // 列表页面公共参数、方法
  44. const { tableContext } = useListPage({
  45. tableProps: {
  46. api: list,
  47. columns: columns,
  48. canResize: true,
  49. showTableSetting: false,
  50. showActionColumn: false,
  51. bordered: false,
  52. size: 'small',
  53. scroll: props.scroll,
  54. formConfig: {
  55. labelAlign: 'left',
  56. showAdvancedButton: false,
  57. // autoAdvancedCol: 2,
  58. baseColProps: {
  59. // offset: 0.5,
  60. xs: 24,
  61. sm: 24,
  62. md: 24,
  63. lg: 9,
  64. xl: 7,
  65. xxl: 4,
  66. },
  67. schemas: [
  68. {
  69. label: '查询日期',
  70. field: 'tData',
  71. component: 'DatePicker',
  72. defaultValue: dayjs(),
  73. componentProps: {
  74. valueFormat: 'YYYY-MM-DD',
  75. },
  76. },
  77. {
  78. label: '时间区间',
  79. field: 'tickectDate',
  80. component: 'TimeRangePicker',
  81. componentProps: {
  82. placeholder: ['开始时间', '结束时间'],
  83. valueFormat: 'HH:mm:ss',
  84. },
  85. },
  86. {
  87. label: '查询设备',
  88. field: 'gdeviceid',
  89. component: 'ApiSelect',
  90. componentProps: {
  91. api: props.deviceListApi,
  92. resultField: 'records',
  93. labelField: 'strname',
  94. valueField: 'id',
  95. },
  96. },
  97. {
  98. label: '间隔时间',
  99. field: 'skip',
  100. component: 'Select',
  101. componentProps: {
  102. options: [
  103. {
  104. label: '5秒',
  105. value: '1',
  106. },
  107. {
  108. label: '10秒',
  109. value: '2',
  110. },
  111. {
  112. label: '1分钟',
  113. value: '3',
  114. },
  115. {
  116. label: '5分钟',
  117. value: '4',
  118. },
  119. {
  120. label: '10分钟',
  121. value: '5',
  122. },
  123. ],
  124. },
  125. },
  126. ],
  127. fieldMapToTime: [['tickectDate', ['ttime_begin', 'ttime_end'], '']],
  128. },
  129. fetchSetting: {
  130. listField: 'datalist.records',
  131. },
  132. pagination: {
  133. current: 1,
  134. pageSize: 5,
  135. pageSizeOptions: ['5', '10', '20'],
  136. },
  137. beforeFetch(params) {
  138. params.strtype = props.deviceType + '*';
  139. },
  140. afterFetch(resultItems) {
  141. resultItems.map((item) => {
  142. Object.assign(item, item['readData']);
  143. });
  144. return resultItems;
  145. },
  146. },
  147. });
  148. //注册table数据
  149. const [registerTable, { getDataSource }] = tableContext;
  150. watchEffect(() => {
  151. if (historyTable.value && getDataSource) {
  152. const data = getDataSource() || [];
  153. emit('change', data);
  154. console.log('[ data ] >', data);
  155. }
  156. });
  157. </script>
  158. <style scoped lang="less">
  159. @import '/@/design/vent/color.less';
  160. :deep(.@{ventSpace}-table-body) {
  161. height: auto !important;
  162. }
  163. :deep(.zxm-picker){
  164. height: 30px !important;
  165. }
  166. .history-table {
  167. width: 100%;
  168. :deep(.jeecg-basic-table-form-container) {
  169. .@{ventSpace}-table-title {
  170. min-height: 0 !important;
  171. }
  172. }
  173. }
  174. </style>