import request from '@/utils/request';

// 药库订货单初始化
export function getInit () {
  return request ({
    url: '/pharmacy-warehouse/purchase-order/init',
    method: 'get',
  });
}
// 订货单单据列表：显示所有单据 左边框
export function getOrderList (query) {
  return request ({
    url: '/pharmacy-warehouse/purchase-order/purchase-order-page',
    method: 'get',
    params: query,
  });
}

// 根据供应商获取药品：对应添加/编辑时加下一行数据后，点击项目时调用的接口
export function getMedicineList (query) {
  return request ({
    url: '/pharmacy-warehouse/purchase-order/medication-info',
    method: 'get',
    params: query,
  });
}
// 获取单据号：添加时，获取新单据号。编辑的逻辑是先删除后新增。
export function getBusNo () {
  return request ({
    url: '/pharmacy-warehouse/purchase-order/busNo-init',
    method: 'get',
  });
}

// 添加/编辑采购单：添加/编辑采购单
export function addOrEditOrder (data) {
  return request ({
    url: '/pharmacy-warehouse/purchase-order/addOrEdit-purchaseOrder',
    method: 'PUT',
    data,
  });
}
// 删除单据
export function deleteOrder (data) {
  return request ({
    url: '/pharmacy-warehouse/purchase-order/delete-purchaseOrder?busNo=' +
      data,
    method: 'DELETE',
  });
}
// 同意审批
export function agreeApproval (data) {
  return request ({
    url: '/pharmacy-warehouse/purchase-order/agree-approval?busNo=' + data,
    method: 'PUT',
  });
}
// 获取单据详情
export function getOrderDetail (query) {
  return request ({
    url: '/pharmacy-warehouse/purchase-order/purchase-order-detail-page',
    method: 'GET',
    params: query,
  });
}

