config.data.ts 3.89 KB
import type { BasicColumn } from '/@/components/Table';
import type { FormSchema } from '/@/components/Table';
import { getOrganizationList } from '/@/api/system/system';
import { copyTransFun } from '/@/utils/fnUtils';
import { getDeviceProfile } from '/@/api/alarm/position';

export enum AggregateDataEnum {
  MIN = 'MIN',
  MAX = 'MAX',
  AVG = 'AVG',
  SUM = 'SUM',
  COUNT = 'COUNT',
  NONE = 'NONE',
}
export const formSchema: FormSchema[] = [
  {
    field: 'organizationId',
    label: '',
    component: 'ApiTreeSelect',
    componentProps: {
      api: async () => {
        const data = await getOrganizationList();
        copyTransFun(data as any as any[]);
        return data;
      },
    },
  },
  {
    field: 'profileId',
    label: '',
    component: 'ApiSelect',
    componentProps: {
      api: getDeviceProfile,
      placeholder: '请选择设备配置',
      labelField: 'name',
      valueField: 'id',
    },
  },
  {
    field: 'name',
    label: '',
    component: 'Input',
    componentProps: {
      placeholder: '请输入设备名称',
    },
  },
  {
    field: 'deviceState',
    label: '',
    component: 'RadioGroup',
    componentProps: {
      size: 'small',
      options: [
        { label: '全部', value: '' },
        { label: '待激活', value: 'INACTIVE' },
        { label: '在线', value: 'ONLINE' },
        { label: '离线', value: 'OFFLINE' },
      ],
    },
  },
  {
    field: 'alarmStatus',
    label: '是否告警',
    component: 'RadioGroup',
    labelWidth: '85px',
    componentProps: {
      size: 'small',
      options: [
        { label: '是', value: '1' },
        { label: '否', value: '0' },
      ],
    },
  },
];

export const columns: BasicColumn[] = [
  {
    title: '名称',
    dataIndex: 'name',
    width: 100,
  },
  {
    title: '位置',
    dataIndex: 'deviceInfo.address',
    width: 100,
  },
  {
    title: '状态',
    dataIndex: 'deviceState',
    width: 100,
    slots: { customRender: 'deviceState' },
  },
];

export const schemas: FormSchema[] = [
  {
    field: 'name',
    label: '最后数据',
    component: 'Select',
    componentProps: {
      options: [
        {
          label: '最近1小时',
          value: '1',
        },
        {
          label: '最近2小时',
          value: '2',
        },
        {
          label: '最近5小时',
          value: '5',
        },
        {
          label: '最近12小时',
          value: '12',
        },
        {
          label: '最近1天',
          value: '1天',
        },
        {
          label: '最近7天',
          value: '7天',
        },
        {
          label: '最近30天',
          value: '30天',
        },
      ],
    },
    colProps: {
      span: 6,
    },
  },
  {
    field: 'name',
    label: '分组间隔',
    component: 'Select',
    componentProps: {
      options: [
        {
          label: '15秒',
          value: '15',
        },
        {
          label: '30秒',
          value: '30',
        },
        {
          label: '1分钟',
          value: '60',
        },
        {
          label: '2分钟',
          value: '120',
        },
        {
          label: '5分钟',
          value: '360',
        },
        {
          label: '10分钟',
          value: '600',
        },
        {
          label: '15分钟',
          value: '900',
        },
      ],
    },
    colProps: {
      span: 6,
    },
  },
  {
    field: 'name',
    label: '数据聚合功能',
    component: 'Select',
    componentProps: {
      options: [
        {
          label: '最小值',
          value: AggregateDataEnum.MIN,
        },
        {
          label: '最大值',
          value: AggregateDataEnum.MAX,
        },
        {
          label: '平均值',
          value: AggregateDataEnum.AVG,
        },
        {
          label: '求和',
          value: AggregateDataEnum.SUM,
        },
      ],
    },
    colProps: {
      span: 6,
    },
  },
];