index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div class="map-container">
  3. <gw-map ref="mapRef" :config="mapConfig"></gw-map>
  4. <biz-data-card v-for="bizDataShowConfig in bizDataShowConfigList" :key="bizDataShowConfig.id"
  5. :config="bizDataShowConfig"></biz-data-card>
  6. </div>
  7. </template>
  8. <script setup>
  9. import {getBizDataShowConfigList} from "@/api/standardization/bizDataShowConfig.js";
  10. import BizDataCard from "@/views/map/components/bizDataCard.vue";
  11. import GwMap from "./components/map.vue"
  12. const mapRef = ref(null);
  13. const mapConfig = ref({
  14. zoom: 9,
  15. center: [116.397428, 39.90923],
  16. layers: [
  17. {
  18. id: 'weather-stations',
  19. type: 'vector', // 指定为矢量图层
  20. name: '行政区划面图层',
  21. source: {
  22. type: 'api', // 数据源类型为API
  23. url: 'http://localhost:8082/SCSSFM/getCalResultsByStation',
  24. method: 'POST',
  25. body: [
  26. {key: 'projectId', value: '230103', type: 'string'},
  27. {key: 'forecastSchemeId', value: '2301031', type: 'string'},
  28. {key: 'calSchemeIds', value: ["20421b55-5383-4ef0-a"], type: 'array'},
  29. ],
  30. headers: [
  31. {
  32. key: 'authorization',
  33. value: 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjBhOTE3ZDdhLTUwODktNDg1MC05YTUyLTk1NzRjZWUzYWU5ZSJ9.QuFdSq-_mLFwOlM249-ledRlM4U2_qIRVfdOzGIOnf38XY-QXyaP0k-me2gT1wf5LCjOW0z-zJnO-SnNo78eOg',
  34. type: 'string'
  35. },
  36. ],
  37. responseResolution: "$.data",
  38. // 定义数据映射规则
  39. mapping: {
  40. // 指定哪些字段包含几何信息(经度、纬度)
  41. geometry: {
  42. type: 'Point', // 几何类型
  43. coordinates: {
  44. longitude: 'lgtd', // 接口中的经度字段名
  45. latitude: 'lttd' // 接口中的纬度字段名
  46. }
  47. },
  48. textField: 'stationName',
  49. // 定义要保留的属性字段
  50. properties: {
  51. '测站编码': 'stationCode', // 目标属性名: 源数据字段名
  52. '测站名称': 'stationName',
  53. '预报最大水位': 'calSchemeInfos[0].results[0].maxData.value',
  54. '预报最大水位时间': 'calSchemeInfos[0].results[0].maxData.tm',
  55. '预报最小水位': 'calSchemeInfos[0].results[0].minData.value',
  56. '预报最小水位时间': 'calSchemeInfos[0].results[0].minData.tm',
  57. '预报平均水位': 'calSchemeInfos[0].results[0].average',
  58. '警戒水位': 'alarmValue',
  59. '预报潮位': 'calSchemeInfos[0].results[0].datas',
  60. }
  61. },
  62. // 轮询更新(可选)
  63. refreshInterval: 30000 // 30秒刷新一次
  64. },
  65. visible: true,
  66. zIndex: 1000,
  67. style: {
  68. // 点要素样式
  69. point: {
  70. image: {
  71. type: 'icon', // circle|icon
  72. // type: 'circle', // circle|icon
  73. name: 'red_trangle',
  74. radius: 8,
  75. fill: {color: '#FF5722'},
  76. stroke: {color: '#fff', width: 2}
  77. },
  78. text: {
  79. field: 'stationName',
  80. font: '12px Arial',
  81. fill: {color: '#000000'},
  82. stroke: {color: '#ffffff', width: 2},
  83. offsetY: -20
  84. }
  85. },
  86. // 线要素样式
  87. line: {
  88. stroke: {
  89. color: '#0066ff',
  90. width: 3,
  91. lineDash: [5, 5]
  92. }
  93. },
  94. // 面要素样式
  95. polygon: {
  96. fill: {color: 'rgba(0, 102, 255, 0.2)'},
  97. stroke: {color: '#0066ff', width: 2}
  98. }
  99. },
  100. events: {
  101. click: {
  102. action: 'popup', // 点击触发弹窗
  103. popupConfig: {
  104. // 弹窗模板ID
  105. template: 'SCSSFM_POPUP',
  106. offset: [0, -20]
  107. }
  108. },
  109. // hover: {
  110. // action: 'highlight' // 悬停高亮
  111. // }
  112. }
  113. },
  114. ]
  115. });
  116. const bizDataShowConfigList = ref([]);
  117. function getBizDataConfigList() {
  118. getBizDataShowConfigList().then(res => {
  119. bizDataShowConfigList.value = res.data;
  120. })
  121. }
  122. onMounted(() => {
  123. getBizDataConfigList();
  124. });
  125. </script>
  126. <style scoped lang="scss">
  127. .map-container {
  128. height: 100%;
  129. width: 100%;
  130. position: relative;
  131. .biz-data-config-container {
  132. & + .biz-data-config-container {
  133. margin-top: 10px;
  134. }
  135. }
  136. }
  137. /*滚动条里面轨道*/
  138. ::-webkit-scrollbar-track {
  139. background-color: rgba(20, 19, 19, 0);
  140. }
  141. /*关键设置 tbody出现滚动条*/
  142. ::-webkit-scrollbar-thumb {
  143. background-color: rgba(58, 100, 179, 0.5);
  144. border-radius: 8px 10px;
  145. }
  146. ::v-deep(.el-scrollbar) {
  147. --el-scrollbar-bg-color: rgba(58, 100, 179);
  148. --el-scrollbar-hover-bg-color: rgba(58, 100, 179);
  149. }
  150. </style>