import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TimesheetDeptVO, TimesheetDeptForm, TimesheetDeptQuery } from '@/api/oa/erp/timesheetDept/types';

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

export const listTimesheetDept = (query?: TimesheetDeptQuery): AxiosPromise<TimesheetDeptVO[]> => {
  return request({
    url: '/oa/erp/timesheetDept/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询部门工作明细详细
 * @param timesheetDeptId
 */
export const getTimesheetDept = (timesheetDeptId: string | number): AxiosPromise<TimesheetDeptVO> => {
  return request({
    url: '/oa/erp/timesheetDept/' + timesheetDeptId,
    method: 'get'
  });
};

/**
 * 新增部门工作明细
 * @param data
 */
export const addTimesheetDept = (data: TimesheetDeptForm) => {
  return request({
    url: '/oa/erp/timesheetDept',
    method: 'post',
    data: data
  });
};

/**
 * 修改部门工作明细
 * @param data
 */
export const updateTimesheetDept = (data: TimesheetDeptForm) => {
  return request({
    url: '/oa/erp/timesheetDept',
    method: 'put',
    data: data
  });
};

/**
 * 删除部门工作明细
 * @param timesheetDeptId
 */
export const delTimesheetDept = (timesheetDeptId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/timesheetDept/' + timesheetDeptId,
    method: 'delete'
  });
};

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