homePage.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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, isFile }) => {
  162. if (index === -1) return;
  163. if (isFile) return
  164. curIndex.value = index;
  165. if (key === "物候指标") {
  166. phenologyObj.value = handleData("物候指标");
  167. }
  168. if (key === "病虫指标") {
  169. diseasesObj.value = handleData("病虫指标");
  170. }
  171. if (key === "生长指标") {
  172. growObj.value = handleData("生长指标");
  173. }
  174. if (key === "生态指标") {
  175. ecologyObj.value = handleData("生态指标");
  176. }
  177. };
  178. const menuList = ref([]);
  179. function handleData(name, isChange = true) {
  180. console.log('handleData', name);
  181. const arr = reportData.value.filter((item) => item.key === name);
  182. const source = arr[0].obj;
  183. let nameArr = [];
  184. let valueArr = [];
  185. const statItem = source.geoHashSampleStat[curIndex.value];
  186. nameArr = source.legendList.find((legendSubItem) => legendSubItem.key === statItem.key);
  187. valueArr = nameArr.list.map((legendSubItem) => statItem.obj[legendSubItem.val] || 0);
  188. const obj = {
  189. // btnGroup: source.titleList,
  190. btnGroup: source.geoHashSampleStat.map((item) => item.key),
  191. xData: nameArr.list.map((item) => item.name),
  192. yData: valueArr,
  193. text: [source.list2[curIndex.value]],
  194. content: source.text,
  195. };
  196. menuList.value.push({
  197. name,
  198. btnGroup: source.geoHashSampleStat.map((item) => item.key),
  199. legend: source.geoHashSampleList.find((sample) => sample.key === statItem.key),
  200. colorObj: nameArr
  201. });
  202. if (isChange) {
  203. eventBus.emit("changePointType", {legend: source.geoHashSampleList.find((sample) => sample.key === statItem.key), colorObj: nameArr})
  204. eventBus.emit("changePointLegend", {legend: source.geoHashSampleList.find((sample) => sample.key === statItem.key), colorObj: nameArr})
  205. console.log(' menuList.value', menuList.value);
  206. }
  207. return obj;
  208. }
  209. function areaId({ areaId, farmId }) {
  210. menuList.value = []
  211. getReoprt(areaId, farmId);
  212. getBaseData();
  213. }
  214. const getReoprt = (areaId, farmId) => {
  215. VE_API.home.farmIndexReport({ farmId, regionId: areaId }).then((res) => {
  216. reportData.value = res.data || [];
  217. // phenologyObj.value = handleData("物候指标");
  218. diseasesObj.value = handleData("病虫指标", false);
  219. growObj.value = handleData("生长指标", false);
  220. ecologyObj.value = handleData("生态指标", false);
  221. store.commit("home/SET_MAIN_MENU", menuList.value);
  222. console.log('commitcommitcommit', menuList.value);
  223. });
  224. };
  225. const handlePage = () => {
  226. router.push("/variety_map");
  227. };
  228. const activeKey = ref("");
  229. function handleTabItem(e) {
  230. activeKey.value = e;
  231. }
  232. //基本指标
  233. const btnGroup = ["树高", "冠幅"];
  234. // 物候指标
  235. const phenologyObj = ref({});
  236. // 病虫测报
  237. const diseasesObj = ref({});
  238. const phenologyYData1 = [
  239. {
  240. startNum: 0,
  241. endNum: 0,
  242. startColor: "#c6ab6b",
  243. endColor: "#4e442e",
  244. },
  245. ];
  246. // 生长指标
  247. const growObj = ref({});
  248. //生态指标
  249. const ecologyObj = ref({});
  250. const gybg = () => {
  251. VE_API.farm_files.last({ farmId: 766, key: "pdf_report" }).then(({ data }) => {
  252. eventBus.emit("homePage:gybg", { filename: data.path, title: "果园报告" });
  253. });
  254. };
  255. </script>
  256. <style lang="scss" scoped>
  257. .chart-list {
  258. width: calc(100% - 54px - 10px);
  259. height: 100%;
  260. padding: 8px 8px 8px 0;
  261. box-sizing: border-box;
  262. position: relative;
  263. overflow-y: auto;
  264. .chart-item {
  265. width: 100%;
  266. // height: calc(100% / 4.15);
  267. height: 228px;
  268. box-sizing: border-box;
  269. margin-bottom: 10px;
  270. &.weather-item {
  271. height: 260px;
  272. }
  273. .box-flex {
  274. width: 100%;
  275. height: 100%;
  276. display: flex;
  277. align-items: center;
  278. justify-content: center;
  279. .box-card {
  280. background: rgba(255, 255, 255, 0.1);
  281. border-radius: 5px;
  282. width: 292px;
  283. height: 92px;
  284. display: flex;
  285. align-items: center;
  286. justify-content: center;
  287. flex-direction: column;
  288. .box-desc {
  289. font-size: 16px;
  290. font-family: "PangMenZhengDao";
  291. margin-bottom: 8px;
  292. }
  293. .box-button {
  294. font-size: 13px;
  295. border-radius: 20px;
  296. padding: 3px 27px;
  297. cursor: pointer;
  298. border: 1px solid rgba(255, 255, 255, 0.45);
  299. background: linear-gradient(180deg, #ffd887, #ed9e1e);
  300. }
  301. }
  302. }
  303. .button {
  304. border: 1px solid rgba(255, 255, 255, 0.4);
  305. border-radius: 4px;
  306. padding: 2px 10px;
  307. cursor: pointer;
  308. }
  309. &.chart-item:last-child {
  310. margin: 0;
  311. }
  312. .base-wrap {
  313. width: 100%;
  314. height: 56px;
  315. margin-top: 4px;
  316. display: flex;
  317. justify-content: space-evenly;
  318. .base-item {
  319. width: 110px;
  320. height: 100%;
  321. font-size: 12px;
  322. text-align: center;
  323. box-sizing: border-box;
  324. color: #f3c11d;
  325. display: flex;
  326. flex-direction: column;
  327. align-items: center;
  328. margin: 0 12px;
  329. background: url("@/assets/images/home/scale-bg.png") no-repeat center center / 100% 100%;
  330. .label {
  331. width: 85px;
  332. height: 16px;
  333. line-height: 16px;
  334. color: #fff;
  335. background: url("@/assets/images/home/label-bg.png") no-repeat center center / 100% 100%;
  336. }
  337. .value {
  338. font-size: 18px;
  339. font-family: "PangMenZhengDao";
  340. span {
  341. font-size: 12px;
  342. }
  343. }
  344. }
  345. }
  346. .line-chart {
  347. height: calc(100% - 56px);
  348. }
  349. .box-bg {
  350. border-radius: 2px 2px 0 0;
  351. font-size: 12px;
  352. padding: 3px 6px;
  353. box-sizing: border-box;
  354. font-family: Arial, Helvetica, sans-serif;
  355. overflow-y: auto;
  356. background: linear-gradient(180deg, rgb(85, 85, 85, 0.4) 0%, rgb(35, 35, 35, 1) 100%);
  357. .text {
  358. position: relative;
  359. padding-left: 10px;
  360. &::before {
  361. content: "";
  362. position: absolute;
  363. left: 0;
  364. top: 8px;
  365. width: 3px;
  366. height: 3px;
  367. border-radius: 50%;
  368. background: #fff;
  369. }
  370. span {
  371. color: rgba(255, 255, 255, 0.4);
  372. line-height: 1.7;
  373. }
  374. }
  375. }
  376. &.phenology {
  377. .bar-chart {
  378. width: 100%;
  379. height: calc(100% - 75px);
  380. }
  381. .tips {
  382. margin-top: 10px;
  383. width: 100%;
  384. height: 65px;
  385. }
  386. }
  387. &.evaluate {
  388. height: 220px;
  389. .content {
  390. width: 100%;
  391. height: calc(100% - 10px);
  392. display: flex;
  393. align-items: center;
  394. justify-content: space-between;
  395. margin-top: 10px;
  396. .text {
  397. font-weight: 400;
  398. padding: 8px 0 4px 5px;
  399. text-indent: 2em;
  400. margin-left: 8px;
  401. span {
  402. color: #ffd489;
  403. }
  404. }
  405. }
  406. .text-list {
  407. width: 100%;
  408. height: 33px;
  409. display: flex;
  410. align-items: flex-start;
  411. justify-content: space-between;
  412. .text-item {
  413. display: flex;
  414. align-items: center;
  415. .circle {
  416. width: 4px;
  417. height: 4px;
  418. background: rgba(255, 255, 255, 0.44);
  419. border-radius: 50%;
  420. margin-right: 6px;
  421. }
  422. .txt {
  423. font-size: 12px;
  424. span {
  425. color: #ffd489;
  426. }
  427. }
  428. }
  429. }
  430. }
  431. }
  432. }
  433. </style>