瀏覽代碼

813类型切换

tangjunhao 4 周之前
父節點
當前提交
8a791c051c

+ 66 - 32
src/views/mainContent/index.vue

@@ -4,13 +4,13 @@
       <el-container style="height: 100%;">
         <el-aside class="leftaside">
           <div class="left-1">
-            <ex-design ref="exRef" :exDatajson="oneData"/>
+            <ex-design ref="exRef" :type="type" :exDatajson="oneData"/>
           </div>
           <div class="left-2">
-            <agent-model ref="amRef" :amDatajson="twoData"/>
+            <agent-model ref="amRef" :type="type" :amDatajson="twoData" :isfileup="isButtonEnabled"/>
           </div>
           <div class="left-3">
-            <op-algorithm ref="oaRef" :oaDatajson="thirdData"/>
+            <op-algorithm ref="oaRef" :type="type" :oaDatajson="thirdData"/>
           </div>
           <div class="left-4">
             <op-run :type="type" @saveAllData="projectinfochange"/>
@@ -19,10 +19,10 @@
         <el-main></el-main>
         <el-aside class="rightaside">
           <div class="right-1">
-            <op-problem ref="opRef" :opDatajson="fourData" :runtype="type"/>
+            <op-problem ref="opRef" :type="type" :opDatajson="fourData" :runtype="type"/>
           </div>
           <div class="right-2">
-            <analyze-work />
+            <analyze-work @changetype="handleTypeChange"/>
           </div>
         </el-aside>
       </el-container>
