import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProjectReceivingVO, ProjectReceivingForm, ProjectReceivingQuery } from '@/api/oa/erp/projectReceiving/types';

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

export const listProjectReceiving = (query?: ProjectReceivingQuery): AxiosPromise<ProjectReceivingVO[]> => {
  return request({
    url: '/oa/erp/projectReceiving/list',
    method: 'get',
    params: query
  });
};

/**
 * 下拉框查询项目收货确认列表
 * @param query
 * @returns {*}
 */
export const getErpProjectReceivingList = (query?: ProjectReceivingQuery): AxiosPromise<ProjectReceivingVO[]> => {
  return request({
    url: '/oa/erp/projectReceiving/getErpProjectReceivingList',
    method: 'get',
    params: query
  });
};

/**
 * 提交项目收货确认并发起流程
 * @param data
 */
export const submitProjectReceivingAndFlowStart = (data: ProjectReceivingForm): AxiosPromise<ProjectReceivingVO> => {
  return request({
    url: '/oa/erp/projectReceiving/submitAndFlowStart',
    method: 'post',
    data: data
  });
};

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

/**
 * 查询项目收货确认详细
 * @param receivingId
 */
export const getProjectReceiving = (receivingId: string | number): AxiosPromise<ProjectReceivingVO> => {
  return request({
    url: '/oa/erp/projectReceiving/' + receivingId,
    method: 'get'
  });
};

/**
 * 新增项目收货确认
 * @param data
 */
export const addProjectReceiving = (data: ProjectReceivingForm) => {
  return request({
    url: '/oa/erp/projectReceiving',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目收货确认
 * @param data
 */
export const updateProjectReceiving = (data: ProjectReceivingForm) => {
  return request({
    url: '/oa/erp/projectReceiving',
    method: 'put',
    data: data
  });
};

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