import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TimesheetSummaryVO, TimesheetSummaryForm, TimesheetSummaryQuery } from '@/api/oa/erp/timesheetSummary/types';

/**
 * 查询月汇总工时信息列表
 * @param query
 * @returns {*}
 */

export const listTimesheetSummary = (query?: TimesheetSummaryQuery): AxiosPromise<TimesheetSummaryVO[]> => {
  return request({
    url: '/oa/erp/timesheetSummary/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询月汇总工时信息详细
 * @param summaryId
 */
export const getTimesheetSummary = (summaryId: string | number): AxiosPromise<TimesheetSummaryVO> => {
  return request({
    url: '/oa/erp/timesheetSummary/' + summaryId,
    method: 'get'
  });
};

/**
 * 新增月汇总工时信息
 * @param data
 */
export const addTimesheetSummary = (data: TimesheetSummaryForm) => {
  return request({
    url: '/oa/erp/timesheetSummary',
    method: 'post',
    data: data
  });
};

/**
 * 修改月汇总工时信息
 * @param data
 */
export const updateTimesheetSummary = (data: TimesheetSummaryForm) => {
  return request({
    url: '/oa/erp/timesheetSummary',
    method: 'put',
    data: data
  });
};

/**
 * 删除月汇总工时信息
 * @param summaryId
 */
export const delTimesheetSummary = (summaryId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/timesheetSummary/' + summaryId,
    method: 'delete'
  });
};

/**
 * 下拉框查询月汇总工时信息列表
 * @param query
 * @returns {*}
 */
export function getErpTimesheetSummaryList(query) {
  return request({
    url: '/oa/erp/timesheetSummary/getErpTimesheetSummaryList',
    method: 'get',
    params: query
  });
}

/**
 * 生成月汇总工时预览
 * @param query
 */
export const generateTimesheetSummary = (query: any): AxiosPromise<TimesheetSummaryVO> => {
  return request({
    url: '/oa/erp/timesheetSummary/generate',
    method: 'post',
    data: query
  });
};
