import request from '@/utils/request';

// 查询调价审核列表
export function getPriceAdjustmentPage (query) {
  // 创建请求参数对象，确保使用后端期望的参数名
  const requestParams = {
    // 映射pageNum到pageNo，因为后端API期望使用pageNo
    pageNo: query.pageNum || query.current || query.page || 1,
    // 映射pageSize到pageSize，保持一致
    pageSize: query.pageSize || query.size || query.limit || 10,
    // 保留其他查询参数
    ...Object.entries(query).reduce((acc, [key, value]) => {
      if (!['pageNum', 'current', 'page', 'pageSize', 'size', 'limit'].includes(key)) {
        acc[key] = value;
      }
      return acc;
    }, {})
  };
  
  return request ({
    url: '/change/price/list/getPage',
    method: 'get',
    params: requestParams,
  });
}

// 查询调价申请详情
export function getPriceAdjustmentDetail (query) {
  return request({
    url: '/change/price/list/searchSupplyRequestInfo',
    method: 'post',
    params: query
  });
}

// 作废价格调整申请
export function cancelSupplyRequestData (query) {
  return request({
    url: '/change/price/list/cancelChangePriceData',
    method: 'post',
    params: query
  });
}

// 查询挂号调价详情
export function searchSupplyRequestByHealth (query) {
  return request({
    url: '/change/price/list/searchChangePriceDataByHealth',
    method: 'post',
    params: query
  });
}

// 查询诊疗调价详情
export function searchSupplyRequestByActivity (query) {
  return request({
    url: '/change/price/list/searchChangePriceDataByActivity',
    method: 'post',
    params: query || {}
  });
}

// 查询耗材调价详情
export function searchSupplyRequestByDevice (query) {
  return request({
    url: '/change/price/list/searchChangePriceDataByDevice',
    method: 'post',
    params: query
  });
}

// 查询药品调价详情
export function searchSupplyRequestByMed(query) {
  return request({
    url: '/change/price/list/searchChangePriceDataByMed',
    method: 'post',
    params: query || {}
  });
}

// 提审价格调整申请
export function submitApprovalForPriceAdjustment (query) {
  return request({
    url: '/change/price/list/updateStatusByApproval',
    method: 'post',
    params: query
  });
}

