import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProjectInfoVO, ProjectInfoForm, ProjectInfoQuery } from '@/api/oa/erp/projectInfo/types';

/**
 * 查询项目信息列表
 * @param query
 * @returns {*}
 */

export const listProjectInfo = (query?: ProjectInfoQuery): AxiosPromise<ProjectInfoVO[]> => {
  return request({
    url: '/oa/erp/projectInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目信息详细
 * @param projectId
 */
export const getProjectInfo = (projectId: string | number): AxiosPromise<ProjectInfoVO> => {
  return request({
    url: '/oa/erp/projectInfo/' + projectId,
    method: 'get'
  });
};

/**
 * 新增项目信息
 * @param data
 */
export const addProjectInfo = (data: ProjectInfoForm) => {
  return request({
    url: '/oa/erp/projectInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目信息
 * @param data
 */
export const updateProjectInfo = (data: ProjectInfoForm) => {
  return request({
    url: '/oa/erp/projectInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目信息
 * @param projectId
 */
export const delProjectInfo = (projectId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/projectInfo/' + projectId,
    method: 'delete'
  });
};

/**
 * 项目信息提交并发起流程
 * @param data
 */
export const projectSubmitAndFlowStart = (data: ProjectInfoForm) => {
  return request({
    url: '/oa/erp/projectInfo/submitAndFlowStart',
    method: 'post',
    data: data
  });
};

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



