import request from '@/utils/request';
import { download } from "@/utils/request";

/**
 * 查询接口
 */

// 获取物料列表信息以及表头字段
const materialList = (data, page) => {

  return request({
    url: `/system/material/list?pageSize=${page.pageSize}&pageNum=${page.pageNum}`,
    method: 'post',
    data: data
  })
}

// 表头数据 | 表单控件
const tagList = (data) => {
  return request({
    url: `/system/tag/list`,
    method: 'post',
    data: data
  })
}

// 获取物料基本信息详细信息
const materialDetails = (id, templateCode) => {
  return request({
    url: `/system/material/details/${id}`,
    method: 'get',
    params: { templateCode }
  })
}

// 医药id 获取医药行业信息详细信息
const medcineDetails = (id) => {
  return request({
    url: `/system/medcine/details/${id}`,
    method: 'get',
    params: {}
  })
}

// 根据物料id获取医药行业信息详细信息  
const medcineDetailsInfo = (id) => {
  return request({
    url: `/system/medcine/detailsInfo/${id}`,
    method: 'get',
    params: {}
  })
}

// 根据物料id查询医药行业信息子列表 /dev-api/drp-admin/system/medcineitem/list
const medcineitemList = (data) => {
  return request({
    url: `/system/medcineitem/list`,
    method: 'post',
    data: data
  })
}

// 查询成本信息列表
const costList = (data) => {
  return request({
    url: `/system/cost/list`,
    method: 'post',
    data: data
  })
}

// 成本信息详情 
const costDetails = (id) => {
  return request({
    url: `/system/cost/details/${id}`,
    method: 'get',
    params: {}
  })
}


// 查询财务信息列表
const financeList = (data) => {
  return request({
    url: `/system/finance/list`,
    method: 'post',
    data: data
  })
}

// 获取财务信息详细信息 /dev-api/drp-admin/system/finance/details/{id}
const financeDetails = (id) => {
  return request({
    url: `/system/finance/details/${id}`,
    method: 'get',
    params: {}
  })
}



// 获取物料辅助属性详细信息
const propertyDetails = (id) => {
  return request({
    url: `/system/property/details/${id}`,
    method: 'get',
    params: {}
  })
}

// 查询物料辅助属性列表
const propertyList = (data) => {
  return request({
    url: `/system/property/list`,
    method: 'post',
    data: data
  })
}

//获取辅助计量单位基本信息
const unitDetails = (materialId, templateCode, id) => {
  return request({
    url: `/system/unit/details/${materialId}`,
    method: 'get',
    params: { templateCode, id }
  })
}

//获取辅计量管理列表信息
const unitList = (data) => {
  return request({
    url: `/system/unit/list`,
    method: 'post',
    data: data
  })
}

// 查询计划信息列表
const planList = (data) => {
  return request({
    url: `/system/plan/list`,
    method: 'post',
    data: data
  })
}

// 查询计划信息详情 
const planDetails = (id) => {
  return request({
    url: `/system/plan/details/${id}`,
    method: 'get',
    params: {}
  })
}

// 获取利润中心信息列表 
const centerList = (data) => {
  return request({
    url: `/system/center/list`,
    method: 'post',
    data: data
  })
}

// 获取利润中心详细信息 
const centerDetails = (id) => {
  return request({
    url: `/system/center/details/${id}`,
    method: 'get',
    params: {}
  })
}

// 获取采购信息列表  
const purchaseList = (data) => {
  return request({
    url: `/system/purchase/list`,
    method: 'post',
    data: data
  })
}

// 获取采购详细信息 
const purchaseDetails = (id) => {
  return request({
    url: `/system/purchase/details/${id}`,
    method: 'get',
    params: {}
  })
}

// 获取库存信息列表  
const inventoryList = (data) => {
  return request({
    url: `/system/inventory/list`,
    method: 'post',
    data: data
  })
}

// 获取库存详细信息 
const inventoryDetails = (id) => {
  return request({
    url: `/system/inventory/details/${id}`,
    method: 'get',
    params: {}
  })
}


// 根据参数动态执行方法  -输入框点击弹窗出现数据查询
const executeMethods = (methodName, data, page) => {
  return request({
    url: `/system/archival/${methodName}?pageSize=${page.pageSize}&pageNum=${page.pageNum}`,
    // url: `/system/archival/queryDosageForm`,
    method: 'post',
    data: data
  })
}



/**
 * 修改接口
 */
// 修改物料基本信息 /dev-api/drp-admin/system/material/edit
const materialEdit = (data) => {
  return request({
    url: `/system/material/edit`,
    method: 'post',
    data: data
  })
}

// 修改医药行业信息 /dev-api/drp-admin/system/medcine/edit   
const medcineEdit = (data) => {
  return request({
    url: `/system/medcine/edit `,
    method: 'post',
    data: data
  })
}

// 保存物料以及相关页签 material
const saveMaterial = (data) => {
  return request({
    url: `/system/material/saveMaterial `,
    method: 'post',
    data: data
  })
}

