import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProjectPurchaseMaterialVO, ProjectPurchaseMaterialForm, ProjectPurchaseMaterialQuery } from '@/api/oa/erp/projectPurchaseMaterial/types';

/**
 * 查询项目采购物料列表
 * @param query
 * @returns {*}
 */

export const listProjectPurchaseMaterial = (query?: ProjectPurchaseMaterialQuery): AxiosPromise<ProjectPurchaseMaterialVO[]> => {
  return request({
    url: '/oa/erp/projectPurchaseMaterial/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目采购物料详细
 * @param purchaseMaterialId
 */
export const getProjectPurchaseMaterial = (purchaseMaterialId: string | number): AxiosPromise<ProjectPurchaseMaterialVO> => {
  return request({
    url: '/oa/erp/projectPurchaseMaterial/' + purchaseMaterialId,
    method: 'get'
  });
};

/**
 * 新增项目采购物料
 * @param data
 */
export const addProjectPurchaseMaterial = (data: ProjectPurchaseMaterialForm) => {
  return request({
    url: '/oa/erp/projectPurchaseMaterial',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目采购物料
 * @param data
 */
export const updateProjectPurchaseMaterial = (data: ProjectPurchaseMaterialForm) => {
  return request({
    url: '/oa/erp/projectPurchaseMaterial',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目采购物料
 * @param purchaseMaterialId
 */
export const delProjectPurchaseMaterial = (purchaseMaterialId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/projectPurchaseMaterial/' + purchaseMaterialId,
    method: 'delete'
  });
};

/**
 * 下拉框查询项目采购物料列表
 * @param query
 * @returns {*}
 */
export function getErpProjectPurchaseMaterialList (query) {
    return request({
        url: '/oa/erp/projectPurchaseMaterial/getErpProjectPurchaseMaterialList',
        method: 'get',
        params: query
    });
};
