import { requestAPI, baseUrl } from './request.js';
//获取检查计划列表
export function getCheckPlanList(params) {
  return requestAPI({
    url: '/frontend/plan/list',
    method: 'GET',
    data: params
  });
}
//进入巡检（获取第一个未完成的任务）
export function enterCheckPlan(oneTableId) {
  return requestAPI({
    url: `/frontend/task/start/${oneTableId}`,
    method: 'GET'
  });
}
//获取指定任务详情
export function getCheckTaskDetail(taskId) {
  return requestAPI({
    url: `/frontend/task/detail/${taskId}`,
    method: 'GET'
  });
}
//提交巡检结果
export function submitCheckResult(params) {
  return requestAPI({
    url: '/frontend/task/submit',
    method: 'POST',
    data: params
  });
}
//新增隐患
export function addHiddenDanger(params) {
  return requestAPI({
    url: '/frontend/hazard/add',
    method: 'POST',
    data: params
  });
}
//交办隐患
export function assignHiddenDanger(params) {
  return requestAPI({
    url: '/frontend/hazard/assign',
    method: 'POST',
    data: params
  });
}
//文件图片上传
export function uploadFile(params) {
  return requestAPI({
    url: '/frontend/attachment/upload',
    method: 'POST',
    data: params
  });
}
//获取我的隐患排查列表
export function getMyHiddenDangerList(params) {
  return requestAPI({
    url: '/frontend/hazard/my/list',
    method: 'GET',
    data: params
  });
}
//获取隐患详情
export function getHiddenDangerDetail(params) {
  // 过滤掉 assignId 为 null、undefined、'null'、空字符串的情况
  const filteredParams = { ...params };
  if (filteredParams.assignId == null || filteredParams.assignId === 'null' || filteredParams.assignId === '') {
    delete filteredParams.assignId;
  }
  return requestAPI({
    url: '/frontend/hazard/detail',
    method: 'GET',
    data: filteredParams
  });
}
//获取隐患排查列表
export function getHiddenDangerList(params) {
  return requestAPI({
    url: '/frontend/hazard/my/list',
    method: 'GET',
    data: params
  });
}

//提交整改
export function submitRectification(params) {
  return requestAPI({
    url: '/frontend/hazard/rectify',
    method: 'POST',
    data: params
  });
}

//获取整改详情
export function getRectifyDetail(params) {
  return requestAPI({
    url: '/frontend/hazard/rectify/detail',
    method: 'GET',
    data: params
  });
}

//修改整改
export function updateRectification(params) {
  return requestAPI({
    url: '/frontend/hazard/rectify/update',
    method: 'POST',
    data: params
  });
}

//获取隐患标签列表
export function getHiddenDangerLabelList() {
  return requestAPI({
    url: '/frontend/hazard/tag/list',
    method: 'GET'
  });
}
//获取部门人员列表（本部门、上级部门、上上级部门）
export function getDepartmentPersonUsers(params) {
  return requestAPI({
    url: '/frontend/hazard/dept/users',
    method: 'GET',
    data: params
  });
}

//获取部门人员列表（包含参与过该隐患环节下的所有部门人员）
export function getDeptUsersWithSubordinates(params) {
  return requestAPI({
    url: '/frontend/hazard/dept/users/with-subordinates',
    method: 'GET',
    data: params
  });
}
//成员管理
//添加成员
export function addMember(params) {
  return requestAPI({
    url: '/frontend/member/add',
    method: 'POST',
    data: params
  });
}
//获取成员列表
export function getMemberList(params) {
  return requestAPI({
    url: '/frontend/member/list',
    method: 'GET',
    data: params
  });
}
//锁定/解锁成员
export function lockOrUnlockMember(params) {
  return requestAPI({
    url: '/frontend/member/lock',
    method: 'POST',
    data: params
  });
}
//销号申请
//申请销号
export function applyDelete(params) {
  return requestAPI({
    url: '/frontend/hazard/writeoff/apply',
    method: 'POST',
    data: params
  });
}
//获取验收完成的隐患列表（可申请销号）
export function getAcceptanceList(params) {
  return requestAPI({
    url: '/frontend/hazard/verified/list',
    method: 'GET',
    data: params
  });
}
//获取我的销号申请列表
export function getMyWriteOffList(params) {
  return requestAPI({
    url: '/frontend/hazard/writeoff/my/list',
    method: 'GET',
    data: params
  });
}

