rui.jiang 2 months ago
parent
commit
758b980809
2 changed files with 25 additions and 6 deletions
  1. 0 3
      jg/electron/main.mjs
  2. 25 3
      jg/src/views/laserRangeFinder/index.vue

+ 0 - 3
jg/electron/main.mjs

@@ -52,7 +52,6 @@ function createWindow() {
       }
       // **修改 Python EXE 的路径**
 
-      console.log("🔹 正在执行 Python EXE:", pythonExePath);
       if (!fs.existsSync(pythonExePath)) {
         reject(`Python EXE 不存在: ${pythonExePath}`);
         return;
@@ -64,8 +63,6 @@ function createWindow() {
         apiName,
         Buffer.from(JSON.stringify(params)).toString("base64"),
       ];
-      console.log("📡 发送给 Python 的参数(Base64 编码):", args);
-      console.log("📡 调用 Python EXE:", pythonExePath, "参数:", args);
       const res = execFile(
         pythonExePath,
         args,

+ 25 - 3
jg/src/views/laserRangeFinder/index.vue

@@ -32,7 +32,8 @@
           :accept="'.csv, .xlsx, .xls'"
           :auto-upload="false"
           limit="1"
-          @click.prevent
+          :disabled="true"
+          :before-upload="() => false"
         >
           <div class="iconText" @click="validateAndHandleChange">
             <app-icon icon="UploadFilled" size="50px" />
@@ -74,6 +75,7 @@
         <!-- <el-button @click="validateAndHandleChange" type="primary"
             >导入定位数据</el-button
           > -->
+        <el-button type="primary" @click="submitPy">数据测量分析</el-button>
       </div>
       <div class="stepTwo" v-if="stepsActive === 1">
         <el-empty
@@ -316,11 +318,13 @@ import InitCharts from "./components/initCharts.vue";
 import CylinderOfTower from "./components/CylinderOfTower.vue";
 import PlotOfFit from "./components/PlotOfFit.vue";
 import axios from "axios";
+import path from "path";
 
 export default {
   data() {
     return {
       stepsActive: 0,
+      pathFileName: "",
       chartKey: 0, // 用于强制重新渲染子组件
       activeNames: ["1"],
       tabActiveName: "init",
@@ -366,7 +370,7 @@ export default {
         const absolutePath = await window.electronAPI.getFilePath(); // ✅ 修正:不传 file
         if (absolutePath) {
           console.log("文件绝对路径:", absolutePath);
-          this.fetchA1(absolutePath);
+          this.pathFileName = absolutePath;
           // this.fetchA2(absolutePath);
         } else {
           console.log("未选择文件或路径获取失败");
@@ -374,11 +378,29 @@ export default {
       } catch (error) {
         console.error("获取文件路径失败:", error);
       }
+      // ✅ 手动触发 input[type="file"]
+      this.$nextTick(() => {
+        const inputEl =
+          this.$refs.uploadRef.$el.querySelector("input[type='file']");
+        // if (inputEl) {
+        //   inputEl.click();
+        // }
+      });
+    },
+    submitPy() {
+      if (this.pathFileName !== "") {
+        this.fetchA1(this.pathFileName);
+      } else {
+        this.$message({
+          message: "请先选择文件",
+          type: "warning",
+        });
+      }
     },
 
     async fetchA1(path) {
       try {
-        const result = await window.electronAPI.callPythonAPI("a1",path);
+        const result = await window.electronAPI.callPythonAPI("a1", path);
         console.log("A1 API 响应:", result);
       } catch (error) {
         console.error("A1 API 失败:", error);