index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <template>
  2. <div class="base-container no-events">
  3. <fnHeader showDate></fnHeader>
  4. <div class="content">
  5. <navigation @handleTab="handleTab" @handleTabItem="handleTabItem"></navigation>
  6. <div class="left yes-events">
  7. <tool-list
  8. direction="left"
  9. :list="leftToolList"
  10. @handleActive="handleActiveLeft"
  11. ></tool-list>
  12. <component :is="components[currentComponent]" />
  13. <!-- 箭头 -->
  14. <div class="arrow" @click="handleShrink">
  15. <el-icon class="icon" color="#141414"><DArrowLeft /></el-icon>
  16. </div>
  17. </div>
  18. <div class="home-bottom">
  19. <time-line class="time-wrap yes-events"></time-line>
  20. <img class="fly-icon" src="@/assets/images/home/fly-icon.png" alt="">
  21. <!-- <div class="log-box yes-events">
  22. <chart-box class="overflow">
  23. <template #title-name>
  24. <div class="box-name" @click="handleSelectArea">果园日志</div>
  25. </template>
  26. <div class="log-content">
  27. 2月13日,共抽样193棵树,拍摄了193张照片,{{indicatorChartData.content}}
  28. </div>
  29. <div class="chart-wrap">
  30. <indicator-chart :key="0 + 'log'" type="feature" :chartData="indicatorChartData"></indicator-chart>
  31. </div>
  32. </chart-box>
  33. </div> -->
  34. <!-- <div class="file-box yes-events">
  35. <chart-box name="果园档案">
  36. <template #title-right>
  37. <el-icon class="arrow-icon cursor-pointer" color="#141414"
  38. ><DArrowLeft
  39. /></el-icon>
  40. <div class="edit-btn cursor-pointer" @click="toFilePage">编辑</div>
  41. </template>
  42. <file-bar></file-bar>
  43. </chart-box>
  44. </div> -->
  45. </div>
  46. <div class="right yes-events">
  47. <div class="list">
  48. <chart-box name="农事列表" arrow="arrow-left" :class="{'list-wrap': rightIndex===0}">
  49. <template v-if="rightIndex===0">
  50. <!-- <album></album> -->
  51. <!-- <img class="tabs" src="@/assets/images/home/ns-tabs.png" alt="">
  52. <div class="img-box">
  53. <img @click="handleAct(item)" v-for="item in 2" :key="item" :src="require(`@/assets/images/home/0${act<=2&&act==item?item+'-act':item}.png`)" alt="">
  54. </div> -->
  55. </template>
  56. <template v-if="rightIndex===1">
  57. <div class="img-box1">
  58. <img src="@/assets/images/home/fh01.png" alt="">
  59. <img src="@/assets/images/home/fh02.png" alt="">
  60. </div>
  61. </template>
  62. <template v-if="rightIndex===2">
  63. <div class="btn-wrap">
  64. <div :class="{active:btnIndex===0}" @click="handleBtn(0)">{{btnIndex===0&&btnName!=''?'采样分区:'+ btnName:'选择采样分区'}}</div>
  65. <div :class="{active:btnIndex===1}" @click="handleBtn(1)">{{btnIndex===1&&btnName!=''?'单树编号:'+ btnName:'选择树'}}</div>
  66. </div>
  67. <div class="img-box2" v-show="showPoint">
  68. <img v-if="showType==='point'" src="@/assets/images/home/line-chart.png" alt="">
  69. <img v-else src="@/assets/images/home/line-chart2.png" alt="">
  70. <img src="@/assets/images/home/fh01.png" alt="">
  71. </div>
  72. <div class="img-box2" v-show="!showPoint">
  73. <img v-if="showType==='point'" src="@/assets/images/home/line-chart1.png" alt="">
  74. <img v-else src="@/assets/images/home/line-chart3.png" alt="">
  75. <img src="@/assets/images/home/fh02.png" alt="">
  76. </div>
  77. </template>
  78. </chart-box>
  79. </div>
  80. <tool-list direction="right" :list="rightToolList" @handleActive="handleActiveRight"></tool-list>
  81. </div>
  82. <!-- 图例 -->
  83. <img class="legend yes-events" src="@/assets/images/home/legend.png" alt="">
  84. </div>
  85. </div>
  86. <div ref="mapRef" class="bottom-map"></div>
  87. <!-- 图片弹窗 -->
  88. <PicturePreview
  89. :imageUrl="urls"
  90. :curIndex="urlsIndex"
  91. ></PicturePreview>
  92. <album-carousel></album-carousel>
  93. <PdfDialog title="果园报告" ></PdfDialog>
  94. </template>
  95. <script setup>
  96. import { onMounted, ref } from "vue";
  97. import config from "@/api/config.js"
  98. import timeLine from "@/components/timeLine.vue";
  99. import PicturePreview from "@/components/PicturePreview.vue";
  100. import fnHeader from "@/components/fnHeader.vue";
  101. import navigation from "@/components/navigation.vue";
  102. import chartBox from "@/components/chartBox.vue";
  103. import toolList from "@/components/toolList.vue";
  104. import fileBar from "@/components/fileBar.vue";
  105. import HomeMap from "./map/homeMap";
  106. import homePage from "./components/homePage.vue";
  107. import weatherPage from "./components/weatherPage.vue";
  108. import phenologyPage from "./components/phenologyPage.vue";
  109. import indicatorChart from "./components/indicatorChart.vue";
  110. import { useRouter } from "vue-router";
  111. import SamplePointLayer from "./map/samplePointLayer";
  112. import {useStore} from "vuex";
  113. import RegionLayer from "./map/regionLayer";
  114. import BlueRegionLayer from "./map/blueRegionLayer";
  115. import eventBus from "@/api/eventBus";
  116. import AlbumCarousel from "./album_compoents/albumCarousel.vue";
  117. import album from "./album/index.vue";
  118. import PdfDialog from "../../components/PdfDialog"
  119. let store = useStore()
  120. const components = {
  121. homePage,
  122. weatherPage,
  123. phenologyPage,
  124. };
  125. //当前农场
  126. const currentFarm = {
  127. id: store.getters.userinfo.curFarmId,
  128. name: store.getters.userinfo.curFarmName,
  129. }
  130. //当前区域
  131. const currentRegion = {
  132. id: null,
  133. name: null
  134. }
  135. let homeMap = new HomeMap();
  136. let samplePointLayer = null
  137. let regionLayer = null
  138. let blueRegionLayer = null
  139. const router = useRouter();
  140. const mapRef = ref();
  141. onMounted(() => {
  142. homeMap.initMap("POINT(113.61448114737868 23.585550924763083)", mapRef.value);
  143. // homeMap.initMap(store.getters.userinfo.location, mapRef.value);
  144. samplePointLayer = new SamplePointLayer(homeMap.kmap.map, currentFarm, currentRegion)
  145. // regionLayer = new RegionLayer(homeMap.kmap.map, currentFarm, currentRegion)
  146. blueRegionLayer = new BlueRegionLayer(homeMap.kmap)
  147. getYellow()
  148. getFarmLog()
  149. getBlueRegionList()
  150. });
  151. const blueList = ref([])
  152. const getBlueRegionList = () =>{
  153. VE_API.farm.blueRegionList({farmId:766,regionId:2}).then(({ data }) => {
  154. blueList.value = data.map(item =>{
  155. let color = 'rgba(255, 255, 255, 0.5)' //失效区域
  156. if(item.status===2){ //物候期风险
  157. color = 'rgba(63, 255, 53, 0.5)'
  158. }
  159. if(item.status===3){ //生长异常
  160. color = 'rgba(255, 252, 61, 0.5)'
  161. }
  162. if(item.status===4){ //病虫害
  163. color = 'rgba(255, 73, 73, 0.5)'
  164. }
  165. return {
  166. ...item,
  167. color
  168. }
  169. })
  170. blueRegionLayer.initData(blueList.value)
  171. });
  172. }
  173. //选项卡事件监听
  174. const handleTab = ({name,id}) =>{
  175. console.log('name',name,id);
  176. if(id===0){
  177. getBlueRegionList()
  178. }else{
  179. getFarmIndexReport()
  180. }
  181. }
  182. //选项卡子项事件监听
  183. const handleTabItem = () =>{
  184. }
  185. const active = ref(0)
  186. const reportData = ref({})
  187. const blueListConvert = (data)=>{
  188. const list = []
  189. for (let key in data) {
  190. const filterData = reportData.value.blueZoneLegendList[active.value].list.filter(item => item.val === key)
  191. const arr = data[key]
  192. arr.forEach(item =>{
  193. const listObj = blueList.value.filter(ele =>ele.blueZoneCode === item)
  194. const updateList = listObj.map(ele => {
  195. return{
  196. ...ele,
  197. level: key,
  198. name:filterData[0].name,
  199. color:filterData[0].color
  200. }
  201. })
  202. list.push(...updateList)
  203. })
  204. }
  205. return list
  206. }
  207. const getFarmIndexReport = () =>{
  208. const params = { farmId:766,regionId:2, type: '生态指标' };
  209. VE_API.farm.farmIndexReport(params).then(({data,code}) => {
  210. if (code === 0) {
  211. reportData.value = data || {};
  212. const arr = blueListConvert(data.blueZoneList[active.value].obj)
  213. blueRegionLayer.initData(arr)
  214. }
  215. });
  216. }
  217. const indicatorChartData = ref({})
  218. const blueZone = ref('ws0y1meyhxp4')
  219. const getFarmLog = () =>{
  220. const params = {
  221. id: null,
  222. farmId: 766,
  223. blueZone:blueZone.value
  224. }
  225. VE_API.warning.fetchFarmLog(params).then(({data}) => {
  226. indicatorChartData.value = data || {}
  227. eventBus.emit('chart:updateOption',data)
  228. })
  229. }
  230. const urls = ref([])
  231. const urlsIndex = ref(0)
  232. const getYellow = () =>{
  233. VE_API.home.getYellowList().then(res =>{
  234. // urls.value = res.data.map(item =>{
  235. // return {
  236. // ...item,
  237. // imgPath:config.base_img_url2+item.cloudFilename
  238. // }
  239. // })
  240. // urls.value = [
  241. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-07.jpg",
  242. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-08.jpg",
  243. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-09.jpg",
  244. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-10.jpg",
  245. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-11.jpg",
  246. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-12.jpg",
  247. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-13.jpg",
  248. // ]
  249. })
  250. }
  251. const btnIndex = ref(null)
  252. const btnName = ref("")
  253. const handleBtn = (e) =>{
  254. btnName.value = ""
  255. btnIndex.value = e
  256. eventBus.emit("clear:area")
  257. samplePointLayer.updateAreaStatus(e===0?true:false)
  258. regionLayer.resetData()
  259. samplePointLayer.resetPoint()
  260. }
  261. //点击果园日志
  262. const handleSelectArea = () =>{
  263. btnName.value = ""
  264. btnIndex.value = null
  265. eventBus.emit("clear:area")
  266. regionLayer.resetData()
  267. samplePointLayer.resetPoint()
  268. samplePointLayer.updateAreaStatus(true)
  269. }
  270. //农事点击高亮
  271. const act = ref(null)
  272. const handleAct = (v) =>{
  273. act.value = v
  274. samplePointLayer.resetPoint()
  275. if(v===1){
  276. regionLayer.selectAreaMultiple([
  277. {value:2,color:"blue"},
  278. {value:4,color:"blue1"},
  279. {value:5,color:"blue2"},
  280. {value:7,color:"blue"},
  281. {value:13,color:"blue2"},
  282. ])
  283. }
  284. if(v===2){
  285. regionLayer.selectAreaMultiple([
  286. {value:1,color:"blue"},
  287. {value:2,color:"blue1"},
  288. {value:9,color:"blue2"},
  289. {value:12,color:"blue2"},
  290. ])
  291. }
  292. }
  293. //柱状图点击事件监听
  294. eventBus.on('echart:barClick',(e)=>{
  295. btnName.value = ""
  296. btnIndex.value = null
  297. eventBus.emit("clear:area")
  298. samplePointLayer.updateAreaStatus(false)
  299. const arr = ["花穗伸长", "啃食虫害","毛毡病"]
  300. const isDraw = arr.includes(e)
  301. const index = arr.indexOf(e)
  302. if(isDraw){
  303. if(index===0){
  304. regionLayer.selectAreaMultiple([
  305. {value:0,color:"green"},
  306. {value:1,color:"green"},
  307. {value:2,color:"green"},
  308. {value:3,color:"green1"},
  309. {value:4,color:"green1"},
  310. {value:5,color:"green2"},
  311. {value:6,color:"green1"},
  312. {value:7,color:"green2"},
  313. {value:8,color:"green2"},
  314. {value:9,color:"green"},
  315. {value:10,color:"green"},
  316. {value:11,color:"green1"},
  317. {value:12,color:"green2"},
  318. {value:13,color:"green"},
  319. {value:14,color:"green2"},
  320. ])
  321. }else if(index===1){
  322. regionLayer.selectAreaMultiple([{value:6,color:"red"}])
  323. }else{
  324. regionLayer.selectAreaMultiple([
  325. {value:12,color:"red2"},
  326. {value:10,color:"red"},
  327. {value:1,color:"red"}
  328. ])
  329. }
  330. }
  331. })
  332. //黄板点击事件监听
  333. eventBus.on('click:yellowBlock',(e)=>{
  334. const arr = ["113.61396985128522","113.61390710255375","113.61491218688275"]
  335. if(arr[0]==e){
  336. urls.value = ["HB-ws0y1menggxv"]
  337. urlsIndex.value = 0
  338. }
  339. if(arr[1]==e){
  340. urls.value = ["HB-ws0y1mg0pvd" ]
  341. urlsIndex.value = 3
  342. }
  343. if(arr[2]==e){
  344. urls.value = ["HB-ws0y1mg9wpcp"]
  345. urlsIndex.value = 6
  346. }
  347. eventBus.emit('dialog:show',true)
  348. })
  349. const showPoint = ref(true)
  350. const showType = ref("point")
  351. //地图点击事件
  352. eventBus.on('click:point',(e)=>{
  353. // showType.value = "point"
  354. // if(btnIndex.value===1){
  355. // btnName.value=e.name
  356. // if(e.value===1){
  357. // showPoint.value = true
  358. // samplePointLayer.updatePointStatus(true)
  359. // }else{
  360. // showPoint.value = false
  361. // }
  362. // }
  363. })
  364. //地图点击区域事件
  365. eventBus.on('click:area',(e)=>{
  366. // showType.value = "area"
  367. // if(btnIndex.value===0){
  368. // btnName.value=e.name
  369. // if(e.value===1){
  370. // showPoint.value = true
  371. // }else{
  372. // showPoint.value = false
  373. // }
  374. // regionLayer.selectArea((e.name*1)===0?0: (e.name*1) - 1,"blue")
  375. // }
  376. })
  377. eventBus.on('click:updateArea',(e)=>{
  378. blueZone.value = e.value
  379. btnName.value=e.name
  380. regionLayer.selectArea((e.name*1)===0?0: (e.name*1) - 1,"blue")
  381. getFarmLog()
  382. })
  383. const currentComponent = ref("homePage");
  384. const handleActiveLeft = (e) => {
  385. currentComponent.value = e.componentName;
  386. if(e.title==='首页'){
  387. router.push('/warningHome')
  388. }
  389. };
  390. const leftToolList = [
  391. {
  392. title: "首页",
  393. name: "home",
  394. componentName: "homePage",
  395. },
  396. {
  397. title: "气象预警",
  398. componentName: "weatherPage",
  399. },
  400. {
  401. title: "物候调节",
  402. componentName: "phenologyPage",
  403. },
  404. {
  405. title: "病虫测报",
  406. },
  407. {
  408. title: "营养评估",
  409. },
  410. ];
  411. const rightIndex = ref(0)
  412. const handleActiveRight = ({index}) => {
  413. rightIndex.value = index
  414. btnIndex.value = null
  415. btnName.value = ""
  416. samplePointLayer.updateAreaStatus(false)
  417. regionLayer.resetData()
  418. samplePointLayer.resetPoint()
  419. if(index!==0){
  420. act.value = null
  421. }
  422. };
  423. const hanleRightIndex = (num) =>{
  424. rightIndex.value = num
  425. eventBus.emit('tool:updateAct',num)
  426. }
  427. const rightToolList = [
  428. {
  429. title: "农事列表",
  430. index:0,
  431. },
  432. {
  433. title: "处方分析",
  434. index:2,
  435. },
  436. {
  437. title: "复核对比",
  438. index:1,
  439. },
  440. ];
  441. // 跳转果园档案
  442. const toFilePage = () => {
  443. router.push('/garden-file')
  444. }
  445. </script>
  446. <style lang="scss" scoped>
  447. .base-container {
  448. width: 100%;
  449. height: 100vh;
  450. color: #fff;
  451. position: absolute;
  452. box-sizing: border-box;
  453. z-index: 1;
  454. .content {
  455. width: 100%;
  456. height: calc(100% - 74px - 48px);
  457. display: flex;
  458. justify-content: space-between;
  459. box-sizing: border-box;
  460. .left,
  461. .right {
  462. width: calc(376px + 54px);
  463. height: 100%;
  464. margin-top: 10px;
  465. box-sizing: border-box;
  466. display: flex;
  467. position: relative;
  468. }
  469. .left{
  470. background: #101010;
  471. border-radius: 4px;
  472. border: 1px solid #444444;
  473. .arrow{
  474. position: absolute;
  475. right: -16px;
  476. top:calc(50% - 40px);
  477. background: #fff;
  478. width: 16px;
  479. height: 80px;
  480. line-height: 80px;
  481. border-radius: 0 5px 5px 0;
  482. text-align: center;
  483. cursor: pointer;
  484. }
  485. }
  486. .right {
  487. .list {
  488. width: 100%;
  489. height: 100%;
  490. .btn-wrap{
  491. width: 100%;
  492. height: 25px;
  493. line-height: 25px;
  494. margin: 10px 0;
  495. display: flex;
  496. align-items: center;
  497. justify-content: space-between;
  498. div{
  499. width: 48%;
  500. height: 100%;
  501. color: #FFD489;
  502. border: 1px solid rgba(255,213,137,0.6);
  503. border-radius: 2px;
  504. text-align: center;
  505. font-size: 12px;
  506. cursor: pointer;
  507. &.active{
  508. background: #FFD489;
  509. color: #000;
  510. }
  511. }
  512. }
  513. .img-box{
  514. width: 100%;
  515. height: calc(100% - 35px);
  516. overflow: auto;
  517. }
  518. .img-box1{
  519. width: 100%;
  520. height: calc(100% - 10px);
  521. overflow: auto;
  522. margin-top: 10px;
  523. }
  524. .img-box2{
  525. width: 100%;
  526. height: calc(100% - 45px);
  527. overflow: auto;
  528. margin-top: 10px;
  529. }
  530. img{
  531. width: 100%;
  532. height: auto;
  533. object-fit: cover;
  534. margin-bottom: 12px;
  535. cursor: pointer;
  536. }
  537. .mt{
  538. margin-top: -12px;
  539. }
  540. .list-wrap {
  541. ::v-deep {
  542. .chart-content {
  543. padding: 16px 0 0 0;
  544. }
  545. }
  546. }
  547. }
  548. }
  549. .overflow{
  550. overflow: auto;
  551. }
  552. .home-bottom {
  553. display: flex;
  554. align-items: flex-end;
  555. width: calc(100% - 60px - 430px * 2 );
  556. height: 152px;
  557. align-self: flex-end;
  558. .time-wrap{
  559. height: 85px;
  560. }
  561. .fly-icon{
  562. width: 148px;
  563. height: 100%;
  564. margin-left: 27px;
  565. }
  566. .log-box {
  567. height: 34%;
  568. width: calc(100% - 340px - 28px);
  569. margin-right: 28px;
  570. .box-name{
  571. width: 89px;
  572. height: 22px;
  573. text-align: center;
  574. line-height: 22px;
  575. border-radius: 20px;
  576. margin: 10px 0 5px 6px;
  577. cursor: pointer;
  578. background: linear-gradient(0deg,#BBA269 0%, #3D3523 100%);
  579. }
  580. .log-content {
  581. font-size: 12px;
  582. line-height: 1.5;
  583. padding: 0 18px;
  584. }
  585. .chart-wrap{
  586. width: 100%;
  587. height: calc(100% - 50px);
  588. .line{
  589. margin-top: 10px;
  590. margin-bottom: 12px;
  591. }
  592. img{
  593. width: 100%;
  594. margin-bottom: 10px;
  595. }
  596. }
  597. }
  598. .file-box {
  599. height: 25%;
  600. min-height: 210px;
  601. width: 340px;
  602. position: relative;
  603. img{
  604. width: 100%;
  605. margin-top: 12px;
  606. }
  607. .arrow-icon {
  608. top: -32px;
  609. left: 50%;
  610. position: absolute;
  611. background: #fff;
  612. width: 16px;
  613. height: 80px;
  614. line-height: 80px;
  615. border-radius: 5px 0 0 5px;
  616. text-align: center;
  617. transform: translateX(-50%) rotate(270deg);
  618. }
  619. .edit-btn {
  620. padding: 2px 24px;
  621. background: #FFD489;
  622. border-radius: 4px;
  623. color: #000;
  624. }
  625. }
  626. }
  627. .legend{
  628. position: fixed;
  629. bottom: 8px;
  630. right: 64px;
  631. width: 525px;
  632. height: 16px;
  633. }
  634. }
  635. }
  636. .bottom-map {
  637. width: 100%;
  638. height: 100vh;
  639. position: absolute;
  640. z-index: 0;
  641. }
  642. </style>