import { doFetch } from '@/utils/doFetch';
import { Image } from 'antd';
function getcolumns(setdrawer) {
  return [
    {
      title: '用户名',
      dataIndex: 'username',
      width: 120,
      key: 'username',
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
    },
    {
      title: '姓名',
      dataIndex: 'fullName',
      width: 100,
      key: 'fullName',
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      render: (text, row) => {
        return (
          <a
            onClick={() => {
              setdrawer((s) => ({
                ...s,
                visible: true,
                item: row,
                title: '详情',
                detailpath: '/auth/sysUser/detail',
                params: { id: row.id },
                val: 'detail',
                title: row.fullName + '的详细信息',
              }));
            }}
          >
            {row.fullName}
          </a>
        );
      },
    },
    { title: '手机号', hideInTable: true, dataIndex: 'telephone', key: 'telephone' },
    { title: '邮箱', dataIndex: 'mailNo', key: 'mailNo', hideInTable: true, search: false },
    {
      title: '公司名称',
      align: 'center',
      dataIndex: 'organizationName',
      width: 120,
      key: 'organizationId',
      valueType: 'select',
      options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
    },
    {
      title: '部门名称',
      width: 120,
      align: 'center',
      valueType: 'select',
      dataIndex: 'departmentName',
      key: 'departmentId',
      options: {
        path: '/auth/sysDepartment/query/depart/selectbox',
        linkParams: {
          organizationId: 'parentId',
        },
      },
    },
    {
      title: '负责工厂',
      dataIndex: 'factoryNames',
      align: 'center',
      key: 'factoryNames',
      hideInTable: true,
      hideInForm: true,
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
    },
    {
      title: '负责车间',
      dataIndex: 'shopNames',
      key: 'shopNames',
      align: 'center',
      hideInTable: true,
      hideInForm: true,
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
    },
    {
      title: '角色名称',
      dataIndex: 'roleNames',
      key: 'roleNames',
      hideInForm: true,
      hideInTable: true,
    },
    {
      title: '负责工厂',
      dataIndex: 'factoryNames',
      key: 'factoryNames',
      search: false,
      fieldProps: {
        placeholder: '请选择',
        showSearch: true,
        mode: 'multiple',
      },
      width: 120,
      align: 'center',
      valueType: 'select',
      options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
    },
    {
      title: '负责车间',
      dataIndex: 'shopNames',
      search: false,
      align: 'center',
      fieldProps: {
        placeholder: '请选择',
        showSearch: true,
        mode: 'multiple',
      },
      width: 120,
      valueType: 'select',
      options: {
        path: '/auth/sysShop/getShopSelectionByFactoryIdList',
        linkParams: {
          factoryNames: 'factoryIdList',
        },
      },
      key: 'shopId',
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
    },
    {
      title: '负责工段',
      width: 120,
      dataIndex: 'sectionName',
      align: 'center',
      search: false,
      key: 'sectionId',
      fieldProps: {
        placeholder: '请选择',
        showSearch: true,
        mode: 'multiple',
      },
      valueType: 'select',
      options: {
        path: '/auth/sysSection/getAllSectionSelectionByShopIdList',
        linkParams: {
          shopId: 'shopIdList',
        },
      },
    },
    {
      title: '负责产线',
      search: false,
      width: 120,
      dataIndex: 'productionLines',
      valueType: 'select',
      fieldProps: {
        placeholder: '请选择',
        showSearch: true,
        mode: 'multiple',
      },
      search: false,
      key: 'productLineName',
      align: 'center',
      options: {
        path: '/auth/sysProductionLine/getAllProductLineSelectionByShopIdList',
        linkParams: {
          shopId: 'shopIdList',
        },
      },
    },
    {
      title: '角色配置',
      dataIndex: 'roleNames',
      key: 'roleNames',
      valueType: 'select',
      search: false,
      fieldProps: {
        placeholder: '请选择',
        showSearch: true,
        mode: 'multiple',
      },
      options: {
        path: '/auth/sysRole/selection',
      },
    },
    {
      title: '直属领导',
      valueType: 'select',
      dataIndex: 'parentName',
      key: 'parentId',
      options: {
        path: '/auth/sysUser/selection',
      },
      fieldProps: {
        placeholder: '请选择',
        showSearch: true,
      },
    },
    {
      title: '状态',
      hideInTable: true,
      dataIndex: 'statusName',
      key: 'status',
      valueType: 'radio',
      options: [
        {
          label: '启用',
          value: 1,
        },
        {
          label: '禁用',
          value: 0,
        },
      ],
    },
    // {
    //   title: '状态',
    //   width: 50,
    //   hideInForm: true,
    //   dataIndex: 'statusName',
    //   key: 'status',
    //   search: false,
    // },
    {
      title: '备注',
      hideInTable: true,
      dataIndex: 'remarks',
      valueType: 'textarea',
      key: 'remarks',
      search: false,
    },
    // { title: '个人图片', hideInTable: true, dataIndex: 'userImgList', key: 'userImgList' },
    {
      title: '个人图片',
      search: false,
      dataIndex: 'userImgList',
      key: 'userImgList',
      valueType: 'uploadImage',
      hideInTable: true,
      fieldProps: {
        limit: 2,
      },
      formItemProps: {
        rules: [
          {
            required: true,
            message: '此项为必填项',
          },
        ],
      },
      render: (text, row) => {
        if (row?.pictureUrl == null) {
          return '暂无图片';
        } else {
          return <Image width={70} src={row.pictureUrl} />;
        }
      },
    },
  ];
}

export default getcolumns;