homePage.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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. height: 228px;
  258. box-sizing: border-box;
  259. margin-bottom: 10px;
  260. .box-flex {
  261. width: 100%;
  262. height: 100%;
  263. display: flex;
  264. align-items: center;
  265. justify-content: center;
  266. .box-card {
  267. background: rgba(255, 255, 255, 0.1);
  268. border-radius: 5px;
  269. width: 292px;
  270. height: 92px;
  271. display: flex;
  272. align-items: center;
  273. justify-content: center;
  274. flex-direction: column;
  275. .box-desc {
  276. font-size: 16px;
  277. font-family: "PangMenZhengDao";
  278. margin-bottom: 8px;
  279. }
  280. .box-button {
  281. font-size: 13px;
  282. border-radius: 20px;
  283. padding: 3px 27px;
  284. cursor: pointer;
  285. border: 1px solid rgba(255, 255, 255, 0.45);
  286. background: linear-gradient(180deg, #ffd887, #ed9e1e);
  287. }
  288. }
  289. }
  290. .button {
  291. border: 1px solid rgba(255, 255, 255, 0.4);
  292. border-radius: 4px;
  293. padding: 2px 10px;
  294. cursor: pointer;
  295. }
  296. &.chart-item:last-child {
  297. margin: 0;
  298. }
  299. .base-wrap {
  300. width: 100%;
  301. height: 64px;
  302. margin-top: 4px;
  303. display: flex;
  304. justify-content: space-evenly;
  305. .base-item {
  306. width: 110px;
  307. height: 100%;
  308. font-size: 12px;
  309. text-align: center;
  310. box-sizing: border-box;
  311. color: #f3c11d;
  312. display: flex;
  313. flex-direction: column;
  314. align-items: center;
  315. margin: 0 12px;
  316. background: url("@/assets/images/home/scale-bg.png") no-repeat center center / 100% 100%;
  317. .label {
  318. width: 85px;
  319. height: 20px;
  320. line-height: 20px;
  321. color: #fff;
  322. background: url("@/assets/images/home/label-bg.png") no-repeat center center / 100% 100%;
  323. }
  324. .value {
  325. font-size: 19px;
  326. font-family: "PangMenZhengDao";
  327. span{
  328. font-size: 12px;
  329. }
  330. }
  331. }
  332. }
  333. .line-chart {
  334. height: calc(100% - 65px);
  335. }
  336. .box-bg {
  337. border-radius: 2px 2px 0 0;
  338. font-size: 12px;
  339. padding: 3px 6px;
  340. box-sizing: border-box;
  341. font-family: Arial, Helvetica, sans-serif;
  342. overflow-y: auto;
  343. background: linear-gradient(180deg, rgb(85, 85, 85, 0.4) 0%, rgb(35, 35, 35, 1) 100%);
  344. .text {
  345. position: relative;
  346. padding-left: 10px;
  347. &::before {
  348. content: "";
  349. position: absolute;
  350. left: 0;
  351. top: 8px;
  352. width: 3px;
  353. height: 3px;
  354. border-radius: 50%;
  355. background: #fff;
  356. }
  357. span {
  358. color: rgba(255, 255, 255, 0.4);
  359. line-height: 1.7;
  360. }
  361. }
  362. }
  363. &.phenology {
  364. .bar-chart {
  365. width: 100%;
  366. height: calc(100% - 75px);
  367. }
  368. .tips {
  369. margin-top: 10px;
  370. width: 100%;
  371. height: 65px;
  372. }
  373. }
  374. &.evaluate {
  375. .content {
  376. width: 100%;
  377. height: calc(100% - 10px - 33px);
  378. display: flex;
  379. align-items: center;
  380. justify-content: space-between;
  381. margin-bottom: 10px;
  382. .text {
  383. font-weight: 400;
  384. padding: 8px 0 4px 5px;
  385. text-indent: 2em;
  386. margin-left: 8px;
  387. span {
  388. color: #ffd489;
  389. }
  390. }
  391. }
  392. .text-list {
  393. width: 100%;
  394. height: 33px;
  395. display: flex;
  396. align-items: flex-start;
  397. justify-content: space-between;
  398. .text-item {
  399. display: flex;
  400. align-items: center;
  401. .circle {
  402. width: 4px;
  403. height: 4px;
  404. background: rgba(255, 255, 255, 0.44);
  405. border-radius: 50%;
  406. margin-right: 6px;
  407. }
  408. .txt {
  409. font-size: 12px;
  410. span {
  411. color: #ffd489;
  412. }
  413. }
  414. }
  415. }
  416. }
  417. }
  418. }
  419. </style>