import fetch from '../fetch';
import { getBaseUrl } from '@/utils/index'
let headers = {
  'Content-Type': 'application/json;charset=UTF-8',
  token:  localStorage.getItem('storageToken'),
};
export const getGoodsList = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`store/goods/query`),
    method: 'post',
    data: params,
    description: '商品列表查询',
  })
};
export const getGoodDetails = (goodsId) => {
  return fetch({
    headers,
    url: getBaseUrl(`store/goods/medical/service/detail/${goodsId}/-1`),
    method: 'get',
    description: '商品详情查询',
  })
}
export const uploadExcel = data => {
  // return utils.checkAuth(()=>{
    return fetch({
      headers,
      url:  getBaseUrl(`store/goods/import`),
      method: 'post',
      data: data,
      description: '上传excel文件',
    })
  // })
}
//
export const batchOnOff = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`store/goods/onoff/sale`),
    method: 'post',
    data: params,
    description: '批量上下架',
  })
};
export const updateGoods = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`store/goods/upsert`),
    method: 'post',
    data: params,
    description: '创建/更新商品',
  })
};
export const updateGoodsV2 = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`store/goods/medical/service/upsert`),
    method: 'post',
    data: params,
    description: '创建/更新商品',
  })
};
///dosage/all
export const dosageAll = (parm) => {
  return fetch({
    headers,
    url: getBaseUrl(`store/dosage/all`),
    method: 'get',
    // params: params,
    description: '剂型',
  })
};
export const getDeparts = (parm) => {
  return fetch({
    headers,
    url: getBaseUrl(`api-ws/departments/category`),
    method: 'get',
    // params: params,
    description: '科室',
  })
};

//`basic-data/constants?typeCode=P128`


export const updateStock = (parm) => {
  return fetch({
    headers,
    url: getBaseUrl(`trade/order/admin/query/${orderId}`),
    method: 'get',
    // params: params,
    description: '增加/减少库存',
  })
};
// http://dev-sc.yunqueyi.com/store/getHospitalInfoByStoreId?storeId=85
// GET header:token

export const getHospitalInfoByStoreId = (storeId) => {
  return fetch({
    headers,
    url: getBaseUrl(`store/getHospitalInfoByStoreId?storeId=${storeId}`),
    method: 'get',
    description: '',
  })
};


export const getCheckPackageIdList = (storeId) => {
  return fetch({
    headers,
    url: getBaseUrl(`followup/templet/type?sourceType=9`),
    method: 'post',
    description: '',
  })
};

export const getGoodsIdList = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`store/goods/query/v2`),
    method: 'post',
    data: params,
    description: '商品ID列表查询',
  })
};

export const getTypeCodeList = () => {
  return fetch({
    headers,
    url: getBaseUrl(`basic-data/constants/app?typeCodeList=P306`),
    method: "get",
    description: "获取适用人群类别",
  });
};

export const getBusinessCategory = () => {
  return fetch({
    headers,
    url: getBaseUrl(`store/category/businessCategory/0`),
    method: "get",
    description: "查询业务类型",
  });
};

export const getContractList = (projectId) => {
  return fetch({
    headers,
    url: getBaseUrl(`store/contract/options/queryByProjectId/${projectId}`),
    method: "get",
    description: "查询合同",
  });
};

export const getCooperationProjectList = () => {
  return fetch({
    headers,
    url: getBaseUrl(
      `store/cooperation/project/options/query`
    ),
    method: "get",
    description: "查询合作项目",
  });
};


