import { BasicColumn, FormSchema } from '@jdlinker/ui';
import { Badge, Space } from 'ant-design-vue';

export const statusMap = {
  1: <Badge status='success' text='正常' />,
  0: <Badge status='error' text='禁用' />
};

//列表数据
export const columns: BasicColumn[] = [
  {
    title: '产品编号',
    align: 'center',
    dataIndex: 'id'
  },
  {
    title: '产品名称',
    align: 'center',
    dataIndex: 'name'
  },
  {
    title: '接入方式',
    align: 'center',
    dataIndex: 'accessName',
    width: 120
  },
  {
    title: '设备类型',
    align: 'center',
    dataIndex: 'deviceType',
    width: 120,
    customRender: ({ record }) => {
      return record.deviceType?.text;
    }
  },
  {
    title: '状态',
    align: 'center',
    dataIndex: 'state',
    width: 120,
    customRender: ({ record }) => {
      return <Space size={0}>{statusMap[record.state]}</Space>;
    }
  }
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '产品名称',
    field: 'name',
    component: 'JInput'
  },
  {
    label: '设备类型',
    field: 'deviceType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'device_type'
    }
  },
  {
    label: '消息协议',
    field: 'messageProtocol',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'linker_device_protocol,name,id'
    }
  }
];
