import { Switch } from 'antd';

function getcolumns(changeState) {
  return {
    columns: [
      {
        title: '供应商编号',
        dataIndex: 'supplierNo',
        key: 'supplierNo',
      },
      {
        title: '供应商名称',
        dataIndex: 'supplierName',
        key: 'supplierName',
        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
      },
      {
        title: '官网',
        dataIndex: 'officialWebsite',
        key: 'officialWebsite',
        hideInSearch: true,
        hideInTable: true,
      },
      {
        title: '联系电话',
        dataIndex: 'telephone',
        key: 'telephone',
      },
      {
        title: '邮箱',
        dataIndex: 'email',
        key: 'email',
      },
      {
        title: '地址',
        dataIndex: 'address',
        key: 'address',
        hideInSearch: true,
      },
      {
        title: '备注',
        dataIndex: 'remark',
        key: 'remark',
        colProps: {
          span: 24,
        },
        valueType: 'textarea',
        hideInSearch: true,
      },
      {
        title: '评分',
        dataIndex: 'score',
        key: 'score',
        valueType: 'rate',
      },
      {
        title: '状态',
        dataIndex: 'statusName',
        key: 'status',
        valueType: 'select',
        mode: 'radio',
        options: [
          {
            label: '启用',
            value: 1,
          },
          {
            label: '停用',
            value: 2,
          },
        ],
        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
        render: (text, row) => {
          return (
            <Switch
              checked={row?.status == 1}
              checkedChildren="启用"
              unCheckedChildren="停用"
              onChange={(e) => {
                changeState({ id: row.id, status: e ? 1 : 2 });
              }}
            />
          );
        },
      },
      {
        title: '列表',
        valueType: 'formList',
        dataIndex: 'userList',
        colProps: {
          xs: 24,
          sm: 24,
        },
        columns: [
          {
            title: '联系人名称',
            dataIndex: 'userName',
            key: 'userName',
            formItemProps: {
              rules: [
                {
                  required: true,
                  message: '此项为必填项',
                },
              ],
            },
            colProps: {
              sm: 6,
            },
          },
          {
            title: '联系电话',
            dataIndex: 'telephone',
            key: 'telephone',
            colProps: {
              sm: 6,
            },
          },
          {
            title: '邮箱',
            dataIndex: 'email',
            key: 'email',
            colProps: {
              sm: 6,
            },
          },
          {
            title: '职务',
            dataIndex: 'title',
            key: 'title',
            colProps: {
              sm: 6,
            },
          },
        ],
        hideInSearch: true,
        hideInTable: true,
      },
    ],
    pathconfig: {
      enableadd: true,
      enableedit: true,
      enabledelete: true,
      enabledetail: true,
      add: '/sparepart/sparePartSupplier/save',
      edit: '/sparepart/sparePartSupplier/save',
      list: '/sparepart/sparePartSupplier/queryList',
      delete: '/sparepart/sparePartSupplier/deleteById',
      detail: '/sparepart/sparePartSupplier/queryDetails',
    },
  };
}
export default getcolumns;
