import axios from '@/libs/axios.js'
export const uploadImg = formData => {
  return axios.request({
    url: 'upload',
    data: formData
  })
}
// 根据字典code查询选项
export const getLookUpDatas = (params) => {
  return axios.request({
    url: `lookup/findByLookup/${params.type}`,
    method: 'get'
  })
}
// 根据字典code查询所有数据
export const getAllLookUpDatas = (params) => {
  return axios.request({
    url: `lookup/findAllByLookup/${params.type}`,
    method: 'get'
  })
}
// 查询所有数据字典
export const listLookUp = (params) => {
  let url = `lookup/findAll`
  return axios.request({
    url: url,
    method: 'post'
  }).then(res => res)
}

function randomStr (len) {
  len = len || 32
  const chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'
  const maxPos = chars.length
  let pwd = ''
  for (let i = 0; i < len; i++) {
    pwd += chars.charAt(Math.floor(Math.random() * maxPos))
  }
  return pwd
}

// 下载文件
export const downloadFile = (params) => {
  return axios.request({
      method: 'post',
      url: `excel/getExcel/${params.startDate}/${params.endDate}`,
      data: {},
      responseType: 'blob'
  })
}

// 查询最新版本信息
export const getSysVersion = (params) => {
  return axios.request({
    url: `version/getLatest`,
    method: 'post',
	data: {applyCode:'atit'}
  }, true)
}
//查询省
export const  getProvince = () => {
  return axios.request({
    url: `area/PROVINCE`,
    method: 'get'
  }, true)
}
//查询市
export const  getCityByPro = params => {
  return axios.request({
    url: `area/CITY/${params.id}`,
    method: 'get'
  }, true)
}
//查询区
export const  getDistrictByCity = params => {
  return axios.request({
    url: `area/DISTRICT/${params.id}`,
    method: 'get'
  }, true)
}