mapTools.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import { defHttp } from '/@/utils/http/axios';
  2. enum Api {
  3. GetTools = '/xld-2And3/findAllTool',
  4. GetLayer2d = '/xld-2And3/findAllLayer2d',
  5. GetLayer3d = '/xld-2And3/findAllLayer3d',
  6. GetMenu = '/xld-2And3/findAllMenu',
  7. AddTools = '/xld-2And3/addTool',
  8. RemoveTool = '/xld-2And3/removeTool',
  9. ShowTool = '/xld-2And3/updateToolStatus',
  10. }
  11. const locationType = { mapToolsUrl: true };
  12. /**
  13. * @description: 新增地图工具
  14. */
  15. export const addTools = (params) => {
  16. return new Promise<void>((resolve) => {
  17. defHttp.post({
  18. ...locationType,
  19. url: Api.AddTools,
  20. data: {
  21. data: JSON.stringify(params)
  22. }
  23. }).then((res) => {
  24. resolve(res)
  25. })
  26. })
  27. };
  28. /**
  29. * @description: 删除地图工具
  30. */
  31. export const delTools = (params) => {
  32. return new Promise<void>((resolve) => {
  33. defHttp.post({
  34. ...locationType,
  35. url: Api.RemoveTool,
  36. data: {
  37. id: `${params.id}`
  38. }
  39. },
  40. ).then((res) => {
  41. resolve(res)
  42. })
  43. })
  44. };
  45. /**
  46. * @description: 隐藏地图工具
  47. */
  48. export const showTools = (params) => {
  49. return new Promise<void>((resolve) => {
  50. defHttp.post({
  51. ...locationType,
  52. url: Api.ShowTool,
  53. data: {
  54. id: `${params.id}`,
  55. show: !params.show
  56. }
  57. },
  58. ).then((res) => {
  59. resolve(res)
  60. })
  61. })
  62. };
  63. /**
  64. * @description: 获取所有地图工具
  65. */
  66. export const getAllTools = () => {
  67. return new Promise<void>((resolve) => {
  68. defHttp.get({ ...locationType, url: Api.GetTools }).then((res) => {
  69. resolve(res)
  70. })
  71. })
  72. };
  73. /**
  74. * @description: 获取菜单
  75. */
  76. export const getMenu = () => {
  77. return new Promise<void>((resolve) => {
  78. defHttp.get({ ...locationType, url: Api.GetMenu }).then((res) => {
  79. resolve(res)
  80. })
  81. })
  82. };
  83. /**
  84. * @description: 获取二维图层
  85. */
  86. export const get2dLayers = () => {
  87. return new Promise<void>((resolve) => {
  88. defHttp.get({ ...locationType, url: Api.GetLayer2d }).then((res) => {
  89. resolve(res)
  90. })
  91. })
  92. };
  93. /**
  94. * @description: 获取三维图层
  95. */
  96. export const get3dLayers = () => {
  97. return new Promise<void>((resolve) => {
  98. defHttp.get({ ...locationType, url: Api.GetLayer3d }).then((res) => {
  99. resolve(res)
  100. })
  101. })
  102. };