Переглянути джерело

Merge branch 'master' of http://139.9.51.218:3000/qw/soilgd12 into lili

yes-yes-yes-k 3 тижнів тому
батько
коміт
9cc8ceb6ab

+ 1 - 1
index.html

@@ -4,7 +4,7 @@
     <meta charset="UTF-8">
     <link rel="icon" href="/logo.ico">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>区域土壤重金属评估</title>
+    <title>土壤酸化智能预测专家系统</title>
   </head>
   <body>
     <div id="app"></div>

+ 1 - 1
src/App.vue

@@ -1,10 +1,10 @@
 <script setup lang='ts'>
 import { RouterView } from "vue-router"
-
 </script>
 
 <template>
   <RouterView/>
+  <!-- <AgentDialog/> -->
 </template>
 
 <style scoped>

+ 6 - 0
src/components/layout/AppLayout.vue

@@ -229,6 +229,12 @@ const tabs = computed(() => {
         label: t('Menu.mapcalulate'),
         icon: "el-icon-data-analysis",
         routes: ["/shaoguan_acidmodelmap","nanxiong_acidmodelmap"],
+      },
+       {
+        name: "agentDialog",
+        label: "土壤酸化AI智能体",
+        icon: "el-icon-help-filled",
+        routes: ["/AgentDialog"],
       },
       {
         name: "Calculation",

+ 9 - 0
src/router/index.ts

@@ -115,6 +115,15 @@ const routes = [
           ),
         meta: { title: "土壤pH预测" }
       },
+      {
+        path: "AgentDialog",
+        name: "AgentDialog",
+        component: () =>
+          import(
+            "@/views/User/acidModel/AgentDialog.vue"
+          ),
+        meta: { title: "土壤酸化AI智能体" }
+      },
       {
         path: "SoilAcidificationData",
         name: "SoilAcidificationData",

+ 670 - 0
src/views/User/acidModel/AgentDialog.vue

@@ -0,0 +1,670 @@
+<template>
+  <el-card class="agent-dialog-card">
+    <div class="dialog-container">
+      <!-- 对话历史区域 -->
+      <div class="chat-history" ref="chatHistoryRef">
+        <div v-for="(message, index) in messages" :key="index"
+          :class="['message-item', message.role === 'user' ? 'user-message' : 'ai-message']">
+          <div class="message-avatar">
+            <el-avatar :size="40" :icon="message.role === 'user' ? 'el-icon-user' : 'el-icon-robot'" />
+          </div>
+          <div class="message-content">
+            <div class="message-bubble">
+              <div class="message-text" v-html="parseMarkdown(message.content)"></div>
+            </div>
+            <div class="message-time">{{ message.timestamp }}</div>
+          </div>
+        </div>
+
+        <!-- 加载状态 -->
+        <div v-if="loading" class="loading-item">
+          <div class="message-avatar">
+            <el-avatar size="40" icon="el-icon-robot" />
+          </div>
+          <div class="message-content">
+            <div class="message-bubble">
+              <div class="loading-spinner">
+                <el-icon class="is-loading"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
+                    <path fill="currentColor"
+                      d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768z">
+                    </path>
+                    <path fill="currentColor"
+                      d="M831.9 512a319.9 319.9 0 0 1-33.9 124.3l-73.6-36.8a256.4 256.4 0 0 0 27.2-99.5h-88.7v-64h149.3a320.3 320.3 0 0 1-20.3 64zm-14.5-128a319.9 319.9 0 0 1-31.4 120.9l-73.6-36.8a256.4 256.4 0 0 0 25.6-96.7H580.6v-64h156.8a320.1 320.1 0 0 1-19 64zm-118.8-128h-78.1v-97.9a256 256 0 0 0-170.6 0V256h-78.1a320 320 0 0 1 326.8-320z">
+                    </path>
+                  </svg></el-icon>
+              </div>
+              <div class="loading-text">思考中...</div>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <!-- 快速开始按钮区域 -->
+      <div class="quick-start-section">
+        <el-button type="info" @click="quickStartReflux">反酸计算</el-button>
+        <el-button type="success" @click="quickStartReduce">降酸计算</el-button>
+      </div>
+
+      <!-- 输入区域 -->
+      <div class="input-container">
+        <el-input v-model="inputMessage" type="textarea" :rows="2" placeholder="请输入您的问题..." resize="none"
+          @keyup.enter.exact="sendMessage" :disabled="loading" />
+
+        <!-- 文件上传区域 -->
+        <div class="file-upload-section" v-if="selectedFiles.length > 0">
+          <div class="file-list">
+            <div v-for="(file, index) in selectedFiles" :key="index" class="file-item">
+              <div class="file-info">
+                <span class="file-name">{{ file.name }}</span>
+              </div>
+              <el-button size="small" type="danger" @click="removeFile(index)">删除</el-button>
+            </div>
+          </div>
+        </div>
+
+        <div class="input-actions">
+          <input ref="fileInput" type="file" multiple accept="*/*" style="display: none" @change="handleFileSelect" />
+          <el-button type="secondary" @click="triggerFileUpload" :disabled="loading">
+            上传文件
+          </el-button>
+          <el-button type="primary" @click="sendMessage" :loading="loading"
+            :disabled="(!inputMessage.trim() && selectedFiles.length === 0) || loading">
+            发送
+          </el-button>
+          <el-button @click="clearMessages">清空</el-button>
+        </div>
+      </div>
+    </div>
+  </el-card>
+</template>
+
+<script setup lang="ts">
+import { ref, nextTick, onMounted } from 'vue';
+import { ElMessage } from 'element-plus';
+import { api5000 } from '@/utils/request';
+
+interface Message {
+  role: 'user' | 'assistant';
+  content: string;
+  timestamp: string;
+}
+
+const messages = ref<Message[]>([]);
+const inputMessage = ref('');
+const loading = ref(false);
+const chatHistoryRef = ref<HTMLElement | null>(null);
+const fileInput = ref<HTMLInputElement | null>(null);
+
+interface SelectedFile {
+  file: File;
+  preview: string;
+  name: string;
+  type: string;
+}
+
+const selectedFiles = ref<SelectedFile[]>([]);
+
+// 格式化时间
+const formatTime = (): string => {
+  const now = new Date();
+  return `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}`;
+};
+
+// 滚动到底部
+const scrollToBottom = () => {
+  nextTick(() => {
+    if (chatHistoryRef.value) {
+      chatHistoryRef.value.scrollTop = chatHistoryRef.value.scrollHeight;
+    }
+  });
+};
+
+// 发送消息
+const sendMessage = async () => {
+  const message = inputMessage.value.trim();
+  if ((!message && selectedFiles.value.length === 0) || loading.value) return;
+
+  // 构建用户消息内容
+  let userContent = message;
+  if (selectedFiles.value.length > 0) {
+    selectedFiles.value.forEach((file) => {
+      if (file.type.startsWith('image/')) {
+        userContent += `\n![${file.name}](data:${file.type};base64,${file.preview.split(',')[1]})`;
+      } else {
+        userContent += `\n[${file.name}](file:///${file.name})`;
+      }
+    });
+  }
+
+  // 添加用户消息
+  messages.value.push({
+    role: 'user',
+    content: userContent,
+    timestamp: formatTime(),
+  });
+  inputMessage.value = '';
+  scrollToBottom();
+
+  // 显示加载状态
+  loading.value = true;
+
+  try {
+    // 构建FormData
+    const formData = new FormData();
+    formData.append('input', message);
+
+    // 添加文件
+    selectedFiles.value.forEach((file) => {
+      formData.append('files', file.file);
+    });
+
+    // 调用API
+    const response = await api5000.post('/agent/langchain', formData, {
+      headers: {
+        'Content-Type': 'multipart/form-data'
+      }
+    });
+
+    // 隐藏加载状态
+    loading.value = false;
+
+    // 清空选中的文件
+    selectedFiles.value = [];
+
+    // 处理响应
+    if (response.data && response.data.response) {
+      messages.value.push({
+        role: 'assistant',
+        content: response.data.response,
+        timestamp: formatTime(),
+      });
+    } else {
+      messages.value.push({
+        role: 'assistant',
+        content: '抱歉,我无法理解您的问题,请尝试换一种方式提问。',
+        timestamp: formatTime(),
+      });
+    }
+  } catch (error) {
+    console.error('API调用失败:', error);
+    loading.value = false;
+    ElMessage.error('网络错误,请稍后重试');
+    messages.value.push({
+      role: 'assistant',
+      content: '抱歉,网络连接失败,请稍后重试。',
+      timestamp: formatTime(),
+    });
+  } finally {
+    scrollToBottom();
+  }
+};
+
+// 清空消息
+const clearMessages = () => {
+  messages.value = [];
+};
+
+// 触发文件选择
+const triggerFileUpload = () => {
+  fileInput.value?.click();
+};
+
+// 处理文件选择
+const handleFileSelect = (event: Event) => {
+  const target = event.target as HTMLInputElement;
+  const files = target.files;
+  if (!files || files.length === 0) return;
+
+  for (let i = 0; i < files.length; i++) {
+    const file = files[i];
+    const selectedFile: SelectedFile = {
+      file,
+      preview: '',
+      name: file.name,
+      type: file.type
+    };
+
+    // 为图片生成预览
+    if (file.type.startsWith('image/')) {
+      const reader = new FileReader();
+      reader.onload = (e) => {
+        selectedFile.preview = e.target?.result as string;
+      };
+      reader.readAsDataURL(file);
+    } else {
+      // 非图片文件使用默认预览
+      selectedFile.preview = '';
+    }
+
+    selectedFiles.value.push(selectedFile);
+  }
+
+  // 清空文件输入,以便可以重复选择同一个文件
+  target.value = '';
+};
+
+// 删除文件
+const removeFile = (index: number) => {
+  selectedFiles.value.splice(index, 1);
+};
+
+// 解析Markdown格式
+const parseMarkdown = (text: string): string => {
+  let parsedText = text;
+  
+  // 处理换行
+  parsedText = parsedText.replace(/\n/g, '<br>');
+  
+  // 处理Markdown格式,使用递归方法确保正确处理嵌套
+  // 1. 首先处理加粗格式 **文本**
+  parsedText = parsedText.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
+  
+  // 2. 然后处理斜体格式 *文本*
+  // 使用非贪婪匹配,确保正确处理混合格式
+  parsedText = parsedText.replace(/\*(.*?)\*/g, (content) => {
+    // 递归处理内容中的Markdown格式
+    return `<em>${content.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')}</em>`;
+  });
+  
+  return parsedText;
+};
+
+// 快速开始反酸计算
+const quickStartReflux = () => {
+  // 生成符合反酸模型要求的自然语言输入
+  inputMessage.value = `我想预测一下土壤的反酸情况,目前土壤的氢离子浓度是0.5 cmol/kg,铝离子浓度是0.3 cmol/kg,有机质含量20.0 g/kg,硝态氮20.0 mg/kg,铵态氮10.0 mg/kg,阳离子交换量6.0 cmol/kg。请帮我分析一下未来可能的酸化趋势。`;
+};
+
+// 快速开始降酸计算
+const quickStartReduce = () => {
+  // 生成符合降酸模型要求的自然语言输入
+  inputMessage.value = `我的土壤现在pH值是5.0,想提高到6.5,土壤的氢离子浓度是0.5 cmol/kg,铝离子浓度是0.3 cmol/kg,有机质含量20.0 g/kg,硝态氮20.0 mg/kg,铵态氮10.0 mg/kg,阳离子交换量6.0 cmol/kg。请问需要施加多少生石灰?`;
+};
+
+// 初始化欢迎消息
+const initWelcomeMessage = () => {
+  messages.value.push({
+    role: 'assistant',
+    content: '你好!我是酸化模型助手,有什么可以帮助你的吗?',
+    timestamp: formatTime(),
+  });
+};
+
+onMounted(() => {
+  initWelcomeMessage();
+  scrollToBottom();
+});
+</script>
+
+<style scoped>
+/* 整体容器样式 */
+.agent-dialog-card {
+  width: 100%;
+  max-width: 100%;
+  margin: 0 auto;
+  background-color: #ffffff;
+  border-radius: 16px;
+  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
+  overflow: hidden;
+}
+
+/* 头部样式 */
+.card-header {
+  font-size: 18px;
+  font-weight: 600;
+  text-align: center;
+  color: #333333;
+  padding: 20px;
+  background-color: #fafafa;
+  border-bottom: 1px solid #f0f0f0;
+}
+
+/* 对话容器 */
+.dialog-container {
+  display: flex;
+  flex-direction: column;
+  gap: 16px;
+  min-height: 600px;
+  height: calc(100vh - 160px);
+  padding: 20px;
+}
+
+/* 快速开始按钮区域 */
+.quick-start-section {
+  display: flex;
+  gap: 12px;
+  justify-content: flex-start;
+  padding: 16px;
+  background-color: #ffffff;
+  border-radius: 12px;
+  border: 1px solid #f0f0f0;
+}
+
+/* 快速开始按钮样式 */
+.quick-start-section .el-button {
+  border-radius: 8px;
+  border: 1px solid #d9d9d9;
+  background-color: transparent;
+  color: #333333;
+  padding: 8px 16px;
+  transition: all 0.3s ease;
+}
+
+.quick-start-section .el-button:hover {
+  border-color: #1976d2;
+  color: #1976d2;
+  background-color: rgba(25, 118, 210, 0.04);
+}
+
+/* 聊天历史区域 */
+.chat-history {
+  flex: 1;
+  min-height: 300px;
+  max-height: calc(100vh - 300px);
+  overflow-y: auto;
+  padding: 0;
+  background-color: #ffffff;
+  border-radius: 12px;
+  scroll-behavior: smooth;
+  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
+}
+
+/* 消息项样式 */
+.message-item {
+  display: flex;
+  margin-bottom: 24px;
+  animation: fadeIn 0.3s ease;
+}
+
+.user-message {
+  flex-direction: row-reverse;
+}
+
+/* 头像样式 */
+.message-avatar {
+  margin: 0 12px;
+  flex-shrink: 0;
+}
+
+/* 消息内容样式 */
+.message-content {
+  flex: 1;
+  max-width: 70%;
+  display: flex;
+  flex-direction: column;
+}
+
+.user-message .message-content {
+  align-items: flex-end;
+}
+
+.ai-message .message-content {
+  align-items: flex-start;
+}
+
+/* 消息气泡样式 */
+.message-bubble {
+  padding: 16px 20px;
+  border-radius: 18px;
+  word-wrap: break-word;
+  line-height: 1.6;
+  max-width: 100%;
+  display: inline-block;
+  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+}
+
+/* 用户消息气泡 */
+.user-message .message-bubble {
+  background-color: #1976d2;
+  color: white;
+  border-bottom-right-radius: 6px;
+  align-self: flex-end;
+}
+
+/* AI消息气泡 */
+.ai-message .message-bubble {
+  background-color: #f0f4f8;
+  color: #333333;
+  border-bottom-left-radius: 6px;
+  border: none;
+}
+
+/* 消息文本样式 */
+.message-text {
+  font-size: 15px;
+  font-weight: 400;
+}
+
+.message-text strong {
+  font-weight: 600;
+}
+
+.message-text em {
+  font-style: italic;
+}
+
+/* 消息时间样式 */
+.message-time {
+  font-size: 12px;
+  color: #999999;
+  margin-top: 8px;
+  padding: 0 10px;
+  text-align: right;
+}
+
+.user-message .message-time {
+  text-align: left;
+}
+
+/* 加载状态样式 */
+.loading-item {
+  display: flex;
+  margin-bottom: 24px;
+  animation: fadeIn 0.3s ease;
+}
+
+.loading-spinner {
+  display: inline-block;
+  margin-right: 10px;
+}
+
+.loading-text {
+  font-size: 15px;
+  color: #666666;
+  animation: pulse 1.5s infinite;
+}
+
+/* 输入容器样式 */
+.input-container {
+  display: flex;
+  flex-direction: column;
+  gap: 12px;
+  padding: 16px;
+  background-color: #ffffff;
+  border-radius: 12px;
+  border: 1px solid #f0f0f0;
+  min-height: 150px;
+  flex-shrink: 0;
+}
+
+/* 输入操作按钮区域 */
+.input-actions {
+  display: flex;
+  justify-content: flex-end;
+  gap: 12px;
+  align-items: center;
+}
+
+/* 文件上传区域 */
+.file-upload-section {
+  margin: 10px 0;
+  padding: 12px;
+  background-color: #ffffff;
+  border-radius: 8px;
+  border: 1px solid #e8e8e8;
+}
+
+.file-list {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 12px;
+}
+
+.file-item {
+  display: flex;
+  align-items: center;
+  gap: 10px;
+  padding: 10px;
+  background-color: #ffffff;
+  border-radius: 8px;
+  border: 1px solid #e8e8e8;
+  flex: 1 0 calc(50% - 6px);
+  min-width: 200px;
+  transition: all 0.2s ease;
+}
+
+.file-item:hover {
+  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
+  transform: translateY(-1px);
+}
+
+.file-info {
+  display: flex;
+  align-items: center;
+  flex: 1;
+}
+
+.file-name {
+  font-size: 14px;
+  color: #333333;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+  flex: 1;
+}
+
+/* 上传图片样式 */
+.uploaded-image {
+  max-width: 100%;
+  max-height: 200px;
+  width: auto;
+  height: auto;
+  border-radius: 8px;
+  margin: 12px 0;
+  display: block;
+  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
+  transition: transform 0.2s ease;
+}
+
+.uploaded-image:hover {
+  transform: scale(1.02);
+}
+
+/* 文件链接样式 */
+.file-link {
+  color: #1976d2;
+  text-decoration: none;
+  word-break: break-all;
+  font-weight: 500;
+  transition: color 0.2s ease;
+}
+
+.file-link:hover {
+  color: #1565c0;
+  text-decoration: underline;
+}
+
+/* 动画效果 */
+@keyframes fadeIn {
+  from {
+    opacity: 0;
+    transform: translateY(8px);
+  }
+
+  to {
+    opacity: 1;
+    transform: translateY(0);
+  }
+}
+
+@keyframes pulse {
+
+  0%,
+  100% {
+    opacity: 1;
+  }
+
+  50% {
+    opacity: 0.6;
+  }
+}
+
+/* 滚动条样式 */
+.chat-history::-webkit-scrollbar {
+  width: 6px;
+}
+
+.chat-history::-webkit-scrollbar-track {
+  background: #f1f1f1;
+  border-radius: 3px;
+}
+
+.chat-history::-webkit-scrollbar-thumb {
+  background: #c1c1c1;
+  border-radius: 3px;
+}
+
+.chat-history::-webkit-scrollbar-thumb:hover {
+  background: #a8a8a8;
+}
+
+/* 响应式设计 */
+@media (max-width: 768px) {
+  .agent-dialog-card {
+    max-width: 100%;
+    margin: 0;
+    border-radius: 0;
+  }
+
+  .dialog-container {
+    height: 500px;
+    padding: 16px;
+  }
+
+  .message-content {
+    max-width: 80%;
+  }
+
+  .file-item {
+    flex: 1 0 100%;
+  }
+
+  .quick-start-section {
+    flex-direction: column;
+    align-items: center;
+  }
+}
+
+@media (max-width: 480px) {
+  .dialog-container {
+    height: 400px;
+  }
+
+  .message-content {
+    max-width: 90%;
+  }
+
+  .input-actions {
+    flex-direction: column;
+    align-items: stretch;
+  }
+
+  .input-actions .el-button {
+    width: 100%;
+  }
+
+  .file-item {
+    flex: 1 0 100%;
+  }
+}
+</style>

+ 222 - 106
src/views/User/acidModel/Calculation.vue

@@ -2,71 +2,56 @@
   <el-card class="box-card">
     <template #header>
       <div class="card-header">
-        <span>{{ $t('Calculation.refluxTitle') }}</span>
+        <span>反酸模型</span>
+        <div class="mode-switch">
+          <el-button type="primary" :class="['mode-button', 'dry-mode', currentMode === 'dry' ? 'active' : '']"
+            @click="setMode('dry')" icon="el-icon-crop" round>旱地</el-button>
+          <el-button type="primary" :class="['mode-button', 'paddy-mode', currentMode === 'paddy' ? 'active' : '']"
+            @click="setMode('paddy')" icon="el-icon-watermelon" round>水田</el-button>
+        </div>
       </div>
     </template>
 
-    <el-form
-      :model="form"
-      ref="predictForm"
-      label-width="240px"
-      label-position="left"
-    >
-      <el-form-item :label="$t('Calculation.exchangeableHydrogen')" prop="H" :error="errorMessages.H" required>
-        <el-input
-          v-model="form.H"
-          size="large"
-          :placeholder="$t('Calculation.reflux.exchangeableHydrogenPlaceholder')"
-          @input="handleInput('H', $event, 0, 5)"
-        ></el-input>
+    <el-form :model="form" ref="predictForm" label-width="240px" label-position="left" class="form-container"
+      :class="currentMode === 'dry' ? 'dry-form' : 'paddy-form'">
+      <!-- 旱地模式下显示交换性氢 -->
+      <el-form-item v-if="currentMode === 'dry'" label="交换性氢(cmol/kg)" prop="H" :error="errorMessages.H" required>
+        <el-input v-model="form.H" size="large" placeholder="请输入交换性氢0~5(cmol/kg)"
+          @input="handleInput('H', $event, 0, 5)"></el-input>
       </el-form-item>
-      <el-form-item :label="$t('Calculation.exchangeableAluminum')" prop="Al" :error="errorMessages.Al" required>
-        <el-input
-          v-model="form.Al"
-          size="large"
-          :placeholder="$t('Calculation.reflux.exchangeableAluminumPlaceholder')"
-          @input="handleInput('Al', $event, 0, 10)"
-        ></el-input>
+      <el-form-item label="交换性铝(cmol/kg)" prop="Al" :error="errorMessages.Al" required>
+        <el-input v-model="form.Al" size="large" placeholder="请输入交换性铝0~10(cmol/kg)"
+          @input="handleInput('Al', $event, 0, 10)"></el-input>
       </el-form-item>
-      <el-form-item :label="$t('Calculation.soilOrganicMatter')" prop="OM" :error="errorMessages.OM" required>
-        <el-input
-          v-model="form.OM"
-          size="large"
-          :placeholder="$t('Calculation.reflux.soilOrganicMatterPlaceholder')"
-          @input="handleInput('OM', $event, 0, 35)"
-        ></el-input>
+      <el-form-item label="土壤有机质(g/kg)" prop="OM" :error="errorMessages.OM" required>
+        <el-input v-model="form.OM" size="large" placeholder="请输入土壤有机质0~35(g/kg)"
+          @input="handleInput('OM', $event, 0, 35)"></el-input>
       </el-form-item>
-      <el-form-item :label="$t('Calculation.nitrate')" prop="NO3" :error="errorMessages.NO3" required>
-        <el-input
-          v-model="form.NO3"
-          size="large"
-          :placeholder="$t('Calculation.reflux.nitratePlaceholder')"
-          @input="handleInput('NO3', $event, 0, 70)"
-        ></el-input>
+      <el-form-item label="硝酸盐(mg/kg)" prop="NO3" :error="errorMessages.NO3" required>
+        <el-input v-model="form.NO3" size="large" placeholder="请输入硝酸盐0~70(mg/kg)"
+          @input="handleInput('NO3', $event, 0, 70)"></el-input>
       </el-form-item>
-      <el-form-item :label="$t('Calculation.ammoniumSalt')" prop="NH4" :error="errorMessages.NH4" required>
-        <el-input
-          v-model="form.NH4"
-          size="large"
-          :placeholder="$t('Calculation.reflux.ammoniumSaltPlaceholder')"
-          @input="handleInput('NH4', $event, 0, 20)"
-        ></el-input>
+      <el-form-item label="铵盐(mg/kg)" prop="NH4" :error="errorMessages.NH4" required>
+        <el-input v-model="form.NH4" size="large" placeholder="请输入铵盐0~20(mg/kg)"
+          @input="handleInput('NH4', $event, 0, 20)"></el-input>
       </el-form-item>
-      <el-form-item :label="$t('Calculation.cationExchangeCapacity')" prop="CEC" :error="errorMessages.CEC" required>
-        <el-input
-          v-model="form.CEC"
-          size="large"
-          :placeholder="$t('Calculation.reflux.cationExchangeCapacityPlaceholder')"
-          @input="handleInput('CEC', $event, 0, 20)"
-        ></el-input>
+      <el-form-item label="阳离子交换量(cmol/kg)" prop="CEC" :error="errorMessages.CEC" required>
+        <el-input v-model="form.CEC" size="large" placeholder="请输入阳离子交换量0~20(cmol/kg)"
+          @input="handleInput('CEC', $event, 0, 20)"></el-input>
+      </el-form-item>
+      <!-- 水田模式下显示FeO -->
+      <el-form-item v-if="currentMode === 'paddy'" label="氧化铁(g/kg)" prop="FeO" :error="errorMessages.FeO" required>
+        <el-input v-model="form.FeO" size="large" placeholder="请输入氧化铁 0~50(g/kg)"
+          @input="handleInput('FeO', $event, 0, 50)"></el-input>
       </el-form-item>
 
-      <el-button type="primary" @click="onSubmit" class="onSubmit">{{ $t('Calculation.calculateButton') }}</el-button>
+      <el-button type="primary" @click="onSubmit" class="onSubmit">计算</el-button>
 
-      <el-dialog v-model="dialogVisible" @close="onDialogClose" :close-on-click-modal="false" width="500px" align-center :title="$t('Calculation.resultTitle')">
+      <el-dialog v-model="dialogVisible" @close="onDialogClose" :close-on-click-modal="false" width="500px" align-center
+        title="计算结果">
         <span class="dialog-class">ΔpH: {{ result }}</span>
         <template #footer>
-          <el-button @click="dialogVisible = false">{{ $t('Calculation.closeButton') }}</el-button>
+          <el-button @click="dialogVisible = false">关闭</el-button>
         </template>
       </el-dialog>
     </el-form>
@@ -74,12 +59,12 @@
 </template>
 
 <script setup lang="ts">
-import { reactive, ref, nextTick, onMounted } from "vue";
-import { ElMessage } from "element-plus";
-import { api5000 } from "../../../utils/request";
-import { useI18n } from 'vue-i18n';
+import { reactive, ref, nextTick, onMounted } from 'vue';
+import { ElMessage } from 'element-plus';
+import { api5000 } from '../../../utils/request'; // 使用api5000
 
-const { t } = useI18n();
+// 计算模式类型
+type CalculationMode = 'dry' | 'paddy';
 
 // 表单接口 - 根据文档修改
 interface Form {
@@ -89,6 +74,7 @@ interface Form {
   NO3: number | null;
   NH4: number | null;
   CEC: number | null;
+  FeO?: number | null; // 水田模式下的参数
 }
 
 // 表单数据 - 根据文档修改
@@ -99,43 +85,62 @@ const form = reactive<Form>({
   NO3: null,
   NH4: null,
   CEC: null,
+  FeO: null, // 水田模式下的参数
 });
 
 const result = ref<number | null>(null);
 const dialogVisible = ref(false);
 const predictForm = ref<any>(null);
 const errorMessages = reactive<Record<string, string>>({
-  H: "",
-  Al: "",
-  OM: "",
-  NO3: "",
-  NH4: "",
-  CEC: "",
+  H: '',
+  Al: '',
+  OM: '',
+  NO3: '',
+  NH4: '',
+  CEC: '',
+  FeO: '', // 水田模式下的参数错误信息
 });
 
+// 计算模式状态 - 默认旱地模式
+const currentMode = ref<CalculationMode>('dry');
+
+// 设置计算模式
+const setMode = (mode: CalculationMode) => {
+  if (currentMode.value === mode) return;
+  currentMode.value = mode;
+  // 切换模式时重置表单
+  Object.keys(form).forEach((key) => (form[key as keyof Form] = null));
+  Object.keys(errorMessages).forEach((key) => (errorMessages[key as keyof typeof errorMessages] = ''));
+  nextTick(() => {
+    if (predictForm.value) (predictForm.value as any).resetFields();
+  });
+};
+
 // 当前选中模型
-const selectedModelId = ref<number>(35); // 根据文档修改为 35
-const selectedModelName = ref<string>("反酸预测模型");
+const selectedModelId = ref<number>(35); // 根据文档修改为35
+const selectedModelName = ref<string>('反酸预测模型');
 
 // 输入校验
 const handleInput = (field: keyof Form, event: Event, min: number, max: number) => {
   const target = event.target as HTMLInputElement;
-  let value = target.value.replace(/[^0-9.]/g, "");
+  let value = target.value.replace(/[^0-9.]/g, '');
   (form as any)[field] = value ? parseFloat(value) : null;
 
   if (!value) {
-    errorMessages[field] = "";
+    errorMessages[field] = '';
     return;
   }
 
   const numValue = parseFloat(value);
-  errorMessages[field] = (isNaN(numValue) || numValue < min || numValue > max)
-    ? t('Calculation.validationRange', { min, max })
-    : "";
+  errorMessages[field] =
+    isNaN(numValue) || numValue < min || numValue > max ? `输入值应在 ${min} 到 ${max} 之间且为有效数字` : '';
 };
 
-const validateInput = (value: string, min: number, max: number): boolean => {
-  const numValue = parseFloat(value);
+const validateInput = (value: number | null | undefined, min: number, max: number): boolean => {
+  if (value === null || value === undefined) {
+    return false;
+  }
+  const numValue = typeof value === 'string' ? parseFloat(value) : value;
   return !isNaN(numValue) && numValue >= min && numValue <= max;
 };
 
@@ -148,72 +153,94 @@ const fetchSelectedModel = async () => {
       selectedModelName.value = resp.data.data.model_name;
     }
   } catch (error) {
-    console.warn("获取当前模型失败,使用默认 model_id:", selectedModelId.value);
+    console.warn('获取当前模型失败,使用默认 model_id:', selectedModelId.value);
   }
 };
 
 // 计算方法 - 根据文档修改参数
 const onSubmit = async () => {
-  // 输入校验 - 根据新字段修改
-  const inputConfigs = [
-    { field: "H" as keyof Form, min: 0, max: 5 },
-    { field: "Al" as keyof Form, min: 0, max: 10},
-    { field: "OM" as keyof Form, min: 0, max: 35 },
-    { field: "NO3" as keyof Form, min: 0, max: 70 },
-    { field: "NH4" as keyof Form, min: 0, max: 20 },
-    { field: "CEC" as keyof Form, min: 0, max: 20 },
-  ];
+  // 根据当前模式设置需要验证的参数
+  let inputConfigs;
+  if (currentMode.value === 'dry') {
+    inputConfigs = [
+      { field: 'H' as keyof Form, min: 0, max: 5 },
+      { field: 'Al' as keyof Form, min: 0, max: 10 },
+      { field: 'OM' as keyof Form, min: 0, max: 35 },
+      { field: 'NO3' as keyof Form, min: 0, max: 70 },
+      { field: 'NH4' as keyof Form, min: 0, max: 20 },
+      { field: 'CEC' as keyof Form, min: 0, max: 20 },
+    ];
+  } else {
+    inputConfigs = [
+      { field: 'Al' as keyof Form, min: 0, max: 10 },
+      { field: 'OM' as keyof Form, min: 0, max: 35 },
+      { field: 'NO3' as keyof Form, min: 0, max: 70 },
+      { field: 'NH4' as keyof Form, min: 0, max: 20 },
+      { field: 'CEC' as keyof Form, min: 0, max: 20 },
+      { field: 'FeO' as keyof Form, min: 0, max: 50 },
+    ];
+  }
 
   let isValid = true;
   for (const config of inputConfigs) {
     const { field, min, max } = config;
     const value = form[field];
-    if (value === null || !validateInput(value.toString(), min, max)) {
+    if (!validateInput(value, min, max)) {
       isValid = false;
-      errorMessages[field] = t('Calculation.validationRange', { min, max });
+      errorMessages[field] = `输入值应在 ${min} 到 ${max} 之间且为有效数字`;
     } else {
-      errorMessages[field] = "";
+      errorMessages[field] = '';
     }
   }
 
   if (!isValid) {
-    ElMessage.error(t('Calculation.validationError'));
+    ElMessage.error('输入值不符合要求,请检查输入');
     return;
   }
 
-  // 根据文档修改参数结构
+  // 根据当前模式设置参数结构和model_id
   const data = {
-    model_id: selectedModelId.value,
-    parameters: {
-      H: form.H,
-      Al: form.Al,
-      OM: form.OM,
-      NO3: form.NO3,
-      NH4: form.NH4,
-      CEC: form.CEC,
-    },
+    model_id: currentMode.value === 'dry' ? 35 : 36,
+    parameters:
+      currentMode.value === 'dry'
+        ? {
+          H: form.H,
+          Al: form.Al,
+          OM: form.OM,
+          NO3: form.NO3,
+          NH4: form.NH4,
+          CEC: form.CEC,
+        }
+        : {
+          CEC: form.CEC,
+          NH4: form.NH4,
+          NO3: form.NO3,
+          Al: form.Al,
+          FeO: form.FeO,
+          OM: form.OM,
+        },
   };
-  
+
   try {
     const response = await api5000.post('/predict', data, {
       headers: {
-        "Content-Type": "application/json",
+        'Content-Type': 'application/json',
       },
     });
     if (response.data && response.data.result && response.data.result.length > 0) {
       result.value = parseFloat(response.data.result[0].toFixed(2));
       dialogVisible.value = true;
     } else {
-      ElMessage.error(t('Calculation.invalidResult'));
+      ElMessage.error('未获取到有效的预测结果');
     }
   } catch (error: any) {
-    console.error("请求失败:", error);
+    console.error('请求失败:', error);
     if (error.response) {
-      ElMessage.error(`${t('Calculation.requestFailed')}${error.response.status}`);
+      ElMessage.error(`请求失败,状态码: ${error.response.status}`);
     } else if (error.request) {
-      ElMessage.error(t('Calculation.noResponse'));
+      ElMessage.error('请求发送成功,但没有收到响应');
     } else {
-      ElMessage.error(`${t('Calculation.requestError')}${error.message}`);
+      ElMessage.error('请求过程中发生错误: ' + error.message);
     }
   }
 };
@@ -222,7 +249,7 @@ const onSubmit = async () => {
 const onDialogClose = () => {
   dialogVisible.value = false;
   Object.keys(form).forEach((key) => (form[key as keyof Form] = null));
-  Object.keys(errorMessages).forEach((key) => (errorMessages[key as keyof typeof errorMessages] = ""));
+  Object.keys(errorMessages).forEach((key) => (errorMessages[key as keyof typeof errorMessages] = ''));
   nextTick(() => {
     if (predictForm.value) (predictForm.value as any).resetFields();
   });
@@ -242,6 +269,7 @@ onMounted(() => {
   background-color: #f0f5ff;
   border-radius: 10px;
   box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
+  transition: all 0.3s ease;
 }
 
 .card-header {
@@ -249,10 +277,63 @@ onMounted(() => {
   text-align: center;
   color: #333;
   margin-bottom: 30px;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+}
+
+/* 模式切换按钮样式 */
+.mode-switch {
+  margin-left: auto;
+  display: flex;
+  gap: 10px;
+}
+
+.mode-button {
+  transition: all 0.3s ease;
+  font-weight: bold;
+  background-color: #cccccc;
+  border-color: #cccccc;
+  color: #666666;
+}
+
+.mode-button:hover {
+  background-color: #b3b3b3;
+  border-color: #b3b3b3;
+}
+
+.mode-button.active {
+  opacity: 1;
+  transform: scale(1.05);
+  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
+}
+
+.dry-mode.active {
+  background-color: #2e7d32;
+  border-color: #2e7d32;
+  color: white;
+}
+
+.dry-mode.active:hover {
+  background-color: #388e3c;
+  border-color: #388e3c;
+}
+
+.paddy-mode.active {
+  background-color: #0d47a1;
+  border-color: #0d47a1;
+  color: white;
+}
+
+.paddy-mode.active:hover {
+  background-color: #1565c0;
+  border-color: #1565c0;
 }
 
 .el-form-item {
   margin-bottom: 20px;
+  transition: all 0.3s ease;
+  animation: fadeIn 0.5s ease;
 }
 
 :deep(.el-form-item__label) {
@@ -260,6 +341,40 @@ onMounted(() => {
   color: #666;
 }
 
+/* 表单容器过渡效果 */
+.form-container {
+  transition: all 0.3s ease;
+}
+
+/* 旱地模式表单样式 */
+.dry-form {
+  --form-bg: rgba(240, 245, 255, 0.9);
+}
+
+/* 水田模式表单样式 */
+.paddy-form {
+  --form-bg: rgba(220, 240, 255, 0.9);
+}
+
+/* 表单淡入动画 */
+@keyframes fadeIn {
+  from {
+    opacity: 0;
+    transform: translateY(10px);
+  }
+
+  to {
+    opacity: 1;
+    transform: translateY(0);
+  }
+}
+
+/* 输入框焦点样式 */
+:deep(.el-input__inner:focus) {
+  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
+  border-color: #2196f3;
+}
+
 .model-info {
   text-align: center;
   margin-bottom: 20px;
@@ -290,7 +405,8 @@ onMounted(() => {
   display: flex;
   justify-content: center;
   align-items: center;
-  height: 100%; /* 确保容器占满对话框内容区域 */
+  height: 100%;
+  /* 确保容器占满对话框内容区域 */
   font-size: 22px;
 }
 
@@ -299,4 +415,4 @@ onMounted(() => {
     --el-form-label-width: 100px;
   }
 }
-</style>
+</style>

+ 335 - 147
src/views/User/acidModel/ModelIterationVisualization.vue

@@ -1,11 +1,8 @@
-<script setup lang='ts'>
+<script setup lang="ts">
 import { ref, onMounted, nextTick, onUnmounted, watch } from 'vue';
 import VueEcharts from 'vue-echarts';
 import 'echarts';
 import { api5000 } from '../../../utils/request';
-import { useI18n } from 'vue-i18n';
-
-const { t } = useI18n()
 
 interface HistoryDataItem {
   dataset_id: number;
@@ -35,36 +32,36 @@ interface ScatterDataResponse {
 const props = defineProps({
   showLineChart: {
     type: Boolean,
-    default: true
+    default: true,
   },
   showInitScatterChart: {
     type: Boolean,
-    default: true
+    default: true,
   },
   showMidScatterChart: {
     type: Boolean,
-    default: true
+    default: true,
   },
   showFinalScatterChart: {
     type: Boolean,
-    default: true
+    default: true,
   },
   lineChartPathParam: {
     type: String,
-    default: 'reduce'
+    default: 'reflux',
   },
   initScatterModelId: {
     type: Number,
-    default: 6
+    default: 6,
   },
   midScatterModelId: {
     type: Number,
-    default: 7
+    default: 7,
   },
   finalScatterModelId: {
     type: Number,
-    default: 17
-  }
+    default: 17,
+  },
 });
 
 // 定义响应式变量
@@ -84,29 +81,37 @@ const learningCurveImageUrl = ref('');
 const dataIncreaseCurveImageUrl = ref('');
 const selectedModelType = ref('rf'); // 默认选择随机森林
 
+// 新增:土地类型选择
+const selectedLandType = ref('dryland'); // 默认选择旱地
+
 // 模型类型选项
 const modelTypeOptions = [
-  { label: t('ModelIteration.randomForest'), value: 'rf' },
-  { label: t('ModelIteration.xgboost'), value: 'xgbr' },
-  { label: t('ModelIteration.gradientBoosting'), value: 'gbst' },
+  { label: '随机森林', value: 'rf' },
+  { label: 'XGBoost', value: 'xgbr' },
+  { label: '梯度提升', value: 'gbst' },
 ];
 
+// 土地类型验证
+const validateLandType = (landType: string): boolean => {
+  return ['dryland', 'paddy_field'].includes(landType);
+};
+
 // 计算数据范围的函数
 const calculateDataRange = (data: [number, number][]) => {
-  const xValues = data.map(item => item[0]);
-  const yValues = data.map(item => item[1]);
+  const xValues = data.map((item) => item[0]);
+  const yValues = data.map((item) => item[1]);
   return {
     xMin: Math.min(...xValues),
     xMax: Math.max(...xValues),
     yMin: Math.min(...yValues),
-    yMax: Math.max(...yValues)
+    yMax: Math.max(...yValues),
   };
 };
 
 // 获取折线图数据
 const fetchLineData = async () => {
   try {
-    const response = await api5000.get<HistoryDataResponse>(`/get-model-history/${props.lineChartPathParam}`);    
+    const response = await api5000.get<HistoryDataResponse>(`/get-model-history/${props.lineChartPathParam}`);
     const data = response.data;
 
     const timestamps = data.timestamps;
@@ -120,36 +125,36 @@ const fetchLineData = async () => {
       performanceScores[item.model_name].push(score);
     });
 
-    const series = Object.keys(performanceScores).map(modelName => ({
+    const series = Object.keys(performanceScores).map((modelName) => ({
       name: modelName,
       type: 'line',
-      data: performanceScores[modelName]
+      data: performanceScores[modelName],
     }));
 
     ecLineOption.value = {
       tooltip: {
-        trigger: 'axis'
+        trigger: 'axis',
       },
       legend: {
-        data: Object.keys(performanceScores)
+        data: Object.keys(performanceScores),
       },
       grid: {
-        left: '3%',
-        right: '17%',
+        left: '22%',
+        right: '22%',
         bottom: '3%',
-        containLabel: true
+        containLabel: true,
       },
       xAxis: {
-        name: t('ModelIteration.modelIteration'),
+        name: '模型迭代',
         type: 'category',
         boundaryGap: false,
-        data: timestamps.map((_, index) => `${index + 1}代`)
+        data: timestamps.map((_, index) => `${index + 1}代`),
       },
       yAxis: {
         name: 'Score (R^2)',
-        type: 'value'
+        type: 'value',
       },
-      series
+      series,
     };
     console.log('ecLineOption updated:', ecLineOption.value);
   } catch (error) {
@@ -163,7 +168,10 @@ const fetchScatterData = async (modelId: number, optionRef: any) => {
     const response = await api5000.get<ScatterDataResponse>(`/model-scatter-data/${modelId}`);
     const data = response.data;
 
-    const scatterData = data.scatter_data;
+    // 将数据点格式化为两位小数,并明确指定类型为[number, number][]
+    const scatterData: [number, number][] = data.scatter_data.map(
+      ([x, y]) => [parseFloat(x.toFixed(2)), parseFloat(y.toFixed(2))] as [number, number]
+    );
     const range = calculateDataRange(scatterData);
     const padding = 0.1;
     const xMin = range.xMin - Math.abs(range.xMin * padding);
@@ -177,29 +185,36 @@ const fetchScatterData = async (modelId: number, optionRef: any) => {
       tooltip: {
         trigger: 'axis',
         axisPointer: {
-          type: 'cross'
-        }
+          type: 'cross',
+        },
+        formatter: function (params: any) {
+          if (params.length > 0) {
+            const data = params[0].data;
+            return `True Values: ${data[0]}<br/>Predicted Values: ${data[1]}`;
+          }
+          return '';
+        },
       },
       legend: {
-        data: ['True vs Predicted']
+        data: ['True vs Predicted'],
       },
       grid: {
-        left: '3%',
-        right: '22%',
+        left: '15%',
+        right: '15%',
         bottom: '3%',
-        containLabel: true
+        containLabel: true,
       },
       xAxis: {
         name: 'True Values',
         type: 'value',
-        min: min,
-        max: max
+        min: parseFloat(min.toFixed(2)),
+        max: parseFloat(max.toFixed(2)),
       },
       yAxis: {
         name: 'Predicted Values',
         type: 'value',
         min: parseFloat(min.toFixed(2)),
-        max: parseFloat(max.toFixed(2))
+        max: parseFloat(max.toFixed(2)),
       },
       series: [
         {
@@ -209,23 +224,23 @@ const fetchScatterData = async (modelId: number, optionRef: any) => {
           symbolSize: 10,
           itemStyle: {
             color: '#1f77b4',
-            opacity: 0.7
-          }
+            opacity: 0.7,
+          },
         },
         {
           name: 'Trendline',
           type: 'line',
           data: [
             [min, min],
-            [max, max]
+            [max, max],
           ],
           lineStyle: {
             type: 'dashed',
             color: '#ff7f0e',
-            width: 2
-          }
-        }
-      ]
+            width: 2,
+          },
+        },
+      ],
     };
   } catch (error) {
     console.error('获取散点图数据失败:', error);
@@ -235,14 +250,21 @@ const fetchScatterData = async (modelId: number, optionRef: any) => {
 // 新增:获取学习曲线图片
 const fetchLearningCurveImage = async () => {
   try {
+    // 验证土地类型参数
+    if (!validateLandType(selectedLandType.value)) {
+      console.error('无效的土地类型参数:', selectedLandType.value);
+      return;
+    }
+
     const response = await api5000.get('/latest-learning-curve', {
       params: {
-        data_type: 'reduce',
-        model_type: selectedModelType.value
+        data_type: 'reflux',
+        model_type: selectedModelType.value,
+        land_type: selectedLandType.value,
       },
-      responseType: 'blob'
+      responseType: 'blob',
     });
-    
+
     const blob = new Blob([response.data], { type: 'image/png' });
     learningCurveImageUrl.value = URL.createObjectURL(blob);
   } catch (error) {
@@ -253,13 +275,20 @@ const fetchLearningCurveImage = async () => {
 // 新增:获取数据增长曲线图片
 const fetchDataIncreaseCurveImage = async () => {
   try {
+    // 验证土地类型参数
+    if (!validateLandType(selectedLandType.value)) {
+      console.error('无效的土地类型参数:', selectedLandType.value);
+      return;
+    }
+
     const response = await api5000.get('/latest-data-increase-curve', {
       params: {
-        data_type: 'reduce',
+        data_type: 'reflux',
+        land_type: selectedLandType.value,
       },
-      responseType: 'blob'
+      responseType: 'blob',
     });
-    
+
     const blob = new Blob([response.data], { type: 'image/png' });
     dataIncreaseCurveImageUrl.value = URL.createObjectURL(blob);
   } catch (error) {
@@ -273,6 +302,14 @@ watch(selectedModelType, () => {
   fetchDataIncreaseCurveImage();
 });
 
+// 监听土地类型变化,重新获取图片和散点图数据
+watch(selectedLandType, () => {
+  fetchLearningCurveImage();
+  fetchDataIncreaseCurveImage();
+  const modelId = selectedLandType.value === 'dryland' ? 35 : 36;
+  fetchScatterData(modelId, ecInitScatterOption);
+});
+
 // 定义调整图表大小的函数
 const resizeCharts = () => {
   nextTick(() => {
@@ -285,7 +322,10 @@ const resizeCharts = () => {
 
 onMounted(async () => {
   if (props.showLineChart) await fetchLineData();
-  if (props.showInitScatterChart) await fetchScatterData(props.initScatterModelId, ecInitScatterOption);
+
+  // 根据土地类型选择初始散点图模型ID
+  const initialModelId = selectedLandType.value === 'dryland' ? 35 : 36;
+  if (props.showInitScatterChart) await fetchScatterData(initialModelId, ecInitScatterOption);
   if (props.showMidScatterChart) await fetchScatterData(props.midScatterModelId, ecMidScatterOption);
   if (props.showFinalScatterChart) await fetchScatterData(props.finalScatterModelId, ecFinalScatterOption);
 
@@ -303,7 +343,7 @@ onMounted(async () => {
 // 组件卸载时移除事件监听器
 onUnmounted(() => {
   window.removeEventListener('resize', resizeCharts);
-  
+
   // 清理Blob URL
   if (learningCurveImageUrl.value) {
     URL.revokeObjectURL(learningCurveImageUrl.value);
@@ -316,30 +356,26 @@ onUnmounted(() => {
 
 <template>
   <div class="container">
-    <template v-if="showInitScatterChart">
-      <!-- 散点图 -->
-      <h2 class="chart-header">{{ $t('ModelIteration.scatterPlotTitle') }}</h2>
-      <div class="chart-container">
-        <VueEcharts :option="ecInitScatterOption" ref="ecInitScatterOptionRef" />
+    <!-- 主标题区域,包含标题和土地类型按钮组 -->
+    <div class="main-title-row">
+      <h1 class="main-title">模型迭代可视化</h1>
+      <div class="land-type-buttons">
+        <button :class="['land-button', 'dryland-button', selectedLandType === 'dryland' ? 'active' : '']"
+          @click="selectedLandType = 'dryland'">
+          旱地
+        </button>
+        <button :class="['land-button', 'paddy-button', selectedLandType === 'paddy_field' ? 'active' : '']"
+          @click="selectedLandType = 'paddy_field'">
+          水田
+        </button>
       </div>
-    </template>
+    </div>
 
-    <h2 class="chart-header">{{ $t('ModelIteration.modelPerformanceAnalysis') }}</h2>
-    <!-- 模型性能分析部分 -->
-    <div class="analysis-section">
-       <!-- 数据增长曲线模块 -->
-      <div class="chart-module">
-        <h2 class="chart-header">{{ $t('ModelIteration.dataIncreaseCurve') }}</h2>
-        <div class="image-chart-item">
-          <div class="image-container">
-            <img v-if="dataIncreaseCurveImageUrl" :src="dataIncreaseCurveImageUrl" :alt="$t('ModelIteration.dataIncreaseCurve')" >
-            <div v-else class="image-placeholder">{{ $t('ModelIteration.loading') }}</div>
-          </div>
-        </div>
-      </div>
-      <!-- 学习曲线模块 -->
-      <div class="chart-module">
-        <h2 class="chart-header">{{ $t('ModelIteration.learningCurve') }}</h2>
+    <!-- 学习曲线模块 - 移到最上方 -->
+    <div class="chart-module">
+      <!-- 学习曲线标题和模型选择器在同一行 -->
+      <div class="chart-title-row">
+        <h2 class="chart-header">学习曲线</h2>
         <div class="model-selector-wrapper">
           <select v-model="selectedModelType" class="model-select">
             <option v-for="option in modelTypeOptions" :key="option.value" :value="option.value">
@@ -347,14 +383,35 @@ onUnmounted(() => {
             </option>
           </select>
         </div>
-        <div class="image-chart-item">
-          <div class="image-container">
-            <img v-if="learningCurveImageUrl" :src="learningCurveImageUrl" :alt="$t('ModelIteration.learningCurve')" >
-            <div v-else class="image-placeholder">{{ $t('ModelIteration.loading') }}</div>
-          </div>
+      </div>
+      <div class="chart-container">
+        <div class="image-container">
+          <img v-if="learningCurveImageUrl" :src="learningCurveImageUrl" alt="学习曲线" />
+          <div v-else class="image-placeholder">加载中...</div>
+        </div>
+      </div>
+    </div>
+
+    <!-- 数据增长曲线模块 - 移到中间 -->
+    <div class="chart-module">
+      <h2 class="chart-header">数据增长曲线</h2>
+      <div class="chart-container">
+        <div class="image-container">
+          <img v-if="dataIncreaseCurveImageUrl" :src="dataIncreaseCurveImageUrl" alt="数据增长曲线" />
+          <div v-else class="image-placeholder">加载中...</div>
         </div>
       </div>
     </div>
+
+    <!-- 散点图模块 - 移到最下方 -->
+    <template v-if="showInitScatterChart">
+      <div class="chart-module">
+        <h2 class="chart-header">散点图</h2>
+        <div class="chart-container">
+          <VueEcharts :option="ecInitScatterOption" ref="ecInitScatterOptionRef" />
+        </div>
+      </div>
+    </template>
   </div>
 </template>
 
@@ -363,19 +420,37 @@ onUnmounted(() => {
   display: flex;
   flex-direction: column;
   align-items: center;
-  justify-content: center;
   width: 100%;
-  height: 100%;
-  gap: 20px;
+  gap: 30px;
   color: #000;
   background-color: white;
+  padding: 20px;
+}
+
+/* 主标题样式 */
+.main-title {
+  font-size: 28px;
+  font-weight: bold;
+  color: #2c3e50;
+  text-align: center;
+  margin: 0;
 }
 
 .chart-header {
   font-size: 18px;
   font-weight: bold;
-  margin-bottom: 10px;
   color: #2c3e50;
+  margin: 0;
+}
+
+/* 图表标题行 - 用于放置标题和模型选择器 */
+.chart-title-row {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  width: 100%;
+  margin-bottom: 10px;
+  gap: 20px;
 }
 
 .sub-title {
@@ -383,42 +458,45 @@ onUnmounted(() => {
   font-weight: 700;
 }
 
-.chart-container {
+.chart-module {
   width: 85%;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  gap: 10px;
+}
+
+.chart-container {
+  width: 100%;
   height: 450px;
-  margin: 0 auto;
-  margin-bottom: 20px;
   background-color: white;
   border-radius: 8px;
   box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
+  display: flex;
+  flex-direction: column;
+  overflow: hidden;
 }
 
 .VueEcharts {
   width: 100%;
   height: 100%;
-  margin: 0 10px;
   background-color: white;
 }
 
-/* 新增:图片图表样式 */
-.image-charts-section {
-  width: 90%;
-  margin: 30px auto;
-  padding: 20px;
+/* 图片容器样式 - 与散点图尺寸一致 */
+.image-container {
+  width: 100%;
+  height: 450px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
   background-color: #f8f9fa;
-  border-radius: 8px;
-  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
+  overflow: hidden;
 }
 
-.model-type-selector {
-  margin: 20px 0;
-  text-align: center;
-}
-
-.model-type-selector label {
-  margin-right: 10px;
-  font-weight: bold;
-  color: #2c3e50;
+/* 模型选择器样式 */
+.model-selector-wrapper {
+  margin: 0;
 }
 
 .model-select {
@@ -427,39 +505,15 @@ onUnmounted(() => {
   border-radius: 4px;
   background-color: white;
   font-size: 14px;
+  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
+  cursor: pointer;
+  transition: border-color 0.3s ease;
 }
 
-.image-charts-container {
-  display: grid;
-  grid-template-columns: 1fr 1fr;
-  gap: 30px;
-  margin-top: 20px;
-}
-
-.image-chart-item {
-  background-color: white;
-  padding: 20px;
-  border-radius: 8px;
-  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
-}
-
-.image-chart-title {
-  font-size: 16px;
-  font-weight: bold;
-  margin-bottom: 15px;
-  color: #2c3e50;
-  text-align: center;
-}
-
-.image-container {
-  width: 100%;
-  height: 400px;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  background-color: #f8f9fa;
-  border-radius: 4px;
-  overflow: hidden;
+.model-select:focus {
+  outline: none;
+  border-color: #3498db;
+  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
 }
 
 .image-container img {
@@ -494,19 +548,153 @@ onUnmounted(() => {
   color: #333;
 }
 
+/* 土地类型按钮样式 */
+.main-title-row {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  width: 100%;
+  margin-bottom: 20px;
+  flex-wrap: wrap;
+  gap: 10px;
+}
+
+.land-type-buttons {
+  display: flex;
+  gap: 10px;
+}
+
+.land-button {
+  padding: 8px 16px;
+  border: none;
+  border-radius: 4px;
+  font-size: 14px;
+  font-weight: 500;
+  cursor: pointer;
+  transition: all 0.3s ease;
+}
+
+.dryland-button {
+  background-color: #f0f0f0;
+  color: #666;
+  border: 1px solid #ddd;
+}
+
+.dryland-button.active {
+  background-color: #d4edda;
+  color: #155724;
+  border-color: #c3e6cb;
+}
+
+.paddy-button {
+  background-color: #f0f0f0;
+  color: #666;
+  border: 1px solid #ddd;
+}
+
+.paddy-button.active {
+  background-color: #cce7ff;
+  color: #004085;
+  border-color: #b3d7ff;
+}
+
+.land-button:not(.active) {
+  background-color: #e9ecef;
+  color: #6c757d;
+}
+
+/* 主标题行样式 */
+.main-title-row {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  width: 85%;
+  margin-bottom: 10px;
+  flex-wrap: wrap;
+  gap: 15px;
+}
+
+/* 土地类型按钮组样式 */
+.land-type-buttons {
+  display: flex;
+  gap: 10px;
+}
+
+.land-button {
+  padding: 10px 20px;
+  border: 2px solid transparent;
+  border-radius: 25px;
+  font-size: 16px;
+  font-weight: 600;
+  cursor: pointer;
+  transition: all 0.3s ease;
+  outline: none;
+}
+
+.dryland-button {
+  background-color: #8B4513;
+  color: white;
+}
+
+.paddy-button {
+  background-color: #1E90FF;
+  color: white;
+}
+
+.land-button:not(.active) {
+  background-color: #ddd;
+  color: #666;
+}
+
+.land-button.active {
+  border-color: #333;
+  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
+}
+
+.land-button:hover:not(.active) {
+  background-color: #ccc;
+  color: #333;
+}
+
 /* 响应式设计 */
 @media (max-width: 768px) {
-  .image-charts-container {
-    grid-template-columns: 1fr;
+  .container {
+    padding: 10px;
+    gap: 20px;
   }
-  
-  .image-container {
-    height: 300px;
+
+  .main-title {
+    font-size: 24px;
   }
-  
-  .chart-container {
+
+  .chart-module {
     width: 95%;
+  }
+
+  .main-title-row {
+    width: 95%;
+    flex-direction: column;
+    align-items: flex-start;
+    gap: 10px;
+  }
+
+  .chart-container,
+  .image-container {
     height: 400px;
   }
+
+  .chart-title-row {
+    flex-direction: column;
+    align-items: flex-start;
+    gap: 10px;
+  }
+
+  .model-selector-wrapper {
+    width: 100%;
+  }
+
+  .model-select {
+    width: 100%;
+  }
 }
-</style>
+</style>