// 修改列表中的停用/启用
const updateEnableMaterial = (data) => {
  // enableMaterial
  return request({
    url: `/system/material/enableMaterial `,
    method: 'post',
    data,
  })
}

// 保存物料以及医药行业接口 /dev-api/drp-admin/system/material/insertMaterialInfo
const insertMaterialInfo = (data) => {
  return request({
    url: `/system/material/insertMaterialInfo `,
    method: 'post',
    data: data
  })
}

//  批量保存医药行业信息子表  dev-api/drp-admin/system/medcineitem/batchSave
const medcineitemBatchSave = (data) => {
  return request({
    url: `/system/medcineitem/batchSave `,
    method: 'post',
    data,
  })
}

// 修改财务信息 /dev-api/drp-admin/system/finance/edit 
const financeEdit = (data) => {
  return request({
    url: `/system/finance/edit `,
    method: 'post',
    data,
  })
}

// 修改利润中心信息 /dev-api/drp-admin/system/center/edit
const centerEdit = (data) => {
  return request({
    url: `/system/center/edit `,
    method: 'post',
    data,
  })
}

// 修改采购信息 /dev-api/drp-admin/system/purchase/edit
const purchaseEdit = (data) => {
  return request({
    url: `/system/purchase/edit `,
    method: 'post',
    data,
  })
}

// 修改库存信息 /dev-api/drp-admin/system/inventory/edit
const inventoryEdit = (data) => {
  return request({
    url: `/system/inventory/edit `,
    method: 'post',
    data,
  })
}

// 修改计划信息 /dev-api/drp-admin/system/plan/edit
const planEdit = (data) => {
  return request({
    url: `/system/plan/edit `,
    method: 'post',
    data,
  })
}

// 修改成本信息 /dev-api/drp-admin/system/cost/edit
const costEdit = (data) => {
  return request({
    url: `/system/cost/edit `,
    method: 'post',
    data,
  })
}



/*
*导入导出
*/

// 导入文件  /dev-api/drp-admin/system/material/import
const fileImport = (data) => {
  return request({
    url: '/system/material/import',
    method: 'post',
    data,
  })
}


/**
 * 删除接口
 */
// 删除物料基本信息-列表   /dev-api/drp-admin/system/material/delete/{id}
const delMaterial = (data) => {
  return request({
    url: '/system/material/delete',
    method: 'post',
    data,
  })
}

// 删除利润中心信息 /dev-api/drp-admin/system/center/delete/{id}
const delCenter = (data) => {
  return request({
    url: `/system/center/delete`,
    method: 'post',
    data,
  })
}

// 删除库存信息 /dev-api/drp-admin/system/inventory/delete/{id}
const delInventory = (data) => {
  return request({
    url: `/system/inventory/delete`,
    method: 'post',
    data,
  })
}

// 删除成本信息 /dev-api/drp-admin/system/cost/delete/{id}
const delCost = (data) => {
  return request({
    url: `/system/cost/delete`,
    method: 'post',
    data,
  })
}

// 删除计划信息 /dev-api/drp-admin/system/plan/delete/{id}
const delPlan = (data) => {
  return request({
    url: `/system/plan/delete`,
    method: 'post',
    data,
  })
}

// 删除财物信息 /dev-api/drp-admin/system/finance/delete/{id}
const delFinance = (data) => {
  return request({
    url: `/system/finance/delete`,
    method: 'post',
    data,
  })
}

// 删除采购信息 /dev-api/drp-admin/system/purchase/delete/{id}
const delPurchase = (data) => {
  return request({
    url: `/system/purchase/delete`,
    method: 'post',
    data,
  })
}


//  物料维护新版本 /system/material/versions
const versions = (data) => {
  return request({
    url: `/system/material/versions`,
    method: 'post',
    data,
  })
}

//  物料维护新版本保存 /system/material/versions/save
const saveVersions = (data) => {
  return request({
    url: `/system/material/versions/save`,
    method: 'post',
    data,
  })
}

export default {
  // 查询
  materialList,
  tagList,
  materialDetails,
  medcineDetails,
  medcineDetailsInfo,
  costList,
  costDetails,
  financeList,
  medcineitemList,
  financeDetails,
  propertyDetails,
  propertyList,
  unitDetails,
  unitList,
  planList,
  planDetails,
  centerList,
  centerDetails,
  purchaseList,
  purchaseDetails,
  inventoryList,
  inventoryDetails,
  executeMethods,
  // 编辑
  materialEdit,
  medcineEdit,
  saveMaterial,
  updateEnableMaterial,
  insertMaterialInfo,
  medcineitemBatchSave,
  financeEdit,
  centerEdit,
  purchaseEdit,
  inventoryEdit,
  planEdit,
  costEdit,

  // 导入
  fileImport,

  // 删除
  delMaterial,
  delCenter,
  delInventory,
  delCost,
  delPlan,
  delFinance,
  delPurchase,
  // 维护新版本
  versions,
  saveVersions
}