瀏覽代碼

812气动页,选项联动,保存

tangjunhao 1 月之前
父節點
當前提交
ff1b7e6065

+ 48 - 6
src/views/mainContent/index.vue

@@ -4,22 +4,22 @@
       <el-container style="height: 100%;">
         <el-aside class="leftaside">
           <div class="left-1">
-            <ex-design :exDatajson="oneData"/>
+            <ex-design ref="exRef" :exDatajson="oneData"/>
           </div>
           <div class="left-2">
-            <agent-model :amDatajson="twoData"/>
+            <agent-model ref="amRef" :amDatajson="twoData"/>
           </div>
           <div class="left-3">
-            <op-algorithm :oaDatajson="thirdData"/>
+            <op-algorithm ref="oaRef" :oaDatajson="thirdData"/>
           </div>
           <div class="left-4">
-            <op-run />
+            <op-run :type="type" @saveAllData="projectinfochange"/>
           </div>
         </el-aside>
         <el-main></el-main>
         <el-aside class="rightaside">
           <div class="right-1">
-            <op-problem :opDatajson="fourData" :runtype="type"/>
+            <op-problem ref="opRef" :opDatajson="fourData" :runtype="type"/>
           </div>
           <div class="right-2">
             <analyze-work />
@@ -61,6 +61,11 @@ const oneData = ref()
 const twoData = ref()
 const thirdData = ref()
 const fourData = ref()
+const exRef = ref()
+const amRef = ref()
+const oaRef = ref()
+const opRef = ref()
+
 const valType1Items = ref()
 
 
@@ -80,6 +85,7 @@ const getProjectInit = () => {
       thirdData.value = projectInitJson.value[2];
       fourData.value = projectInitJson.value[3];
 
+      // 初始化选项
       valType1Items.value = findValType1Items(projectInitJson.value);
       // 去重
       const valCodeTypes = [
@@ -106,7 +112,7 @@ const getProjectInit = () => {
         console.log(err);
       });
 
-      console.log('xuanxiang',valType1Items);
+      console.log('选项',valType1Items);
 
       // console.log(oneData.value);
     })
@@ -145,6 +151,42 @@ function findValType1Items(nodes) {
   return result;
 }
 
+
+// 项目属性添加修改
+const projectinfochange = () => {
+  let exdata = exRef.value.saveData();
+  let amdata = amRef.value.saveData();
+  let oadata = oaRef.value.saveData();
+  let opdata = opRef.value.gatherData();
+
+  let allData = [...exdata,...amdata,...oadata,...opdata];
+
+  console.log('alldata',allData);
+
+  let rows = allData.map(item => ({
+    pid:pid.value,
+    attId:item.attId,
+    pattId: item.pattId,
+    val: item.val
+  }) )
+  
+
+  const params = {
+    transCode: 'AC00005',
+    rows:rows
+  }
+  request(params)
+    .then((res) => {
+      // ElMessage.success('保存成功');
+    })
+    .catch((err) => {
+      console.error(err);
+      ElMessage.error(err.returnMsg || '保存失败');
+    });
+}
+
+
+
 onMounted(() => {
   getProjectInit();
 });

+ 35 - 2
src/views/mainContent/js/analysisData.js

