import { Image, Tag } from 'antd';

function getcolumns(setdrawer) {
  return [
    {
      title: '设备编号',
      dataIndex: 'equipmentNo',
      key: 'equipmentNo',
      align: 'center',
      width: 120,
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
    },
    {
      title: '设备名称',
      dataIndex: 'equipmentName',
      align: 'center',
      width: 120,
      key: 'equipmentName',
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
    },
    { title: '位置号', width: 120, align: 'center', dataIndex: 'positionNo', key: 'positionNo' },
    {
      width: 120,
      title: '设备类型',
      align: 'center',
      dataIndex: 'equipmentTypeName',
      key: 'equipmentTypeId',
      valueType: 'treeSelect',
      options: { path: '/asset/equipmentType/queryTreeList', params: {} },
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
    },
    {
      title: '设备型号',
      dataIndex: 'equipmentModelName',
      width: 120,
      align: 'center',
      key: 'equipmentModelId',
      valueType: 'select',
      options: { path: '/asset/equipmentModel/query/selection', params: {} },
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
    },
    {
      title: '公司名称',
      align: 'center',
      dataIndex: 'organizationName',
      width: 120,
      key: 'organizationId',
      valueType: 'select',
      options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
    },
    {
      title: '部门名称',
      width: 120,
      align: 'center',
      valueType: 'select',
      dataIndex: 'departmentName',
      key: 'departmentId',
      options: {
        path: '/auth/sysDepartment/query/depart/selectbox',
        linkParams: {
          organizationId: 'parentId',
        },
      },
    },
    {
      title: '工厂名称',
      dataIndex: 'factoryName',
      key: 'factoryId',
      width: 120,
      align: 'center',
      valueType: 'select',
      options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
    },
    {
      title: '车间名称',
      dataIndex: 'shopName',
      align: 'center',
      width: 120,
      valueType: 'select',
      options: {
        path: '/auth/sysShop/getShopSelectionByFactory',
        linkParams: {
          factoryId: '',
        },
      },
      key: 'shopId',
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
    },
    {
      title: '工段名称',
      width: 120,
      dataIndex: 'sectionName',
      align: 'center',
      key: 'sectionId',
      valueType: 'select',
      options: {
        path: '/auth/sysSection/getAllSectionSelectionByShop',
        linkParams: {
          shopId: '',
        },
      },
    },
    {
      title: '产线名称',
      width: 120,
      dataIndex: 'productLineName',
      valueType: 'select',
      key: 'productLineName',
      align: 'center',
      options: {
        path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
        linkParams: {
          shopId: '',
        },
      },
    },
    {
      title: '供应商',
      width: 120,
      valueType: 'select',
      dataIndex: 'supplierName',
      align: 'center',
      hideInTable: true,
      key: 'supplierId',
      options: {
        path: '/asset/equipmentSupplier/query/selection',
        params: {},
      },
    },
    {
      title: '设备原值(万元)',
      hideInTable: true,
      align: 'center',
      dataIndex: 'equipmentWorth',
      key: 'equipmentWorth',
    },
    {
      title: '安装投产日期',
      hideInTable: true,
      align: 'center',
      dataIndex: 'productDate',
      key: 'productDate',
      valueType: 'date',
    },
    {
      title: '图片',
      width: 120,
      dataIndex: 'pictureUrl',
      search: false,
      key: 'picList',
      align: 'center',
      valueType: 'uploadImage',
      fieldProps: {
        limit: 1,
      },
      formItemProps: {
        rules: [
          {
            required: true,
            message: '此项为必填项',
          },
        ],
      },
      render: (text, row) => {
        if (row?.pictureUrl == null) {
          return '暂无图片';
        } else {
          return <Image width={70} src={row.pictureUrl} />;
        }
      },
    },
    {
      title: '二维码',
      width: 120,
      align: 'center',
      align: 'center',
      dataIndex: 'qrCodeUrl',
      key: 'qrCodeUrl',
      valueType: 'uploadImage',
      search: false,
      hideInForm: true,
      render: (text, row) => {
        if (row?.qrCodeUrl == null) {
          return '暂无图片';
        } else {
          return <Image width={70} src={row.qrCodeUrl} />;
        }
      },
    },
    {
      title: '状态名称',
      align: 'center',
      hideInTable: true,
      dataIndex: 'statusName',
      key: 'statusName',
      hideInForm: true,
    },
    {
      title: '设备状态',
      dataIndex: 'status',
      width: 120,
      align: 'center',
      hideInForm: true,
      fixed: 'right',
      key: 'status',
      render: (text, row) => {
        switch (row.status) {
          case 1:
            return <Tag color="success">在用</Tag>;
          case 3:
            return <Tag>报废</Tag>;
          case 2:
            return <Tag color="volcano">借用中</Tag>;
          default:
            break;
        }
      },
    },
  ];
}

export default getcolumns;