export type A1ListType = {
  address: string
  age: string
  city: string
  createTime: string
  creatorName: string
  dictVillageId: string
  id: number
  imgIds: string
  intro: string
  moduleLink: string
  name: string
  province: string
  region: string
  sceneLink: string
  sort: number
  thumb: string
  thumbPc: string
  type: string
  updateTime: string
  videoIds: string
  village: string
  villageName: string
  lat: string
  lng: string

  img: []
  video: []
}

export const A1select1 = [
  {
    value: '木梁桥',
    label: '木梁桥'
  },
  {
    value: '铁链吊桥',
    label: '铁链吊桥'
  },
  {
    value: '石拱桥',
    label: '石拱桥'
  },
  {
    value: '刚桁桥',
    label: '刚桁桥'
  },
  {
    value: '藤桥',
    label: '藤桥'
  }
]

// 处理所在位置
export const cityResFu = (item: A1ListType) => {
  let res = '（空）'

  const val1 = 'province'
  const val2 = 'city'
  const val3 = 'region'
  // const val4 = 'lat'
  // const val5 = 'lng'
  // const val6 = 'address'

  if (item[val1]) res = item[val1]
  if (item[val2]) res += ` / ${item[val2]}`
  if (item[val3]) res += ` / ${item[val3]}`

  return res
}

// 附件类型
export const A1fileArr = [
  {
    value: 'img',
    label: '图片'
  },
  {
    value: 'video',
    label: '视频'
  },
  {
    value: 'model',
    label: '三维'
  },
  {
    value: 'audio',
    label: '音频'
  },
  {
    value: 'doc',
    label: '文档'
  },
  {
    value: 'other',
    label: '其他'
  }
]

// 上传文件自动归类
type FileObjType = {
  [key: string]: string[]
}
export const fileImgArr = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff', 'webp', 'svg', 'psd', 'ai']
export const fileVideoArr = ['mp4', 'mov', 'avi', 'mkv', 'flv', 'wmv', 'mpeg', 'webm']

const fileObj: FileObjType = {
  img: fileImgArr,
  video: fileVideoArr,
  model: ['4dage', 'obj', 'stl', 'fbx', 'gltf', '3ds', 'blend', 'dae', 'step'],
  audio: ['mp3', 'wav', 'flac', 'aac', 'ogg', 'm4a'],
  doc: ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'csv', 'md', 'html']
  // 'other':[]
}

export const fileTypeRes = (fileName: string) => {
  const txtArr = fileName.split('.')
  const txt = txtArr[txtArr.length - 1]

  let type = 'other'

  for (const k in fileObj) {
    if (fileObj[k].includes(txt.toLowerCase())) type = k
  }
  return type
}
