homePage.vue 15 KB

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