import { FormType } from "@/components/form/interface";
import { UserDataType } from "@/model/userModel";
import { ColumnsType } from "antd/lib/table";
import { Image } from "antd";
import { getBirthDateAndGender } from "@/util/util";
export const defaultConfig = (team, per) => [
  {
    type: FormType.input,
    label: "用户名",
    name: "user_name",
    value: "",
    rules: [{ required: true, message: "请输入用户名称!" }],
  },

  {
    type: FormType.inputNumber,
    label: "年龄",
    name: "age",
    value: "",
    rules: [{ required: true, message: "请输入年龄" }],
  },
  {
    type: FormType.input,
    label: "身份证",
    name: "id_card",
    value: "",
    rules: [{ required: true, message: "请输入身份证" }],
  },
  {
    type: FormType.input,
    label: "登录账号",
    name: "account",
    value: "",
    rules: [{ required: true, message: "请输入登录账号" }],
  },

  {
    type: FormType.input,
    label: "联系电话",
    name: "tel",
    value: "",
  },

  {
    type: FormType.input,
    label: "邮箱",
    name: "email",
    value: "",
  },
  {
    type: FormType.upload,
    label: "头像",
    name: "head_img",
    value: [],
  },
];

export const columns: ColumnsType<UserDataType> = [
  {
    title: "用户名",
    dataIndex: "user_name",
    width: 200,
    fixed: "left",
  },
  {
    title: "性别",
    width: 150,
    render: (render) => (
      <span>{getBirthDateAndGender(render.id_card)?.gender}</span>
    ),
  },

  {
    title: "头像",
    dataIndex: "head_img",
    width: 150,
    render: (head_img) => {
      return <Image src={head_img}></Image>;
    },
  },

  {
    title: "登录账号",
    width: 150,
    dataIndex: "account",
  },
  {
    title: "身份证",
    width: 150,
    dataIndex: "id_card",
  },
  {
    title: "联系电话",
    width: 150,
    dataIndex: "tel",
  },
];
