index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  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, onUnmounted, 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. //区域切换监听事件
  150. eventBus.on('area:id',areaId)
  151. });
  152. onUnmounted(()=>{
  153. eventBus.off('area:id',areaId)
  154. })
  155. const blueList = ref([])
  156. const getBlueRegionList = () =>{
  157. VE_API.farm.blueRegionList({farmId:organId.value,regionId:regionId.value}).then(({ data }) => {
  158. blueList.value = data.map(item =>{
  159. let color = 'rgba(255, 255, 255, 0.5)' //失效区域
  160. if(item.status===2){ //物候期风险
  161. color = 'rgba(63, 255, 53, 0.5)'
  162. }
  163. if(item.status===3){ //生长异常
  164. color = 'rgba(255, 252, 61, 0.5)'
  165. }
  166. if(item.status===4){ //病虫害
  167. color = 'rgba(255, 73, 73, 0.5)'
  168. }
  169. return {
  170. ...item,
  171. color
  172. }
  173. })
  174. blueRegionLayer.initData(blueList.value)
  175. });
  176. }
  177. const organId = ref(null)
  178. const regionId = ref(null)
  179. const tabName = ref('')
  180. const tabId = ref(0)
  181. //选项卡事件监听
  182. const handleTab = ({name,id}) =>{
  183. tabName.value = name
  184. tabId.value = id
  185. if(id===0){
  186. getBlueRegionList()
  187. }else{
  188. getFarmIndexReport()
  189. }
  190. }
  191. //区域切换监听事件
  192. function areaId({areaId,farmId}){
  193. organId.value = farmId
  194. regionId.value = areaId
  195. if(tabId.value===0){
  196. getBlueRegionList()
  197. }else{
  198. getFarmIndexReport()
  199. }
  200. }
  201. //选项卡子项事件监听
  202. const handleTabItem = (e) =>{
  203. const index = reportData.value.blueZoneList.findIndex(item => item.key===e)
  204. let arr = []
  205. if(reportData.value.blueZoneList.length){
  206. arr = blueListConvert(reportData.value.blueZoneList[index].obj,index)
  207. }
  208. blueRegionLayer.initData(arr,'87')
  209. }
  210. const reportData = ref({})
  211. const blueListConvert = (data,index)=>{
  212. const list = []
  213. for (let key in data) {
  214. const filterData = reportData.value.blueZoneLegendList[index].list.filter(item => item.val === key)
  215. const arr = data[key]
  216. arr.forEach(item =>{
  217. const listObj = blueList.value.filter(ele =>ele.blueZoneCode === item)
  218. const updateList = listObj.map(ele => {
  219. return{
  220. ...ele,
  221. level: key,
  222. name:filterData[0].name,
  223. color:filterData[0].color
  224. }
  225. })
  226. list.push(...updateList)
  227. })
  228. }
  229. return list
  230. }
  231. const getFarmIndexReport = () =>{
  232. const params = { farmId:organId.value,regionId:regionId.value, type: tabName.value };
  233. VE_API.farm.farmIndexReport(params).then(({data,code}) => {
  234. if (code === 0) {
  235. reportData.value = data || {};
  236. let arr = []
  237. if(data.blueZoneList.length){
  238. arr = blueListConvert(data.blueZoneList[0].obj,0)
  239. }
  240. blueRegionLayer.initData(arr,'87')
  241. }
  242. });
  243. }
  244. const indicatorChartData = ref({})
  245. const blueZone = ref('ws0y1meyhxp4')
  246. const getFarmLog = () =>{
  247. const params = {
  248. id: null,
  249. farmId: 766,
  250. blueZone:blueZone.value
  251. }
  252. VE_API.warning.fetchFarmLog(params).then(({data}) => {
  253. indicatorChartData.value = data || {}
  254. eventBus.emit('chart:updateOption',data)
  255. })
  256. }
  257. const urls = ref([])
  258. const urlsIndex = ref(0)
  259. const getYellow = () =>{
  260. VE_API.home.getYellowList().then(res =>{
  261. // urls.value = res.data.map(item =>{
  262. // return {
  263. // ...item,
  264. // imgPath:config.base_img_url2+item.cloudFilename
  265. // }
  266. // })
  267. // urls.value = [
  268. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-07.jpg",
  269. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-08.jpg",
  270. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-09.jpg",
  271. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-10.jpg",
  272. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-11.jpg",
  273. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-12.jpg",
  274. // "@/assets/images/home/HB-ws0y1menggxv/HB-ws0y1menggxv2025-01-13.jpg",
  275. // ]
  276. })
  277. }
  278. const btnIndex = ref(null)
  279. const btnName = ref("")
  280. const handleBtn = (e) =>{
  281. btnName.value = ""
  282. btnIndex.value = e
  283. eventBus.emit("clear:area")
  284. samplePointLayer.updateAreaStatus(e===0?true:false)
  285. regionLayer.resetData()
  286. samplePointLayer.resetPoint()
  287. }
  288. //点击果园日志
  289. const handleSelectArea = () =>{
  290. btnName.value = ""
  291. btnIndex.value = null
  292. eventBus.emit("clear:area")
  293. regionLayer.resetData()
  294. samplePointLayer.resetPoint()
  295. samplePointLayer.updateAreaStatus(true)
  296. }
  297. //农事点击高亮
  298. const act = ref(null)
  299. const handleAct = (v) =>{
  300. act.value = v
  301. samplePointLayer.resetPoint()
  302. if(v===1){
  303. regionLayer.selectAreaMultiple([
  304. {value:2,color:"blue"},
  305. {value:4,color:"blue1"},
  306. {value:5,color:"blue2"},
  307. {value:7,color:"blue"},
  308. {value:13,color:"blue2"},
  309. ])
  310. }
  311. if(v===2){
  312. regionLayer.selectAreaMultiple([
  313. {value:1,color:"blue"},
  314. {value:2,color:"blue1"},
  315. {value:9,color:"blue2"},
  316. {value:12,color:"blue2"},
  317. ])
  318. }
  319. }
  320. //柱状图点击事件监听
  321. eventBus.on('echart:barClick',(e)=>{
  322. btnName.value = ""
  323. btnIndex.value = null
  324. eventBus.emit("clear:area")
  325. samplePointLayer.updateAreaStatus(false)
  326. const arr = ["花穗伸长", "啃食虫害","毛毡病"]
  327. const isDraw = arr.includes(e)
  328. const index = arr.indexOf(e)
  329. if(isDraw){
  330. if(index===0){
  331. regionLayer.selectAreaMultiple([
  332. {value:0,color:"green"},
  333. {value:1,color:"green"},
  334. {value:2,color:"green"},
  335. {value:3,color:"green1"},
  336. {value:4,color:"green1"},
  337. {value:5,color:"green2"},
  338. {value:6,color:"green1"},
  339. {value:7,color:"green2"},
  340. {value:8,color:"green2"},
  341. {value:9,color:"green"},
  342. {value:10,color:"green"},
  343. {value:11,color:"green1"},
  344. {value:12,color:"green2"},
  345. {value:13,color:"green"},
  346. {value:14,color:"green2"},
  347. ])
  348. }else if(index===1){
  349. regionLayer.selectAreaMultiple([{value:6,color:"red"}])
  350. }else{
  351. regionLayer.selectAreaMultiple([
  352. {value:12,color:"red2"},
  353. {value:10,color:"red"},
  354. {value:1,color:"red"}
  355. ])
  356. }
  357. }
  358. })
  359. //黄板点击事件监听
  360. eventBus.on('click:yellowBlock',(e)=>{
  361. const arr = ["113.61396985128522","113.61390710255375","113.61491218688275"]
  362. if(arr[0]==e){
  363. urls.value = ["HB-ws0y1menggxv"]
  364. urlsIndex.value = 0
  365. }
  366. if(arr[1]==e){
  367. urls.value = ["HB-ws0y1mg0pvd" ]
  368. urlsIndex.value = 3
  369. }
  370. if(arr[2]==e){
  371. urls.value = ["HB-ws0y1mg9wpcp"]
  372. urlsIndex.value = 6
  373. }
  374. eventBus.emit('dialog:show',true)
  375. })
  376. const showPoint = ref(true)
  377. const showType = ref("point")
  378. //地图点击事件
  379. eventBus.on('click:point',(e)=>{
  380. // showType.value = "point"
  381. // if(btnIndex.value===1){
  382. // btnName.value=e.name
  383. // if(e.value===1){
  384. // showPoint.value = true
  385. // samplePointLayer.updatePointStatus(true)
  386. // }else{
  387. // showPoint.value = false
  388. // }
  389. // }
  390. })
  391. //地图点击区域事件
  392. eventBus.on('click:area',(e)=>{
  393. // showType.value = "area"
  394. // if(btnIndex.value===0){
  395. // btnName.value=e.name
  396. // if(e.value===1){
  397. // showPoint.value = true
  398. // }else{
  399. // showPoint.value = false
  400. // }
  401. // regionLayer.selectArea((e.name*1)===0?0: (e.name*1) - 1,"blue")
  402. // }
  403. })
  404. eventBus.on('click:updateArea',(e)=>{
  405. blueZone.value = e.value
  406. btnName.value=e.name
  407. regionLayer.selectArea((e.name*1)===0?0: (e.name*1) - 1,"blue")
  408. getFarmLog()
  409. })
  410. const currentComponent = ref("homePage");
  411. const handleActiveLeft = (e) => {
  412. currentComponent.value = e.componentName;
  413. if(e.title==='首页'){
  414. router.push('/warningHome')
  415. }
  416. };
  417. const leftToolList = [
  418. {
  419. title: "首页",
  420. name: "home",
  421. componentName: "homePage",
  422. },
  423. {
  424. title: "气象预警",
  425. componentName: "weatherPage",
  426. },
  427. {
  428. title: "物候调节",
  429. componentName: "phenologyPage",
  430. },
  431. {
  432. title: "病虫测报",
  433. },
  434. {
  435. title: "营养评估",
  436. },
  437. ];
  438. const rightIndex = ref(0)
  439. const handleActiveRight = ({index}) => {
  440. rightIndex.value = index
  441. btnIndex.value = null
  442. btnName.value = ""
  443. samplePointLayer.updateAreaStatus(false)
  444. regionLayer.resetData()
  445. samplePointLayer.resetPoint()
  446. if(index!==0){
  447. act.value = null
  448. }
  449. };
  450. const hanleRightIndex = (num) =>{
  451. rightIndex.value = num
  452. eventBus.emit('tool:updateAct',num)
  453. }
  454. const rightToolList = [
  455. {
  456. title: "农事列表",
  457. index:0,
  458. },
  459. {
  460. title: "处方分析",
  461. index:2,
  462. },
  463. {
  464. title: "复核对比",
  465. index:1,
  466. },
  467. ];
  468. // 跳转果园档案
  469. const toFilePage = () => {
  470. router.push('/garden-file')
  471. }
  472. </script>
  473. <style lang="scss" scoped>
  474. .base-container {
  475. width: 100%;
  476. height: 100vh;
  477. color: #fff;
  478. position: absolute;
  479. box-sizing: border-box;
  480. z-index: 1;
  481. .content {
  482. width: 100%;
  483. height: calc(100% - 74px - 48px);
  484. display: flex;
  485. justify-content: space-between;
  486. box-sizing: border-box;
  487. .left,
  488. .right {
  489. width: calc(376px + 54px);
  490. height: 100%;
  491. margin-top: 10px;
  492. box-sizing: border-box;
  493. display: flex;
  494. position: relative;
  495. }
  496. .left{
  497. background: #101010;
  498. border-radius: 4px;
  499. border: 1px solid #444444;
  500. .arrow{
  501. position: absolute;
  502. right: -16px;
  503. top:calc(50% - 40px);
  504. background: #fff;
  505. width: 16px;
  506. height: 80px;
  507. line-height: 80px;
  508. border-radius: 0 5px 5px 0;
  509. text-align: center;
  510. cursor: pointer;
  511. }
  512. }
  513. .right {
  514. .list {
  515. width: 100%;
  516. height: 100%;
  517. .btn-wrap{
  518. width: 100%;
  519. height: 25px;
  520. line-height: 25px;
  521. margin: 10px 0;
  522. display: flex;
  523. align-items: center;
  524. justify-content: space-between;
  525. div{
  526. width: 48%;
  527. height: 100%;
  528. color: #FFD489;
  529. border: 1px solid rgba(255,213,137,0.6);
  530. border-radius: 2px;
  531. text-align: center;
  532. font-size: 12px;
  533. cursor: pointer;
  534. &.active{
  535. background: #FFD489;
  536. color: #000;
  537. }
  538. }
  539. }
  540. .img-box{
  541. width: 100%;
  542. height: calc(100% - 35px);
  543. overflow: auto;
  544. }
  545. .img-box1{
  546. width: 100%;
  547. height: calc(100% - 10px);
  548. overflow: auto;
  549. margin-top: 10px;
  550. }
  551. .img-box2{
  552. width: 100%;
  553. height: calc(100% - 45px);
  554. overflow: auto;
  555. margin-top: 10px;
  556. }
  557. img{
  558. width: 100%;
  559. height: auto;
  560. object-fit: cover;
  561. margin-bottom: 12px;
  562. cursor: pointer;
  563. }
  564. .mt{
  565. margin-top: -12px;
  566. }
  567. .list-wrap {
  568. ::v-deep {
  569. .chart-content {
  570. padding: 16px 0 0 0;
  571. }
  572. }
  573. }
  574. }
  575. }
  576. .overflow{
  577. overflow: auto;
  578. }
  579. .home-bottom {
  580. display: flex;
  581. align-items: flex-end;
  582. width: calc(100% - 60px - 430px * 2 );
  583. height: 152px;
  584. align-self: flex-end;
  585. .time-wrap{
  586. height: 85px;
  587. }
  588. .fly-icon{
  589. width: 148px;
  590. height: 100%;
  591. margin-left: 27px;
  592. }
  593. .log-box {
  594. height: 34%;
  595. width: calc(100% - 340px - 28px);
  596. margin-right: 28px;
  597. .box-name{
  598. width: 89px;
  599. height: 22px;
  600. text-align: center;
  601. line-height: 22px;
  602. border-radius: 20px;
  603. margin: 10px 0 5px 6px;
  604. cursor: pointer;
  605. background: linear-gradient(0deg,#BBA269 0%, #3D3523 100%);
  606. }
  607. .log-content {
  608. font-size: 12px;
  609. line-height: 1.5;
  610. padding: 0 18px;
  611. }
  612. .chart-wrap{
  613. width: 100%;
  614. height: calc(100% - 50px);
  615. .line{
  616. margin-top: 10px;
  617. margin-bottom: 12px;
  618. }
  619. img{
  620. width: 100%;
  621. margin-bottom: 10px;
  622. }
  623. }
  624. }
  625. .file-box {
  626. height: 25%;
  627. min-height: 210px;
  628. width: 340px;
  629. position: relative;
  630. img{
  631. width: 100%;
  632. margin-top: 12px;
  633. }
  634. .arrow-icon {
  635. top: -32px;
  636. left: 50%;
  637. position: absolute;
  638. background: #fff;
  639. width: 16px;
  640. height: 80px;
  641. line-height: 80px;
  642. border-radius: 5px 0 0 5px;
  643. text-align: center;
  644. transform: translateX(-50%) rotate(270deg);
  645. }
  646. .edit-btn {
  647. padding: 2px 24px;
  648. background: #FFD489;
  649. border-radius: 4px;
  650. color: #000;
  651. }
  652. }
  653. }
  654. .legend{
  655. position: fixed;
  656. bottom: 8px;
  657. right: 64px;
  658. width: 525px;
  659. height: 16px;
  660. }
  661. }
  662. }
  663. .bottom-map {
  664. width: 100%;
  665. height: 100vh;
  666. position: absolute;
  667. z-index: 0;
  668. }
  669. </style>