index.vue 15 KB

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