import { BasicColumn } from '@/components/Table';
import { FormSchema } from '/@/components/Form';
import { listDictModel } from '@/api/common';
import dayjs from 'dayjs';

export const BasicTab = [
  {
    key: '0',
    label: '全部',
    value: 128,
    hasValue: true,
    hasBracket: true,
  },
  {
    key: '1',
    label: '正常使用',
    value: 12,
    hasValue: true,
    prefixColor: '#1BC1B3',
    hasBracket: true,
  },
  {
    key: '2',
    label: '备用机',
    value: 18,
    hasValue: true,
    prefixColor: '#2D5AFF',
    hasBracket: true,
  },
  {
    key: '3',
    label: '报废机',
    value: 18,
    hasValue: true,
    prefixColor: '#D3D8DD',
    hasBracket: true,
  },
];

export const BasicTabActive = BasicTab[0].key;

// 抽屉搜索条件
export const siftFormSchema: FormSchema[] = [
  {
    label: '设备厂家',
    field: 'manufacturer',
    component: 'ApiSelect',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'pb_sex',
      },
    },
  },
  {
    label: '泵类型',
    field: 'pumpType',
    component: 'ApiSelect',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'bm_pump',
      },
    },
  },
  {
    label: '传染标识',
    field: 'infectiousDiseases',
    component: 'ApiSelect',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'pb_epidemic',
      },
    },
  },
];

export const columns: BasicColumn[] = [
  {
    title: '设备编号',
    dataIndex: 'unique',
    align: 'left',
  },
  {
    title: '设备厂家',
    dataIndex: 'manufacturer',
    align: 'left',
  },
  {
    title: '设备型号',
    dataIndex: 'model',
    align: 'left',
  },
  {
    title: '序列号',
    dataIndex: 'serialNumber',
    align: 'left',
  },
  {
    title: '设备类型',
    dataIndex: 'deviceType',
    align: 'left',
  },
  {
    title: '泵类型',
    dataIndex: 'pumpType',
    align: 'left',
  },
  {
    title: '传染标识',
    dataIndex: 'infectiousDiseases',
    align: 'left',
  },
  {
    title: '使用时间',
    dataIndex: 'useDate',
    align: 'left',
    width: 180,
    sorter: true,
  },
  {
    title: '生产时间',
    dataIndex: 'produceDate',
    align: 'left',
    width: 180,
    sorter: true,
  },
  {
    title: '保修期限(年)',
    dataIndex: 'warrantyPeriod',
    align: 'left',
  },
];

// 表单新增编辑
export const dataFormSchema: FormSchema[] = [
  {
    label: '设备编号',
    field: 'unique',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入设备编号',
      maxLength: 60,
    },
  },
  {
    label: '设备类型',
    field: 'deviceType',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'pb_blood',
      },
    },
  },
  {
    label: '传染标识',
    field: 'infectiousDiseases',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: listDictModel,
      mode: 'multiple',
      params: {
        dictCode: 'pb_epidemic',
      },
    },
  },
  {
    label: '序列号',
    field: 'serialNumber',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入序列号',
      maxLength: 60,
    },
  },

  {
    label: '备注',
    field: 'remark',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入备注',
    },
  },
  {
    label: '泵类型',
    field: 'pumpType',
    required: true,
    component: 'ApiRadioGroup',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'bm_pump',
      },
    },
  },
  {
    label: '设备厂家',
    field: 'manufacturer',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入设备厂家',
      maxLength: 60,
    },
  },
  {
    label: '型号',
    field: 'model',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入型号',
    },
  },
  {
    label: '产地',
    field: 'model',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入产地',
    },
  },
  {
    label: '采购金额(万元)',
    field: 'price',
    required: true,
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入采购金额(万元)',
    },
  },
  {
    label: '购入日期',
    field: 'birthday',
    required: true,
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      placeholder: '请输入购入日期',
      getPopupContainer: () => document.body,
      valueFormat: 'YYYY-MM-DD',
      disabledDate: current => {
        return current > dayjs().endOf('day');
      },
    },
  },
  {
    label: '使用日期',
    field: 'birthday',
    required: true,
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      placeholder: '请输入使用日期',
      getPopupContainer: () => document.body,
      valueFormat: 'YYYY-MM-DD',
      disabledDate: current => {
        return current > dayjs().endOf('day');
      },
    },
  },
  {
    label: '生产日期',
    field: 'birthday',
    required: true,
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      placeholder: '请输入生产日期',
      getPopupContainer: () => document.body,
      valueFormat: 'YYYY-MM-DD',
      disabledDate: current => {
        return current > dayjs().endOf('day');
      },
    },
  },
  {
    label: '保修期限(年)',
    field: 'price',
    required: true,
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入保修期限(年)',
    },
  },
];
