index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <template>
  2. <div class="base-container no-events">
  3. <fnHeader showDate :autoGo="true"></fnHeader>
  4. <div class="content">
  5. <div class="warning-l left">
  6. <div class="warning-top">
  7. <div class="back-icon yes-events" v-if="!hideChatMapLayer" @click="toggleChatMapLayer">
  8. <img src="@/assets/images/common/back-icon.png" />
  9. 返回
  10. </div>
  11. <div class="top-l yes-events">
  12. <div>
  13. <el-cascader
  14. style="width: 184px"
  15. :show-all-levels="false"
  16. v-model="areaVal"
  17. :props="props1"
  18. :options="areaListOptions"
  19. @change="toggleArea"
  20. popper-class="area-cascader"
  21. />
  22. </div>
  23. <!-- <div class="type-box"><img src="@/assets/images/warningHome/lz.png" /></div> -->
  24. </div>
  25. <div class="top-r yes-events">
  26. <div class="data-box" @click="toggleBox('面积')" :class="{ active: activeBoxName === '面积' }">
  27. <div class="data-value"><span>{{areaVal.includes('3186') ? 31.2 : 419.89}}</span>万亩</div>
  28. <div class="data-name">种植面积</div>
  29. </div>
  30. <div
  31. class="data-box"
  32. v-if="areaVal.includes('3186')"
  33. @click="toggleBox('从化荔枝')"
  34. :class="{ active: activeBoxName === '从化荔枝' }"
  35. >
  36. <div class="data-value"><span>11.9</span>万亩</div>
  37. <div class="data-name">疑似失管面积</div>
  38. </div>
  39. <div class="data-box" @click="toggleBox('产量')" :class="{ active: activeBoxName === '产量' }">
  40. <div class="data-value"><span>{{areaVal.includes('3186') ? 10.4 : 192.12}}</span>万吨</div>
  41. <div class="data-name">预估产量</div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="warning-alarm yes-events" v-show="hideChatMapLayer">
  46. <alarm-list></alarm-list>
  47. </div>
  48. <div class="time-wrap yes-events">
  49. <time-line></time-line>
  50. </div>
  51. </div>
  52. <div class="warning-r right yes-events">
  53. <!-- <album></album> -->
  54. <!-- <chat></chat> -->
  55. <!-- 地图图例 -->
  56. <!-- <div class="map-legend" v-if="legendImg">-->
  57. <!-- <img :src="legendImg" />-->
  58. <!-- </div>-->
  59. <!-- <div class="map-legend chat-legend" v-show="!legendImg">-->
  60. <!-- <StaticMapLegend></StaticMapLegend>-->
  61. <!-- </div>-->
  62. </div>
  63. <div class="warning-search yes-events">
  64. <img src="@/assets/images/warningHome/search-img.png" />
  65. <!-- <div class="focus-farm">
  66. <el-select
  67. v-model="farmVal"
  68. placeholder="我的关注农场"
  69. style="width: 189px"
  70. popper-class="focus-farm-select"
  71. @change="toggleFarm"
  72. >
  73. <el-option label="荔博园" :value="1" />
  74. <el-option label="井冈红糯基地" :value="2" />
  75. </el-select>
  76. </div> -->
  77. </div>
  78. </div>
  79. </div>
  80. <div ref="mapRef" class="bottom-map"></div>
  81. <div id="popup" class="ol-popup-warning">
  82. <div class="warning-info-title">
  83. <div class="icon">
  84. <img src="@/assets/images/common/chart-icon.png" />
  85. </div>
  86. <div id="popup-title"></div>
  87. <div class="close" @click="destroyPopup">
  88. <img src="@/assets/images/warningHome/close-btn.png" />
  89. </div>
  90. </div>
  91. <div id="popup-content" class="info-content"></div>
  92. </div>
  93. <track-dialog></track-dialog>
  94. </template>
  95. <script setup>
  96. import "./map/mockFarmLayer";
  97. import StaticMapLayers from "@/components/static_map_change/Layers.js"
  98. import StaticMapLegend from "@/components/static_map_change/legend.vue"
  99. import StaticMapPointLayers from "@/components/static_map_change/pointLayer.js"
  100. import { onMounted, onUnmounted, ref } from "vue";
  101. import fnHeader from "@/components/fnHeader.vue";
  102. import WarningMap from "./warningMap";
  103. import AlarmLayer from "./map/alarmLayer";
  104. import GardenPointLayer from "./map/gardenPointLayer";
  105. import album from "./components/album.vue";
  106. import trackDialog from "./components/trackDialog.vue";
  107. import chat from "./components/chat_components/index.vue";
  108. import alarmList from "./components/alarmList.vue";
  109. import timeLine from "./components/timeLine.vue";
  110. import { useRouter } from "vue-router";
  111. import eventBus from "@/api/eventBus";
  112. import { areaListOptions } from "./area";
  113. import { useStore } from "vuex";
  114. let store = useStore();
  115. let warningMap = new WarningMap();
  116. let alarmLayer = null;
  117. let gardenPointLayer = null;
  118. let staticMapLayers = null;
  119. let staticMapPointLayers = null;
  120. const router = useRouter();
  121. const areaVal = ref(["3"]);
  122. const mapRef = ref();
  123. const legendImg = ref("");
  124. const warningLayers = ref({})
  125. onMounted(() => {
  126. warningMap.initMap(store.getters.userinfo.location, mapRef.value);
  127. alarmLayer = new AlarmLayer(warningMap.kmap);
  128. staticMapLayers = new StaticMapLayers(warningMap.kmap);
  129. staticMapPointLayers = new StaticMapPointLayers(warningMap.kmap);
  130. gardenPointLayer = new GardenPointLayer(warningMap.kmap);
  131. // setTimeout(() => {
  132. // staticMapLayers.show("testpng")
  133. // },2000)
  134. eventBus.emit("warningMap:init", warningMap.kmap)
  135. // 图例数据
  136. eventBus.on("alarmList:warningLayers", (data) => {
  137. warningLayers.value = data
  138. });
  139. eventBus.on("alarmList:changeMapLayer", ({name, legendUrl}) => {
  140. if(legendUrl){
  141. legendImg.value = legendUrl;
  142. }else{
  143. legendImg.value = warningLayers.value[`${name}图例`];
  144. let text = ''
  145. if(name==='日间温度'){
  146. text = '从化地块日温'
  147. }else if(name==='夜间温度'){
  148. text = '从化地块夜温'
  149. }else if(name==='土壤水分'){
  150. text = '从化地块水分'
  151. }
  152. if(text!==''){
  153. staticMapLayers.showSingle(text,true)
  154. }else{
  155. staticMapLayers.hideAll()
  156. }
  157. }
  158. });
  159. // ai与地图交互
  160. eventBus.off("chat:showMapLayer", handleMapLayer)
  161. eventBus.on("chat:showMapLayer", handleMapLayer)
  162. });
  163. sessionStorage.removeItem("farmId")
  164. onUnmounted(()=>{
  165. eventBus.off("alarmList:changeMapLayer")
  166. })
  167. // ai与地图交互
  168. const hideChatMapLayer = ref(true)
  169. const handleMapLayer = ({mapName, isHome}) => {
  170. if (!isHome) {
  171. hideChatMapLayer.value = false
  172. }
  173. staticMapPointLayers.hidePoint()
  174. staticMapLayers.hideAll()
  175. // 重置时间轴
  176. // eventBus.emit("map_click_alarm")
  177. if (mapName === "植保机") {
  178. staticMapLayers.show("分散种植", true)
  179. staticMapPointLayers.showPoint()
  180. } else if (mapName) {
  181. // staticMapLayers.show("作物种类")
  182. if (isHome) {
  183. staticMapLayers.show(mapName, true)
  184. } else {
  185. staticMapLayers.showSingle(mapName, true)
  186. }
  187. }
  188. }
  189. const toggleChatMapLayer = () => {
  190. hideChatMapLayer.value = true
  191. eventBus.emit("chat:hideMapLayer");
  192. staticMapLayers.hideAll()
  193. }
  194. const destroyPopup = () => {
  195. eventBus.emit("map:destroyPopup");
  196. };
  197. const props1 = {
  198. checkStrictly: true,
  199. };
  200. const toggleArea = (v) => {
  201. activeBoxName.value = null;
  202. const val = v[v.length - 1];
  203. if (val === "3" || val === "3186") {
  204. eventBus.emit("warningHome:toggleArea", val);
  205. }
  206. };
  207. const activeBoxName = ref(null);
  208. const toggleBox = (name) => {
  209. activeBoxName.value = name;
  210. legendImg.value = warningLayers.value[`${name}图例`];
  211. eventBus.emit("warningHome:toggleMapLayer", name);
  212. };
  213. </script>
  214. <style lang="scss" scoped>
  215. .base-container {
  216. width: 100%;
  217. height: 100vh;
  218. color: #fff;
  219. position: absolute;
  220. box-sizing: border-box;
  221. z-index: 1;
  222. ::v-deep {
  223. .focus-farm {
  224. top: 42px;
  225. }
  226. }
  227. .content {
  228. width: 100%;
  229. height: calc(100% - 74px - 48px);
  230. padding: 0 20px 0 27px;
  231. display: flex;
  232. justify-content: space-between;
  233. box-sizing: border-box;
  234. position: relative;
  235. .left,
  236. .right {
  237. width: calc(376px + 54px);
  238. height: 100%;
  239. padding-top: 10px;
  240. box-sizing: border-box;
  241. // display: flex;
  242. }
  243. .right {
  244. // width: 395px;
  245. width: 500px;
  246. position: relative;
  247. .list {
  248. width: 100%;
  249. height: 100%;
  250. }
  251. }
  252. .warning-r {
  253. .map-legend {
  254. position: absolute;
  255. bottom: -33px;
  256. left: -360px;
  257. width: 340px;
  258. img {
  259. width: 340px;
  260. opacity: 0.6;
  261. }
  262. }
  263. .chat-legend {
  264. bottom: -12px;
  265. }
  266. }
  267. .warning-search {
  268. position: absolute;
  269. right: 400px;
  270. top: -34px;
  271. display: flex;
  272. align-items: center;
  273. .focus-farm {
  274. padding-left: 15px;
  275. }
  276. ::v-deep {
  277. .el-select__wrapper {
  278. background: rgba(255, 212, 137, 0.2);
  279. box-shadow: 0 0 0 1px rgba(255, 212, 137, 0.3) inset;
  280. height: 50px;
  281. line-height: 50px;
  282. .el-select__caret {
  283. color: #ffd489;
  284. }
  285. }
  286. .el-select__placeholder {
  287. color: #f7be5a;
  288. font-size: 20px;
  289. font-family: "PangMenZhengDao";
  290. text-align: center;
  291. }
  292. }
  293. }
  294. .warning-top {
  295. display: flex;
  296. width: max-content;
  297. align-items: center;
  298. .back-icon {
  299. cursor: pointer;
  300. margin-right: 20px;
  301. height: 50px;
  302. display: flex;
  303. align-items: center;
  304. padding: 0 20px;
  305. border: 1px solid rgba(255, 255, 255, 0.6);
  306. background: rgba(0, 0, 0, 0.2);
  307. border-radius: 4px;
  308. img {
  309. width: 17px;
  310. margin-right: 10px;
  311. }
  312. }
  313. .top-l {
  314. display: flex;
  315. flex-direction: column;
  316. align-items: center;
  317. .type-box {
  318. margin-top: 10px;
  319. background: rgba(29, 29, 29, 0.54);
  320. border: 1px solid rgba(255, 212, 137, 0.3);
  321. border-radius: 2px;
  322. text-align: center;
  323. line-height: 48px;
  324. height: 48px;
  325. width: 184px;
  326. }
  327. ::v-deep {
  328. .el-input__wrapper {
  329. background: rgba(29, 29, 29, 0.54);
  330. box-shadow: 0 0 0 1px rgba(255, 212, 137, 0.3) inset;
  331. height: 50px;
  332. line-height: 50px;
  333. padding: 0 10px;
  334. .el-input__inner {
  335. color: #f7be5a;
  336. font-size: 20px;
  337. font-family: "PangMenZhengDao";
  338. text-align: center;
  339. }
  340. }
  341. .el-select__wrapper {
  342. background: rgba(29, 29, 29, 0.54);
  343. box-shadow: 0 0 0 1px rgba(255, 212, 137, 0.3) inset;
  344. height: 50px;
  345. line-height: 50px;
  346. .el-select__caret {
  347. color: #ffd489;
  348. }
  349. }
  350. .el-select__placeholder {
  351. color: #f7be5a;
  352. font-size: 20px;
  353. font-family: "PangMenZhengDao";
  354. text-align: center;
  355. }
  356. }
  357. }
  358. .top-r {
  359. display: flex;
  360. .data-box {
  361. cursor: pointer;
  362. margin-left: 20px;
  363. width: 200px;
  364. height: 104px;
  365. background: url("@/assets/images/warningHome/box-bg.png") no-repeat center center / 100% 100%;
  366. display: flex;
  367. flex-direction: column;
  368. align-items: center;
  369. &.active {
  370. position: relative;
  371. &::before {
  372. content: "";
  373. position: absolute;
  374. bottom: -26px;
  375. left: 0;
  376. right: 0;
  377. width: 35px;
  378. height: 17px;
  379. margin: 0 auto;
  380. background: url("@/assets/images/warningHome/triangle.png") no-repeat center center / cover;
  381. }
  382. }
  383. .data-value {
  384. padding-top: 15px;
  385. font-size: 20px;
  386. color: rgba(255, 212, 137, 0.4);
  387. font-family: "PangMenZhengDao";
  388. span {
  389. font-size: 38px;
  390. color: #f7be5a;
  391. padding-right: 2px;
  392. }
  393. }
  394. .data-name {
  395. color: #cecece;
  396. font-size: 16px;
  397. }
  398. }
  399. }
  400. }
  401. .warning-alarm {
  402. width: 88px;
  403. padding-top: 14px;
  404. }
  405. .time-wrap {
  406. position: absolute;
  407. bottom: -20px;
  408. left: 140px;
  409. width: 46vw;
  410. min-width: 700px;
  411. height: 71px;
  412. }
  413. }
  414. }
  415. .bottom-map {
  416. width: 100%;
  417. height: 100vh;
  418. position: absolute;
  419. z-index: 0;
  420. }
  421. </style>
  422. <style lang="less">
  423. .ol-scale-line {
  424. left: auto;
  425. right: 435px;
  426. bottom: 13px;
  427. .ol-scale-line-inner {
  428. max-width: 80px;
  429. width: 80px !important;
  430. color: #fff;
  431. border-color: #fff;
  432. }
  433. }
  434. .focus-farm-select {
  435. &.el-popper.is-light {
  436. background: #232323;
  437. border-color: rgba(255, 212, 137, 0.3);
  438. box-shadow: 0px 0px 12px rgba(255, 212, 137, 0.3);
  439. .el-select-dropdown__item {
  440. background: none;
  441. color: rgba(255, 212, 137, 0.6);
  442. }
  443. .el-select-dropdown__item.is-selected {
  444. background: rgba(255, 212, 137, 0.2);
  445. color: #ffd489;
  446. }
  447. }
  448. &.el-popper.is-light .el-popper__arrow:before {
  449. background: #232323;
  450. border-color: rgba(255, 212, 137, 0.3);
  451. }
  452. }
  453. .ol-popup-warning {
  454. position: relative;
  455. width: 295px;
  456. background: rgb(35, 35, 35, 0.86);
  457. color: #fff;
  458. font-size: 16px;
  459. border-radius: 4px;
  460. .warning-info-title {
  461. display: flex;
  462. padding: 6px 10px;
  463. background: rgba(255, 255, 255, 0.05);
  464. font-size: 18px;
  465. border-radius: 4px 4px 0 0;
  466. .icon {
  467. padding-right: 6px;
  468. }
  469. .close {
  470. position: absolute;
  471. right: 12px;
  472. top: 4px;
  473. }
  474. }
  475. .info-content {
  476. padding: 16px 20px 40px 20px;
  477. line-height: 26px;
  478. text-indent: 2em;
  479. }
  480. }
  481. .area-cascader {
  482. &.el-popper.is-light {
  483. background: #232323;
  484. border-color: rgba(255, 212, 137, 0.3);
  485. box-shadow: 0px 0px 12px rgba(255, 212, 137, 0.3);
  486. .el-cascader-menu {
  487. color: rgba(255, 212, 137, 0.6);
  488. border-color: rgba(255, 212, 137, 0.3);
  489. }
  490. .el-cascader-node.in-active-path,
  491. .el-cascader-node.is-active,
  492. .el-cascader-node.is-selectable.in-checked-path {
  493. color: #f7be5a;
  494. background: transparent;
  495. }
  496. .el-radio__input.is-checked .el-radio__inner {
  497. background: #f7be5a;
  498. border-color: #f7be5a;
  499. }
  500. .el-cascader-node:not(.is-disabled):hover,
  501. .el-cascader-node:not(.is-disabled):focus,
  502. .el-cascader-node:not(.is-disabled):hover {
  503. background: rgba(255, 212, 137, 0.2);
  504. }
  505. }
  506. .el-radio__inner {
  507. background-color: rgba(255, 212, 137, 0.3);
  508. border-color: rgba(255, 212, 137, 0.6);
  509. }
  510. &.el-popper.is-light .el-popper__arrow:before {
  511. background: #232323;
  512. border-color: rgba(255, 212, 137, 0.3);
  513. }
  514. }
  515. </style>