homePage.vue 16 KB

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