homePage.vue 15 KB

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