// 统一用户管理系统类型定义

// 企业信息
export interface Enterprise {
  id: string;
  // 企业基本信息
  name: string;
  type: string; // 企业类型
  province: string;
  city: string;
  district?: string;
  
  // 其他信息
  companySize?: string; // 公司规模
  registeredCapital?: string; // 注册资本
  establishmentDate?: string; // 成立时间
  invoiceType?: string; // 发票类型
  socialCreditCode: string; // 社会信用代码
  businessScope?: string; // 经营范围
  businessLicense?: string; // 营业执照（图片URL）
  
  // 开户信息
  bankAccount?: string; // 银行账号
  bankName?: string; // 开户行
  bankFullName?: string; // 开户行全称
  bankAddress?: string; // 开户行地址
  bankLicense?: string; // 开户许可证（图片URL）
  
  // 法人信息
  legalPerson?: string; // 法人名称
  idCardFront?: string; // 身份证正面（图片URL）
  idCardBack?: string; // 身份证反面（图片URL）
  
  // 联系信息
  registrant: string;
  contactPhone: string;
  address: string;
  
  // 系统信息
  status: EnterpriseStatus;
  auditStatus: AuditStatus;
  auditReason?: string;
  auditTime?: string;
  auditor?: string;
  createdAt: string;
  updatedAt: string;
}

export type EnterpriseStatus = 'active' | 'inactive' | 'suspended';
export type AuditStatus = 'pending' | 'approved' | 'rejected';

// 审核记录
export interface AuditRecord {
  id: string;
  enterpriseId: string;
  enterpriseName: string;
  auditType: 'register' | 'update';
  submitTime: string;
  auditTime?: string;
  auditor?: string;
  result: AuditStatus;
  reason?: string;
  remarks?: string;
}

// 审核状态
export type AuditStatusType = 'pending' | 'approved' | 'rejected';

// 员工信息
export interface Employee {
  id: string;
  enterpriseId: string;
  enterpriseName: string;
  username: string;
  name: string;
  phone: string;
  email?: string;
  department?: string;
  position?: string;
  team?: string; // 所属班组
  skills?: string[]; // 专业技能
  idCard?: string; // 身份证号
  address?: string; // 住址
  emergencyContact?: string; // 紧急联系人
  emergencyPhone?: string; // 紧急联系电话
  roleIds: string[];
  roles?: string[];
  status: UserStatus;
  auditStatus: AuditStatusType; // 审核状态
  auditReason?: string; // 审核意见/驳回原因
  auditTime?: string; // 审核时间
  auditor?: string; // 审核人
  createdAt: string;
  updatedAt: string;
  lastLoginTime?: string;
}

// 用户信息
export interface User {
  id: string;
  username: string;
  name: string;
  phone: string;
  email?: string;
  enterpriseId?: string;
  enterpriseName?: string;
  roleIds: string[];
  roles?: string[];
  userType: UserType;
  status: UserStatus;
  createdAt: string;
  updatedAt: string;
  lastLoginTime?: string;
}

export type UserType = 'super_admin' | 'enterprise_admin' | 'employee';
export type UserStatus = 'active' | 'inactive' | 'frozen';

// 角色信息
export interface Role {
  id: string;
  name: string;
  code: string;
  description?: string;
  type: RoleType;
  menuIds: string[];
  permissionIds: string[];
  defaultHomePage?: string;
  status: 'active' | 'inactive';
  createdAt: string;
  updatedAt: string;
}

export type RoleType = 'system' | 'custom';

// 菜单信息
export interface Menu {
  id: string;
  parentId?: string;
  name: string;
  code: string;
  path?: string;
  icon?: string;
  component?: string;
  sort: number;
  type: MenuType;
  visible: boolean;
  status: 'active' | 'inactive';
  children?: Menu[];
}

export type MenuType = 'directory' | 'menu' | 'button';

// 权限信息
export interface Permission {
  id: string;
  name: string;
  code: string;
  type: PermissionType;
  description?: string;
  menuId?: string; // 关联菜单ID
  menuPath?: string; // 菜单完整路径，如：智能农机管理系统 > 农机档案 > 农机录入
  status: 'active' | 'inactive';
  createdAt: string;
  updatedAt: string;
}

export type PermissionType = 
  | 'view'
  | 'add'
  | 'edit'
  | 'delete'
  | 'export'
  | 'import'
  | 'approve'
  | 'control';
