import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ContractChangeMaterialVO, ContractChangeMaterialForm, ContractChangeMaterialQuery } from '@/api/oa/erp/contractChangeMaterial/types';

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

export const listContractChangeMaterial = (query?: ContractChangeMaterialQuery): AxiosPromise<ContractChangeMaterialVO[]> => {
  return request({
    url: '/oa/erp/contractChangeMaterial/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询合同变更物料详细
 * @param changeMaterialId
 */
export const getContractChangeMaterial = (changeMaterialId: string | number): AxiosPromise<ContractChangeMaterialVO> => {
  return request({
    url: '/oa/erp/contractChangeMaterial/' + changeMaterialId,
    method: 'get'
  });
};

/**
 * 新增合同变更物料
 * @param data
 */
export const addContractChangeMaterial = (data: ContractChangeMaterialForm) => {
  return request({
    url: '/oa/erp/contractChangeMaterial',
    method: 'post',
    data: data
  });
};

/**
 * 修改合同变更物料
 * @param data
 */
export const updateContractChangeMaterial = (data: ContractChangeMaterialForm) => {
  return request({
    url: '/oa/erp/contractChangeMaterial',
    method: 'put',
    data: data
  });
};

/**
 * 删除合同变更物料
 * @param changeMaterialId
 */
export const delContractChangeMaterial = (changeMaterialId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/contractChangeMaterial/' + changeMaterialId,
    method: 'delete'
  });
};

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