import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { budgetDetailVO, budgetDetailForm, budgetDetailQuery } from '@/api/oa/erp/budgetDetail/types';

/**
 * 查询项目预算详情列表
 * @param query
 * @returns {*}
 */

export const listErp = (query?: budgetDetailQuery): AxiosPromise<budgetDetailVO[]> => {
  return request({
    url: '/oa/erp/budgetDetail/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目预算详情详细
 * @param budgetDetailId
 */
export const getErp = (budgetDetailId: string | number): AxiosPromise<budgetDetailVO> => {
  return request({
    url: '/oa/erp/budgetDetail/' + budgetDetailId,
    method: 'get'
  });
};

/**
 * 新增项目预算详情
 * @param data
 */
export const addErp = (data: budgetDetailForm) => {
  return request({
    url: '/oa/erp/budgetDetail',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目预算详情
 * @param data
 */
export const updateErp = (data: budgetDetailForm) => {
  return request({
    url: '/oa/erp/budgetDetail',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目预算详情
 * @param budgetDetailId
 */
export const delErp = (budgetDetailId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/budgetDetail/' + budgetDetailId,
    method: 'delete'
  });
};

/**
 * 下拉框查询项目预算详情列表
 * @param query
 * @returns {*}
 */
export function getErpBudgetDetailList (query) {
    return request({
        url: '/oa/erp/budgetDetail/getErpBudgetDetailList',
        method: 'get',
        params: query
    });
};
