xiaoyi
5 天以前 27c8277d717b34b55f3ea967027b53b067f77df3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<script lang="ts" setup>
  import type { VxeTableGridOptions } from '#/adapter/vxe-table';
  import type { MesDvTelemetryApi } from '#/api/mes/dv/telemetry';
 
  import { watch } from 'vue';
 
  import { Tag } from 'ant-design-vue';
 
  import { useVbenVxeGrid } from '#/adapter/vxe-table';
  import { getLatestTelemetry } from '#/api/mes/dv/telemetry';
 
  import { useLatestColumns } from '../../telemetry/data';
 
  const props = defineProps<{ tbDeviceId?: string }>();
 
  const [Grid, gridApi] = useVbenVxeGrid({
    gridOptions: {
      columns: useLatestColumns(),
      height: 320,
      keepSource: true,
      // /latest 返回裸数组,需关闭分页,否则 vxe 会按 {list,total} 解析导致不展示
      pagerConfig: { enabled: false },
      proxyConfig: {
        ajax: {
          query: async () =>
            await getLatestTelemetry({ tbDeviceId: props.tbDeviceId }),
        },
      },
      rowConfig: { keyField: 'id', isHover: true },
      toolbarConfig: { refresh: true },
    } as VxeTableGridOptions<MesDvTelemetryApi.Telemetry>,
  });
 
  watch(
    () => props.tbDeviceId,
    (value) => {
      if (value) {
        gridApi.query();
      }
    },
  );
</script>
 
<template>
  <Grid table-title="数采实时数据">
    <template #anomaly="{ row }">
      <Tag :color="row.whetherAnomaly ? 'red' : 'green'">
        {{ row.whetherAnomaly ? '异常' : '正常' }}
      </Tag>
    </template>
  </Grid>
</template>