//验收整改
export function acceptanceRectification(params) {
  return requestAPI({
    url: '/frontend/hazard/verify',
    method: 'POST',
    data: params
  });
}

//登录
export function login(params) {
  return requestAPI({
    url: '/frontend/auth/login',
    method: 'POST',
    data: params,
    noAuth: true  // 登录接口不需要 Authorization
  });
}
//获取检查表
export function getCheckTableList(params) {
  return requestAPI({
    url: '/admin/oneTable/list',
    method: 'GET',
    data: params
  });
}
//新增安全隐患常见病检查
export function addCheckTable(params) {
  return requestAPI({
    url: '/admin/oneTable/add',
    method: 'POST',
    data: params
  });
}
//获取检查表详情
export function getCheckTableDetail(params) {
  return requestAPI({
    url: '/admin/oneTable/detail/{id}',
    method: 'GET',
    data: params
  });
}


// 获取企业类型下拉列表
export function getEnterprisetype() {
  return requestAPI({
    url: '/frontend/enterprise/type/select',
    method: 'GET'
  });
}



// 获取当前部门的企业基本信息
export function getEnterpriseinfo() {
  return requestAPI({
    url: '/frontend/enterprise/info',
    method: 'GET'
  });
}

// 新增本部门企业基本信息（需要admin或manage权限）
export function addEnterprise(params) {
  return requestAPI({
    url: '/frontend/enterprise/add',
    method: 'POST',
    data: params
  });
}

// 修改本部门企业基本信息（需要admin或manage权限）
export function updateEnterprise(params) {
  return requestAPI({
    url: '/frontend/enterprise/update',
    method: 'POST',
    data: params
  });
}


// 获取行业类型下拉列表
export function getindustry(params) {
  return requestAPI({
    url: '/frontend/enterprise/industry/select',
    method: 'GET'
  });
}

// 获取法规列表（可搜索筛选）
export function getRegulationList(params) {
  return requestAPI({
    url: '/admin/regulation/list',
    method: 'GET',
    data: params
  });
}

// 新增检查项
export function addCheckPoint(params) {
  return requestAPI({
    url: '/admin/oneTable/checkPoint/add',
    method: 'POST',
    data: params
  });
}

// 获取检查项详情
export function detailcheckPoint(id) {
  return requestAPI({
    url: `/admin/oneTable/checkPoint/detail/${id}`,
    method: 'POST'
  });
}

// 删除检查点
export function deleteCheckPoint(params) {
  return requestAPI({
    url: '/admin/oneTable/checkPoint/delete',
    method: 'POST',
    data: params
  });
}

// 获取检查库列表（可搜索筛选）
export function getCheckItemList(params) {
  return requestAPI({
    url: '/admin/oneTable/item/list',
    method: 'GET',
    data: params
  });
}

// 获取检查库详情列表
export function getCheckItemListDetail(params) {
  return requestAPI({
    url: '/admin/oneTable/item/listDetail',
    method: 'GET',
    data: params
  });
}

// 获取当前部门所有用户
export function getDeptUsers(params) {
  return requestAPI({
    url: '/admin/user/dept/users',
    method: 'GET',
    data: params
  });
}

// 获取父级部门列表（从当前到顶层）
export function getParentDepts() {
  return requestAPI({
    url: '/admin/dept/parents',
    method: 'GET'
  });
}

// 获取日常检查预警列表
export function getInspectionWarningList(params) {
  return requestAPI({
    url: '/admin/warning/inspection/list',
    method: 'GET',
    data: params
  });
}