tangjunhao 1 semana atrás
pai
commit
169a206369
1 arquivos alterados com 51 adições e 18 exclusões
  1. 51 18
      src/views/mainContent/rightaside/iterativeCurve.vue

+ 51 - 18
src/views/mainContent/rightaside/iterativeCurve.vue

@@ -11,7 +11,7 @@
             <el-form-item :label="lineName">
               <el-row :gutter="5">
                 <el-col :span="12">
-                  <el-select v-model="lineOption.linetype1" size="small">
+                  <el-select v-model="lineOption.linetype1" size="small" @change="updateOption2">
                     <el-option
                       v-for="item in option1"
                       :key="item.value"
@@ -63,25 +63,24 @@ const Labelwidth = '90px'
 
 const lineName = ref('选择曲线数据')
 
+const rankeys = ref([]);
+const option1 = ref([]);
+const option2 = ref([]);
 const lineOption = ref({
-  linetype1:'ScipyOptimize_SLSQP',
-  linetype2:'twist_cp'
-})
+  linetype1: '', // 动态赋值
+  linetype2: ''  // 动态赋值
+});
 
-const option1 = ref([
-  {label: 'ScipyOptimize_SLSQP',value: 'ScipyOptimize_SLSQP'},
-  {label: 'DOEDriver_LatinHypercube',value: 'DOEDriver_LatinHypercube'}
-])
-
-const option2 = ref([
-  {label: '扭转分布',value: 'twist_cp'},
-  {label: '厚度分布',value: 'thickness_cp'},
-  {label: '升力系数',value: 'CL'},
-  {label: '阻力系数',value: 'CD'},
-  {label: '失效应力',value: 'failure'},
-  {label: '结构质量',value: 'structural_mass'},
-  {label: '燃油消耗',value: 'fuelburn'},
-])
+// key 对应的中文显示
+const keyLabelMap = {
+  twist_cp: '扭转分布',
+  thickness_cp: '厚度分布',
+  CL: '升力系数',
+  CD: '阻力系数',
+  failure: '失效应力',
+  structural_mass: '结构质量',
+  fuelburn: '燃油消耗'
+};
 
 const lineData = ref({})
 const ChartKey = ref(0)
@@ -106,6 +105,20 @@ const getlineData = () => {
     
     lineData.value = {}
 
+    // 保存 rankeys,给 updateOption2 用
+    rankeys.value = res.rankeys;
+
+    // 生成 option1
+    option1.value = res.rankeys.map(item => ({
+      label: item.rankey,
+      value: item.rankey
+    }));
+
+    // 默认选择第一个 rankey
+    if (option1.value.length > 0) {
+      lineOption.value.linetype1 = option1.value[0].value;
+    }
+
     // 遍历处理每个 rankey 数据
     res.rankeys.forEach(item => {
       const processed = processData(item);
@@ -114,6 +127,9 @@ const getlineData = () => {
     })
     
     console.log('解析曲线数据', lineData.value)
+
+    // 根据默认的 linetype1 生成 option2
+    updateOption2();
   })
   .catch((err) => {
     ElMessage.error(err.returnMsg || "曲线数据获取失败");
@@ -141,6 +157,23 @@ function processData(data) {
   return result;
 }
 
+const updateOption2 = () => {
+  const selected = rankeys.value.find(item => item.rankey === lineOption.value.linetype1);
+  if (selected) {
+    option2.value = selected.keys.map(k => ({
+      label: keyLabelMap[k.key] || k.key, // 显示中文,没有映射就显示原 key
+      value: k.key
+    }));
+
+    if (option2.value.length > 0) {
+      lineOption.value.linetype2 = option2.value[0].value;
+    }
+  } else {
+    option2.value = [];
+    lineOption.value.linetype2 = '';
+  }
+};
+
 // 监听 chartdata 的变化
 watch(chartdata, () => {
   ChartKey.value++   // 每次数据变动,强制刷新 echartline 组件