monitor.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <div>
  3. <div class="main" @mouseleave="boxMouseleave" @mouseenter="boxMouseenter">
  4. <div class="main_in">
  5. <weatherTitle :title="'气象站监测'" refreshName="monitorRefreshName" />
  6. <div>
  7. <div class="re-ul">
  8. <vue3-seamless-scroll :list="monitoringData.monitoring" class="scroll" :step="0.2" :hover="true" :wheel="true">
  9. <div
  10. class="re-list"
  11. @click="
  12. () => {
  13. openModal(item.stcd), setActive(item);
  14. }
  15. "
  16. v-for="(item, index) in monitoringData.monitoring"
  17. :key="index"
  18. >
  19. <div>
  20. <div>{{ item.st_name }}</div>
  21. <div>{{ item.time }}</div>
  22. </div>
  23. <div>
  24. <div>
  25. <img src="../../../assets/images/weatheHome/mo-icon1.png" />
  26. {{ item.temp.v }}℃
  27. </div>
  28. <div>
  29. <img src="../../../assets/images/weatheHome/mo-icon2.png" />
  30. {{ item.hum.v }}%</div
  31. >
  32. <div>
  33. <img src="../../../assets/images/weatheHome/mo-icon3.png" />
  34. {{ item.ws.v }}m/s {{ setWd(item.wd.v) }}</div
  35. >
  36. </div>
  37. </div>
  38. </vue3-seamless-scroll>
  39. </div>
  40. </div>
  41. <div class="main-title" @click="openModal(stcd)">
  42. <div>
  43. <span>{{ title }}&nbsp;</span>近24小时气象监测站过程线</div
  44. >
  45. </div>
  46. <monitorEcharts
  47. :temperatureCharts="monitoringData.temperatureCharts"
  48. :windSpeeCharts="monitoringData.windSpeeCharts"
  49. :windDirection="monitoringData.windDirection"
  50. />
  51. </div>
  52. </div>
  53. </div>
  54. </template>
  55. <script lang="ts" setup>
  56. import { ref, getCurrentInstance, onBeforeUnmount, onMounted, reactive } from 'vue';
  57. import weatherTitle from '../../../components/Title/weatherTitle.vue';
  58. import { useMapStore } from '/@/store/modules/map';
  59. import monitorEcharts from './monitorEcharts.vue';
  60. import { getWeathMonitoring, getMonitorInfo } from '/@/api/swHome/index';
  61. import { useBasicStore } from '/@/store/modules/basicData';
  62. import { obtainingStations, getNowTime, getSensor } from '/@/utils/fnUtils.ts';
  63. // 滚动插件
  64. import { getAppEnvConfig } from '/@/utils/env';
  65. const { VITE_GLOB_UPDATE_TIME } = getAppEnvConfig();
  66. import { Vue3SeamlessScroll } from 'vue3-seamless-scroll';
  67. import eventBus from '/@/utils/eventBus';
  68. eventBus.on('monitorRefreshName', () => {
  69. getWeathMonitoringData();
  70. });
  71. const basicStore = useBasicStore();
  72. const stcd = ref();
  73. const mapStore = useMapStore();
  74. const openModal = (item) => {
  75. mapStore.setstInfo({ stcd: item });
  76. };
  77. let monitoringData = reactive({
  78. monitoring: [],
  79. stDetailArrStoreData: [],
  80. activeObtaining: {},
  81. temperatureCharts: {
  82. name: [],
  83. data: [],
  84. },
  85. windSpeeCharts: {
  86. name: [],
  87. data: [],
  88. },
  89. windDirection: {
  90. name: [],
  91. data: [],
  92. },
  93. });
  94. // 鼠标移出
  95. function boxMouseleave() {
  96. // console.log('鼠标移出');
  97. circulateData();
  98. }
  99. // 鼠标移入
  100. function boxMouseenter() {
  101. // console.log('鼠标移入');
  102. if (circulateFn) {
  103. clearInterval(circulateFn);
  104. }
  105. }
  106. // 点击列表
  107. function setActive(item) {
  108. // console.log(item);
  109. stcd.value = item.stcd;
  110. getObtainingStations(item);
  111. }
  112. // 循环轮播数据
  113. let circulateNum = 1;
  114. let circulateFn = null;
  115. function circulateData() {
  116. circulateFn = setInterval(async () => {
  117. setActive(monitoringData.monitoring[circulateNum]);
  118. if (circulateNum == monitoringData.monitoring.length - 1) {
  119. circulateNum = 0;
  120. } else {
  121. circulateNum += 1;
  122. }
  123. }, VITE_GLOB_UPDATE_TIME);
  124. }
  125. // 处理风向
  126. function setWd(wds) {
  127. let wd = wds*1
  128. if (wd >= 348.76 || wd <= 11.25) {
  129. return 'N';
  130. }
  131. if (wd >= 11.26 && wd <= 33.75) {
  132. return 'NNE';
  133. }
  134. if (wd >= 33.76 && wd <= 56.25) {
  135. return 'NE';
  136. }
  137. if (wd >= 56.26 && wd <= 78.75) {
  138. return 'ENE';
  139. }
  140. if (wd >= 78.76 && wd <= 101.25) {
  141. return 'E';
  142. }
  143. if (wd >= 101.26 && wd <= 123.75) {
  144. return 'ESE';
  145. }
  146. if (wd >= 123.76 && wd <= 146.25) {
  147. return 'SE';
  148. }
  149. if (wd >= 146.26 && wd <= 168.75) {
  150. return 'SSE';
  151. }
  152. if (wd >= 168.76 && wd <= 191.25) {
  153. return 'S';
  154. }
  155. if (wd >= 191.26 && wd <= 213.75) {
  156. return 'SSW';
  157. }
  158. if (wd >= 213.76 && wd <= 236.25) {
  159. return 'SW';
  160. }
  161. if (wd >= 236.26 && wd <= 258.75) {
  162. return 'WSW';
  163. }
  164. if (wd >= 258.76 && wd <= 281.25) {
  165. return 'W';
  166. }
  167. if (wd >= 281.76 && wd <= 303.75) {
  168. return 'WNW';
  169. }
  170. if (wd >= 303.76 && wd <= 326.25) {
  171. return 'NW';
  172. }
  173. if (wd >= 326.26 && wd <= 348.75) {
  174. return 'NNW';
  175. }
  176. return '-'
  177. }
  178. // 获取温度数据
  179. async function setActiveEcharts(activeSensor) {
  180. let formData = {
  181. start_time: getNowTime(2),
  182. senid: activeSensor,
  183. end_time: getNowTime(1),
  184. };
  185. let data = await getMonitorInfo(formData).then((res) => {
  186. return res.data;
  187. });
  188. monitoringData.temperatureCharts.name = [];
  189. monitoringData.temperatureCharts.data = [];
  190. let temperatureCharts = {
  191. name: [],
  192. data: [],
  193. };
  194. data.forEach((element) => {
  195. temperatureCharts.name.push(element.time);
  196. temperatureCharts.data.push(element.factv);
  197. });
  198. monitoringData.temperatureCharts = temperatureCharts;
  199. }
  200. // 获取风速信息
  201. async function getWindSpeed(activeSensor) {
  202. let formData = {
  203. start_time: getNowTime(2),
  204. senid: activeSensor,
  205. end_time: getNowTime(1),
  206. };
  207. let data = await getMonitorInfo(formData).then((res) => {
  208. return res.data;
  209. });
  210. // windSpeeCharts
  211. monitoringData.windSpeeCharts.name = [];
  212. monitoringData.windSpeeCharts.data = [];
  213. let windSpeeCharts = {
  214. name: [],
  215. data: [],
  216. };
  217. data.forEach((element) => {
  218. windSpeeCharts.name.push(element.time);
  219. windSpeeCharts.data.push(element.factv);
  220. });
  221. monitoringData.windSpeeCharts = windSpeeCharts;
  222. }
  223. async function getWindDirection(activeSensor) {
  224. let formData = {
  225. start_time: getNowTime(2),
  226. senid: activeSensor,
  227. end_time: getNowTime(1),
  228. };
  229. let data = await getMonitorInfo(formData).then((res) => {
  230. return res.data;
  231. });
  232. let windDirection = {
  233. name: [],
  234. data: [],
  235. };
  236. data.forEach((element) => {
  237. windDirection.name.push(element.time);
  238. windDirection.data.push(element.factv);
  239. });
  240. monitoringData.windDirection.name = [];
  241. monitoringData.windDirection.data = [];
  242. monitoringData.windDirection = windDirection;
  243. }
  244. // 获取气象监测列表数据
  245. function getWeathMonitoringData() {
  246. getWeathMonitoring().then((res) => {
  247. monitoringData.monitoring = res.data;
  248. // 筛选当前数据测站信息
  249. getObtainingStations(res.data[0]);
  250. stcd.value = res.data[0].stcd;
  251. circulateData();
  252. });
  253. }
  254. let title = ref('');
  255. // 筛选测站和传感器数据
  256. function getObtainingStations(data) {
  257. setActiveEcharts(data.temp.senid);
  258. getWindSpeed(data.ws.senid);
  259. getWindDirection(data.wd.senid);
  260. title.value = data.st_name;
  261. // if (monitoringData.stDetailArrStoreData.length > 0) {
  262. // monitoringData.activeObtaining = obtainingStations(monitoringData.stDetailArrStoreData, data.stcd);
  263. // // 根据当前测站获取传感器信息
  264. // let activeSensor = getSensor(monitoringData.activeObtaining, '温度');
  265. // setActiveEcharts(activeSensor);
  266. // } else {
  267. // setTimeout(() => {
  268. // getObtainingStations(data);
  269. // }, 500);
  270. // }
  271. }
  272. // 监听测站基础数据是否请求回来
  273. // const subBasicStore = basicStore.$subscribe((mutation: any, state: any) => {
  274. // if (Object.keys(state.stDetailArrStore).length != 0) {
  275. // monitoringData.stDetailArrStoreData = state.stDetailArrStore;
  276. // // setActiveEcharts();
  277. // subBasicStore();
  278. // }
  279. // });
  280. onMounted(() => {
  281. if (Object.keys(basicStore.getStDetailArrStore).length != 0) {
  282. monitoringData.stDetailArrStoreData = basicStore.getStDetailArrStore;
  283. }
  284. getWeathMonitoringData();
  285. });
  286. onBeforeUnmount(() => {
  287. if (circulateFn) {
  288. clearInterval(circulateFn);
  289. }
  290. });
  291. // 获取气象监测信息
  292. </script>
  293. <style lang="less" scoped>
  294. .main {
  295. box-sizing: border-box;
  296. padding: 2px;
  297. border-radius: 0px 30px 0px 30px;
  298. background-image: linear-gradient(200deg, rgba(40, 165, 255, 0.9) 9%, rgba(100, 255, 255, 0) 34%, rgba(40, 126, 255, 0) 66%, #28a5ff 100%);
  299. }
  300. .main_in {
  301. width: 100%;
  302. height: 100%;
  303. border-radius: 0px 30px 0px 30px;
  304. background: rgba(6, 37, 70, 0.9);
  305. }
  306. //
  307. .re-ul {
  308. // height: 46vh;
  309. // height: 500px;
  310. padding: 20px;
  311. padding-bottom: 0px;
  312. overflow: auto;
  313. margin-bottom: 20px;
  314. }
  315. .scroll {
  316. height: 480px;
  317. overflow: hidden;
  318. }
  319. .re-list {
  320. cursor: pointer;
  321. background-color: rgba(0, 139, 246, 0.1);
  322. border-radius: 4px;
  323. padding: 10px;
  324. margin-bottom: 10px;
  325. & > div:nth-child(1) {
  326. display: flex;
  327. justify-content: space-between;
  328. margin-bottom: 10px;
  329. div:nth-child(1) {
  330. font-size: 14px;
  331. font-weight: 500;
  332. color: #fff;
  333. }
  334. div:nth-child(2) {
  335. font-size: 12px;
  336. color: #4d7dc6;
  337. }
  338. }
  339. & > div:nth-child(2) {
  340. display: flex;
  341. justify-content: space-between;
  342. div {
  343. font-size: 18px;
  344. background: linear-gradient(0deg, #00f7ff 0%, #007ff6 100%);
  345. -webkit-background-clip: text;
  346. -webkit-text-fill-color: transparent;
  347. background-clip: text;
  348. text-fill-color: transparent;
  349. img {
  350. display: inline-block;
  351. vertical-align: middle;
  352. }
  353. }
  354. }
  355. }
  356. .main-title {
  357. cursor: pointer;
  358. display: flex;
  359. justify-content: space-between;
  360. padding: 6px 20px;
  361. color: #dffeff;
  362. font-size: 16px;
  363. background: linear-gradient(90deg, rgba(40, 126, 255, 0.16) 0%, rgba(40, 126, 255, 0) 100%);
  364. margin-left: 8px;
  365. span {
  366. color: linear-gradient(0deg, #00f7ff 0%, #007ff6 100%);
  367. background: linear-gradient(0deg, #fbf70e 0%, #f4af10 100%);
  368. -webkit-text-fill-color: transparent;
  369. background-clip: text;
  370. -webkit-background-clip: text;
  371. font-size: 16px;
  372. }
  373. margin-bottom: 20px;
  374. }
  375. </style>