import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AfterSalesMaterialCostsVO, AfterSalesMaterialCostsForm, AfterSalesMaterialCostsQuery } from '@/api/oa/erp/afterSalesMaterialCosts/types';

/**
 * 查询售后材料费用明细列表
 * @param query
 * @returns {*}
 */

export const listAfterSalesMaterialCosts = (query?: AfterSalesMaterialCostsQuery): AxiosPromise<AfterSalesMaterialCostsVO[]> => {
  return request({
    url: '/oa/erp/afterSalesMaterialCosts/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询售后材料费用明细详细
 * @param materialCostsId
 */
export const getAfterSalesMaterialCosts = (materialCostsId: string | number): AxiosPromise<AfterSalesMaterialCostsVO> => {
  return request({
    url: '/oa/erp/afterSalesMaterialCosts/' + materialCostsId,
    method: 'get'
  });
};

/**
 * 新增售后材料费用明细
 * @param data
 */
export const addAfterSalesMaterialCosts = (data: AfterSalesMaterialCostsForm) => {
  return request({
    url: '/oa/erp/afterSalesMaterialCosts',
    method: 'post',
    data: data
  });
};

/**
 * 修改售后材料费用明细
 * @param data
 */
export const updateAfterSalesMaterialCosts = (data: AfterSalesMaterialCostsForm) => {
  return request({
    url: '/oa/erp/afterSalesMaterialCosts',
    method: 'put',
    data: data
  });
};

/**
 * 删除售后材料费用明细
 * @param materialCostsId
 */
export const delAfterSalesMaterialCosts = (materialCostsId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/afterSalesMaterialCosts/' + materialCostsId,
    method: 'delete'
  });
};

/**
 * 下拉框查询售后材料费用明细列表
 * @param query
 * @returns {*}
 */
export function getErpAfterSalesMaterialCostsList (query) {
    return request({
        url: '/oa/erp/afterSalesMaterialCosts/getErpAfterSalesMaterialCostsList',
        method: 'get',
        params: query
    });
};
