import {
  AccountParams,
  DeptListItem,
  MenuParams,
  RoleParams,
  RolePageParams,
  MenuListGetResultModel,
  PositionByOrgParams,
  DeptListGetResultModel,
  AccountListGetResultModel,
  RolePageListGetResultModel,
  RoleListGetResultModel,
  addDept,
  ReportParams,
  ReportListGetResultModel,
  NoticeListGetResultModel,
  UserListParams,
  UserListGetResultModel,
  StatisticalListGetResultModel,
} from './model/systemModel';
import { defHttp } from '@/utils/http/axios';

enum Api {
  DeptList = '/api/Orgs/OrgsTree',
  AccountList = '/api/users/load',
  AddAccount = '/api/Users/AddOrUpdate',
  DeleteAccount = '/api/Users/Delete',
  AddDept = '/api/Orgs/Add',
  UpdateDept = '/api/Orgs/Update',
  DeleteDept = '/api/Orgs/Delete',
  OrgList = '/api/Orgs/LoadPage',
  RolePageList = '/api/Roles/LoadPage',
  AddRole = '/api/Roles/Add',
  UpdateRole = '/api/Roles/Update',
  DeleteRole = '/api/Roles/Delete',
  MenuList = '/api/Modules/ModulesTree',
  ButtonList = '/api/Modules/ElementsByModule',
  AddMenu = '/api/Modules/Add',
  AddButton = '/api/Modules/AddMenu',
  EditMenu = '/api/Modules/Update',
  EditButton = '/api/Modules/UpdateMenu',
  DeleteMenu = '/api/Modules/Delete',
  DeleteButton = '/api/Modules/DeleteMenu',
  MenuDetail = '/api/Modules/ModuleById',
  AllModuleDetail = '/api/Modules/AllModule',
  PositionList = '/api/SysPosition/Load',
  AddPosition = '/api/SysPosition/Add',
  PosGroupList = '/api/SysPosGroup/Load',
  AddPosGroup = '/api/SysPosGroup/Add',
  PositionsTree = '/api/SysPosition/PositionsTree',
  OrgPosGroup = '/api/Orgs/OrgPosGroup',
  UserRoles = '/api/Users/UserRoles',
  OrgPositonTree = '/api/Orgs/OrgPositonTree',
  UserOrgs = '/api/Users/UserOrgs',
  AssignModule = '/api/Roles/AssignModule',
  LoadForRole = '/api/Modules/LoadForRole',
  LoadByRole = '/api/Users/LoadByRole',
  IsAccountExist = '/system/accountExist',
  setRoleStatus = '/system/setRoleStatus',
  GetAllRoleList = '/system/getAllRoleList',
  LoadPositionByOrg = '/api/SysPosition/LoadPositionByOrg',
  LoadDataBaseLinkTree = '/api/SysDatabaseLink/LoadDataBaseLinkTree',
  GetPosInfo = '/api/SysPosition/Get',
  UpdatePosition = '/api/SysPosition/Update',
  ReportList = '/api/DroneCaseinfo/LoadCaseInfoList',
  NoticeList = '/api/DroneCaseinfo/LoadMessageList',
  AddNotice = '/api/DroneCaseinfo/AddMessage',
  UpdateNotice = '/api/DroneCaseinfo/UpdateMessage',
  DeleteNotice = '/api/DroneCaseinfo/UpdateDelMessage',
  UserList = '/api/users/load',
  // StatisticalList='/api/DroneCaseinfo/CaseSynthesisCensus',
  StatisticalList = '/api/DroneCaseInfoSingle/CaseSynthesisCensusSingle',
  StatisticalListExport = '/api/DroneCaseInfoSingle/ExportCaseSynthesisCensusStreet',
  LoadNoticeDetail = '/api/DroneCaseinfo/LoadMessage',
  getChildrenTree = '/api/Orgs/LoadChildren',
  GetUserRoles = '/api/Roles/UserRoles',
  GetUserOrgs = '/api/Orgs/UserOrgs',
  GetSpecialData = '/api/Specialcolumn/GetDataColName',
  LoadCaseInfoTuBanList = '/api/DroneCaseInfoSingle/LoadCaseInfoTuBanList',
  LoadCaseInfoIllegalList = '/api/DroneCaseInfoSingle/LoadCaseInfoIllegalList',
  CaseOffence = '/api/DroneCaseInfoSingle/CaseOffence',
  LoadCaseInfoListOffence = '/api/DroneCaseInfoSingle/LoadCaseInfoListOffence',
  DealIllegalCaseInfo = '/api/DroneCaseInfoSingle/dealIllegalCaseInfo',
  // 修改图斑-获取图斑列表
  LoadCaseInfoListForUpdate = '/api/DroneCaseInfoSingle/LoadCaseInfoListForUpdate',
  // 修改图斑-获取单个图斑信息
  LoadCaseInfoById = '/api/DroneCaseInfoSingle/LoadCaseInfoById',
  // 修改图斑-修改图斑信息
  UpdateCaseInfo = '/api/DroneCaseInfoSingle/UpdateCaseInfo',
  // 修改图斑-获取图斑历史信息
  LoadCaseHistoryInfoList = '/api/DroneCaseInfoSingle/LoadCaseHistoryInfoList',
  // 成果管理-图层管理
  // geo服务增加
  ShpGeoLayerAdd = '/api/ShpGeoLayer/Add',
  // geo列表
  ShpGeoLayerLoadPage = '/api/ShpGeoLayer/LoadPage',
  // geo获取
  ShpGeoLayerGet = '/api/ShpGeoLayer/Get',
  // geo更新
  ShpGeoLayerUpdateLayer = '/api/ShpGeoLayer/UpdateLayer',
  // geo删除
  ShpGeoLayerDelete = '/api/ShpGeoLayer/Delete',
  // geo解析shp文件
  ShpGeoLayerParseShpInfo = '/api/ShpGeoLayer/ParseShpInfo',
  // 获取地图中心点
  getGeomData = '/api/ShpGeoLayer/GetGeomData',
  // 通过表名和id获取该条数据
  getDataTableRecord = '/api/ShpGeoLayer/GetDataTableRecord',
  // 成果管理-影像管理
  // 更新tiff影像
  GeoTiffManagerUpdateGeoTiff = '/api/GeoTiffManager/UpdateGeoTiff',
  // 影像列表
  GeoTiffManagerLoadPage = '/api/GeoTiffManager/LoadPage',
  // 影像单个获取
  GeoTiffManagerGet = '/api/GeoTiffManager/Get',
  // 删除tiff影像
  DeleteTifStore = '/api/GeoTiffManager/DeleteTifStore',
  // 更新tiff周的影像缩略图
  UpdateLayerGroupThumb = '/api/GeoTiffManager/UpdateLayerGroupThumb',
  // 成果管理-航飞图片
  // 添加成果
  AchievementManageAddImageexif = '/api/AchievementManage/AddImageexif',
  // 案件判读
  AchievementManageIntactById = '/api/AchievementManage/IntactById',
  // 添加任务
  AchievementManageAddTask = '/api/AchievementManage/AddTask',
  // 任务查询
  AchievementManageListTask = '/api/AchievementManage/ListTask',
  // 任务查询个体
  AchievementManageListDroneShpImageexif = '/api/AchievementManage/ListDroneShpImageexif',
  // 成果管理-图层样式
  // 添加
  GeoStyleAdd = '/api/GeoStyle/Add',
  // 遍历
  GeoStylePage = '/api/GeoStyle/Page',
  GeoStyleBindLayer = '/api/GeoStyle/BindLayer',
  // 非法采矿-统计列表
  CaseOffenceMinerals = '/api/DroneCaseInfoMinerals/CaseOffenceMinerals',
  // 非法采矿-统计列表New
  CaseOffenceMineralsNew = '/api/DroneCaseInfoMinerals/CaseOffenceMineralsNew',
}
export const getPositionsTree = (params?: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.PositionsTree, params });

