index.vue 19 KB

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