import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProjectAcceptanceVO, ProjectAcceptanceForm, ProjectAcceptanceQuery } from '@/api/oa/erp/projectAcceptance/types';

/**
 * 查询项目验收确认列表
 * @param query
 * @returns {*}
 */

export const listProjectAcceptance = (query?: ProjectAcceptanceQuery): AxiosPromise<ProjectAcceptanceVO[]> => {
  return request({
    url: '/oa/erp/projectAcceptance/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目验收确认详细
 * @param acceptanceId
 */
export const getProjectAcceptance = (acceptanceId: string | number): AxiosPromise<ProjectAcceptanceVO> => {
  return request({
    url: '/oa/erp/projectAcceptance/' + acceptanceId,
    method: 'get'
  });
};

/**
 * 新增项目验收确认
 * @param data
 */
export const addProjectAcceptance = (data: ProjectAcceptanceForm) => {
  return request({
    url: '/oa/erp/projectAcceptance',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目验收确认
 * @param data
 */
export const updateProjectAcceptance = (data: ProjectAcceptanceForm) => {
  return request({
    url: '/oa/erp/projectAcceptance',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目验收确认
 * @param acceptanceId
 */
export const delProjectAcceptance = (acceptanceId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/projectAcceptance/' + acceptanceId,
    method: 'delete'
  });
};

/**
 * 根据项目ID准备验收信息
 * @param projectId
 */
export const prepareProjectAcceptanceByProjectId = (projectId: string | number): AxiosPromise<ProjectAcceptanceVO> => {
  return request({
    url: '/oa/erp/projectAcceptance/prepareByProjectId/' + projectId,
    method: 'get'
  });
};

/**
 * 提交项目验收确认并发起流程
 * @param data
 */
export const submitProjectAcceptanceAndFlowStart = (data: ProjectAcceptanceForm): AxiosPromise<ProjectAcceptanceVO> => {
  return request({
    url: '/oa/erp/projectAcceptance/submitAndFlowStart',
    method: 'post',
    data: data
  });
};

/**
 * 下拉框查询项目验收确认列表
 * @param query
 * @returns {*}
 */
export function getErpProjectAcceptanceList (query) {
    return request({
        url: '/oa/erp/projectAcceptance/getErpProjectAcceptanceList',
        method: 'get',
        params: query
    });
};
