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";
import { CompanyConfig, DepConfig, RoleConfig } from "@/service/user_config";
export const defaultConfig = [
  {
    type: FormType.input,
    label: "用户名",
    name: "user_name",
    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.select,
    label: "所属部门",
    name: "dep_identity",
    selectUrl: DepConfig.LIST,
    keys: "dep_name",
    value: "",
    rules: [{ required: true, message: "所属部门不能为空" }],
  },
  {
    type: FormType.treeSelect,
    label: "所属单位",
    name: "company_identity",
    treeCheckbox: false,
    selectUrl: CompanyConfig.LIST,
    value: "",
    keys: "company_id",
    rules: [{ required: true, message: "所属单位不能为空" }],
  },
  {
    type: FormType.select,
    label: "角色",
    name: "role_identity",
    selectUrl: RoleConfig.LIST,
    value: "",
    rules: [{ required: true, message: "角色不能为空" }],
  },
  {
    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: "登录账号",
    dataIndex: "account",
  },
  {
    title: "身份证",
    dataIndex: "id_card",
  },
  {
    title: "联系电话",
    dataIndex: "tel",
  },
  {
    title: "所属部门",
    render: (render) => (
      <span>{render.dep[0]?.dep_name}</span>
    ),
  },
  {
    title: "所属单位",
     render: (render) => (
      <span>{render.company[0]?.name}</span>
    ),
    
  },
  {
    title: "角色",
    dataIndex: "",
  }
];
