index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. <template>
  2. <div class="base-container no-events">
  3. <fnHeader showDate></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. staticMapLayers.show(mapName, true)
  183. }
  184. }
  185. const toggleChatMapLayer = () => {
  186. hideChatMapLayer.value = true
  187. eventBus.emit("chat:hideMapLayer");
  188. staticMapLayers.hideAll()
  189. }
  190. const destroyPopup = () => {
  191. eventBus.emit("map:destroyPopup");
  192. };
  193. const props1 = {
  194. checkStrictly: true,
  195. };
  196. const toggleArea = (v) => {
  197. activeBoxName.value = null;
  198. const val = v[v.length - 1];
  199. if (val === "3" || val === "3186") {
  200. eventBus.emit("warningHome:toggleArea", val);
  201. }
  202. };
  203. const activeBoxName = ref(null);
  204. const toggleBox = (name) => {
  205. activeBoxName.value = name;
  206. legendImg.value = warningLayers.value[`${name}图例`];
  207. eventBus.emit("warningHome:toggleMapLayer", name);
  208. };
  209. </script>
  210. <style lang="scss" scoped>
  211. .base-container {
  212. width: 100%;
  213. height: 100vh;
  214. color: #fff;
  215. position: absolute;
  216. box-sizing: border-box;
  217. z-index: 1;
  218. ::v-deep {
  219. .focus-farm {
  220. top: 42px;
  221. }
  222. }
  223. .content {
  224. width: 100%;
  225. height: calc(100% - 74px - 48px);
  226. padding: 0 20px 0 27px;
  227. display: flex;
  228. justify-content: space-between;
  229. box-sizing: border-box;
  230. position: relative;
  231. .left,
  232. .right {
  233. width: calc(376px + 54px);
  234. height: 100%;
  235. padding-top: 10px;
  236. box-sizing: border-box;
  237. // display: flex;
  238. }
  239. .right {
  240. // width: 395px;
  241. width: 500px;
  242. position: relative;
  243. .list {
  244. width: 100%;
  245. height: 100%;
  246. }
  247. }
  248. .warning-r {
  249. .map-legend {
  250. position: absolute;
  251. bottom: -33px;
  252. left: -360px;
  253. width: 340px;
  254. img {
  255. width: 340px;
  256. opacity: 0.6;
  257. }
  258. }
  259. .chat-legend {
  260. bottom: -12px;
  261. }
  262. }
  263. .warning-search {
  264. position: absolute;
  265. right: 400px;
  266. top: -34px;
  267. display: flex;
  268. align-items: center;
  269. .focus-farm {
  270. padding-left: 15px;
  271. }
  272. ::v-deep {
  273. .el-select__wrapper {
  274. background: rgba(255, 212, 137, 0.2);
  275. box-shadow: 0 0 0 1px rgba(255, 212, 137, 0.3) inset;
  276. height: 50px;
  277. line-height: 50px;
  278. .el-select__caret {
  279. color: #ffd489;
  280. }
  281. }
  282. .el-select__placeholder {
  283. color: #f7be5a;
  284. font-size: 20px;
  285. font-family: "PangMenZhengDao";
  286. text-align: center;
  287. }
  288. }
  289. }
  290. .warning-top {
  291. display: flex;
  292. width: max-content;
  293. align-items: center;
  294. .back-icon {
  295. cursor: pointer;
  296. margin-right: 20px;
  297. height: 50px;
  298. display: flex;
  299. align-items: center;
  300. padding: 0 20px;
  301. border: 1px solid rgba(255, 255, 255, 0.6);
  302. background: rgba(0, 0, 0, 0.2);
  303. border-radius: 4px;
  304. img {
  305. width: 17px;
  306. margin-right: 10px;
  307. }
  308. }
  309. .top-l {
  310. display: flex;
  311. flex-direction: column;
  312. align-items: center;
  313. .type-box {
  314. margin-top: 10px;
  315. background: rgba(29, 29, 29, 0.54);
  316. border: 1px solid rgba(255, 212, 137, 0.3);
  317. border-radius: 2px;
  318. text-align: center;
  319. line-height: 48px;
  320. height: 48px;
  321. width: 184px;
  322. }
  323. ::v-deep {
  324. .el-input__wrapper {
  325. background: rgba(29, 29, 29, 0.54);
  326. box-shadow: 0 0 0 1px rgba(255, 212, 137, 0.3) inset;
  327. height: 50px;
  328. line-height: 50px;
  329. padding: 0 10px;
  330. .el-input__inner {
  331. color: #f7be5a;
  332. font-size: 20px;
  333. font-family: "PangMenZhengDao";
  334. text-align: center;
  335. }
  336. }
  337. .el-select__wrapper {
  338. background: rgba(29, 29, 29, 0.54);
  339. box-shadow: 0 0 0 1px rgba(255, 212, 137, 0.3) inset;
  340. height: 50px;
  341. line-height: 50px;
  342. .el-select__caret {
  343. color: #ffd489;
  344. }
  345. }
  346. .el-select__placeholder {
  347. color: #f7be5a;
  348. font-size: 20px;
  349. font-family: "PangMenZhengDao";
  350. text-align: center;
  351. }
  352. }
  353. }
  354. .top-r {
  355. display: flex;
  356. .data-box {
  357. cursor: pointer;
  358. margin-left: 20px;
  359. width: 200px;
  360. height: 104px;
  361. background: url("@/assets/images/warningHome/box-bg.png") no-repeat center center / 100% 100%;
  362. display: flex;
  363. flex-direction: column;
  364. align-items: center;
  365. &.active {
  366. position: relative;
  367. &::before {
  368. content: "";
  369. position: absolute;
  370. bottom: -26px;
  371. left: 0;
  372. right: 0;
  373. width: 35px;
  374. height: 17px;
  375. margin: 0 auto;
  376. background: url("@/assets/images/warningHome/triangle.png") no-repeat center center / cover;
  377. }
  378. }
  379. .data-value {
  380. padding-top: 15px;
  381. font-size: 20px;
  382. color: rgba(255, 212, 137, 0.4);
  383. font-family: "PangMenZhengDao";
  384. span {
  385. font-size: 38px;
  386. color: #f7be5a;
  387. padding-right: 2px;
  388. }
  389. }
  390. .data-name {
  391. color: #cecece;
  392. font-size: 16px;
  393. }
  394. }
  395. }
  396. }
  397. .warning-alarm {
  398. width: 88px;
  399. padding-top: 14px;
  400. }
  401. .time-wrap {
  402. position: absolute;
  403. bottom: -20px;
  404. left: 140px;
  405. width: 46vw;
  406. min-width: 700px;
  407. height: 71px;
  408. }
  409. }
  410. }
  411. .bottom-map {
  412. width: 100%;
  413. height: 100vh;
  414. position: absolute;
  415. z-index: 0;
  416. }
  417. </style>
  418. <style lang="less">
  419. .ol-scale-line {
  420. left: auto;
  421. right: 435px;
  422. bottom: 13px;
  423. .ol-scale-line-inner {
  424. max-width: 80px;
  425. width: 80px !important;
  426. color: #fff;
  427. border-color: #fff;
  428. }
  429. }
  430. .focus-farm-select {
  431. &.el-popper.is-light {
  432. background: #232323;
  433. border-color: rgba(255, 212, 137, 0.3);
  434. box-shadow: 0px 0px 12px rgba(255, 212, 137, 0.3);
  435. .el-select-dropdown__item {
  436. background: none;
  437. color: rgba(255, 212, 137, 0.6);
  438. }
  439. .el-select-dropdown__item.is-selected {
  440. background: rgba(255, 212, 137, 0.2);
  441. color: #ffd489;
  442. }
  443. }
  444. &.el-popper.is-light .el-popper__arrow:before {
  445. background: #232323;
  446. border-color: rgba(255, 212, 137, 0.3);
  447. }
  448. }
  449. .ol-popup-warning {
  450. position: relative;
  451. width: 295px;
  452. background: rgb(35, 35, 35, 0.86);
  453. color: #fff;
  454. font-size: 16px;
  455. border-radius: 4px;
  456. .warning-info-title {
  457. display: flex;
  458. padding: 6px 10px;
  459. background: rgba(255, 255, 255, 0.05);
  460. font-size: 18px;
  461. border-radius: 4px 4px 0 0;
  462. .icon {
  463. padding-right: 6px;
  464. }
  465. .close {
  466. position: absolute;
  467. right: 12px;
  468. top: 4px;
  469. }
  470. }
  471. .info-content {
  472. padding: 16px 20px 40px 20px;
  473. line-height: 26px;
  474. text-indent: 2em;
  475. }
  476. }
  477. .area-cascader {
  478. &.el-popper.is-light {
  479. background: #232323;
  480. border-color: rgba(255, 212, 137, 0.3);
  481. box-shadow: 0px 0px 12px rgba(255, 212, 137, 0.3);
  482. .el-cascader-menu {
  483. color: rgba(255, 212, 137, 0.6);
  484. border-color: rgba(255, 212, 137, 0.3);
  485. }
  486. .el-cascader-node.in-active-path,
  487. .el-cascader-node.is-active,
  488. .el-cascader-node.is-selectable.in-checked-path {
  489. color: #f7be5a;
  490. background: transparent;
  491. }
  492. .el-radio__input.is-checked .el-radio__inner {
  493. background: #f7be5a;
  494. border-color: #f7be5a;
  495. }
  496. .el-cascader-node:not(.is-disabled):hover,
  497. .el-cascader-node:not(.is-disabled):focus,
  498. .el-cascader-node:not(.is-disabled):hover {
  499. background: rgba(255, 212, 137, 0.2);
  500. }
  501. }
  502. .el-radio__inner {
  503. background-color: rgba(255, 212, 137, 0.3);
  504. border-color: rgba(255, 212, 137, 0.6);
  505. }
  506. &.el-popper.is-light .el-popper__arrow:before {
  507. background: #232323;
  508. border-color: rgba(255, 212, 137, 0.3);
  509. }
  510. }
  511. </style>