leftStation.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div class="chart-list">
  3. <div class="chart-item">
  4. <chart-box name="气温">
  5. <one-line-chart
  6. class="line-chart"
  7. key="tr"
  8. name="阴天寡照"
  9. :yData="[22, 20, 22, 30, 32, 22, 25]"
  10. :minData="[]"
  11. :chartDate="chartDate1"
  12. ></one-line-chart>
  13. <div class="box-bg tips">
  14. <div class="text">
  15. 这里是预警提示的内容,有点长,先用这些文字占位,后续开发会把内容不上的。这里是预警提示的内容,有点长,先用这些文字占位,后续开发会把内容不上的。
  16. </div>
  17. </div>
  18. </chart-box>
  19. </div>
  20. <div class="chart-item">
  21. <chart-box name="湿度">
  22. <one-line-chart
  23. class="line-chart"
  24. key="tr"
  25. name="阴天寡照"
  26. :yData="[22, 20, 22, 30, 32, 22, 25]"
  27. :minData="[]"
  28. :chartDate="chartDate1"
  29. ></one-line-chart>
  30. <div class="box-bg tips">
  31. <div class="text">
  32. 这里是预警提示的内容,有点长,先用这些文字占位,后续开发会把内容不上的。这里是预警提示的内容,有点长,先用这些文字占位,后续开发会把内容不上的。
  33. </div>
  34. </div>
  35. </chart-box>
  36. </div>
  37. <div class="chart-item">
  38. <chart-box name="水质">
  39. <one-line-chart
  40. class="line-chart"
  41. name="阴雨渍水"
  42. :key="1"
  43. :yData="[22, 20, 22, 30, 32, 22, 25]"
  44. :minData="[]"
  45. :chartDate="chartDate"
  46. ></one-line-chart>
  47. <div class="box-bg tips">
  48. <div class="text">
  49. 这里是预警提示的内容,有点长,先用这些文字占位,后续开发会把内容不上的。这里是预警提示的内容,有点长,先用这些文字占位,后续开发会把内容不上的。
  50. </div>
  51. </div>
  52. </chart-box>
  53. </div>
  54. </div>
  55. </template>
  56. <script setup>
  57. import chartBox from "@/components/chartBox.vue";
  58. import oneLineChart from "@/components/charts/oneLineChart.vue";
  59. import { onMounted, ref, onUnmounted } from "vue";
  60. import eventBus from "@/api/eventBus";
  61. import weatherChart from "../weatherChart.vue";
  62. const riskKeys = ref([]);
  63. const yData = ref([]);
  64. const yData1 = ref([]);
  65. const chartDate = ref([]);
  66. const chartDate1 = ref([]);
  67. const text = ref(null);
  68. const text1 = ref(null);
  69. const baseData = ref({});
  70. const organId = ref(sessionStorage.getItem("farmId"));
  71. onMounted(() => {
  72. // getList();
  73. // getBaseData()
  74. // eventBus.on("area:id", changeAreaId);
  75. });
  76. onUnmounted(() => {
  77. eventBus.off("area:id", changeAreaId);
  78. });
  79. function changeAreaId({ farmId }) {
  80. organId.value = farmId;
  81. getList();
  82. getBaseData();
  83. }
  84. function getList() {
  85. riskKeys.value = [];
  86. yData.value.value = [];
  87. yData1.value.value = [];
  88. chartDate.value.value = [];
  89. chartDate1.value.value = [];
  90. // VE_API.farm.getFarmReport({ farmId: organId.value, type: "气象风险" }).then((res) => {
  91. // // if (res.data["物候进程"]) {}
  92. // // 使用 Object.keys() 提取对象中的键
  93. // riskKeys.value = Object.keys(res.data);
  94. // yData.value = res.data[riskKeys.value[0]].list.map((item) => parseFloat(item.value.toFixed(1)))
  95. // yData1.value = res.data[riskKeys.value[1]].list.map((item) => parseFloat(item.value.toFixed(1)))
  96. // chartDate.value = formattedDates(res.data[riskKeys.value[0]].list.map((item) => item.name))
  97. // chartDate1.value = formattedDates(res.data[riskKeys.value[1]].list.map((item) => item.name))
  98. // text.value = res.data[riskKeys.value[0]].text
  99. // text1.value = res.data[riskKeys.value[1]].text
  100. // })
  101. }
  102. function formattedDates(dates) {
  103. return dates.map((date) => {
  104. const [year, month, day] = date.split("-");
  105. return `${month}-${day}`; // 使用模板字符串格式化为 MM/DD
  106. });
  107. }
  108. const getBaseData = () => {
  109. const point = sessionStorage.getItem("point");
  110. // 获取气象图表数据
  111. VE_API.mini_farm.weather_warning_land_check({ farmId: organId.value, point }).then((res) => {
  112. baseData.value = res.data || {};
  113. });
  114. };
  115. </script>
  116. <style lang="scss" scoped>
  117. .chart-list {
  118. width: calc(100% - 54px - 10px);
  119. height: 100%;
  120. overflow: auto;
  121. padding: 8px 8px 0 0;
  122. box-sizing: border-box;
  123. .chart-item {
  124. width: 100%;
  125. box-sizing: border-box;
  126. margin-bottom: 10px;
  127. height: calc((100% - 277px) / 2);
  128. .import {
  129. font-size: 12px;
  130. background: rgba(255, 255, 255, 0.2);
  131. border-radius: 4px;
  132. padding: 5px 13px;
  133. cursor: pointer;
  134. }
  135. .line-chart {
  136. width: 100%;
  137. height: calc(100% - 70px);
  138. }
  139. .box-bg {
  140. margin-top: 8px;
  141. border-radius: 2px 2px 0 0;
  142. font-size: 12px;
  143. padding: 3px 6px;
  144. box-sizing: border-box;
  145. font-family: Arial, Helvetica, sans-serif;
  146. overflow-y: auto;
  147. background: linear-gradient(180deg, rgb(85, 85, 85, 0.4) 0%, rgb(35, 35, 35, 1) 100%);
  148. .text {
  149. position: relative;
  150. span {
  151. color: rgba(255, 255, 255, 0.4);
  152. line-height: 1.7;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. </style>