index.vue 12 KB

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