Home.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <script lang="ts" setup>
  2. import {onMounted, reactive, ref} from 'vue'
  3. import {useMapStore} from '@/stores/map'
  4. import RightFrame from '@/components/RightFrame.vue'
  5. import Card01 from '@/components/card/Card01.vue'
  6. import Chart from '@/components/chart.vue'
  7. import StripeTable from '@/components/StripeTable.vue'
  8. import {getRStLLMaxDate} from '@/api/home'
  9. import bus from '@/utils/bus'
  10. import {stations} from '@/utils/station'
  11. import {jumpPage} from '@/utils'
  12. import {copyObj} from '@/utils/ruoyi'
  13. import {View} from "@/utils/tdInstruction";
  14. const zmwjianjie = new URL('@/assets/images/zmw_jieshao.jpg', import.meta.url).href
  15. const zmwnd = new URL('@/assets/images/zmw_nd.jpg', import.meta.url).href
  16. const zmwhs = new URL('@/assets/images/zmw_hs.jpg', import.meta.url).href
  17. const mapStore = useMapStore()
  18. const left2Ref = ref(null)
  19. const tableColumns = [
  20. {
  21. label: '站名', prop: 'stnm', convertFn: (data) => {
  22. return data ? data.trim() : ''
  23. }
  24. },
  25. {
  26. label: '时间', prop: 'tm', width: '90', convertFn: (data) => {
  27. return data ? data.substring(5, 16) : ''
  28. }
  29. },
  30. {
  31. label: '水位(m)', prop: 'z', width: '80', convertFn: (data) => {
  32. return Number(data).toFixed(2)
  33. }
  34. },
  35. {
  36. label: '流量', prop: 'q', width: '70', convertFn: (data) => {
  37. return Number(data).toFixed(2)
  38. }
  39. },
  40. {
  41. label: '雨量', prop: 'drp', width: '65', convertFn: (data) => {
  42. return data | 0
  43. }
  44. }
  45. ]
  46. const tableData = reactive([])
  47. function reloadLeft2() {
  48. const option = {
  49. color: ['#fac858', '#ee6666'],
  50. tooltip: {
  51. trigger: 'axis',
  52. axisPointer: {
  53. type: 'shadow'
  54. },
  55. formatter(params) {
  56. let circle = `<span style="display:inline-block;margin-right:5px;border-radius:50%;width:10px;height:10px;left:5px;background-color:`
  57. let info = params[0].axisValueLabel
  58. for (let i = 0; i < params.length; i++) {
  59. let param = params[i]
  60. // if (param.value > 0) {
  61. info += `<br/>${circle}${param.color}"></span> ${param.seriesName}: ${param.value}个`
  62. // break
  63. // }
  64. }
  65. return info
  66. }
  67. },
  68. legend: {
  69. type: 'scroll',
  70. icon: 'circle',
  71. selectedMode: false,
  72. textStyle: {
  73. color: '#fff'
  74. }
  75. },
  76. grid: {
  77. top: '14%',
  78. left: '2%',
  79. right: '2%',
  80. bottom: '0%',
  81. containLabel: true
  82. },
  83. yAxis: {
  84. type: 'value',
  85. name: '个',
  86. max: value => value.max + 1,
  87. nameTextStyle: {
  88. color: '#02cacf'
  89. },
  90. axisLabel: {
  91. color: '#02cacf'
  92. }
  93. },
  94. xAxis: {
  95. type: 'category',
  96. axisLabel: {
  97. // interval: 0,
  98. // rotate: -45, //旋转的角度从 -90 度到 90 度。
  99. color: '#02cacf'
  100. },
  101. data: ['河道水文', '水文', '实验']
  102. },
  103. series: [
  104. {
  105. name: '超警戒(汛限)',
  106. type: 'bar',
  107. // stack: 'total',
  108. // barWidth: '20%',
  109. label: {
  110. show: true,
  111. position: 'top',
  112. color: '#fff',
  113. formatter: params => params.value > 0 ? params.value + '个' : ''
  114. },
  115. data: [0, 0, 0]
  116. },
  117. {
  118. name: '超保证(设计)',
  119. type: 'bar',
  120. label: {
  121. show: true,
  122. position: 'top',
  123. color: '#fff',
  124. formatter: params => params.value > 0 ? params.value + '个' : ''
  125. },
  126. data: [0, 0, 0]
  127. }
  128. ]
  129. }
  130. left2Ref.value.loadChart(option)
  131. }
  132. function getStationList() {
  133. getRStLLMaxDate().then(res => {
  134. res.forEach(s => {
  135. if (s.stcd === '701T0001') {
  136. s.lgtd = '117.99223749'
  137. s.lttd = '29.66659453'
  138. }
  139. })
  140. tableData.push(...res)
  141. initPoints()
  142. }).catch(() => {
  143. })
  144. }
  145. /**
  146. * 初始化测站点位
  147. */
  148. function initPoints() {
  149. const data = copyObj(tableData)
  150. data.forEach(s => {
  151. const station = stations.find(item => item.stcd === s.stcd)
  152. s.jump = !!station
  153. })
  154. const option = {
  155. view: {
  156. center: [104.114129, 37.550339],
  157. zoom: 5
  158. },
  159. layers: [
  160. {
  161. type: 'point',
  162. data: data,
  163. dataOptions: {
  164. parser: {
  165. type: 'json',
  166. x: 'lgtd',
  167. y: 'lttd'
  168. }
  169. },
  170. label: {
  171. show: true,
  172. field: 'stnm'
  173. },
  174. emphasis: {
  175. show: true,
  176. label: {
  177. show: true
  178. }
  179. },
  180. size: [20, 20],
  181. shape: {
  182. isConstant: false,
  183. field: 'jump',
  184. value: value => {
  185. return value ? 'stationPointBlue' : 'stationPointGray'
  186. }
  187. },
  188. popup: {
  189. enabled: true,
  190. trigger: 'click',
  191. content: ''
  192. }
  193. }
  194. ]
  195. }
  196. mapStore.setOption(option)
  197. }
  198. onMounted(() => {
  199. reloadLeft2()
  200. getStationList()
  201. })
  202. // 订阅一个具体的事件
  203. bus.on('point_click', (data: any) => {
  204. console.log('data', data.data, data.e)
  205. const station = stations.find(item => item.stcd === data.data.stcd)
  206. if (station) {
  207. if (station.isExternalAddress) {
  208. jumpPage(station.path, null, true)
  209. } else {
  210. jumpPage(`/station/${station.stcd}`)
  211. View.changeView(station.stnm)
  212. }
  213. }
  214. })
  215. </script>
  216. <template>
  217. <right-frame>
  218. <template #leftModule>
  219. <card01 style="height: 61%" title="简介">
  220. <el-carousel :autoplay="true" :interval="5000" arrow="never" style="width: 100%;height: 100%;" trigger="click">
  221. <el-carousel-item>
  222. <h2 class="introduce-title">浙闽皖水文水资源监测中心</h2>
  223. <p class="introduce-text">
  224. 位于浙江省嘉兴市经济技术开发区龙舟路753号,土地面积4.98亩,建筑面积1699.87平方米。
  225. </p>
  226. <img :src="zmwjianjie" alt="" style="height: 50%;margin-top:8%;margin-left: 1%;" class="introduce-img"/>
  227. </el-carousel-item>
  228. <el-carousel-item>
  229. <h2 class="introduce-title">浙闽皖水文水资源监测中心宁德分中心</h2>
  230. <p class="introduce-text">
  231. 位于福建省宁德市蕉城区金涵畲族乡金漳路10号,征地3亩,建筑面积1800平方米。紧邻福建省福建省宁德水文水资源勘测分中心管理的蕉城水文站。
  232. </p>
  233. <img :src="zmwnd" alt="" style="height: 50%;margin-top:8%;margin-left: 1%;" class="introduce-img"/>
  234. </el-carousel-item>
  235. <el-carousel-item>
  236. <h2 class="introduce-title">黄山水文水资源监测分中心</h2>
  237. <p class="introduce-text">
  238. 位于安徽省黄山市高新区蓬莱路3号,占地4亩,基地建成684平方米实验室及附属办公设施。
  239. </p>
  240. <img :src="zmwhs" alt="" style="height: 50%;margin-top:8%;margin-left: 1%;" class="introduce-img"/>
  241. </el-carousel-item>
  242. </el-carousel>
  243. </card01>
  244. <card01 style="height: 36%" title="超警超保统计">
  245. <chart ref="left2Ref"></chart>
  246. </card01>
  247. </template>
  248. <template #rightModule>
  249. <card01 style="height: 97%" title="实时数据">
  250. <stripe-table :columns="tableColumns" :data="tableData"></stripe-table>
  251. </card01>
  252. </template>
  253. </right-frame>
  254. </template>
  255. <style lang="scss" scoped>
  256. @use "@/assets/styles/introduce.scss";
  257. .el-carousel :deep(.el-carousel__container) {
  258. height: 500px;
  259. }
  260. </style>