import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TimesheetInfoVO, TimesheetInfoForm, TimesheetInfoQuery } from '@/api/oa/erp/timesheetInfo/types';

/**
 * 查询工时填报列表
 * @param query
 * @returns {*}
 */

export const listTimesheetInfo = (query?: TimesheetInfoQuery): AxiosPromise<TimesheetInfoVO[]> => {
  return request({
    url: '/oa/erp/timesheetInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询工时填报详细
 * @param timesheetId
 */
export const getTimesheetInfo = (timesheetId: string | number): AxiosPromise<TimesheetInfoVO> => {
  return request({
    url: '/oa/erp/timesheetInfo/' + timesheetId,
    method: 'get'
  });
};

/**
 * 新增工时填报
 * @param data
 */
export const addTimesheetInfo = (data: TimesheetInfoForm) => {
  return request({
    url: '/oa/erp/timesheetInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改工时填报
 * @param data
 */
export const updateTimesheetInfo = (data: TimesheetInfoForm) => {
  return request({
    url: '/oa/erp/timesheetInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除工时填报
 * @param timesheetId
 */
export const delTimesheetInfo = (timesheetId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/timesheetInfo/' + timesheetId,
    method: 'delete'
  });
};

/**
 * 下拉框查询工时填报列表
 * @param query
 * @returns {*}
 */
export function getErpTimesheetInfoList(query) {
  return request({
    url: '/oa/erp/timesheetInfo/getErpTimesheetInfoList',
    method: 'get',
    params: query
  });
}

/**
 * 工时填报提交并发起流程
 * @param data 表单数据
 */
export const submitTimesheetAndFlowStart = (data: any) => {
  return request({
    url: '/oa/erp/timesheetInfo/submitAndFlowStart',
    method: 'post',
    data: data
  });
};
