index.vue 2.09 KB
<script lang="ts" setup>
  import { reactive, ref } from 'vue';
  import { useMultipleDataFetch } from '../../../hook/useSocket';
  import { ComponentPropsConfigType, MultipleDataFetchUpdateFn } from '../../../index.type';
  import { option } from './config';
  import { DeviceName } from '/@/views/visual/commonComponents/DeviceName';
  import { BasicTable, useTable, BasicColumn } from '/@/components/Table';

  const props = defineProps<{
    config: ComponentPropsConfigType<typeof option>;
  }>();

  const realTimeList = ref<any>([
    { attribute: '测试', price: 2, time: '2023-06-29' },
    { attribute: '测试1', price: 21, time: '2023-06-29' },
    { attribute: '测试2', price: 213, time: '2023-06-29' },
  ]);
  const realTimeColumn = reactive<BasicColumn[]>([
    { title: '属性', dataIndex: 'attribute', width: 80, ellipsis: true },
    { title: '值', dataIndex: 'price', width: 80, ellipsis: true },
    { title: '时间', dataIndex: 'time', width: 80, ellipsis: true },
  ]);

  const [registerTable] = useTable({
    showIndexColumn: false,
    showTableSetting: false,
    dataSource: realTimeList,
    canResize: true,
    maxHeight: 144,
    size: 'small',
    // columns: [{ title: '属性', dataIndex: 'attribute', width: 80 }],
    columns: realTimeColumn as any,
  });

  // const getDesign = computed(() => {
  //   const { persetOption, option } = props.config;
  //   clearInterval;
  //   return {};
  // });

  // const randomFn = () => {
  //   useIntervalFn(() => {
  //     const value = (Math.random() * 100).toFixed(0);
  //     unref(chartInstance)?.setOption({
  //       series: [{ data: [{ value }] }, { data: [{ value }] }],
  //     } as EChartsOption);
  //   }, 3000);
  // };

  const updateFn: MultipleDataFetchUpdateFn = () => {};

  useMultipleDataFetch(props, updateFn);

  // const { getRatio } = useComponentScale(props);
</script>

<template>
  <main class="flex flex-col justify-center items-center">
    <DeviceName :config="config" />
    <div>
      <!-- <PageWrapper> -->
      <BasicTable @register="registerTable" />
      <!-- </PageWrapper> -->
    </div>
  </main>
</template>