homePage.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <template>
  2. <div class="chart-list">
  3. <div class="chart-item weather-item">
  4. <chart-box name="气象预警">
  5. <!-- <template #title-right>
  6. <div class="button" @click="gybg">果园报告</div>
  7. </template> -->
  8. <div class="base-wrap">
  9. <div class="base-item" v-for="(item, index) in baseData.labels" :key="index">
  10. <div class="label">{{ item }}风险</div>
  11. <div class="value">{{ baseData.valueMaxList[index].toFixed(0) }}<span>%</span></div>
  12. </div>
  13. </div>
  14. <!-- <one-line-chart class="line-chart" :yData="lineYdata" :minData="minData"></one-line-chart> -->
  15. <weatherChart class="line-chart"></weatherChart>
  16. </chart-box>
  17. </div>
  18. <!-- <div class="chart-item phenology">-->
  19. <!-- <chart-box name="基本指标">-->
  20. <!-- <template #title-right>-->
  21. <!-- <tabs :list="btnGroup"></tabs>-->
  22. <!-- </template>-->
  23. <!-- &lt;!&ndash; <bar-chart class="bar-chart" styleName="styleName3" :xData="phenologyXData" :yData="phenologyYData"></bar-chart>-->
  24. <!-- <div class="tips box-bg">-->
  25. <!-- <div class="text" v-for="item in 3" :key="item">-->
  26. <!-- 桂味:<span>占比30%,分布在2区、5区</span>-->
  27. <!-- </div>-->
  28. <!-- </div> &ndash;&gt;-->
  29. <!-- <div class="box-flex">-->
  30. <!-- <div class="box-card">-->
  31. <!-- <div class="box-desc">当前分区无品种信息,请确权</div>-->
  32. <!-- <div class="box-button" @click="handlePage">立即确权</div>-->
  33. <!-- </div>-->
  34. <!-- </div>-->
  35. <!-- </chart-box>-->
  36. <!-- </div>-->
  37. <!-- <div class="chart-item phenology">
  38. <chart-box name="物候指标">
  39. <template #title-right>
  40. <tabs :list="phenologyObj.btnGroup" keyStr="物候指标" :active="activeKey"></tabs>
  41. </template>
  42. <bar-chart
  43. class="bar-chart"
  44. styleName="styleName1"
  45. :xData="phenologyObj.xData"
  46. :yData="phenologyObj.yData"
  47. ></bar-chart>
  48. <div class="tips box-bg">
  49. <div class="text" v-for="(item, index) in phenologyObj.text" :key="index">
  50. {{ item[0] }}:<span>{{ item[1] }}{{ item[2] }},占比{{ item[3] }}%</span>
  51. </div>
  52. </div>
  53. </chart-box>
  54. </div> -->
  55. <div class="chart-item phenology">
  56. <chart-box name="生态指标">
  57. <template #title-right>
  58. <tabs :list="ecologyObj.btnGroup" keyStr="生态指标" :active="activeKey"></tabs>
  59. </template>
  60. <bar-chart
  61. class="bar-chart"
  62. styleName="styleName1"
  63. :xData="ecologyObj.xData"
  64. :yData="ecologyObj.yData"
  65. ></bar-chart>
  66. <div class="tips box-bg">
  67. <div class="text" v-for="(item, index) in ecologyObj.text" :key="index">
  68. {{ item.key }}:<span>{{ item.val }}</span>
  69. </div>
  70. </div>
  71. </chart-box>
  72. </div>
  73. <div class="chart-item evaluate">
  74. <chart-box name="生长指标">
  75. <template #title-right>
  76. <tabs :list="growObj.btnGroup" keyStr="生长指标" :active="activeKey"></tabs>
  77. </template>
  78. <div class="content">
  79. <bar-chart
  80. style="width: 52%"
  81. styleName="styleName1"
  82. :xData="growObj.xData"
  83. :yData="growObj.yData"
  84. ></bar-chart>
  85. <div class="box-bg text" v-for="(item, index) in growObj.text" :key="index">
  86. <div class="txt">
  87. {{ item.key }}:<span>{{ item.val }}</span>
  88. </div>
  89. </div>
  90. </div>
  91. <!-- <div class="text-list box-bg">
  92. <div class="text-item" v-for="(item, index) in growObj.text" :key="index">
  93. <div class="circle"></div>
  94. <div class="txt">
  95. {{ item.key }}:<span>{{ item.val }}</span>
  96. </div>
  97. </div>
  98. </div> -->
  99. </chart-box>
  100. </div>
  101. <div class="chart-item phenology">
  102. <chart-box name="病虫指标">
  103. <template #title-right>
  104. <tabs :list="diseasesObj.btnGroup" keyStr="病虫指标" :active="activeKey"></tabs>
  105. </template>
  106. <bar-chart
  107. class="bar-chart"
  108. styleName="styleName1"
  109. :xData="diseasesObj.xData"
  110. :yData="diseasesObj.yData"
  111. ></bar-chart>
  112. <div class="tips box-bg">
  113. <div class="text" v-for="(item, index) in diseasesObj.text" :key="index">
  114. {{ item.key }}:<span>{{ item.val }}</span>
  115. </div>
  116. </div>
  117. </chart-box>
  118. </div>
  119. </div>
  120. </template>
  121. <script setup>
  122. import { ref, onMounted, onUnmounted } from "vue";
  123. import chartBox from "@/components/chartBox.vue";
  124. import tabs from "./tabs.vue";
  125. import weatherChart from "./weatherChart.vue";
  126. import barChart from "@/components/charts/barChart.vue";
  127. import oneLineChart from "@/components/charts/oneLineChart.vue";
  128. import eventBus from "@/api/eventBus";
  129. import { useStore } from "vuex";
  130. import { useRouter } from "vue-router";
  131. const store = useStore();
  132. const router = useRouter();
  133. const baseData = ref({});
  134. const minData = ref([]);
  135. const lineYdata = ref([]);
  136. const getBaseData = () => {
  137. const point = sessionStorage.getItem("point");
  138. VE_API.mini_farm.weather_warning_land_check({ point }).then((res) => {
  139. baseData.value = res.data || {};
  140. });
  141. // 获取气象图表数据
  142. // VE_API.mini_farm.gardenItemChart({point}).then(res =>{
  143. // console.log('tq', res.data)
  144. // minData.value = res.data.weatherData.map(item =>item.tempMin)
  145. // lineYdata.value = res.data.weatherData.map(item =>item.tempMax)
  146. // })
  147. };
  148. onMounted(() => {
  149. //选项子项监听事件
  150. eventBus.on("handleTabItem", handleTabItem);
  151. eventBus.on("handleActive", handleActive);
  152. eventBus.on("area:id", areaId);
  153. });
  154. onUnmounted(() => {
  155. eventBus.off("handleTabItem", handleTabItem);
  156. eventBus.off("handleActive", handleActive);
  157. eventBus.off("area:id", areaId);
  158. });
  159. const reportData = ref([]);
  160. const curIndex = ref(0);
  161. const handleActive = ({ index, key }) => {
  162. if (index === -1) return;
  163. curIndex.value = index;
  164. if (key === "物候指标") {
  165. phenologyObj.value = handleData("物候指标");
  166. }
  167. if (key === "病虫指标") {
  168. diseasesObj.value = handleData("病虫指标");
  169. }
  170. if (key === "生长指标") {
  171. growObj.value = handleData("生长指标");
  172. }
  173. if (key === "生态指标") {
  174. ecologyObj.value = handleData("生态指标");
  175. }
  176. };
  177. const menuList = ref([]);
  178. function handleData(name, isChange = true) {
  179. console.log('handleData', name);
  180. const arr = reportData.value.filter((item) => item.key === name);
  181. const source = arr[0].obj;
  182. let nameArr = [];
  183. let valueArr = [];
  184. const statItem = source.geoHashSampleStat[curIndex.value];
  185. nameArr = source.legendList.find((legendSubItem) => legendSubItem.key === statItem.key);
  186. valueArr = nameArr.list.map((legendSubItem) => statItem.obj[legendSubItem.val] || 0);
  187. const obj = {
  188. // btnGroup: source.titleList,
  189. btnGroup: source.geoHashSampleStat.map((item) => item.key),
  190. xData: nameArr.list.map((item) => item.name),
  191. yData: valueArr,
  192. text: [source.list2[curIndex.value]],
  193. content: source.text,
  194. };
  195. menuList.value.push({
  196. name,
  197. btnGroup: source.geoHashSampleStat.map((item) => item.key),
  198. legend: source.geoHashSampleList.find((sample) => sample.key === statItem.key),
  199. colorObj: nameArr
  200. });
  201. if (isChange) {
  202. eventBus.emit("changePointType", {legend: source.geoHashSampleList.find((sample) => sample.key === statItem.key), colorObj: nameArr})
  203. eventBus.emit("changePointLegend", {legend: source.geoHashSampleList.find((sample) => sample.key === statItem.key), colorObj: nameArr})
  204. console.log(' menuList.value', menuList.value);
  205. }
  206. return obj;
  207. }
  208. function areaId({ areaId, farmId }) {
  209. menuList.value = []
  210. getReoprt(areaId, farmId);
  211. getBaseData();
  212. }
  213. const getReoprt = (areaId, farmId) => {
  214. VE_API.home.farmIndexReport({ farmId, regionId: areaId }).then((res) => {
  215. reportData.value = res.data || [];
  216. // phenologyObj.value = handleData("物候指标");
  217. diseasesObj.value = handleData("病虫指标", false);
  218. growObj.value = handleData("生长指标", false);
  219. ecologyObj.value = handleData("生态指标", false);
  220. store.commit("home/SET_MAIN_MENU", menuList.value);
  221. console.log('commitcommitcommit', menuList.value);
  222. });
  223. };
  224. const handlePage = () => {
  225. router.push("/variety_map");
  226. };
  227. const activeKey = ref("");
  228. function handleTabItem(e) {
  229. activeKey.value = e;
  230. }
  231. //基本指标
  232. const btnGroup = ["树高", "冠幅"];
  233. // 物候指标
  234. const phenologyObj = ref({});
  235. // 病虫测报
  236. const diseasesObj = ref({});
  237. const phenologyYData1 = [
  238. {
  239. startNum: 0,
  240. endNum: 0,
  241. startColor: "#c6ab6b",
  242. endColor: "#4e442e",
  243. },
  244. ];
  245. // 生长指标
  246. const growObj = ref({});
  247. //生态指标
  248. const ecologyObj = ref({});
  249. const gybg = () => {
  250. VE_API.farm_files.last({ farmId: 766, key: "pdf_report" }).then(({ data }) => {
  251. eventBus.emit("homePage:gybg", { filename: data.path, title: "果园报告" });
  252. });
  253. };
  254. </script>
  255. <style lang="scss" scoped>
  256. .chart-list {
  257. width: calc(100% - 54px - 10px);
  258. height: 100%;
  259. padding: 8px 8px 8px 0;
  260. box-sizing: border-box;
  261. position: relative;
  262. overflow-y: auto;
  263. .chart-item {
  264. width: 100%;
  265. // height: calc(100% / 4.15);
  266. height: 228px;
  267. box-sizing: border-box;
  268. margin-bottom: 10px;
  269. &.weather-item {
  270. height: 260px;
  271. }
  272. .box-flex {
  273. width: 100%;
  274. height: 100%;
  275. display: flex;
  276. align-items: center;
  277. justify-content: center;
  278. .box-card {
  279. background: rgba(255, 255, 255, 0.1);
  280. border-radius: 5px;
  281. width: 292px;
  282. height: 92px;
  283. display: flex;
  284. align-items: center;
  285. justify-content: center;
  286. flex-direction: column;
  287. .box-desc {
  288. font-size: 16px;
  289. font-family: "PangMenZhengDao";
  290. margin-bottom: 8px;
  291. }
  292. .box-button {
  293. font-size: 13px;
  294. border-radius: 20px;
  295. padding: 3px 27px;
  296. cursor: pointer;
  297. border: 1px solid rgba(255, 255, 255, 0.45);
  298. background: linear-gradient(180deg, #ffd887, #ed9e1e);
  299. }
  300. }
  301. }
  302. .button {
  303. border: 1px solid rgba(255, 255, 255, 0.4);
  304. border-radius: 4px;
  305. padding: 2px 10px;
  306. cursor: pointer;
  307. }
  308. &.chart-item:last-child {
  309. margin: 0;
  310. }
  311. .base-wrap {
  312. width: 100%;
  313. height: 56px;
  314. margin-top: 4px;
  315. display: flex;
  316. justify-content: space-evenly;
  317. .base-item {
  318. width: 110px;
  319. height: 100%;
  320. font-size: 12px;
  321. text-align: center;
  322. box-sizing: border-box;
  323. color: #f3c11d;
  324. display: flex;
  325. flex-direction: column;
  326. align-items: center;
  327. margin: 0 12px;
  328. background: url("@/assets/images/home/scale-bg.png") no-repeat center center / 100% 100%;
  329. .label {
  330. width: 85px;
  331. height: 16px;
  332. line-height: 16px;
  333. color: #fff;
  334. background: url("@/assets/images/home/label-bg.png") no-repeat center center / 100% 100%;
  335. }
  336. .value {
  337. font-size: 18px;
  338. font-family: "PangMenZhengDao";
  339. span {
  340. font-size: 12px;
  341. }
  342. }
  343. }
  344. }
  345. .line-chart {
  346. height: calc(100% - 56px);
  347. }
  348. .box-bg {
  349. border-radius: 2px 2px 0 0;
  350. font-size: 12px;
  351. padding: 3px 6px;
  352. box-sizing: border-box;
  353. font-family: Arial, Helvetica, sans-serif;
  354. overflow-y: auto;
  355. background: linear-gradient(180deg, rgb(85, 85, 85, 0.4) 0%, rgb(35, 35, 35, 1) 100%);
  356. .text {
  357. position: relative;
  358. padding-left: 10px;
  359. &::before {
  360. content: "";
  361. position: absolute;
  362. left: 0;
  363. top: 8px;
  364. width: 3px;
  365. height: 3px;
  366. border-radius: 50%;
  367. background: #fff;
  368. }
  369. span {
  370. color: rgba(255, 255, 255, 0.4);
  371. line-height: 1.7;
  372. }
  373. }
  374. }
  375. &.phenology {
  376. .bar-chart {
  377. width: 100%;
  378. height: calc(100% - 75px);
  379. }
  380. .tips {
  381. margin-top: 10px;
  382. width: 100%;
  383. height: 65px;
  384. }
  385. }
  386. &.evaluate {
  387. height: 220px;
  388. .content {
  389. width: 100%;
  390. height: calc(100% - 10px);
  391. display: flex;
  392. align-items: center;
  393. justify-content: space-between;
  394. margin-top: 10px;
  395. .text {
  396. font-weight: 400;
  397. padding: 8px 0 4px 5px;
  398. text-indent: 2em;
  399. margin-left: 8px;
  400. span {
  401. color: #ffd489;
  402. }
  403. }
  404. }
  405. .text-list {
  406. width: 100%;
  407. height: 33px;
  408. display: flex;
  409. align-items: flex-start;
  410. justify-content: space-between;
  411. .text-item {
  412. display: flex;
  413. align-items: center;
  414. .circle {
  415. width: 4px;
  416. height: 4px;
  417. background: rgba(255, 255, 255, 0.44);
  418. border-radius: 50%;
  419. margin-right: 6px;
  420. }
  421. .txt {
  422. font-size: 12px;
  423. span {
  424. color: #ffd489;
  425. }
  426. }
  427. }
  428. }
  429. }
  430. }
  431. }
  432. </style>