@@ -1,3 +1,7 @@
+import { request } from "@/utils/request";
+import { ElMessage } from 'element-plus'
+
+
 // 递归处理函数,展平节点并过滤 code === "switch" 的节点
 export function flattenBody(nodes) {
   let result = [];
@@ -25,10 +29,39 @@ export function analysisJson(data) {
 
   if (data?.svo) {
     const switchItem = data.svo.find(item => item?.vo?.code === "switch");
-    DataObj['swich'] = switchItem?.vo || null;
+    DataObj['switch'] = switchItem?.vo || null;
   } else {
-    DataObj['swich'] = null;
+    DataObj['switch'] = null;
   }
 
   return DataObj;
 }
+
+
+export function delChangeInfo (obj) {
+  const filteredBody = obj.value.body
+  .map(item => item.vo);
+  const switchObj = obj.value.switch
+  const saveArr = switchObj ? [...filteredBody, switchObj] : filteredBody;
+
+  let rows = saveArr.filter(item => item.pattId != null && item.pattId !== '')
+    .map(item => ({
+      pattId:item.pattId
+    }))
+  
+  const params = {
+    transCode: 'AC00007',
+    rows: rows,
+  };   
+  if(rows.length > 0) {
+    request(params)
+      .then((res) => {
+        console.log('删除成功',res)
+        // ElMessage.success('删除成功');
+      })
+      .catch((err) => {
+        console.error(err);
+        ElMessage.error(err.returnMsg || '删除失败');
+      });
+  }
+}

+ 55 - 5
src/views/mainContent/leftaside/agentModel.vue

@@ -12,13 +12,15 @@
             <template v-for="(item, index) in amDataObj.body" :key="index">
               <!-- 下拉框和输入框(带 label) -->
               <el-form-item 
-                v-if="item.vo.valCodeType !== 'swithType' && item.vo.code !== 'from_file'" 
+                v-if="item.vo.valCodeType !== 'swithType' && item.vo.code !== 'from_file'"
+                v-show="shouldShowItem(getNameVal(), item.vo.attId)" 
                 :label="item.vo.name"
               >
                 <el-select
                   v-if="item.vo.valType === 1"  
                   v-model="item.vo.val" 
                   size="small"
+                  v-on="item.vo.attId === 'a23' ? { change: handleNameChange } : {}"
                 >
                   <el-option
                     v-for="option in valoption[item.vo.valCodeType]"
@@ -35,7 +37,8 @@
               </el-form-item>
 
               <el-form-item 
-                v-else-if="item.vo.code === 'from_file'" 
+                v-else-if="item.vo.code === 'from_file'"
+                v-show="shouldShowItem(getNameVal(), item.vo.attId)" 
                 :label="item.vo.name"
               >
                 <el-input 
@@ -52,6 +55,7 @@
               <!-- 复选框(无 label、不占位) -->
               <el-checkbox 
                 v-else-if="item.vo.valType === 1 && item.vo.valCodeType === 'swithType'"
+                v-show="shouldShowItem(getNameVal(), item.vo.attId)"
                 v-model="item.vo.val"
                 class="custom-checkbox"
               >
@@ -66,8 +70,8 @@
             <img src="@/assets/img/dlmx.png" class="content-aside-img" alt="Experiment Icon" />
           </el-row>
           <el-row justify="center" align="middle">
-            <span style="font-size: 10px;">{{ amDataObj.swich?.name }}</span>
-            <el-switch v-if="amDataObj.swich" v-model="amDataObj.swich.val" active-value="1" inactive-value="0"
+            <span style="font-size: 10px;">{{ amDataObj.switch?.name }}</span>
+            <el-switch v-if="amDataObj.switch" v-model="amDataObj.switch.val" active-value="1" inactive-value="0"
               class="custom-switch custom-switch-colors" />
           </el-row>
         </div>
@@ -77,7 +81,7 @@
 </template>
 
 <script setup>
-import { analysisJson } from '../js/analysisData.js'
+import { analysisJson, delChangeInfo } from '../js/analysisData.js'
 
 import { useValOptionsStore } from '@/store/valoptions'
 import { FolderOpened } from '@element-plus/icons-vue'
@@ -111,4 +115,50 @@ const getdatainit = () => {
 }
 
 
+// 删除项目属性
+const handleNameChange = () => {
+  delChangeInfo(amDataObj);
+}
+
+// 代理模型
+const getNameVal = () => {
+  const target = amDataObj.value.body.find(item => item?.vo?.valCodeType === 'selectModel');
+  return target?.vo?.val ?? null;
+}
+
+const linkageRules = {
+  '0': ['a22','a23','a241', 'a242'], // 选Kriging时显示
+  '1': ['a22','a23','a243'],              // 选最近邻
+  '2': ['a22','a23'],                      // 选响应面
+}
+
+const shouldShowItem = (currentValue = '0', targetCode) => {
+  return linkageRules[currentValue]?.includes(targetCode) ?? false
+}
+
+// 保存前过滤
+const saveData = () => {
+  // 获取当前选中的 选项value
+  const selectValue = getNameVal()
+
+  // 根据规则过滤出要保留的 attId
+  const allowedAttIds = linkageRules[selectValue] || [];
+
+  // 过滤 body
+  const filteredBody = amDataObj.value.body
+  .filter(item => allowedAttIds.includes(item.vo?.attId))
+  .map(item => item.vo);
+
+  const switchObj = amDataObj.value.switch
+  const saveArr = switchObj ? [...filteredBody, switchObj] : filteredBody;
+
+  console.log("am保存数据:", saveArr);
+  // 这里执行你的上传或保存逻辑
+  return saveArr;
+};
+
+defineExpose({saveData})
+
+
+
 </script>

+ 52 - 5
src/views/mainContent/leftaside/exDesign.vue

@@ -11,8 +11,8 @@
             <img src="@/assets/img/sysj.png" class="content-aside-img" alt="Experiment Icon" />
           </el-row>
           <el-row justify="center" align="middle" >
-            <span style="font-size: 10px;">{{ exDataObj.swich?.name }}</span>
-            <el-switch v-if="exDataObj.swich" v-model="exDataObj.swich.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
+            <span style="font-size: 10px;">{{ exDataObj.switch?.name }}</span>
+            <el-switch v-if="exDataObj.switch" v-model="exDataObj.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
           </el-row>
         </div>
         <div class="content-form content-form-right">
@@ -20,13 +20,15 @@
             <template v-for="(item, index) in exDataObj.body" :key="index">
               <!-- 下拉框和输入框(带 label) -->
               <el-form-item 
-                v-if="item.vo.valCodeType !== 'swithType'" 
+                v-if="item.vo.valCodeType !== 'swithType'"
+                v-show="shouldShowItem(getNameVal(), item.vo.attId)"
                 :label="item.vo.name"
               >
                 <el-select
                   v-if="item.vo.valType === 1"  
                   v-model="item.vo.val" 
                   size="small"
+                  v-on="item.vo.attId === 'a12' ? { change: handleNameChange } : {}"
                 >
                   <el-option
                     v-for="option in valoption[item.vo.valCodeType]"
@@ -45,6 +47,7 @@
               <!-- 复选框(无 label、不占位) -->
               <el-checkbox 
                 v-else-if="item.vo.valType === 1 && item.vo.valCodeType === 'swithType'"
+                v-show="shouldShowItem(getNameVal(), item.vo.attId)"
                 v-model="item.vo.val"
                 class="custom-checkbox"
               >
@@ -59,7 +62,7 @@
 </template>
 
 <script setup>
-import { analysisJson } from '../js/analysisData.js'
+import { analysisJson, delChangeInfo } from '../js/analysisData.js'
 
 import { useValOptionsStore } from '@/store/valoptions'
 
@@ -88,11 +91,55 @@ watch(
 
 const getdatainit = () => {
   exDataObj.value = analysisJson(props.exDatajson);
-  // console.log('exDataObj', exDataObj.value );
+  console.log('exDataObj', exDataObj.value );
   
 }
 
+// 删除项目属性
+const handleNameChange = () => {
+  delChangeInfo(exDataObj);
+}
+
+
+// 试验设计
+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
+}
+
+// 保存前过滤
+const saveData = () => {
+  // 获取当前选中的 选项value
+  const selectValue = getNameVal()
+
+  // 根据规则过滤出要保留的 attId
+  const allowedAttIds = linkageRules[selectValue] || [];
+
+  // 过滤 body
+  const filteredBody = exDataObj.value.body
+  .filter(item => allowedAttIds.includes(item.vo?.attId))
+  .map(item => item.vo);
+
+  const switchObj = exDataObj.value.switch
+  const saveArr = switchObj ? [...filteredBody, switchObj] : filteredBody;
+
+  console.log("ex保存数据:", saveArr);
+  // 这里执行你的上传或保存逻辑
+  return saveArr;
+};
 
+defineExpose({saveData})
 
 </script>
 

+ 51 - 3
src/views/mainContent/leftaside/opAlgorithm.vue

@@ -11,8 +11,8 @@
             <img src="@/assets/img/yhsf.png" class="content-aside-img" alt="Experiment Icon" />
           </el-row>
           <el-row justify="center" align="middle" >
-            <span style="font-size: 10px;">{{ oaDataObj.swich?.name }}</span>
-            <el-switch v-if="oaDataObj.swich" v-model="oaDataObj.swich.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
+            <span style="font-size: 10px;">{{ oaDataObj.switch?.name }}</span>
+            <el-switch v-if="oaDataObj.switch" v-model="oaDataObj.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
           </el-row>
         </div>
         <div class="content-form content-form-right">
@@ -20,13 +20,15 @@
             <template v-for="(item, index) in oaDataObj.body" :key="index">
               <!-- 下拉框和输入框(带 label) -->
               <el-form-item 
-                v-if="item.vo.valCodeType !== 'swithType'" 
+                v-if="item.vo.valCodeType !== 'swithType'"
+                v-show="shouldShowItem(getNameVal(), item.vo.attId)"
                 :label="item.vo.name"
               >
                 <el-select
                   v-if="item.vo.valType === 1"  
                   v-model="item.vo.val" 
                   size="small"
+                  v-on="item.vo.attId === 'a12' ? { change: handleNameChange } : {}"
                 >
                   <el-option
                     v-for="option in valoption[item.vo.valCodeType]"
@@ -45,6 +47,7 @@
               <!-- 复选框(无 label、不占位) -->
               <el-checkbox 
                 v-else-if="item.vo.valType === 1 && item.vo.valCodeType === 'swithType'"
+                v-show="shouldShowItem(getNameVal(), item.vo.attId)"
                 v-model="item.vo.val"
                 class="custom-checkbox"
               >
@@ -88,6 +91,51 @@ watch(
 
 const getdatainit = () => {
   oaDataObj.value = analysisJson(props.oaDatajson);
+  console.log('oaDataObj', oaDataObj.value );
 }
 
+// 删除项目属性
+const handleNameChange = () => {
+  delChangeInfo(oaDataObj);
+}
+
+// 优化算法
+const getNameVal = () => {
+  const target = oaDataObj.value.body.find(item => item?.vo?.valCodeType === 'optimizerType');
+  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 shouldShowItem = (currentValue = 'ScipyOptimizeDriver', targetCode) => {
+  return linkageRules[currentValue]?.includes(targetCode) ?? false
+}
+
+// 保存前过滤
+const saveData = () => {
+  // 获取当前选中的 选项value
+  const selectValue = getNameVal()
+
+  // 根据规则过滤出要保留的 attId
+  const allowedAttIds = linkageRules[selectValue] || [];
+
+  // 过滤 body
+  const filteredBody = oaDataObj.value.body
+  .filter(item => allowedAttIds.includes(item.vo?.attId))
+  .map(item => item.vo);
+
+  const switchObj = oaDataObj.value.switch
+  const saveArr = switchObj ? [...filteredBody, switchObj] : filteredBody;
+
+  console.log("oa保存数据:", saveArr);
+  // 这里执行你的上传或保存逻辑
+  return saveArr;
+};
+
+defineExpose({saveData})
+
 </script>

+ 38 - 1
src/views/mainContent/leftaside/opRun.vue

@@ -6,7 +6,7 @@
         <span>优化运行</span>
       </template>
       <div class="container">
-        <div class="container-item">
+        <div class="container-item" @click="startRun">
           <img src="@/assets/img/start.png" class="container-img" alt="Experiment Icon" />
           <span class="container-text">开始</span>
         </div>
@@ -20,6 +20,43 @@
 </template>
 
 <script setup>
+import { request, enPassword } from "@/utils/request";
+import { ElMessage, ElMessageBox } from 'element-plus'
+
+import { useProjectStore } from '@/store/project'
+
+const emit = defineEmits(['saveAllData'])
+
+const projectStore = useProjectStore()
+
+const props = defineProps({
+  type: {
+    type: Number,
+    default:0
+  }
+})
+
+const pid = computed(() => projectStore.pid)
+
+
+const startRun = () => {
+  emit('saveAllData')
+  const params = {
+    transCode: 'AC00006',
+    pid: pid.value,
+    type: props.type
+  };
+  request(params)
+    .then((res) => {
+      ElMessage.success('开始运行')
+    })
+    .catch((err) => {
+      console.error(err);
+      ElMessage.error(err.returnMsg);
+    })
+}
+
+
 
 </script>
 

+ 2 - 0
src/views/mainContent/rightaside/analyzeWork.vue

@@ -35,6 +35,7 @@ import jiegou1 from '@/assets/img/jiegou1.png'
 import qitan1 from '@/assets/img/qitan1.png'
 
 const selectedWork = ref('气动')
+const type = ref(0)
 
 const btninfo = ref([
   { name: '气动', img: qidong, highlightImg: qidong1 },
@@ -44,6 +45,7 @@ const btninfo = ref([
 
 const handleWorkClick = (name) => {
   selectedWork.value = name
+  
 }
 
 </script>

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

@@ -14,7 +14,7 @@
               </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.swich" v-model="opDataObj1.swich.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
+                <el-switch v-if="opDataObj1.switch" v-model="opDataObj1.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
               </el-row>
             </div>
             <div class="content-form content-form-right">
@@ -81,7 +81,7 @@
               </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.swich" v-model="opDataObj2.swich.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
+                <el-switch v-if="opDataObj2.switch" v-model="opDataObj2.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
               </el-row>
             </div>
             <div class="content-form content-form-right">
@@ -133,7 +133,7 @@
               </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.swich" v-model="opDataObj3.swich.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
+                <el-switch v-if="opDataObj3.switch" v-model="opDataObj3.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
               </el-row>
             </div>
             <div class="content-form content-form-right">
@@ -229,9 +229,39 @@ const getdatainit = () => {
   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);
 }
 
+const gatherData = () => {
+  let opdata1 = saveData(opDataObj1)
+  let opdata2 = saveData(opDataObj2)
+  let opdata3 = saveData(opDataObj3)
+  let opdata = [...opdata1,...opdata2,...opdata3]
+
+  console.log("op保存数据:", opdata)
+  return opdata
+}
+
+// 保存前过滤
+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);
+
+  const switchObj = obj.value.switch
+  const saveArr = switchObj ? [...filteredBody, switchObj] : filteredBody;
+
+  // 这里执行你的上传或保存逻辑
+  return saveArr;
+};
+
+defineExpose({gatherData})
+
 
 </script>
 

+ 1 - 0
src/views/project/index.vue

@@ -189,6 +189,7 @@ const addProject = () => {
       getprojectlist();
     })
     .catch((err) => {
+      console.error(err);
       ElMessage.error(err.returnMsg);
     });
 };