/**
 * 供应商合作状态枚举
 * 与后端 SupplierCooperationStatusEnum 保持一致
 */
export enum SupplierCooperationStatusEnum {
  UNCOOPERATIVE = 0,  // 未合作
  COOPERATIVE = 1     // 已合作
}

/**
 * 供应商合作状态配置
 */
export const SUPPLIER_COOPERATION_STATUS_CONFIG = {
  [SupplierCooperationStatusEnum.UNCOOPERATIVE]: {
    code: 0,
    displayName: '未合作'
  },
  [SupplierCooperationStatusEnum.COOPERATIVE]: {
    code: 1,
    displayName: '已合作'
  }
};

/**
 * 获取供应商合作状态选项列表（用于下拉框）
 */
export const getSupplierCooperationStatusOptions = () => {
  return Object.values(SUPPLIER_COOPERATION_STATUS_CONFIG).map(item => ({
    label: item.displayName,
    value: item.code
  }));
};

/**
 * 根据code获取展示文案
 */
export const getSupplierCooperationStatusDisplayName = (code: number | null | undefined): string => {
  // 空值校验，避免空指针
  if (code === null || code === undefined) {
    return '未知状态';
  }
  
  const config = SUPPLIER_COOPERATION_STATUS_CONFIG[code as SupplierCooperationStatusEnum];
  return config ? config.displayName : '未知状态';
};