import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {
  budgetInfoVO,
  budgetInfoForm,
  budgetInfoQuery
} from '@/api/oa/erp/budgetInfo/types';
import { ProjectInfoVO, ProjectInfoQuery } from '@/api/oa/erp/projectInfo/types';
import { MaterialInfoVO, MaterialInfoQuery } from '@/api/oa/base/materialInfo/types';

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

export const listErpBudgetInfo = (query?: budgetInfoQuery): AxiosPromise<budgetInfoVO[]> => {
  return request({
    url: '/oa/erp/budgetInfo/list',
    method: 'get',
    params: query
  });
};

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

/**
 * 新增项目预算
 * @param data
 */
export const addErpBudgetInfo = (data: budgetInfoForm) => {
  return request({
    url: '/oa/erp/budgetInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目预算
 * @param data
 */
export const updateErpBudgetInfo = (data: budgetInfoForm) => {
  return request({
    url: '/oa/erp/budgetInfo',
    method: 'put',
    data: data
  });
};

/**
 * 变更项目预算
 * @param data
 */
export const changeErpBudgetInfo = (data: budgetInfoForm) => {
  return request({
    url: '/oa/erp/budgetInfo/change',
    method: 'post',
    data: data
  });
};

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

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


/**
 * 查询项目信息列表
 * @param query
 * @returns {*}
 */
export const listProjectInfo = (query?: ProjectInfoQuery): AxiosPromise<ProjectInfoVO[]> => {
  return request({
    url: '/oa/erp/budgetInfo/listProjectInfo',
    method: 'get',
    params: query
  });
};


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

export const listMaterialInfo = (query?: MaterialInfoQuery): AxiosPromise<MaterialInfoVO[]> => {
  return request({
    url: '/oa/erp/budgetInfo/listMaterialInfo',
    method: 'get',
    params: query
  });
};

/**
 * 查询研发预算标准编制书评
 * @param query
 * @returns {*}
 */
export function getRdBudgetDefinitionList() {
  return request({
    url: '/oa/erp/budgetInfo/getRdBudgetDefinitionList',
    method: 'get'
  });
};
