import pcaData from '/@/assets/pca-code.json'

export interface PCAreaItem {
  code: string
  name: string
  children?: PCAreaItem[]
}

// 获取省市区数据
export function getPCAData(): PCAreaItem[] {
  return pcaData
}

// 根据区域编码获取完整的省市区名称
export function getFullAreaName(codes: string[]): string {
  if (!codes || codes.length === 0) return ''
  
  let result = ''
  let currentLevel = pcaData as PCAreaItem[]
  
  for (const code of codes) {
    const area = currentLevel.find((item: PCAreaItem) => item.code === code)
    if (area) {
      result += (result ? '/' : '') + area.name
      currentLevel = area.children || []
    }
  }
  
  return result
} 