subsurfaceLeakageInputFlux.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div class="agricultural-input-management">
  3. <div class="page-container">
  4. <el-card class="results-card">
  5. <div class="results-content">
  6. <!-- 地图区域 -->
  7. <div class="map-section">
  8. <h3>地下渗漏Cd通量分布图</h3>
  9. <div v-if="isLoading" class="loading-container">
  10. <el-icon class="loading-icon"><Loading /></el-icon>
  11. <span>数据加载中...</span>
  12. </div>
  13. <div v-else-if="isError" class="error-container">
  14. <el-icon class="error-icon"><Warning /></el-icon>
  15. <span>{{ errorMessage }}</span>
  16. <el-button class="retry-btn" @click="fetchMap">
  17. <el-icon><Refresh /></el-icon> 重新加载
  18. </el-button>
  19. </div>
  20. <div v-else class="image-container">
  21. <img :src="mapImageUrl" class="result-image"></img>
  22. </div>
  23. </div>
  24. </div>
  25. </el-card>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import { ElButton, ElCard, ElIcon } from 'element-plus';
  31. import { Loading, Warning, Picture, Refresh } from '@element-plus/icons-vue';
  32. import { api8000 } from '@/utils/request';
  33. export default {
  34. name: 'LeakageFluxMap',
  35. components: {
  36. ElButton,
  37. ElCard,
  38. ElIcon,
  39. Loading,
  40. Warning,
  41. Picture,
  42. Refresh
  43. },
  44. data() {
  45. return {
  46. mapImageUrl: null,
  47. isLoading: true,
  48. isError: false,
  49. errorMessage: '',
  50. area: '乐昌市',
  51. level: 'county',
  52. colormap: 'blues',
  53. };
  54. },
  55. mounted() {
  56. this.fetchMap();
  57. },
  58. methods: {
  59. async fetchMap() {
  60. this.isLoading = true;
  61. this.isError = false;
  62. try {
  63. const response = await api8000.get(
  64. `/api/cd-flux-removal/groundwater_leaching/latest-map/乐昌市`,
  65. {
  66. params: {
  67. area: this.area,
  68. level: this.level,
  69. colormap: this.colormap
  70. },
  71. responseType: 'blob'
  72. }
  73. );
  74. const blob = new Blob([response.data], { type: response.headers['content-type'] });
  75. this.mapImageUrl = URL.createObjectURL(blob);
  76. } catch (error) {
  77. console.error('加载地图失败:', error);
  78. this.isError = true;
  79. this.errorMessage = '地图加载失败,请稍后重试';
  80. } finally {
  81. this.isLoading = false;
  82. }
  83. },
  84. handleImageLoad() {
  85. console.log('地图图片加载完成');
  86. }
  87. }
  88. };
  89. </script>
  90. <style scoped>
  91. .page-container {
  92. width: 100%;
  93. height: 100%;
  94. }
  95. /* 结果卡片样式 */
  96. .results-card {
  97. background-color: rgba(255, 255, 255, 0.8);
  98. border-radius: 8px;
  99. padding: 20px;
  100. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  101. backdrop-filter: blur(5px);
  102. height: 100%;
  103. box-sizing: border-box;
  104. }
  105. .results-content {
  106. height: 100%;
  107. display: flex;
  108. flex-direction: column;
  109. }
  110. .map-section {
  111. background-color: rgba(255, 255, 255, 0.8);
  112. border-radius: 8px;
  113. padding: 20px;
  114. margin-bottom: 20px;
  115. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  116. }
  117. h3 {
  118. margin-bottom: 15px;
  119. color: #333;
  120. font-size: 18px;
  121. font-weight: 600;
  122. }
  123. /* 图片容器限定大小 */
  124. .image-container {
  125. width: 100%;
  126. height: 500px;
  127. display: flex;
  128. justify-content: center;
  129. align-items: center;
  130. background-color: #f9f9f9;
  131. border-radius: 8px;
  132. overflow: hidden;
  133. }
  134. .result-image {
  135. max-width: 100%;
  136. max-height: 100%;
  137. object-fit: contain;
  138. transition: transform 0.3s ease;
  139. }
  140. .result-image:hover {
  141. transform: scale(1.02);
  142. }
  143. /* 加载和错误状态 */
  144. .loading-container, .error-container {
  145. display: flex;
  146. flex-direction: column;
  147. align-items: center;
  148. justify-content: center;
  149. height: 300px;
  150. gap: 15px;
  151. }
  152. .loading-container {
  153. color: #47C3B9;
  154. }
  155. .error-container {
  156. color: #F56C6C;
  157. }
  158. .loading-icon {
  159. font-size: 36px;
  160. margin-bottom: 10px;
  161. animation: rotate 2s linear infinite;
  162. }
  163. .error-icon {
  164. font-size: 36px;
  165. margin-bottom: 10px;
  166. }
  167. .retry-btn {
  168. margin-top: 15px;
  169. }
  170. .no-data {
  171. display: flex;
  172. flex-direction: column;
  173. align-items: center;
  174. justify-content: center;
  175. height: 300px;
  176. color: #999;
  177. font-size: 16px;
  178. }
  179. .no-data .el-icon {
  180. font-size: 48px;
  181. margin-bottom: 10px;
  182. }
  183. @keyframes rotate {
  184. from { transform: rotate(0deg); }
  185. to { transform: rotate(360deg); }
  186. }
  187. /* 响应式设计 */
  188. @media (max-width: 768px) {
  189. .image-container {
  190. height: 400px;
  191. }
  192. }
  193. @media (max-width: 480px) {
  194. .agricultural-input-management {
  195. padding: 10px;
  196. }
  197. .image-container {
  198. height: 300px;
  199. }
  200. }
  201. </style>