import request from '@/utils/request';

/**
 * 项目工时统计报表查询参数
 */
export interface ProjectManHourReportQuery {
  pageNum?: number;
  pageSize?: number;
  startTime?: string;
  endTime?: string;
  projectName?: string;
  projectCode?: string;
  projectCategory?: string;
  deptName?: string; // 使用部门名称模糊查询
}

/**
 * 项目工时统计报表 VO
 */
export interface ProjectManHourReportVO {
  projectId: number;
  deptName: string;
  managerName: string;
  projectName: string;
  projectCode: string;
  projectCategory: string;
  totalHours: number;
  crossDeptHours: number;
}

/**
 * 查询项目工时统计列表
 * @param query
 * @returns
 */
export function listProjectManHourReport(query: ProjectManHourReportQuery) {
  return request({
    url: '/oa/erp/timesheetReport/projectManHourList',
    method: 'get',
    params: query
  });
}

/**
 * 导出项目工时统计报表
 * @param query
 * @returns
 */
export function exportProjectManHourReport(query: ProjectManHourReportQuery) {
  return request({
    url: '/oa/erp/timesheetReport/exportProjectManHour',
    method: 'post',
    params: query,
    responseType: 'blob'
  });
  // ... existing export function ...
}

/**
 * 项目工时人员统计报表 VO
 */
export interface ProjectPersonnelReportVO {
  columns: Array<{
    label: string;
    prop: string;
    userId?: number;
  }>;
  rows: Array<any>;
  footer: {
    totalDays: number;
    deptHeadCount: number;
    totalManDays: number;
  };
}

/**
 * 获取项目工时人员统计报表
 * @param query { deptId, startTime, endTime }
 */
export function getProjectPersonnelReport(query: { deptId: number | string; startTime?: string; endTime?: string }) {
  return request({
    url: '/oa/erp/timesheetReport/projectPersonnelReport',
    method: 'get',
    params: query
  });
}
