import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {
  ProjectReportDetailVO,
  ProjectReportDetailForm,
  ProjectReportDetailQuery,
  ProjectReportAndDetailWrapper
} from '@/api/oa/erp/projectReportDetail/types';

/**
 * 查询项目周报明细列表
 * @param query
 * @returns {*}
 */

export const listProjectReportDetail = (query?: ProjectReportDetailQuery): AxiosPromise<ProjectReportDetailVO[]> => {
  return request({
    url: '/oa/erp/projectReportDetail/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目周报明细详细
 * @param reportDetailId
 */
export const getProjectReportDetail = (reportDetailId: string | number): AxiosPromise<ProjectReportDetailVO> => {
  return request({
    url: '/oa/erp/projectReportDetail/' + reportDetailId,
    method: 'get'
  });
};

/**
 * 新增项目周报明细
 * @param data
 */
export const addProjectReportDetail = (data: ProjectReportDetailForm) => {
  return request({
    url: '/oa/erp/projectReportDetail',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目周报明细
 * @param data
 */
export const updateProjectReportDetail = (data: ProjectReportDetailForm) => {
  return request({
    url: '/oa/erp/projectReportDetail',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目周报明细
 * @param reportDetailId
 */
export const delProjectReportDetail = (reportDetailId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/projectReportDetail/' + reportDetailId,
    method: 'delete'
  });
};

/**
 * 下拉框查询项目周报明细列表
 * @param query
 * @returns {*}
 */
export function getErpProjectReportDetailList(query) {
  return request({
    url: '/oa/erp/projectReportDetail/getErpProjectReportDetailList',
    method: 'get',
    params: query
  });
}

/**
 * 提交项目周报信息并发起流程
 * @param data
 */
export const projectReportSubmitAndFlowStart = (data: ProjectReportAndDetailWrapper): AxiosPromise<ProjectReportDetailVO> => {
  return request({
    url: '/oa/erp/projectReportDetail/projectReportSubmitAndFlowStart',
    method: 'post',
    data: data
  });
};
