import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TimesheetPreAllocDetailVO, TimesheetPreAllocDetailForm, TimesheetPreAllocDetailQuery } from '@/api/oa/erp/timesheetPreAllocDetail/types';

/**
 * 查询预投工时分配明细列表
 * @param query
 * @returns {*}
 */

export const listTimesheetPreAllocDetail = (query?: TimesheetPreAllocDetailQuery): AxiosPromise<TimesheetPreAllocDetailVO[]> => {
  return request({
    url: '/oa/erp/timesheetPreAllocDetail/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询预投工时分配明细详细
 * @param allocDetailId
 */
export const getTimesheetPreAllocDetail = (allocDetailId: string | number): AxiosPromise<TimesheetPreAllocDetailVO> => {
  return request({
    url: '/oa/erp/timesheetPreAllocDetail/' + allocDetailId,
    method: 'get'
  });
};

/**
 * 新增预投工时分配明细
 * @param data
 */
export const addTimesheetPreAllocDetail = (data: TimesheetPreAllocDetailForm) => {
  return request({
    url: '/oa/erp/timesheetPreAllocDetail',
    method: 'post',
    data: data
  });
};

/**
 * 修改预投工时分配明细
 * @param data
 */
export const updateTimesheetPreAllocDetail = (data: TimesheetPreAllocDetailForm) => {
  return request({
    url: '/oa/erp/timesheetPreAllocDetail',
    method: 'put',
    data: data
  });
};

/**
 * 删除预投工时分配明细
 * @param allocDetailId
 */
export const delTimesheetPreAllocDetail = (allocDetailId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/timesheetPreAllocDetail/' + allocDetailId,
    method: 'delete'
  });
};

/**
 * 下拉框查询预投工时分配明细列表
 * @param query
 * @returns {*}
 */
export function getErpTimesheetPreAllocDetailList (query) {
    return request({
        url: '/oa/erp/timesheetPreAllocDetail/getErpTimesheetPreAllocDetailList',
        method: 'get',
        params: query
    });
};
