index.vue 20 KB

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