import { doFetch } from '@/utils/doFetch';
import { Image } from 'antd';
import fieldsDetail from '@/utils/fieldsDetail';
import { useState, useEffect } from 'react';
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={async () => {
            //   let newfieldscolumns = [];
            //   const fieldscolumns = [
            //     {
            //       title: '用户名',
            //       dataIndex: 'username',
            //       key: 'username',
            //     },
            //     {
            //       title: '姓名',
            //       dataIndex: 'fullName',
            //       key: 'fullName',
            //     },
            //     { title: '手机号', dataIndex: 'telephone', key: 'telephone' },
            //     {
            //       title: '邮箱',
            //       dataIndex: 'mailNo',
            //       key: 'mailNo',
            //     },
            //     {
            //       title: '公司名称',
            //       dataIndex: 'organizationName',
            //       key: 'organizationId',
            //     },
            //     {
            //       title: '部门名称',
            //       dataIndex: 'departmentName',
            //       key: 'departmentId',
            //     },
            //     {
            //       title: '负责工厂',
            //       dataIndex: 'factoryNames',
            //       key: 'factoryNames',
            //     },
            //     {
            //       title: '负责车间',
            //       dataIndex: 'shopNames',
            //       key: 'shopNames',
            //     },
            //     {
            //       title: '负责工段',
            //       dataIndex: 'sectionName',
            //       key: 'sectionIdList',
            //     },
            //     {
            //       title: '负责产线',
            //       dataIndex: 'productionLines',
            //       key: 'productionLineIdList',
            //     },
            //     {
            //       title: '角色配置',
            //       dataIndex: 'roleNames',
            //       key: 'roleIdList',
            //     },
            //     {
            //       title: '直属领导',
            //       dataIndex: 'parentName',
            //       key: 'parentId',
            //     },
            //     {
            //       title: '状态',
            //       dataIndex: 'statusName',
            //       key: 'status',
            //     },
            //   ];
            //   const selectValueType = (type, options) => {
            //     switch (type) {
            //       case 1:
            //         return {
            //           valueType: 'input',
            //         };
            //       case 2:
            //         return {
            //           valueType: 'select',
            //           options,
            //         };
            //       case 3:
            //         return {
            //           valueType: 'radio',
            //           options,
            //         };
            //       case 4:
            //         return {
            //           valueType: 'select',
            //           options,
            //         };
            //       default:
            //         break;
            //     }
            //   };

            //   let res = await doFetch({
            //     url: '/base/paFormField/queryList',
            //     params: {
            //       formId: '1',
            //     },
            //   });
            //   if (res?.data?.dataList) {
            //     let column = [
            //       {
            //         title: '扩展字段',
            //         valueType: 'split',
            //       },
            //     ];
            //     res?.data?.dataList?.forEach((el) => {
            //       column.push({
            //         ...selectValueType(el.fieldChar, el.valueList),
            //         title: el.fieldName,
            //         dataIndex: el.id,
            //         key: el.id,
            //       });
            //     });
            //     newfieldscolumns = fieldscolumns.concat(column);
            //     //console.log('fieldscolumns', newfieldscolumns);
            //   }
            //   setdrawer((s) => ({
            //     ...s,
            //     visible: true,
            //     item: row,
            //     title: '详情',
            //     fields: newfieldscolumns,
            //     extendField: 'userCharList',
            //     detailpath: '/auth/sysUser/detail',
            //     params: { id: row.id },
            //     val: 'detail',
            //     title: row.fullName + '的详细信息',
            //   }));
            // }}
            onClick={() => {
              fieldsDetail(
                [
                  {
                    title: '用户名',
                    dataIndex: 'username',
                    key: 'username',
                  },
                  {
                    title: '姓名',
                    dataIndex: 'fullName',
                    key: 'fullName',
                  },
                  { title: '手机号', dataIndex: 'telephone', key: 'telephone' },
                  {
                    title: '邮箱',
                    dataIndex: 'mailNo',
                    key: 'mailNo',
                  },
                  {
                    title: '公司名称',
                    dataIndex: 'organizationName',
                    key: 'organizationId',
                  },
                  {
                    title: '部门名称',
                    dataIndex: 'departmentName',
                    key: 'departmentId',
                  },
                  {
                    title: '负责工厂',
                    dataIndex: 'factoryNames',
                    key: 'factoryNames',
                  },
                  {
                    title: '负责车间',
                    dataIndex: 'shopNames',
                    key: 'shopNames',
                  },
                  {
                    title: '负责工段',
                    dataIndex: 'sectionName',
                    key: 'sectionIdList',
                  },
                  {
                    title: '负责产线',
                    dataIndex: 'productionLines',
                    key: 'productionLineIdList',
                  },
                  {
                    title: '角色配置',
                    dataIndex: 'roleNames',
                    key: 'roleIdList',
                  },
                  {
                    title: '直属领导',
                    dataIndex: 'parentName',
                    key: 'parentId',
                  },
                  {
                    title: '状态',
                    dataIndex: 'statusName',
                    key: 'status',
                  },
                ],
                setdrawer,
                row,
                '1',
                '/auth/sysUser/detail',
              );
            }}
          >
            {row.fullName}
          </a>
        );
      },
    },
    {
      title: '手机号',
      hideInTable: true,
      dataIndex: 'telephone',
      key: 'telephone',
      hideInTable: true,
      search: false,
    },
    { 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: 'factoryIdList',
      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: {
          factoryIdList: 'factoryIdList',
        },
      },
      key: 'shopIdList',
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
    },
    {
      title: '负责工段',
      width: 120,
      dataIndex: 'sectionNames',
      align: 'center',
      search: false,
      key: 'sectionIdList',
      fieldProps: {
        placeholder: '请选择',
        showSearch: true,
        mode: 'multiple',
      },
      valueType: 'select',
      options: {
        path: '/auth/sysSection/getAllSectionSelectionByShopIdList',
        linkParams: {
          shopIdList: '',
        },
      },
    },
    {
      title: '负责产线',
      search: false,
      width: 120,
      dataIndex: 'productionLines',
      valueType: 'select',
      fieldProps: {
        placeholder: '请选择',
        showSearch: true,
        mode: 'multiple',
      },
      search: false,
      key: 'productionLineIdList',
      align: 'center',
      options: {
        path: '/auth/sysProductionLine/getAllProductLineSelectionByShopIdList',
        linkParams: {
          shopIdList: '',
        },
      },
    },
    {
      title: '角色配置',
      dataIndex: 'roleNames',
      key: 'roleIdList',
      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',
      formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      valueType: 'radio',
      options: [
        {
          label: '启用',
          value: 1,
        },
        {
          label: '禁用',
          value: 0,
        },
      ],
    },
    {
      title: '备注',
      hideInTable: true,
      dataIndex: 'remarks',
      valueType: 'textarea',
      key: 'remarks',
      search: false,
    },
    {
      title: '个人图片',
      search: false,
      dataIndex: 'userImgList',
      key: 'userImgList',
      valueType: 'uploadImage',
      hideInTable: true,
      fieldProps: {
        limit: 1,
      },

      render: (text, row) => {
        if (row?.pictureUrl == null) {
          return '暂无图片';
        } else {
          return <Image width={70} src={row.pictureUrl} />;
        }
      },
    },
  ];
}

export default getcolumns;