index.vue 14 KB

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