Ver Fonte

增加接口,bug修改

tangjunhao há 7 meses atrás
pai
commit
55176442c5

+ 6 - 1
src/style/index.css

@@ -119,6 +119,11 @@ body{
 .item1, .item2 {
     cursor: pointer;
 }
+
+.threelist :hover{
+    background-color: #f1f0f0;
+}
+
 .imgzong .item2 .el-image{
     margin: 0 19px;
     width: 60px;
@@ -540,7 +545,7 @@ text-align: left;
 }
 .custom-tree{
   width: 195px;
-height: 180px;
+height: 20%;
 background: #fafafa;
 border-radius: 0px 0px 0px 0px;
 border: 1px solid #B3B3B3;

+ 27 - 8
src/views/home.vue

@@ -149,7 +149,7 @@
               <el-tab-pane label="可视化" name="Config">
                 <div class="imgzong">
                   <!-- <button @click="etImgPath()"></button> -->
-                  <div class="listitem lbg_color3 bkcolor3" v-for="(item, index) in question" :key="'Config-' + index"
+                  <div class="listitem lbg_color3 bkcolor3 threelist" v-for="(item, index) in question" :key="'Config-' + index"
                     :class="{ activeOrange: active == 'Config-' + index }"
                     @click="clickgeometry($event, index, 'Config-' + index, item.titlie)">
                     <div class="item2 ">
@@ -161,7 +161,7 @@
               </el-tab-pane>
               <el-tab-pane label="数据库管理" name="Seven">
                 <div class="imgzong">
-                  <div class="listitem lbg_color3 bkcolor3" v-for="(item, index) in Sevenlist" :key="'Seven' + index"
+                  <div class="listitem lbg_color3 bkcolor3 threelist" v-for="(item, index) in Sevenlist" :key="'Seven' + index"
                     :class="{ activeOrange: active == 'Seven' + index }"
                     @click="clickgeometry($event, index, 'Seven' + index, item.titlie)">
                     <div class="item2 ">
@@ -173,7 +173,7 @@
               </el-tab-pane>
               <el-tab-pane label="帮助" name="eight">
                 <div class="imgzong">
-                  <div class="listitem lbg_color3 bkcolor3" v-for="(item, index) in eightlist" :key="'eight' + index"
+                  <div class="listitem lbg_color3 bkcolor3 threelist" v-for="(item, index) in eightlist" :key="'eight' + index"
                     :class="{ activeOrange: active == 'eight' + index }"
                     @click="clickgeometry($event, index, 'eight' + index, item.titlie)">
                     <div class="item2 ">
@@ -1779,7 +1779,20 @@ let Sidebarref = ref();
 let resource=ref(0);
 let cstnum=ref('');
 let textarea2=ref()
-let textarea1=ref("import os\nnimport numpy as np+\nfrom surromdao.solver import BaseSolv+\nclass Branin(BaseSolver):+\ndef __init__(self, filename=os.pa+\nsuper().__init__(filename)+\ndef compute(self, xdict):+\nx= np.zeros(2)+\n#x[0] = xdict['x1']+\n#x[1] = xdict['x2']");
+
+let textarea1 = ref(`import os
+import numpy as np
+from surromdao.solver import BaseSolver
+
+class Branin(BaseSolver):
+    def __init__(self, filename=os.path):
+        super().__init__(filename)
+    
+    def compute(self, xdict):
+        x = np.zeros(2)
+        # x[0] = xdict['x1']
+        # x[1] = xdict['x2']`);
+
 let Joptimizeref=ref();
 let Doptimizeref=ref();
 let Toptimizeref=ref();
@@ -2491,15 +2504,21 @@ const initoptimize = () => {
 const initPython = () => {
   console.log('Pythonchushihua');
   const param = {
-    transCode:'MDO0036',
+    transCode: 'MDO0036',
     pid: pid.value,
-  }
+  };
+  
   request(param).then((res) => {
     console.log('Python:', res);
+    
+    // 判断 res.ptython 是否为空,若不为空则赋值
+    if (res.ptython) {
+      textarea1.value = res.ptython;
+    }
   }).catch((err) => {
     console.error('请求失败:', err);
   });
-}
+};
 
 // Python确认按钮提交
 const pythonSubmit = () => {
@@ -2507,7 +2526,7 @@ const pythonSubmit = () => {
   const param = {
     transCode:'MDO0037',
     pid: pid.value,
-    code: textarea1.value,
+    python: textarea1.value,
   }
   request(param).then((res) => {
     console.log('Python确认按钮提交:', res);

+ 45 - 15
src/views/titlecomponent/csts.vue

@@ -21,7 +21,7 @@
               :label-width="formLabelWidth200"
             >
               <el-input
-                v-model="youhua.popsize"
+                v-model="cstvalue.uppern1"
                 :step="100"
                 :min="0"
                 :max="1000"
@@ -35,7 +35,7 @@
               :label-width="formLabelWidth200"
             >
               <el-input
-                v-model="youhua.popsize"
+                v-model="cstvalue.lowern1"
                 :step="100"
                 :min="0"
                 :max="1000"
@@ -51,7 +51,7 @@
               :label-width="formLabelWidth200"
             >
               <el-input
-                v-model="youhua.popsize"
+                v-model="cstvalue.uppern2"
                 :step="100"
                 :min="0"
                 :max="1000"
@@ -65,7 +65,7 @@
               :label-width="formLabelWidth200"
             >
               <el-input
-                v-model="youhua.popsize"
+                v-model="cstvalue.lowern2"
                 :step="100"
                 :min="0"
                 :max="1000"
@@ -102,20 +102,12 @@ import myheader from "@/components/header.vue"
 import { request, uploadFile } from "@/utils/request"
 import { ElMessage, ElButton, ElDialog, ElSelect } from "element-plus"
 import { Edit, CaretBottom } from "@element-plus/icons-vue"
+import { cs } from "element-plus/es/locale/index.mjs"
 let formLabelWidth3 = ref(100)
 let formLabelWidth200 = ref(200)
 let cstnum = ref("")
-let youhua = ref({
-  algorithm: "GA",
-  popsize: 1,
-  epoch: 100,
-  probcrossover: 0.1,
-  probmut: 0.1,
-  proboperator: "SBX交叉",
-  probscale: 1,
-  strategy: "最佳保留策略",
-  operator: "倒位变异",
-  gpu: "YES"
+let cstvalue = ref({
+  
 })
 let tableDatacst = ref([{ date: "上表面CST参数" }, { date: "下表面CST参数" }])
 let tablecstHeaders = ref([])
@@ -148,6 +140,44 @@ const clickblur = () => {
     console.log(tableDatacst.value)
   }
 }
+
+//查询cst 
+const getcst = (id) => {
+  pid.value=id;
+  const params = {
+    transCode: 'MDO0040',
+    pid: pid.value,
+  }
+  request(params)
+    .then((res) => {
+
+      if (res.hasOwnProperty('eid')) {
+
+        eid.value = res.eid;
+        youhua.value.algorithm = res.algorithm
+        youhua.value.popsize = Number(res.popsize); // 将id属性转换为数字
+        youhua.value.epoch = Number(res.epoch);
+        youhua.value.probcrossover = Number(res.probcrossover);
+        youhua.value.probmut = Number(res.probmut);
+        youhua.value.probscale = Number(res.probscale);
+        youhua.value.proboperator = res.proboperator;
+        youhua.value.strategy = res.strategy;
+        youhua.value.operator = res.operator;
+        youhua.value.gpu = res.gpu;
+
+        // youhua=res;
+
+      } else {
+        //  youhua=res;
+      }
+
+    })
+    .catch((err) => {
+      ElMessage.error(err.returnMsg)
+    })
+}
+
+
 </script>
 
 

+ 1 - 1
src/views/vuetree/Sidebar.vue

@@ -313,7 +313,7 @@ onUnmounted(() => {
   padding-left: 0 !important;
 }
 .custom-tree1{
-  height: 358px;
+  height: 80%;
     overflow: auto;  
 }
 </style>

+ 71 - 41
src/views/vuetree/index.vue

@@ -53,6 +53,31 @@
     
     </Controls>
 
+    <el-dialog v-model="changeNameshow" align-center :modal="false" :close-on-click-modal="false"
+            :append-to-body="true" draggable :fullscreen="false" :modal-append-to-body="false" modal-class="summary-dlg"
+            :before-close="handleClose" width="400" class="dialog_class bgcolor colortext tianjia sel">
+      <template #header="{ titleId, titleClass }">
+        <div class="my-header ">
+          <h4 :id="titleId" :class="titleClass">修改名称</h4>
+        </div>
+      </template>
+      <div style="margin-top: 20px;padding: 20px;">
+        <el-form :model="changeName" label-width="100px" class="demo-ruleForm">
+        <el-form-item label="新名称:" prop="name">
+          <el-input v-model="changeName.name" placeholder="请输入名称"></el-input>
+        </el-form-item>
+        
+        </el-form>
+      </div>
+      
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="changeNameshow = false">取 消</el-button>
+          <el-button type="primary" @click="handleUpdate">确 定</el-button>
+        </div>
+      </template>
+    </el-dialog>
+
   </VueFlow>
   <div class="dnd-flow">
 
@@ -142,6 +167,13 @@ let nnum=ref(0);
 const { onDragOver, onDrop, onDragLeave, isDragOver } = useDragAndDrop();
 const edges = ref([]);
 const nodes = ref([]);
+
+const changeNameshow = ref(false);
+const changeName = ref({
+  name: '',
+  
+})
+
 onConnect((connection) => {
   console.log(connection);
   connection.type = 'smoothstep';//  smoothstep straight
@@ -153,11 +185,16 @@ onConnect((connection) => {
   seledge.value=null;
 })
 //修改名称
-function handleUpdate(){
-
-  noid.value.data.label=labelname.value;
-  console.log( noid.value.data.label);
-}
+const handleUpdate = () => {
+  if (noid.value && noid.value.data) {
+    noid.value.data.label = changeName.value.name; // 更新名称
+    console.log(noid.value.data.label); // 打印更新后的值
+  } else {
+    console.error("noid.value 或 noid.value.data 未定义"); // 错误日志
+  }
+  changeNameshow.value = false; // 更新后关闭对话框
+  // noid.value.data.label = labelname;
+};
 emitter.on('child2Data', data => {
   datatree.value = data;
   console.log(datatree.value);
@@ -167,8 +204,10 @@ onUnmounted(() => {
 });
 function onNodeClick(e) {
   noid.value = e.node;
-  labelname.value=e.node.data.label;
-  console.log(e.node);
+  changeName.value.name=e.node.data.label;
+  console.log("shuju:",e.node.data);
+  console.log("noid.value:",noid.value);
+  console.log("changeName.value:",changeName.value.name);
   djshow.value = !djshow.value;
   // if(djshow.value){
   //   console.log('选中');
@@ -245,41 +284,14 @@ function onSelection(){
       console.log(nodesitem.value[i]);
       nodes.value.push(nodesitem.value[i])
     }
-console.log(1111)
-
-   console.log( nodes.value);
-//console.log(nodesitem.value);
-     //nodes.value.push( nodes.value)
-//  let item= {
-//     id:nnum.value.toString(),
-//     data: { label: '模块化' },
-//     position: positionxy,
-//     style: { backgroundColor: bgcolor.value, width: '200px',height: '200px' },
-//   }
-//  console.log(Nested2.value)
-//     nodes.value = Nested2.value.map(node => {
-//       positionxy=node.position;
-//       if(node.parentNode==undefined){
-//         node.parentNode=item.id;
-//       // node.expandParent=true;
-//       node.extent='parent';
-     
-//   }
-//   return node;
-//   });
-//   Nested2.value.push(item)
-//   nodes.value.push(item);
-//  console.log( nodes.value);
- 
-// }else{
-// console.log(222)
-//  }
- 
+
+   console.log( nodes.value); 
 }
+
+
 function onNodeDoubleClick(e) {
   noid.value = e.node;
   console.log( e.node.data.name);
-  console.log(111111)
   if (e.node.data.name == '优化器') {
     emit('optimizerfalse','优化器');
   }else if(e.node.data.name=="进化优化器"){
@@ -323,9 +335,27 @@ function onEdgeClick(e) {
 function logEvent(name, event) {
   console.log(2222)
 }
-function onContextMenu(event) {
 
-}
+// 右键更改名字
+const onContextMenu = (e) => {
+      e.preventDefault();  // 阻止浏览器默认的右键菜单
+
+      const node = e.target.closest(".vue-flow__node");
+      console.log("nodes:",nodes);
+      console.log("node:",node);
+      if (node) {
+        // 获取当前右键点击的节点
+        const nodeId = node.getAttribute("data-id");
+        const clickedNode = nodes.value.find((n) => n.id === nodeId);
+        console.log("clickedNode:",clickedNode);
+        
+        if (clickedNode) {
+          noid.value = clickedNode;
+          changeName.value.name = clickedNode.label;  // 将当前节点的label放入弹窗中
+          changeNameshow.value = true;  // 显示弹窗
+        }
+      }
+};
 onInit((vueFlowInstance) => {
   vueFlowInstance.fitView()
 })
@@ -333,7 +363,7 @@ onInit((vueFlowInstance) => {
 onNodeDragStop(({ event, nodes, node }) => {
   console.log(nodes)
   Nested.value=nodes;
-  //console.log('Node Drag Stop', { event, nodes, node })
+  console.log('Node Drag Stop', { event, nodes, node })
 })
 
 onConnect((connection) => {