import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ContractMaterialVO, ContractMaterialForm, ContractMaterialQuery } from '@/api/oa/erp/contractMaterial/types';

/**
 * 查询合同物料信息列表
 * @param query
 * @returns {*}
 */

export const listContractMaterial = (query?: ContractMaterialQuery): AxiosPromise<ContractMaterialVO[]> => {
  return request({
    url: '/oa/erp/contractMaterial/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询合同物料信息详细
 * @param contractMaterialId
 */
export const getContractMaterial = (contractMaterialId: string | number): AxiosPromise<ContractMaterialVO> => {
  return request({
    url: '/oa/erp/contractMaterial/' + contractMaterialId,
    method: 'get'
  });
};

/**
 * 新增合同物料信息
 * @param data
 */
export const addContractMaterial = (data: ContractMaterialForm) => {
  return request({
    url: '/oa/erp/contractMaterial',
    method: 'post',
    data: data
  });
};

/**
 * 修改合同物料信息
 * @param data
 */
export const updateContractMaterial = (data: ContractMaterialForm) => {
  return request({
    url: '/oa/erp/contractMaterial',
    method: 'put',
    data: data
  });
};

/**
 * 删除合同物料信息
 * @param contractMaterialId
 */
export const delContractMaterial = (contractMaterialId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/contractMaterial/' + contractMaterialId,
    method: 'delete'
  });
};

/**
 * 下拉框查询合同物料信息列表
 * @param query
 * @returns {*}
 */
export function getErpContractMaterialList (query) {
    return request({
        url: '/oa/erp/contractMaterial/getErpContractMaterialList',
        method: 'get',
        params: query
    });
};