export const getPositionList = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.PositionList, params });

export const getPosGroupList = (params?: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.PosGroupList, params });

export const getAccountList = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params });

export const getDeptList = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({ url: Api.DeptList, params });

export const getOrgList = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({ url: Api.OrgList, params });

export const getOrgPositonTree = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({ url: Api.OrgPositonTree, params });

export const loadForRole = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({ url: Api.LoadForRole, params });

export const loadByRole = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({ url: Api.LoadByRole, params });

export const getChildrenTree = (params: { parentId: number }) =>
  defHttp.get({ url: Api.getChildrenTree, params });

export function addAccount(params) {
  return defHttp.post({
    url: Api.AddAccount,
    params,
  });
}
export function deleteAccount(params) {
  return defHttp.post({
    url: Api.DeleteAccount,
    params,
  });
}

export function addPosGroup(params) {
  return defHttp.post({
    url: Api.AddPosGroup,
    params,
  });
}
export function orgPosGroup(params) {
  return defHttp.post({
    url: Api.OrgPosGroup,
    params,
  });
}
export function userRoles(params) {
  return defHttp.post({
    url: Api.UserRoles,
    params,
  });
}

export function userOrgs(params) {
  return defHttp.post({
    url: Api.UserOrgs,
    params,
  });
}

export function addPosition(params) {
  return defHttp.post({
    url: Api.AddPosition,
    params,
  });
}

