import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TimesheetProjectVO, TimesheetProjectForm, TimesheetProjectQuery } from '@/api/oa/erp/timesheetProject/types';

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

export const listTimesheetProject = (query?: TimesheetProjectQuery): AxiosPromise<TimesheetProjectVO[]> => {
  return request({
    url: '/oa/erp/timesheetProject/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目工作明细详细
 * @param timesheetProjectId
 */
export const getTimesheetProject = (timesheetProjectId: string | number): AxiosPromise<TimesheetProjectVO> => {
  return request({
    url: '/oa/erp/timesheetProject/' + timesheetProjectId,
    method: 'get'
  });
};

/**
 * 新增项目工作明细
 * @param data
 */
export const addTimesheetProject = (data: TimesheetProjectForm) => {
  return request({
    url: '/oa/erp/timesheetProject',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目工作明细
 * @param data
 */
export const updateTimesheetProject = (data: TimesheetProjectForm) => {
  return request({
    url: '/oa/erp/timesheetProject',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目工作明细
 * @param timesheetProjectId
 */
export const delTimesheetProject = (timesheetProjectId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/timesheetProject/' + timesheetProjectId,
    method: 'delete'
  });
};

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