@@ -153,39 +153,73 @@ function findValType1Items(nodes) {
 
 
 // 项目属性添加修改
-const projectinfochange = () => {
-  let exdata = exRef.value.saveData();
-  let amdata = amRef.value.saveData();
-  let oadata = oaRef.value.saveData();
-  let opdata = opRef.value.gatherData();
+const projectinfochange = async () => {
+  try {
+    const exdata = exRef.value.saveData();
+    const amdata = amRef.value.saveData();
+    const oadata = oaRef.value.saveData();
+    const opdata = opRef.value.gatherData();
+
+    // 合并数据
+    const allData = [...exdata, ...amdata, ...oadata, ...opdata];
+    console.log('alldata', allData);
+
+    // 格式化 rows
+    const rows = allData.map(item => ({
+      pid: pid.value,
+      attId: item.attId,
+      pattId: item.pattId,
+      val: item.val
+    }));
+
+    // 发请求
+    const params = {
+      transCode: 'AC00005',
+      rows
+    };
+
+    const res = await request(params);
+    // ElMessage.success('保存成功');
+  } catch (err) {
+    console.error(err);
+    ElMessage.error(err.returnMsg || '保存失败');
+  }
+};
 
-  let allData = [...exdata,...amdata,...oadata,...opdata];
+// 分析工况类型切换
+const handleTypeChange = async (val) => {
+  console.log('type', val);
+  await projectinfochange();
+  type.value = val;
+};
 
-  console.log('alldata',allData);
 
-  let rows = allData.map(item => ({
-    pid:pid.value,
-    attId:item.attId,
-    pattId: item.pattId,
-    val: item.val
-  }) )
-  
+// 代理模型文件上传是否可用
+const isButtonEnabled = computed(() => {
+  const DOE = exRef.value?.exDataObj?.switch?.val;
+  const SMT = amRef.value?.amDataObj?.switch?.val;
+  const OPT = oaRef.value?.oaDataObj?.switch?.val;
+  // console.log('[调试] DOE:', DOE, 'SMT:', SMT, 'OPT:', OPT );
 
-  const params = {
-    transCode: 'AC00005',
-    rows:rows
-  }
-  request(params)
-    .then((res) => {
-      // ElMessage.success('保存成功');
-    })
-    .catch((err) => {
-      console.error(err);
-      ElMessage.error(err.returnMsg || '保存失败');
-    });
-}
+  // 情况 3: DOE关, SMT开, OPT关
+  const case3 = DOE === '0' && SMT === '1' && OPT === '0';
+
+  // 情况 6: DOE关, SMT开, OPT开
+  const case6 = DOE === '0' && SMT === '1' && OPT === '1';
 
+  // console.log('[调试] case3:', case3, 'case6:', case6, '最终可用:', case3 || case6);
 
+  return case3 || case6;
+});
+
+
+// 监听 type 的变化
+watch(
+  () => type.value,
+  (newVal) => {
+    getProjectInit();
+  }
+)
 
 onMounted(() => {
   getProjectInit();

+ 1 - 1
src/views/mainContent/js/analysisData.js

@@ -46,7 +46,7 @@ export function delChangeInfo (obj) {
 
   let rows = saveArr.filter(item => item.pattId != null && item.pattId !== '')
     .map(item => ({
-      pattId:item.pattId
+      pattId:item.pattId,
     }))
   
   const params = {

+ 31 - 10
src/views/mainContent/leftaside/agentModel.vue

@@ -47,7 +47,7 @@
                   size="small"
                 >
                   <template #append>
-                    <el-button :icon="FolderOpened" />
+                    <el-button :icon="FolderOpened" :disabled="!isfileup" @click="handleFileUp"/>
                   </template>
                 </el-input>
               </el-form-item>
@@ -58,6 +58,8 @@
                 v-show="shouldShowItem(getNameVal(), item.vo.attId)"
                 v-model="item.vo.val"
                 class="custom-checkbox"
+                true-value = 1
+                false-value = 0
               >
                 {{ item.vo.name }}
               </el-checkbox>
@@ -89,8 +91,16 @@ import { FolderOpened } from '@element-plus/icons-vue'
 const valOptionsStore = useValOptionsStore()
 
 const props = defineProps({
+  type: {
+    type: Number,
+    default:0
+  },
   amDatajson: {
     type: Object,
+  },
+  isfileup: {
+    type: Boolean,
+    default: false
   }
 })
 
@@ -126,14 +136,21 @@ const getNameVal = () => {
   return target?.vo?.val ?? null;
 }
 
-const linkageRules = {
-  '0': ['a22','a23','a241', 'a242'], // 选Kriging时显示
-  '1': ['a22','a23','a243'],              // 选最近邻
-  '2': ['a22','a23'],                      // 选响应面
-}
+const generateRules = (prefix) => ({
+  '0': [`${prefix}22`, `${prefix}23`, `${prefix}241`, `${prefix}242`], // Kriging
+  '1': [`${prefix}22`, `${prefix}23`, `${prefix}243`],                 // 最近邻
+  '2': [`${prefix}22`, `${prefix}23`],                                 // 响应面
+});
+
+const linkageRulesMap = {
+  0: generateRules('a'),
+  1: generateRules('b'),
+  2: generateRules('c'),
+};
 
 const shouldShowItem = (currentValue = '0', targetCode) => {
-  return linkageRules[currentValue]?.includes(targetCode) ?? false
+  const rules = linkageRulesMap[props.type] || {}; // 取当前 type 对应规则
+  return rules[currentValue]?.includes(targetCode) ?? false
 }
 
 // 保存前过滤
@@ -141,8 +158,9 @@ const saveData = () => {
   // 获取当前选中的 选项value
   const selectValue = getNameVal()
 
+  const rules = linkageRulesMap[props.type] || {}; 
   // 根据规则过滤出要保留的 attId
-  const allowedAttIds = linkageRules[selectValue] || [];
+  const allowedAttIds = rules[selectValue] || [];
 
   // 过滤 body
   const filteredBody = amDataObj.value.body
@@ -157,8 +175,11 @@ const saveData = () => {
   return saveArr;
 };
 
-defineExpose({saveData})
-
 
+const handleFileUp = () => {
+  console.log('file up');
+  
+}
 
+defineExpose({amDataObj, saveData})
 </script>

+ 47 - 13
src/views/mainContent/leftaside/exDesign.vue

@@ -50,6 +50,8 @@
                 v-show="shouldShowItem(getNameVal(), item.vo.attId)"
                 v-model="item.vo.val"
                 class="custom-checkbox"
+                true-value = 1
+                false-value = 0
               >
                 {{ item.vo.name }}
               </el-checkbox>
@@ -69,6 +71,10 @@ import { useValOptionsStore } from '@/store/valoptions'
 const valOptionsStore = useValOptionsStore()
 
 const props = defineProps({
+  type: {
+    type: Number,
+    default:0
+  },
   exDatajson: {
     type: Object,
   }
@@ -102,29 +108,57 @@ const handleNameChange = () => {
 
 
 // 试验设计
+// const getNameVal = () => {
+//   const target = exDataObj.value.body.find(item => item?.vo?.valCodeType === 'samplingMethod');
+//   return target?.vo?.val ?? null;
+// }
+
+// const linkageRules = {
+//   LatinHypercubeGenerator: ['a11','a12','a141', 'a142'], // 选拉丁超立方时显示
+//   BoxBehnkenGenerator: ['a11','a12','a143'],              // 选BoxBehnken
+//   PlackettBurmanGenerator: ['a11','a12'],                      // 选PlackettBurman
+//   FullFactorialGenerator:['a11','a12','a144']                         //全因子设计
+// }
+
+// const shouldShowItem = (currentValue = 'LatinHypercubeGenerator', targetCode) => {
+//   return linkageRules[currentValue]?.includes(targetCode) ?? false
+// }
+
+// 不同 type 下的 linkageRules
+const generateGeneratorRules = (prefix) => ({
+  LatinHypercubeGenerator: [`${prefix}11`, `${prefix}12`, `${prefix}141`, `${prefix}142`],
+  BoxBehnkenGenerator: [`${prefix}11`, `${prefix}12`, `${prefix}143`],
+  PlackettBurmanGenerator: [`${prefix}11`, `${prefix}12`],
+  FullFactorialGenerator: [`${prefix}11`, `${prefix}12`, `${prefix}144`],
+});
+
+const linkageRulesMap = {
+  0: generateGeneratorRules('a'),
+  1: generateGeneratorRules('b'),
+  2: generateGeneratorRules('c'),
+};
+
 const getNameVal = () => {
-  const target = exDataObj.value.body.find(item => item?.vo?.valCodeType === 'samplingMethod');
+  const target = exDataObj.value.body.find(
+    item => item?.vo?.valCodeType === 'samplingMethod'
+  );
   return target?.vo?.val ?? null;
-}
-
-const linkageRules = {
-  LatinHypercubeGenerator: ['a11','a12','a141', 'a142'], // 选拉丁超立方时显示
-  BoxBehnkenGenerator: ['a11','a12','a143'],              // 选BoxBehnken
-  PlackettBurmanGenerator: ['a11','a12'],                      // 选PlackettBurman
-  FullFactorialGenerator:['a11','a12','a144']                         //全因子设计
-}
+};
 
+// 判断是否显示
 const shouldShowItem = (currentValue = 'LatinHypercubeGenerator', targetCode) => {
-  return linkageRules[currentValue]?.includes(targetCode) ?? false
-}
+  const rules = linkageRulesMap[props.type] || {}; // 取当前 type 对应规则
+  return rules[currentValue]?.includes(targetCode) ?? false;
+};
 
 // 保存前过滤
 const saveData = () => {
   // 获取当前选中的 选项value
   const selectValue = getNameVal()
 
+  const rules = linkageRulesMap[props.type] || {};
   // 根据规则过滤出要保留的 attId
-  const allowedAttIds = linkageRules[selectValue] || [];
+  const allowedAttIds = rules[selectValue] || [];
 
   // 过滤 body
   const filteredBody = exDataObj.value.body
@@ -139,7 +173,7 @@ const saveData = () => {
   return saveArr;
 };
 
-defineExpose({saveData})
+defineExpose({exDataObj, saveData})
 
 </script>
 

+ 40 - 8
src/views/mainContent/leftaside/opAlgorithm.vue

@@ -50,6 +50,8 @@
                 v-show="shouldShowItem(getNameVal(), item.vo.attId)"
                 v-model="item.vo.val"
                 class="custom-checkbox"
+                true-value = 1
+                false-value = 0
               >
                 {{ item.vo.name }}
               </el-checkbox>
@@ -69,6 +71,10 @@ import { useValOptionsStore } from '@/store/valoptions'
 const valOptionsStore = useValOptionsStore()
 
 const props = defineProps({
+  type: {
+    type: Number,
+    default:0
+  },
   oaDatajson: {
     type: Object,
   }
@@ -105,14 +111,39 @@ const getNameVal = () => {
   return target?.vo?.val ?? null;
 }
 
-const linkageRules = {
-  ScipyOptimizeDriver: ['a31','a334', 'a331', 'a332', 'a333'], // 选ScipyOptimizeDriver时显示
-  pyOptSparseDriver: ['a31','a335','a336','a337'],// 选pyOptSparseDriver
-  DifferentialEvolutionDriver: ['a31','a338','a339','a3310','a3311','a3312'],// 选DifferentialEvolutionDriver
-}
+const generateDriverRules = (prefix) => ({
+  ScipyOptimizeDriver: [
+    `${prefix}31`, 
+    `${prefix}334`, 
+    `${prefix}331`, 
+    `${prefix}332`, 
+    `${prefix}333`,
+  ],
+  pyOptSparseDriver: [
+    `${prefix}31`, 
+    `${prefix}335`, 
+    `${prefix}336`, 
+    `${prefix}337`,
+  ],
+  DifferentialEvolutionDriver: [
+    `${prefix}31`, 
+    `${prefix}338`, 
+    `${prefix}339`, 
+    `${prefix}3310`, 
+    `${prefix}3311`, 
+    `${prefix}3312`,
+  ],
+});
+
+const linkageRulesMap = {
+  0: generateDriverRules('a'),
+  1: generateDriverRules('b'),
+  2: generateDriverRules('c'),
+};
 
 const shouldShowItem = (currentValue = 'ScipyOptimizeDriver', targetCode) => {
-  return linkageRules[currentValue]?.includes(targetCode) ?? false
+  const rules = linkageRulesMap[props.type] || {};
+  return rules[currentValue]?.includes(targetCode) ?? false
 }
 
 // 保存前过滤
@@ -120,8 +151,9 @@ const saveData = () => {
   // 获取当前选中的 选项value
   const selectValue = getNameVal()
 
+  const rules = linkageRulesMap[props.type] || {};
   // 根据规则过滤出要保留的 attId
-  const allowedAttIds = linkageRules[selectValue] || [];
+  const allowedAttIds = rules[selectValue] || [];
 
   // 过滤 body
   const filteredBody = oaDataObj.value.body
@@ -136,6 +168,6 @@ const saveData = () => {
   return saveArr;
 };
 
-defineExpose({saveData})
+defineExpose({oaDataObj, saveData})
 
 </script>

+ 9 - 7
src/views/mainContent/rightaside/analyzeWork.vue

@@ -10,7 +10,7 @@
           <el-button
             :key="item.name"
             class="work-btn"
-            @click="handleWorkClick(item.name)"
+            @click="handleWorkClick(item)"
           >
             <img
               :src="selectedWork === item.name ? item.highlightImg : item.img"
@@ -37,15 +37,17 @@ import qitan1 from '@/assets/img/qitan1.png'
 const selectedWork = ref('气动')
 const type = ref(0)
 
+const emit = defineEmits(['changetype'])
+
 const btninfo = ref([
-  { name: '气动', img: qidong, highlightImg: qidong1 },
-  { name: '结构', img: jiegou, highlightImg: jiegou1 },
-  { name: '气弹', img: qitan, highlightImg: qitan1 },
+  { type: 0, name: '气动', img: qidong, highlightImg: qidong1 },
+  { type: 1, name: '结构', img: jiegou, highlightImg: jiegou1 },
+  { type: 2, name: '气弹', img: qitan, highlightImg: qitan1 },
 ])
 
-const handleWorkClick = (name) => {
-  selectedWork.value = name
-  
+const handleWorkClick = (item) => {
+  selectedWork.value = item.name
+  emit('changetype',item.type)
 }
 
 </script>

+ 5 - 3
src/views/mainContent/rightaside/opProblem.vue

@@ -168,6 +168,8 @@
                     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>
@@ -291,15 +293,15 @@ defineExpose({gatherData})
 .class-jiegou {
   .first-container {
     width: 100%;
-    height: 48%;
+    height: 33%;
   }
   .second-container {
     width: 100%;
-    height: 25%;
+    height: 33%;
   }
   .third-container {
     width: 100%;
-    height: 25%;
+    height: 33%;
   }
 }