import { request } from 'umi';
import { stringify } from 'qs';

export async function queryWorkType(params) {
  return request(`/api/v2/workload/type/info?${stringify(params)}`);
}
/**
 * 
    + pageSize:每页记录数
    + currentPage：当前页
    + project_id：项目id
    + user_id：用户id
    + dep_id：部门id
    + type_id：工作分项id
    + audit_status：审核状态
    + s_time：开始时间
    + e_time：结束时间 
 */
// 查询本人工时列表
export async function queryWorkHours(params) {
  return request(`/api/v2/workload/record?${stringify(params)}`);
}
// 审核员查询待审核工时列表
export async function queryAuthWorkHours(params) {
  return request(`/api/v2/workload/list/auth?${stringify(params)}`);
}
export async function queryProject(params) {
  return request(`/api/v2/workload/project?${stringify(params)}`);
}
/** id，status，desc */
export async function authWorkload(data) {
  return request(`/api/v2/workload/auths`, {
    method: 'POST',
    data,
  });
}

// export async function addWorkHours(data) {
//   return request(`/api/v2/workload/record`,{
//     method: 'POST',
//     body: data
//   });
// }

export async function addWorkHours(data) {
  return request(`/api/v2/workload/record`, {
    method: 'POST',
    data,
  });
}

export async function addAuthWorkHours(data) {
  return request(`/api/v2/workload/records`, {
    method: 'POST',
    data,
  });
}

export async function queryResReport(params) {
  return request(`/api/v2/workload/user/rpt?${stringify(params)}`);
}

export async function queryUserReport(params) {
  return request(`/api/v2/workload/dep/hr/rpt?${stringify(params)}`);
}

export async function queryUserProjectReport(params) {
  return request(
    `/api/v2/workload/project/month/rpt/user?${stringify(params)}`,
  );
}

export async function queryDepReport(params) {
  return request(`/api/v2/workload/dep/sum/hr/rpt?${stringify(params)}`);
}

export async function queryProjectReport(params) {
  return request(`/api/v2/workload/rpt/projects?${stringify(params)}`);
  // return request(`/api/v2/workload/project/month/rpt?${stringify(params)}`);
  // return request(`/api/v2/workload/project/rpt?${stringify(params)}`);
}

export async function queryProjectReportDetail(params) {
  return request(`/api/v2/workload/project/month/rpt?${stringify(params)}`);
}

export async function queryFinanceReport(params) {
  return request(`/api/v2/workload/finance/rpt?${stringify(params)}`);
}

export async function queryDepCompare(params) {
  return request(`/api/v2/workload/dep/compare?${stringify(params)}`);
}

export async function queryDepCompareUser(params) {
  return request(`/api/v2/workload/dep/compare/users?${stringify(params)}`);
}

export async function queryUserProject(params) {
  return request(
    `/api/v2/workload/dep/compare/users/project?${stringify(params)}`,
  );
}

//项目报表-新
export async function queryProjectReportNew(params) {
  return request(`/api/v2/workload/rpt/projects_news?${stringify(params)}`);
}

//删除工时
export async function deleteWorkHour(params) {
  return request(`/api/v2/workload/unaudit/delete/${params.id}`, {
    method: 'DELETE',
  });
}

//财务报表资源中心
//params: s_time, e_time按月份
export async function queryFinanceResReport(params) {
  return request(`/api/v2/workload/finance/resource/rpt?${stringify(params)}`);
}

//财务报表执行项目
//params: s_time, e_time按月份
export async function queryFinanceProjReport(params) {
  return request(`/api/v2/workload/finance/exe/rpt?${stringify(params)}`);
}

//财务报表执行项目详情
//params: s_time, e_time按月份, project_id
export async function queryFinanceProjDetail(params) {
  return request(
    `/api/v2/workload/finance/exe/rpt/detail?${stringify(params)}`,
  );
}
