index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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. })
  149. }
  150. const btnIndex = ref(null)
  151. const btnName = ref("")
  152. const handleBtn = (e) =>{
  153. btnName.value = ""
  154. btnIndex.value = e
  155. eventBus.emit("clear:area")
  156. samplePointLayer.updateAreaStatus(e===0?true:false)
  157. regionLayer.resetData()
  158. samplePointLayer.resetPoint()
  159. }
  160. //点击果园日志
  161. const handleSelectArea = () =>{
  162. btnName.value = ""
  163. btnIndex.value = null
  164. eventBus.emit("clear:area")
  165. regionLayer.resetData()
  166. samplePointLayer.resetPoint()
  167. samplePointLayer.updateAreaStatus(true)
  168. }
  169. //农事点击高亮
  170. const act = ref(null)
  171. const handleAct = (v) =>{
  172. act.value = v
  173. samplePointLayer.resetPoint()
  174. if(v===1){
  175. regionLayer.selectAreaMultiple([
  176. {value:2,color:"blue"},
  177. {value:4,color:"blue1"},
  178. {value:5,color:"blue2"},
  179. {value:7,color:"blue"},
  180. {value:13,color:"blue2"},
  181. ])
  182. }
  183. if(v===2){
  184. regionLayer.selectAreaMultiple([
  185. {value:1,color:"blue"},
  186. {value:2,color:"blue1"},
  187. {value:9,color:"blue2"},
  188. {value:12,color:"blue2"},
  189. ])
  190. }
  191. }
  192. //柱状图点击事件监听
  193. eventBus.on('echart:barClick',(e)=>{
  194. btnName.value = ""
  195. btnIndex.value = null
  196. eventBus.emit("clear:area")
  197. samplePointLayer.updateAreaStatus(false)
  198. const arr = ["花芽萌动", "毛毡病"]
  199. const isDraw = arr.includes(e)
  200. const index = arr.indexOf(e)
  201. if(isDraw){
  202. if(index===0){
  203. regionLayer.selectAreaMultiple([
  204. {value:1,color:"green"},
  205. {value:3,color:"green1"},
  206. {value:5,color:"green2"},
  207. {value:6,color:"green1"},
  208. {value:9,color:"green"},
  209. {value:11,color:"green1"},
  210. {value:12,color:"green2"},
  211. {value:0,color:"green"},
  212. ])
  213. }else{
  214. regionLayer.selectAreaMultiple([{value:8,color:"red"}])
  215. }
  216. }
  217. })
  218. //黄板点击事件监听
  219. eventBus.on('click:yellowBlock',()=>{
  220. eventBus.emit('dialog:show',true)
  221. })
  222. const showPoint = ref(true)
  223. const showType = ref("point")
  224. //地图点击事件
  225. eventBus.on('click:point',(e)=>{
  226. showType.value = "point"
  227. if(btnIndex.value===1){
  228. btnName.value=e.name
  229. if(e.value===1){
  230. showPoint.value = true
  231. samplePointLayer.updatePointStatus(true)
  232. }else{
  233. showPoint.value = false
  234. }
  235. }
  236. })
  237. //地图点击区域事件
  238. eventBus.on('click:area',(e)=>{
  239. showType.value = "area"
  240. if(btnIndex.value===0){
  241. btnName.value=e.name
  242. if(e.value===1){
  243. showPoint.value = true
  244. }else{
  245. showPoint.value = false
  246. }
  247. regionLayer.selectArea((e.name*1)===0?0: (e.name*1) - 1,"blue")
  248. }
  249. })
  250. eventBus.on('click:updateArea',(e)=>{
  251. btnName.value=e.name
  252. regionLayer.selectArea((e.name*1)===0?0: (e.name*1) - 1,"blue")
  253. })
  254. const currentComponent = ref("homePage");
  255. const handleActiveLeft = (e) => {
  256. currentComponent.value = e.componentName;
  257. };
  258. const leftToolList = [
  259. {
  260. title: "首页",
  261. name: "home",
  262. componentName: "homePage",
  263. },
  264. {
  265. title: "气象预警",
  266. componentName: "weatherPage",
  267. },
  268. {
  269. title: "物候调节",
  270. componentName: "phenologyPage",
  271. },
  272. {
  273. title: "病虫测报",
  274. },
  275. {
  276. title: "营养评估",
  277. },
  278. ];
  279. const rightIndex = ref(0)
  280. const handleActiveRight = ({index}) => {
  281. rightIndex.value = index
  282. btnIndex.value = null
  283. btnName.value = ""
  284. samplePointLayer.updateAreaStatus(false)
  285. regionLayer.resetData()
  286. samplePointLayer.resetPoint()
  287. if(index!==0){
  288. act.value = null
  289. }
  290. };
  291. const hanleRightIndex = (num) =>{
  292. rightIndex.value = num
  293. eventBus.emit('tool:updateAct',num)
  294. }
  295. const rightToolList = [
  296. {
  297. title: "农事列表",
  298. index:0,
  299. },
  300. {
  301. title: "处方分析",
  302. index:2,
  303. },
  304. {
  305. title: "复核对比",
  306. index:1,
  307. },
  308. ];
  309. // 跳转果园档案
  310. const toFilePage = () => {
  311. router.push('/garden-file')
  312. }
  313. </script>
  314. <style lang="scss" scoped>
  315. .base-container {
  316. width: 100%;
  317. height: 100vh;
  318. color: #fff;
  319. position: absolute;
  320. box-sizing: border-box;
  321. z-index: 1;
  322. .content {
  323. width: 100%;
  324. height: calc(100% - 74px - 48px);
  325. display: flex;
  326. justify-content: space-between;
  327. box-sizing: border-box;
  328. .left,
  329. .right {
  330. width: calc(376px + 54px);
  331. height: 100%;
  332. padding-top: 10px;
  333. box-sizing: border-box;
  334. display: flex;
  335. }
  336. .right {
  337. .list {
  338. width: 100%;
  339. height: 100%;
  340. .btn-wrap{
  341. width: 100%;
  342. height: 25px;
  343. line-height: 25px;
  344. margin: 10px 0;
  345. display: flex;
  346. align-items: center;
  347. justify-content: space-between;
  348. div{
  349. width: 48%;
  350. height: 100%;
  351. color: #FFD489;
  352. border: 1px solid rgba(255,213,137,0.6);
  353. border-radius: 2px;
  354. text-align: center;
  355. font-size: 12px;
  356. cursor: pointer;
  357. &.active{
  358. background: #FFD489;
  359. color: #000;
  360. }
  361. }
  362. }
  363. .img-box{
  364. width: 100%;
  365. height: calc(100% - 35px);
  366. overflow: auto;
  367. }
  368. .img-box1{
  369. width: 100%;
  370. height: calc(100% - 10px);
  371. overflow: auto;
  372. margin-top: 10px;
  373. }
  374. .img-box2{
  375. width: 100%;
  376. height: calc(100% - 45px);
  377. overflow: auto;
  378. margin-top: 10px;
  379. }
  380. img{
  381. width: 100%;
  382. height: auto;
  383. object-fit: cover;
  384. margin-bottom: 12px;
  385. cursor: pointer;
  386. }
  387. .mt{
  388. margin-top: -12px;
  389. }
  390. }
  391. }
  392. .overflow{
  393. overflow: auto;
  394. }
  395. .home-bottom {
  396. display: flex;
  397. align-items: flex-end;
  398. width: calc(100% - 430px - 430px - 72px);
  399. height: 100%;
  400. align-self: flex-end;
  401. .log-box {
  402. height: 34%;
  403. width: calc(100% - 340px - 28px);
  404. margin-right: 28px;
  405. .box-name{
  406. width: 89px;
  407. height: 22px;
  408. text-align: center;
  409. line-height: 22px;
  410. border-radius: 20px;
  411. margin: 10px 0 5px 6px;
  412. cursor: pointer;
  413. background: linear-gradient(0deg,#BBA269 0%, #3D3523 100%);
  414. }
  415. .log-content {
  416. font-size: 12px;
  417. line-height: 1.5;
  418. padding: 0 18px;
  419. }
  420. .chart-wrap{
  421. width: 100%;
  422. height: calc(100% - 50px);
  423. .line{
  424. margin-top: 10px;
  425. margin-bottom: 12px;
  426. }
  427. img{
  428. width: 100%;
  429. margin-bottom: 10px;
  430. }
  431. }
  432. }
  433. .file-box {
  434. height: 25%;
  435. min-height: 210px;
  436. width: 340px;
  437. position: relative;
  438. img{
  439. width: 100%;
  440. margin-top: 12px;
  441. }
  442. .arrow-icon {
  443. top: -32px;
  444. left: 50%;
  445. position: absolute;
  446. background: #fff;
  447. width: 16px;
  448. height: 80px;
  449. line-height: 80px;
  450. border-radius: 5px 0 0 5px;
  451. text-align: center;
  452. transform: translateX(-50%) rotate(270deg);
  453. }
  454. .edit-btn {
  455. padding: 2px 24px;
  456. background: #FFD489;
  457. border-radius: 4px;
  458. color: #000;
  459. }
  460. }
  461. }
  462. .legend{
  463. position: fixed;
  464. bottom: 8px;
  465. right: 64px;
  466. width: 525px;
  467. height: 16px;
  468. }
  469. }
  470. }
  471. .bottom-map {
  472. width: 100%;
  473. height: 100vh;
  474. position: absolute;
  475. z-index: 0;
  476. }
  477. </style>