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


export function listApply(query) {
  return request({
    url: '/purchase/apply/list',
    method: 'post',
    data: query
  })
}

export function auditListApply(query) {
  return request({
    url: '/purchase/apply/auditList',
    method: 'post',
    data: query
  })
}


export function listApplyDetail(query) {
  return request({
    url: '/purchase/apply/drug/list/detail',
    method: 'get',
    params: query
  })
}

export function getApply(id) {
  return request({
    url: '/purchase/apply/' + id,
    method: 'get'
  })
}

export function addApply(data) {
  return request({
    url: '/purchase/apply',
    method: 'post',
    data: data
  })
}


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


// 修改pur
export function updateApply(data) {
  return request({
    url: '/purchase/apply',
    method: 'put',
    data: data
  })
}

// 删除pur
export function delApply(id) {
  return request({
    url: '/purchase/apply/' + id,
    method: 'delete'
  })
}

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


// 删除pur
export function delApplyDetail(id) {
  return request({
    url: '/purchase/apply/detail/' + id,
    method: 'delete'
  })
}

// 添加pur
export function addApplyDetail(data) {
  return request({
    url: "/purchase/apply/addDetail",
    method: 'post',
    data: data
  })
}

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

// 添加app
export function addApplyId() {
  return request({
    url: "/purchase/apply/add",
    method: 'post'
  })
}

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

//删除申购表和详情表
export function delApplyDetailAll(data) {
  return request({
    url: "/purchase/apply/delApplyDetailAll",
    method: 'post',
    data: data
  })
}

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


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

