import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProjectContractsVO, ProjectContractsForm, ProjectContractsQuery } from '@/api/oa/erp/projectContracts/types';

/**
 * 查询项目关联合同列表
 * @param query
 * @returns {*}
 */

export const listProjectContracts = (query?: ProjectContractsQuery): AxiosPromise<ProjectContractsVO[]> => {
  return request({
    url: '/oa/erp/projectContracts/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目关联合同详细
 * @param projectContractsId
 */
export const getProjectContracts = (projectContractsId: string | number): AxiosPromise<ProjectContractsVO> => {
  return request({
    url: '/oa/erp/projectContracts/' + projectContractsId,
    method: 'get'
  });
};

/**
 * 新增项目关联合同
 * @param data
 */
export const addProjectContracts = (data: ProjectContractsForm) => {
  return request({
    url: '/oa/erp/projectContracts',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目关联合同
 * @param data
 */
export const updateProjectContracts = (data: ProjectContractsForm) => {
  return request({
    url: '/oa/erp/projectContracts',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目关联合同
 * @param projectContractsId
 */
export const delProjectContracts = (projectContractsId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/projectContracts/' + projectContractsId,
    method: 'delete'
  });
};

/**
 * 下拉框查询项目关联合同列表
 * @param query
 * @returns {*}
 */
export function getErpProjectContractsList (query) {
    return request({
        url: '/oa/erp/projectContracts/getErpProjectContractsList',
        method: 'get',
        params: query
    });
};
