import fetch from '../fetch';
import { getBaseUrl, getSaasDomain, getSaasApiDomain } from '@/utils/index'


const headers = {
  sysCode: 9
}

/*常量API*/
export const getConstants = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`basic-data/constants/`),
    method: 'get',
    params: params,
    description: '获取常量',
  })
};
/*获取省市县乡列表*/
export const getProvinceList = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`basic-data/position/provinces`),
    method: 'get',
    params: params,
    description: '获取省列表',
  })
};
export const getCityList = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`basic-data/position/cities`),
    method: 'get',
    params: params,
    description: '获取市列表',
  })
};
export const getCountyList = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`basic-data/position/counties`),
    method: 'get',
    params: params,
    description: '获取区县列表',
  })
};
export const getTownList = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`basic-data/position/towns`),
    method: 'get',
    params: params,
    description: '获取乡镇列表',
  })
};
/*居民管理*/
export const getPatientList = (data) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/patients/infolist`),
    method: 'post',
    data: data,
    description: '获取居民列表',
  })
};
export const getDiseasesList = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/patients/diseases/-1`),
    method: 'get',
    params: params,
    description: '获取所有疾病',
  })
};

// 新增居民

export const getUploadHistory = params => {  // 获取上传历史记录
  return fetch({
    headers,
    url: getBaseUrl(`/healths/docImpPat/import/records`),
    method: 'get',
    params: params,
    description: '获取上传历史记录',
  })
}


// 分组管理
export const getLabelList = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/labels/`),
    method: 'get',
    params: params,
    description: '获取分组列表',
  })
}

export const createNewLabel = (data) => {
  return fetch({
    url: getBaseUrl(`healths/labels/`),
    headers: {
      "Content-Type": 'application/json'
    },
    method: 'post',
    data: data,
    description: '新增分组',
  })
}

export const changeLabelName = (data) => {
  return fetch({
    url: getBaseUrl(`healths/labels/`),
    // headers: {
    //   "Content-Type": 'application/json'
    // },
    method: 'put',
    data: data,
    description: '修改分组名',
  })
}

export const getLabelDetail = (labelId, params) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/labels/${labelId}/patients`),
    method: 'get',
    params: params,
    description: '获取分组详情',
  })
}

export const deleteCurrentLabel = (data) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/labels/`),
    method: 'delete',
    data: data,
    description: '删除分组',
  })
}

export const deleteCurrentPatients = data => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/labels/patients`),
    method: 'delete',
    data: data,
    description: '删除分组下的居民',
  })
}

export const saveLabelsForPatient = (labelId, data) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/labels/${labelId}/patients`),
    method: 'post',
    data: data,
    description: '分组中添加居民',
  })
}

// 获取七牛上传token
export const getQiniuToken = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`file/image/token`),
    method: 'get',
    params: params,
  })
};

// 意见反馈 getSaasApiDomain
export const submitFeedback = (data) => {
  return fetch({
    headers: {
      noSysCode: true,
      "Content-Type": 'application/json'
    },
    url: getSaasApiDomain(`web/companys/feedback`),
    method: 'post',
    data: data,
  })
};

/*资料不全居民*/
export const getNotCompleteList = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/patients/uncomplate/${params.pageNo}/${params.pageSize}`),
    method: 'get',
    description: '获取资料不全居民列表',
  })
};
export const sendCompleteMessage = (data) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/patients/remind`),
    method: 'post',
    data: data,
    description: '提醒居民完善信息',
  })
};
export const sendCompleteMessageList = (data) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/patients/list/remind`),
    method: 'post',
    data: data,
    description: '批量提醒居民完善信息',
  })
};
export const getNotCompleteCount = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/patients/uncomplate/counts`),
    method: 'get',
    params: params,
    description: '获取未完善居民人数',
  })
};
export const getRedNum = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/patients/uncompleted/last/counts`),
    method: 'get',
    params: params,
    description: '获取小红点数据',
  })
};
export const getPatientDetail = (patientId) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/patients/${patientId}`),
    method: 'get',
    // params: params,
    description: '获取居民详情',
  })
};
export const deletePatient = (data) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/patients/batch`),
    method: 'delete',
    data: data,
    description: '删除居民',
  })
};
export const getRemindPatient = (data) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/patients/remind`),
    method: 'post',
    data: data,
    description: '提醒居民绑定微信',
  })
};
export const savePatientInfo = (data) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/patients/update`),
    method: 'post',
    data: data,
    description: '保存居民信息',
  })
};
export const getNationsList = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`resident/constants/nations`),
    method: 'get',
    params: params,
    description: '获取56个民族列表',
  })
};
export const getHealthRecordList = (data) => {
  return fetch({
    headers,
    url: getBaseUrl(`followup/entering/health/records`),
    method: 'post',
    data: data,
    description: '健康档案记录列表',
  })
};
/*新的获取居民接口，搜索条件有变化*/
export const getPatientInfoList = (data) => {
  return fetch({
    headers,
    url: getBaseUrl(`healths/patients/v2/infolist`),
    method: 'post',
    data: data,
    description: '获取居民列表',
  })
};
