import request from '@/utils/request'

// 采购需求单列表
export function getDemandList(data) {
  return request({
    url: `/pu/demand/list?pageSize=${data.pageSize}&pageNum=${data.pageNum}&isAsc=desc&orderByColumn=updateTime`,
    method: 'post',
    data: data
  })
}
// 采购需求单新增
export function addDemand(data) {
  return request({
    url: `/pu/demand/add`,
    method: 'post',
    data: data
  })
}
// 采购需求单编辑
export function editDemand(data) {
  return request({
    url: `/pu/demand/edit`,
    method: 'put',
    data: data
  })
}
// 采购需求单提交
export function submitDemand(data) {
  return request({
    url: `/pu/demand/submit`,
    method: 'POST',
    data: data
  })
}
// 采购需求单基本信息详情
export function getDemandDetail(id) {
  return request({
    url: `/pu/demand/detail/${id}`,
    method: 'get',
  })
}
// 采购需求单基本子表详情
export function getDemandSonDetail(data) {
  return request({
    url: `/pu/demand/item/list/${data.id}?pageSize=${data.pageSize}&pageNum=${data.pageNum}`,
    method: 'post',
    data: data
  })
}
// 采购需求单删除
export function delDemand(ids) {
  return request({
    url: `/pu/demand/delete/${ids}`,
    method: 'delete',
  })
}
// 采购需求单模板下载
export function downLoadDemand(data) {
  return request({
    url: `/pu/demand/download`,
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}
// 采购需求单导出
export function exportDemand(data) {
  return request({
    url: `/pu/demand/export`,
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}
// 通过物料ID查询采购员
export function queryMan(id) {
  return request({
    url: `/material/division/queryBuyer?materialId=${id}`,
    method: 'get',
  })
}