export function updatePosition(params) {
  return defHttp.post({
    url: Api.UpdatePosition,
    params,
  });
}

export function addDept(params) {
  return defHttp.post({
    url: Api.AddDept,
    params,
  });
}
export function updateDept(params) {
  return defHttp.post({
    url: Api.UpdateDept,
    params,
  });
}
export function deleteDept(params) {
  return defHttp.post({
    url: Api.DeleteDept,
    params,
  });
}
export function addMenu(params) {
  return defHttp.post({
    url: Api.AddMenu,
    params,
  });
}
export function addButton(params) {
  return defHttp.post({
    url: Api.AddButton,
    params,
  });
}
export function editMenu(params) {
  return defHttp.post({
    url: Api.EditMenu,
    params,
  });
}
export function editButton(params) {
  return defHttp.post({
    url: Api.EditButton,
    params,
  });
}
export function deleteMenu(params) {
  return defHttp.post({
    url: Api.DeleteMenu,
    params,
  });
}
export function deleteButton(params) {
  return defHttp.post({
    url: Api.DeleteButton,
    params,
  });
}

export function addRole(params) {
  return defHttp.post({
    url: Api.AddRole,
    params,
  });
}
export function updateRole(params) {
  return defHttp.post({
    url: Api.UpdateRole,
    params,
  });
}
export function deleteRole(params) {
  return defHttp.post({
    url: Api.DeleteRole,
    params,
  });
}
export function assignModule(params) {
  return defHttp.post({
    url: Api.AssignModule,
    params,
  });
}

export const getMenuDetail = (params?: MenuParams) => defHttp.get({ url: Api.MenuDetail, params });
export const getAllModuleDetail = () => defHttp.get({ url: Api.AllModuleDetail });

export const getMenuList = (params?: MenuParams) =>
  defHttp.get<MenuListGetResultModel>({ url: Api.MenuList, params });

export const getButtonList = (params?: MenuParams) =>
  defHttp.get<MenuListGetResultModel>({ url: Api.ButtonList, params });

export const getRoleListByPage = (params?: RolePageParams) =>
  defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params });

export const getAllRoleList = (params?: RoleParams) =>
  defHttp.get<RoleListGetResultModel>({ url: Api.GetAllRoleList, params });

export const setRoleStatus = (id: number, status: string) =>
  defHttp.post({ url: Api.setRoleStatus, params: { id, status } });

export const isAccountExist = (account: string) =>
  defHttp.post({ url: Api.IsAccountExist, params: { account } }, { errorMessageMode: 'none' });

export const getLoadPositionByOrg = (params?: PositionByOrgParams) =>
  defHttp.get<RolePageListGetResultModel>({ url: Api.LoadPositionByOrg, params });

export const getLoadDataBaseLinkTree = () => defHttp.get({ url: Api.LoadDataBaseLinkTree });

