1
0

unitTable.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <!--定义表格-->
  3. <BasicTable @register="registerTable" />
  4. </template>
  5. <script lang="ts" name="basic-table-demo" setup>
  6. import { BasicTable } from '/@/components/Table';
  7. import { useListPage } from '/@/hooks/system/useListPage';
  8. import { UnitTableColumns } from '../gasPumpSetting.data';
  9. import { getEvaluationUnitList } from '../gasPumpSetting.api';
  10. import { onMounted, onUnmounted } from 'vue';
  11. const { tableContext } = useListPage({
  12. designScope: 'basic-table-demo',
  13. tableProps: {
  14. columns: UnitTableColumns,
  15. size: 'small',
  16. useSearchForm: false,
  17. showActionColumn: false,
  18. showTableSetting: false,
  19. },
  20. });
  21. // BasicTable绑定注册
  22. const [registerTable, { setPagination, setLoading, setTableData }] = tableContext;
  23. function fetchTableData() {
  24. setLoading(true);
  25. return getEvaluationUnitList({})
  26. .then(({ current, total, records }) => {
  27. setPagination({
  28. current,
  29. total,
  30. });
  31. setTableData(records);
  32. })
  33. .finally(() => {
  34. setLoading(false);
  35. });
  36. }
  37. let timer: any = null;
  38. onMounted(() => {
  39. timer = setInterval(() => {
  40. fetchTableData();
  41. }, 10000);
  42. fetchTableData();
  43. });
  44. onUnmounted(() => {
  45. timer = clearInterval(timer);
  46. });
  47. </script>