import request from '@/utils/request'

// 获取物料申请单列表
export function getReqList(params) {
  return request({
    url: `/system/apply/material/list`,
    method: 'get',
    params: params
  })
}

// 物料申请单-新增
export function addReq(data) {
  return request({
    url: `/system/apply/material`,
    method: 'post',
    data: data,
  })
}

// 获取物料申请单详情
export function getReqDetail(id) {
  return request({
    url: `/system/apply/material/${id}`,
    method: 'get',
  })
}

// 物料申请单-修改提交
export function editReq(data) {
  return request({
    url: `/system/apply/material`,
    method: 'put',
    data: data
  })
}

// 物料申请单-修改提交
export function betchSubmit(data) {
  return request({
    url: `/system/apply/material/submit`,
    method: 'post',
    data: data,
  })
}

// 物料申请单-删除
export function delReq(id) {
  return request({
    url: `/system/apply/material/${id}`,
    method: 'delete',
  })
}

// 参照-计量单位
export function getUnit(data) {
  return request({
    url: `/system/archival/queryUnit?pageSize=${data.pageSize}&pageNum=${data.pageNo}`,
    method: 'post',
    data: data
  })
}

// 参照-产地
export function getPlace(data) {
  return request({
    url: `/system/archival/queryOrigin?pageSize=${data.pageSize}&pageNum=${data.pageNo}`,
    method: 'post',
    data: data
  })
}

// 参照-税类
export function getTax(data) {
  return request({
    url: `/system/archival/queryTaxrate?pageSize=${data.pageSize}&pageNum=${data.pageNo}`,
    method: 'post',
    data: data
  })
}

// 参照-采购员
export function getStaff(data) {
  return request({
    url: `/system/archival/queryStaffInfo?pageSize=${data.pageSize}&pageNum=${data.pageNo}`,
    method: 'post',
    data: data
  })
}

// 参照-业务线
export function getLine(data) {
  return request({
    url: `/system/archival/queryServiceline?pageSize=${data.pageSize}&pageNum=${data.pageNo}`,
    method: 'post',
    data: data
  })
}

// 参照-剂型-树形
export function getDose(data) {
  return request({
    url: `/system/archival/queryDosageForm`,
    method: 'post',
    data: data
  })
}

// 参照-采购组织-树形
// 查询部门下拉树结构
export function getOrgs(data) {
  return request({
    url: '/system/user/deptTree',
    method: 'get',
    params: data
  })
}

// 参照-药品类别(子表)-树形
export function getDrug(data) {
  return request({
    url: `/system/archival/queryMedcineItemDrug`,
    method: 'post',
    data: data
  })
}

// 参照-中包装单位
export function getMidPack(data) {
  return request({
    url: `/system/archival/queryMediumPackage?pageSize=${data.pageSize}&pageNum=${data.pageNo}`,
    method: 'post',
    data: data
  })
}

// 导入
export function importData(data) {
  return request({
    url: `/system/apply/material/import`,
    method: 'post',
    data: data
  })
}

// 下载失败导入文件数据
export function fileImport(data) {
  return request({
    url: `/system/apply/material/downloadFailData`,
    method: 'post',
    data: data,
    responseType: 'blob',
  })
}

export function toOA(userName, fdId) {
  return request({
    url: `/oaflow/redirectToOa/${userName}/${fdId}`,
    method: 'get',
  })
}

//收回
export function oaBack(data) {
  return request({
    url: `/oaflow/rollback`,
    method: "POST",
    data: data,
  });
}

//收回
export function saveAndToOa(data) {
  return request({
    url: `/system/apply/material/saveAndToOa`,
    method: "POST",
    data: data,
  });
}

export const REFER = (data, params) => {
  return request({
    url: "/refer/query",
    method: "POST",
    data: data,
    params: params,
  });
}

export function classifyDetails(params) {
  return request({
    url: `/system/classify/details`,
    method: 'get',
    params: params,
  })
}

// 物料DI /system/apply/material/getDiCode/{dicode)
export function getDiCode(dicode) {
  return request({
    url: `/system/apply/material/getDiCode/${dicode}`,
    method: 'get',
  })
}

export function deleteApplies(data) {
  return request({
    url: `/system/apply/material/deleteApplies`,
    method: "POST",
    data: data,
  })
}