export const getPosInfo = (params) => defHttp.get({ url: Api.GetPosInfo, params });

export const getUserRoles = (params) => defHttp.get({ url: Api.GetUserRoles, params });

export const getUserOrgs = (params) => defHttp.get({ url: Api.GetUserOrgs, params });

export const getReportList = (params: ReportParams) =>
  defHttp.get<ReportListGetResultModel>({ url: Api.ReportList, params });

export const getStatisticalList = (params: ReportParams) =>
  defHttp.get<StatisticalListGetResultModel>({ url: Api.StatisticalList, params });

export const exportStatisticalList = (params: ReportParams) => {
  return defHttp.post({
    url: Api.StatisticalListExport,
    params,
  });
};

export const getNoticeList = (params?: Object) =>
  defHttp.get<NoticeListGetResultModel>({ url: Api.NoticeList, params });

export function addNotice(params) {
  return defHttp.post({
    url: Api.AddNotice,
    params,
  });
}

export function updateNotice(params) {
  return defHttp.post({
    url: Api.UpdateNotice,
    params,
  });
}

export function deleteNotice(params) {
  return defHttp.post({
    url: Api.DeleteNotice,
    params,
  });
}

export function getNoticeDetail(params) {
  return defHttp.get({
    url: Api.LoadNoticeDetail,
    params,
  });
}

export function getCaseInfoList(params) {
  return defHttp.get({
    url: Api.ReportList,
    params,
  });
}

export const getUserList = (params: UserListParams) =>
  defHttp.get<UserListGetResultModel>({ url: Api.UserList, params });

export const getSpecialData = () => defHttp.get({ url: Api.GetSpecialData });
const loadCaseInfoTuBanListUrlObj = {
  "违法用地": '/api/DroneCaseInfoSingle/LoadCaseInfoTuBanList',
  "非法采矿": '',
  "耕地非粮化": '/api/DroneCaseInfoFLH/LoadCaseInfoTuBanList',
  "重点问题": '/api/DroneCaseInfoZdwt1/LoadCaseInfoTuBanListTotal',
  "巡察审计": '/api/DroneCaseInfoXcsj/LoadCaseInfoTuBanList',
  "生态保护红线": '/api/DroneCaseInfoSTHX/LoadCaseInfoTuBanList',
  "生态修复": '/api/DroneCaseInfoSTXF/LoadCaseInfoTuBanList',
}
export function homePageLoadCaseInfoTuBanList(type,params) {
  return defHttp.get({
    url: loadCaseInfoTuBanListUrlObj[type],
    params,
  });
}
export function loadCaseInfoTuBanList(params) {
  return defHttp.get({
    url: Api.LoadCaseInfoTuBanList,
    params,
  });
}
export function loadCaseInfoIllegalList(params) {
  return defHttp.get({
    url: Api.LoadCaseInfoIllegalList,
    params,
  });
}
export const getCaseOffence = (params: ReportParams) =>
  defHttp.get<StatisticalListGetResultModel>({ url: Api.CaseOffence, params });

export const getLoadCaseInfoListOffence = (params: ReportParams) =>
  defHttp.get<StatisticalListGetResultModel>({ url: Api.LoadCaseInfoListOffence, params });

export function dealIllegalCaseInfo(params) {
  return defHttp.post({
    url: Api.DealIllegalCaseInfo,
    params,
  });
}
export function LoadCaseInfoListForUpdate(params) {
  return defHttp.get({
    url: Api.LoadCaseInfoListForUpdate,
    params,
  });
}
export function LoadCaseInfoById(params: { id: string }) {
  return defHttp.get({
    url: Api.LoadCaseInfoById,
    params,
  });
}
export function UpdateCaseInfo(data,shppath='') {
  return defHttp.post({
    url: `${Api.UpdateCaseInfo}?shppath=${shppath}`,
    data,
  });
}
export function LoadCaseHistoryInfoList(params: { key: string }) {
  return defHttp.get({
    url: Api.LoadCaseHistoryInfoList,
    params,
  });
}

