Sfoglia il codice sorgente

814优化问题修改

tangjunhao 4 settimane fa
parent
commit
04044d777e

+ 18 - 7
src/views/mainContent/js/analysisData.js

@@ -6,7 +6,7 @@ import { ElMessage } from 'element-plus'
 export function flattenBody(nodes) {
   let result = [];
   nodes.forEach(item => {
-    if (item?.vo?.code === "switch") {
+    if (item?.vo?.code === "switch" || item?.vo?.code === "is_cons") {
       return; // 跳过
     }
 
@@ -20,6 +20,21 @@ export function flattenBody(nodes) {
   return result;
 }
 
+// 递归查找 switch / is_cons 节点
+function findSwitchNode(nodes) {
+  const targetCodes = ["switch", "is_cons"];
+  for (const item of nodes) {
+    if (targetCodes.includes(item?.vo?.code)) {
+      return item; // 找到就返回
+    }
+    if (item?.vo?.valType === 3 && Array.isArray(item.svo)) {
+      const found = findSwitchNode(item.svo);
+      if (found) return found;
+    }
+  }
+  return null;
+}
+
 // 主处理函数,接收数据参数,返回处理后的对象
 export function analysisJson(data) {
   const DataObj = {};
@@ -27,12 +42,8 @@ export function analysisJson(data) {
   DataObj['header'] = data?.vo || null;
   DataObj['body'] = flattenBody(data?.svo || []);
 
-  if (data?.svo) {
-    const switchItem = data.svo.find(item => item?.vo?.code === "switch");
-    DataObj['switch'] = switchItem?.vo || null;
-  } else {
-    DataObj['switch'] = null;
-  }
+  const switchItem = data?.svo ? findSwitchNode(data.svo) : null;
+  DataObj.switch = switchItem?.vo || null;
 
   return DataObj;
 }

+ 1 - 1
src/views/mainContent/leftaside/agentModel.vue

@@ -150,7 +150,7 @@ const linkageRulesMap = {
 
 const shouldShowItem = (currentValue = 'KrigingSurrogate', targetCode) => {
   const rules = linkageRulesMap[props.type] || {}; // 取当前 type 对应规则
-  console.log('currentValue',currentValue)
+  // console.log('currentValue',currentValue)
   return rules[currentValue]?.includes(targetCode) ?? false
 }
 

+ 159 - 144
src/views/mainContent/rightaside/opProblem.vue

@@ -3,7 +3,7 @@
   <div style="height: 100%;">
     <el-card class="custom-card">
       <template #header>
-        <span>{{ opDataObj.header?.name }}</span>
+        <span>{{ opDatajson?.vo.name }}</span>
       </template>
       <div class="opProblem-container" :class="currentClass">
         <div class="first-container">
@@ -13,62 +13,52 @@
                 <img src="@/assets/img/yhwt.png" class="content-aside-img" alt="Experiment Icon" />
               </el-row>
               <el-row justify="center" align="middle">
-                <span style="font-size: 10px;line-height: 32px;">{{ opDataObj1.header?.name }}</span>
-                <el-switch v-if="opDataObj1.switch" v-model="opDataObj1.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
+                <span style="font-size: 10px;line-height: 32px;">{{ opDatajson?.svo[0]?.vo.name }}</span>
+                <el-switch v-if="ophasSwitch1.switch" v-model="ophasSwitch1.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
               </el-row>
             </div>
             <div class="content-form content-form-right">
-              
-              <el-form class="custom-form" :label-width="Labelwidth" label-position="left">
-                <template v-for="(item, index) in opDataObj1.body" :key="index">
-                  <!-- 下拉框和输入框(带 label) -->
-                  <el-form-item 
-                    v-if="item.vo.valCodeType !== 'swithType'" 
-                    :label="item.vo.name"
-                  >
-                    <el-select
-                      v-if="item.vo.valType === 1"  
-                      v-model="item.vo.val" 
-                      size="small"
+              <template v-for="(form, formIndex) in opDataObj1" :key="formIndex">
+                <el-form class="custom-form" :label-width="Labelwidth" label-position="left">
+                  <el-form-item v-if="form.header.code !== 'is_cons'"  :label="form.header.name"></el-form-item>
+                  <template v-for="(item, index) in form.body" :key="index">
+                    <!-- 下拉框和输入框(带 label) -->
+                    <el-form-item 
+                      v-if="item.vo.valCodeType !== 'swithType'" 
+                      :label="item.vo.name"
                     >
-                      <el-option
-                        v-for="option in valoption[item.vo.valCodeType]"
-                        :key="option.val"
-                        :label="option.tag"
-                        :value="option.val"
+                      <el-select
+                        v-if="item.vo.valType === 1"  
+                        v-model="item.vo.val" 
+                        size="small"
+                      >
+                        <el-option
+                          v-for="option in valoption[item.vo.valCodeType]"
+                          :key="option.val"
+                          :label="option.tag"
+                          :value="option.val"
+                        />
+                      </el-select>
+                      <el-input 
+                        v-else-if="item.vo.valType === 2"
+                        v-model="item.vo.val" 
+                        size="small"
                       />
-                    </el-select>
-                    <el-input 
-                      v-else-if="item.vo.valType === 2"
-                      v-model="item.vo.val" 
-                      size="small"
-                    />
-                  </el-form-item>
-
-                  <!-- 复选框(无 label、不占位) -->
-                  <el-checkbox 
-                    v-else-if="item.vo.valType === 1 && item.vo.valCodeType === 'swithType'"
-                    v-model="item.vo.val"
-                    class="custom-checkbox"
-                  >
-                    {{ item.vo.name }}
-                  </el-checkbox>
-                </template>
-              </el-form>
-              
-              <!-- <div class="content-form-bottom">
-                <el-form class="custom-form" :label-width="Labelwidth" label-position="left">
-                  <el-form-item label="厚度分布">
-                    <el-input v-model="qitanOPData1.thickness"  size="small"></el-input>
-                  </el-form-item>
-                  <el-form-item label="上限">
-                    <el-input-number v-model="qitanOPData1.upperLimit"  size="small" controls-position="right"></el-input-number>
-                  </el-form-item>
-                  <el-form-item label="下限">
-                    <el-input-number v-model="qitanOPData1.lowerLimit"  size="small" controls-position="right"></el-input-number>
-                  </el-form-item>
+                    </el-form-item>
+
+                    <!-- 复选框(无 label、不占位) -->
+                    <el-checkbox 
+                      v-else-if="item.vo.valType === 1 && item.vo.valCodeType === 'swithType'"
+                      v-model="item.vo.val"
+                      class="custom-checkbox"
+                      true-value = 1
+                      false-value = 0
+                    >
+                      {{ item.vo.name }}
+                    </el-checkbox>
+                  </template>
                 </el-form>
-              </div> -->
+              </template>
             </div>
           </div>
         </div>
@@ -80,47 +70,52 @@
                 <img src="@/assets/img/yhwt.png" class="content-aside-img" alt="Experiment Icon" />
               </el-row>
               <el-row justify="center" align="middle" >
-                <span style="font-size: 10px;line-height: 32px;">{{ opDataObj2.header?.name }}</span>
-                <el-switch v-if="opDataObj2.switch" v-model="opDataObj2.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
+                <span style="font-size: 10px;line-height: 32px;">{{ opDatajson?.svo[1]?.vo.name }}</span>
+                <el-switch v-if="ophasSwitch2.switch" v-model="ophasSwitch2.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
               </el-row>
             </div>
             <div class="content-form content-form-right">
-              <el-form class="custom-form" :label-width="Labelwidth" label-position="left">
-                <template v-for="(item, index) in opDataObj2.body" :key="index">
-                  <!-- 下拉框和输入框(带 label) -->
-                  <el-form-item 
-                    v-if="item.vo.valCodeType !== 'swithType'" 
-                    :label="item.vo.name"
-                  >
-                    <el-select
-                      v-if="item.vo.valType === 1"  
-                      v-model="item.vo.val" 
-                      size="small"
+              <template v-for="(form, formIndex) in opDataObj2" :key="formIndex">
+                <el-form v-show="form.body.length>0" class="custom-form" :label-width="Labelwidth" label-position="left">
+                  <el-form-item v-if="form.header.code !== 'is_cons'"  :label="form.header.name"></el-form-item>
+                  <template v-for="(item, index) in form.body" :key="index">
+                    <!-- 下拉框和输入框(带 label) -->
+                    <el-form-item 
+                      v-if="item.vo.valCodeType !== 'swithType'" 
+                      :label="item.vo.name"
                     >
-                      <el-option
-                        v-for="option in valoption[item.vo.valCodeType]"
-                        :key="option.val"
-                        :label="option.tag"
-                        :value="option.val"
+                      <el-select
+                        v-if="item.vo.valType === 1"  
+                        v-model="item.vo.val" 
+                        size="small"
+                      >
+                        <el-option
+                          v-for="option in valoption[item.vo.valCodeType]"
+                          :key="option.val"
+                          :label="option.tag"
+                          :value="option.val"
+                        />
+                      </el-select>
+                      <el-input 
+                        v-else-if="item.vo.valType === 2"
+                        v-model="item.vo.val" 
+                        size="small"
                       />
-                    </el-select>
-                    <el-input 
-                      v-else-if="item.vo.valType === 2"
-                      v-model="item.vo.val" 
-                      size="small"
-                    />
-                  </el-form-item>
-
-                  <!-- 复选框(无 label、不占位) -->
-                  <el-checkbox 
-                    v-else-if="item.vo.valType === 1 && item.vo.valCodeType === 'swithType'"
-                    v-model="item.vo.val"
-                    class="custom-checkbox"
-                  >
-                    {{ item.vo.name }}
-                  </el-checkbox>
-                </template>
-              </el-form>
+                    </el-form-item>
+
+                    <!-- 复选框(无 label、不占位) -->
+                    <el-checkbox 
+                      v-else-if="item.vo.valType === 1 && item.vo.valCodeType === 'swithType'"
+                      v-model="item.vo.val"
+                      class="custom-checkbox"
+                      true-value = 1
+                      false-value = 0
+                    >
+                      {{ item.vo.name }}
+                    </el-checkbox>
+                  </template>
+                </el-form>
+              </template>
             </div>
           </div>
         </div>
@@ -132,49 +127,52 @@
                 <img src="@/assets/img/yhwt.png" class="content-aside-img" alt="Experiment Icon" />
               </el-row>
               <el-row justify="center" align="middle">
-                <span style="font-size: 10px;line-height: 32px;">{{ opDataObj3.header?.name }}</span>
-                <el-switch v-if="opDataObj3.switch" v-model="opDataObj3.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
+                <span style="font-size: 10px;line-height: 32px;">{{ opDatajson?.svo[2]?.vo.name }}</span>
+                <el-switch v-if="ophasSwitch3.switch" v-model="ophasSwitch3.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
               </el-row>
             </div>
             <div class="content-form content-form-right">
-              <el-form class="custom-form" :label-width="Labelwidth" label-position="left">
-                <template v-for="(item, index) in opDataObj3.body" :key="index">
-                  <!-- 下拉框和输入框(带 label) -->
-                  <el-form-item 
-                    v-if="item.vo.valCodeType !== 'swithType'" 
-                    :label="item.vo.name"
-                  >
-                    <el-select
-                      v-if="item.vo.valType === 1"  
-                      v-model="item.vo.val" 
-                      size="small"
+              <template v-for="(form, formIndex) in opDataObj3" :key="formIndex">
+                <el-form class="custom-form" :label-width="Labelwidth" label-position="left">
+                  <el-form-item v-if="form.header.code !== 'is_cons'"  :label="form.header.name"></el-form-item>
+                  <template v-for="(item, index) in form.body" :key="index">
+                    <!-- 下拉框和输入框(带 label) -->
+                    <el-form-item 
+                      v-if="item.vo.valCodeType !== 'swithType'" 
+                      :label="item.vo.name"
                     >
-                      <el-option
-                        v-for="option in valoption[item.vo.valCodeType]"
-                        :key="option.val"
-                        :label="option.tag"
-                        :value="option.val"
+                      <el-select
+                        v-if="item.vo.valType === 1"  
+                        v-model="item.vo.val" 
+                        size="small"
+                      >
+                        <el-option
+                          v-for="option in valoption[item.vo.valCodeType]"
+                          :key="option.val"
+                          :label="option.tag"
+                          :value="option.val"
+                        />
+                      </el-select>
+                      <el-input 
+                        v-else-if="item.vo.valType === 2"
+                        v-model="item.vo.val" 
+                        size="small"
                       />
-                    </el-select>
-                    <el-input 
-                      v-else-if="item.vo.valType === 2"
-                      v-model="item.vo.val" 
-                      size="small"
-                    />
-                  </el-form-item>
-
-                  <!-- 复选框(无 label、不占位) -->
-                  <el-checkbox 
-                    v-else-if="item.vo.valType === 1 && item.vo.valCodeType === 'swithType'"
-                    v-model="item.vo.val"
-                    class="custom-checkbox"
-                    true-value = 1
-                    false-value = 0
-                  >
-                    {{ item.vo.name }}
-                  </el-checkbox>
-                </template>
-              </el-form>
+                    </el-form-item>
+
+                    <!-- 复选框(无 label、不占位) -->
+                    <el-checkbox 
+                      v-else-if="item.vo.valType === 1 && item.vo.valCodeType === 'swithType'"
+                      v-model="item.vo.val"
+                      class="custom-checkbox"
+                      true-value = 1
+                      false-value = 0
+                    >
+                      {{ item.vo.name }}
+                    </el-checkbox>
+                  </template>
+                </el-form>
+              </template>
             </div>
           </div>
         </div>
@@ -213,9 +211,14 @@ const Labelwidth = '70px';
 const valoption = computed(() => valOptionsStore.valOptionsMap)
 
 const opDataObj  = ref({})
-const opDataObj1  = ref({})
-const opDataObj2  = ref({})
-const opDataObj3  = ref({})
+const opDataObj1  = ref([])
+const opDataObj2  = ref([])
+const opDataObj3  = ref([])
+
+
+const ophasSwitch1 = ref({})
+const ophasSwitch2 = ref({})
+const ophasSwitch3 = ref({})
 
 // 监听 opDatajson 变化
 watch(
@@ -227,18 +230,34 @@ watch(
 );
 
 const getdatainit = () => {
+  // 整体数据
   opDataObj.value = analysisJson(props.opDatajson);
-  opDataObj1.value = analysisJson(props.opDatajson.svo[0]);
-  opDataObj2.value = analysisJson(props.opDatajson.svo[1]);
-  opDataObj3.value = analysisJson(props.opDatajson.svo[2]);
-  // console.log('opDataObj',opDataObj.value);
-  console.log('opDataObj1',opDataObj1.value);
-}
+
+  ophasSwitch1.value = analysisJson(props.opDatajson.svo[0])
+  ophasSwitch2.value = analysisJson(props.opDatajson.svo[1])
+  ophasSwitch3.value = analysisJson(props.opDatajson.svo[2])
+
+  // 生成各个子组的数组
+  const groups = [opDataObj1, opDataObj2, opDataObj3];
+  
+  groups.forEach((targetRef, index) => {
+    const subGroup = props.opDatajson?.svo?.[index]?.svo;
+    targetRef.value = Array.isArray(subGroup)
+      ? subGroup.map(group => analysisJson(group))
+      : [];
+  });
+
+  console.log('props.opDatajson', props.opDatajson);
+  console.log('opDataObj', opDataObj.value);
+  console.log('opDataObj1', opDataObj1.value);
+  console.log('opDataObj2', opDataObj2.value);
+  console.log('opDataObj3', opDataObj3.value);
+};
 
 const gatherData = () => {
-  let opdata1 = saveData(opDataObj1)
-  let opdata2 = saveData(opDataObj2)
-  let opdata3 = saveData(opDataObj3)
+  let opdata1 = saveData(ophasSwitch1)
+  let opdata2 = saveData(ophasSwitch2)
+  let opdata3 = saveData(ophasSwitch3)
   let opdata = [...opdata1,...opdata2,...opdata3]
 
   console.log("op保存数据:", opdata)
@@ -247,10 +266,6 @@ const gatherData = () => {
 
 // 保存前过滤
 const saveData = (obj) => {
-  // 获取当前选中的 选项value
-  const selectValue = obj.value.body
-    .find(item => item?.vo?.valCodeType === 'samplingMethod')?.vo?.val;
-
   // 过滤 body
   const filteredBody = obj.value.body
   .map(item => item.vo);
@@ -308,15 +323,15 @@ defineExpose({gatherData})
 .class-qitan {
   .first-container {
     width: 100%;
-    height: 48%;
+    height: 44%;
   }
   .second-container {
     width: 100%;
-    height: 25%;
+    height: 34%;
   }
   .third-container {
     width: 100%;
-    height: 25%;
+    height: 20%;
   }
 }