import axios from "@/utils/request";
import request from "@/utils/request";

export function listOrder(query) {
  return axios({
    url: '/purchase/order/list',
    method: 'get',
    params: query
  })
}

export function auditListOrder(query) {
  return axios({
    url: '/purchase/order/auditList',
    method: 'get',
    params: query
  })
}


export function listOrderDetail(query) {
  return axios({
    url: '/purchase/order/drug/list/detail',
    method: 'get',
    params: query
  })
}

export function getOrder(id) {
  return axios({
    url: '/purchase/order/' + id,
    method: 'get'
  })
}

export function addOrder(data) {
  return axios({
    url: '/purchase/order',
    method: 'post',
    data: data
  })
}


export function auditOrder(data) {
  return axios({
    url: '/purchase/order/auditOrder',
    method: 'post',
    data: data
  })
}


// 修改pur
export function updateOrder(data) {
  return axios({
    url: '/purchase/order',
    method: 'put',
    data: data
  })
}

// 删除pur
export function delOrder(id) {
  return axios({
    url: '/purchase/order/' + id,
    method: 'delete'
  })
}

export function inserThrOrderWeb(query) {
  return axios({
    url: "/purchase/order/postOrder",
    method: "post",
    data: query
  });
}


// 删除pur
export function delOrderDetail(id) {
  return axios({
    url: '/purchase/order/detail/' + id,
    method: 'delete'
  })
}

// 添加puan
export function addOrderId() {
  return request({
    url: "/purchase/order/add",
    method: 'post'
  })
}

// 添加puan
export function addOrderDetailByWarlockBag(data) {
  return request({
    url: "/purchase/order/addDetailByWarlockBag",
    method: 'post',
    data: data
  })
}

// 根据申购单添加详情表
export function addPlanDetailAndOrder(data) {
  return request({
    url: "/purchase/order/addPlanDetailAndOrder",
    method: 'post',
    data: data
  })
}

// 添加详情表
export function addOrderDetail(data) {
  return request({
    url: "/purchase/order/addOrderDetail",
    method: 'post',
    data: data
  })
}

// 查询详情表
export function selectOrderDetail(query) {
  return request({
    url: "/purchase/order/list/detail",
    method: 'get',
    params: query
  })
}

//删除计划表和详情表
export function delOrderDetailAll(data) {
  return request({
    url: "/purchase/order/delOrderDetailAll",
    method: 'post',
    data: data
  })
}

//更新pur
export function updateDetail(data) {
  return request({
    url: "/purchase/order/updateDetail",
    method: 'post',
    data: data
  })
}

export function getDetailList(params) {
  return axios({
    url: "/purchase/order/list/getDetailList",
    method: "get",
    params: params
  });
}

export function filterSupList(data) {
  return request({
    url: "/purchase/order/filterSupList",
    method: 'post',
    data: data
  })
}


export function printOrder(data) {
  return axios({
    url: "/pur/purchase/order/printOrder",
    method: "post",
    data: data,
    headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
    responseType: 'arraybuffer',   //一定要设置响应类型，否则页面会是空白pdf
  });
}

// 删除pur
export function orderByBillNo(billNo) {
  return axios({
    url: '/purchase/orderByBillNo/' + billNo,
    method: 'get'
  })
}