// 云查询图层
// geo服务增加
export const ShpGeoLayerAdd = (params, timeout = 0) =>
  defHttp.post({ url: Api.ShpGeoLayerAdd, params, timeout });
// geo列表
export const ShpGeoLayerLoadPage = (params) =>
  defHttp.get({ url: Api.ShpGeoLayerLoadPage, params });
// geo获取
export const ShpGeoLayerGet = (params) =>
  defHttp.get({ url: Api.ShpGeoLayerGet, params });
// geo更新
export const ShpGeoLayerUpdateLayer = (params) =>
  defHttp.post({ url: Api.ShpGeoLayerUpdateLayer, params });
// geo删除
export const ShpGeoLayerDelete = (params) =>
  defHttp.post({ url: Api.ShpGeoLayerDelete + '/' + params.id });
// geo解析shp文件
export const ShpGeoLayerParseShpInfo = (params) =>
  defHttp.post({ url: Api.ShpGeoLayerParseShpInfo + "?srid=" + params.srid + "&tableName=" + params.tableName + "&zipFilePath=" + params.zipFilePath });
// 获取地图中心点
export const getGeomData = (params) =>
  defHttp.get({ url: Api.getGeomData + "?tableName=" + params.dataTable });
// 通过表名和id获取该条数据
export const getDataTableRecord = (params) =>
  defHttp.get({ url: Api.getDataTableRecord + "?dataTable=" + params.dataTable + "&id=" + params.id });

// 影像管理
// 更新tiff影像
export const GeoTiffManagerUpdateGeoTiff = () =>
  defHttp.post({ url: Api.GeoTiffManagerUpdateGeoTiff });
// 影像列表
export const GeoTiffManagerLoadPage = (params) =>
  defHttp.get({ url: Api.GeoTiffManagerLoadPage, params });
// 影像单个获取
export const GeoTiffManagerGet = (params) =>
  defHttp.get({ url: Api.GeoTiffManagerGet, params });
// 删除tiff影像
export const GeoTiffManagerDeleteTifStore = (params) =>
  defHttp.post({ url: Api.DeleteTifStore + '?stores=' + params.stores });
// 删除tiff影像
export const GeoTiffManagerUpdateLayerGroupThumb = ((params) => {
  if (params.bbox) {
    return defHttp.post({ url: Api.UpdateLayerGroupThumb + '?layerGroups=' + params.layerGroups + "&num=" + params.num + "&width=" + params.width + "&height=" + params.height + "&bbox=" + params.bbox });
  } else {
    return defHttp.post({ url: Api.UpdateLayerGroupThumb + '?layerGroups=' + params.layerGroups + "&num=" + params.num + "&width=" + params.width + "&height=" + params.height  });
  }
});

// 成果管理-航飞图片
// 添加成果
export const AchievementManageAddImageexif = (params) =>
  defHttp.post({ url: Api.AchievementManageAddImageexif, params });
// 案件判读
export const AchievementManageIntactById = (params) =>
  defHttp.post({ url: Api.AchievementManageIntactById, params });
// 添加任务
export const AchievementManageAddTask = (params) =>
  defHttp.post({ url: Api.AchievementManageAddTask, params });
// 任务查询
export const AchievementManageListTask = (params) =>
  defHttp.get({ url: Api.AchievementManageListTask, params });
// 任务查询个体
export const AchievementManageListDroneShpImageexif = (params) =>
  defHttp.get({ url: Api.AchievementManageListDroneShpImageexif, params });
// 成果管理-图层样式
// 添加
export const GeoStyleAdd = (params) =>
  defHttp.post({ url: Api.GeoStyleAdd, params });
// 遍历
export const GeoStylePage = (params) =>
  defHttp.get({ url: Api.GeoStylePage, params });
// 非法采矿-统计列表
export const CaseOffenceMinerals = (params: ReportParams) =>
  defHttp.get<StatisticalListGetResultModel>({ url: Api.CaseOffenceMinerals, params });
// 非法采矿-统计列表New
export const CaseOffenceMineralsNew = (params: ReportParams) =>
  defHttp.get<StatisticalListGetResultModel>({ url: Api.CaseOffenceMineralsNew, params });