Explorar o código

fix bug 自定义算法限制问题

liujiejie hai 5 meses
pai
achega
bd4fbe9bdc

+ 18 - 24
src/store/dragChart.js

@@ -53,8 +53,7 @@ export default {
     },
     //编辑数据筛选字段
     setFormFilterAlignData(state, data) {
-      //将数据存储起来用于回显 数据
-      // 检查是否已经存在相同的 id
+      //将数据存储起来用于回显数据---检查是否已经存在相同的 id
       state.currentChartList?.map((chartItem, ind) => {
         if (chartItem.id === data.id) {
           state.currentChartList[ind].formFilterAlignData = data.data;
@@ -65,7 +64,6 @@ export default {
     setCurEdit(state, data) {
       state.curEdit = data;
     },
-
     // 当前画布添加图表
     addChart(state, data) {
       //   console.log("当前画布添加图表", data);
@@ -77,12 +75,10 @@ export default {
     },
     //更新数据配置当前选中数据
     updateDataBase(state, data) {
-      // console.log("更改了图表数据", data);
       state.dataBaseCheckList = data;
     },
     // 更新图表
     updateChart(state, data) {
-      // console.log("更改了图表组件", data.index, data);
       if (state.currentChartList[data.index]) {
         state.currentChartList[data.index] = Object.assign(
           state.currentChartList[data.index],
@@ -98,7 +94,6 @@ export default {
     setCurrentChartList(state, list = []) {
       state.currentChartList = list;
     },
-
     // 文件删除
     fileListDelete(state, item) {
       const index = state.fileList.indexOf(item);
@@ -108,7 +103,6 @@ export default {
     fileListAdd(state, item) {
       state.fileList.push(item);
     },
-
     fileListUpdate(state, item) {
       state.fileList = _.cloneDeep(item);
     },
@@ -133,23 +127,23 @@ export default {
       }
     },
     // 缩放屏幕
-    scaleScreen(state, isGrow) {
-      if (isGrow) {
-        state.currentChartList.forEach((item) => {
-          item.x = parseInt(item.x * SCALE);
-          item.y = parseInt(item.y * SCALE);
-          item.height = parseInt(item.height * SCALE);
-          item.width = parseInt(item.width * SCALE);
-        });
-      } else {
-        state.currentChartList.forEach((item) => {
-          item.x = parseInt(item.x / SCALE);
-          item.y = parseInt(item.y / SCALE);
-          item.height = parseInt(item.height / SCALE);
-          item.width = parseInt(item.width / SCALE);
-        });
-      }
-    },
+    // scaleScreen(state, isGrow) {
+    //   if (isGrow) {
+    //     state.currentChartList.forEach((item) => {
+    //       item.x = parseInt(item.x * SCALE);
+    //       item.y = parseInt(item.y * SCALE);
+    //       item.height = parseInt(item.height * SCALE);
+    //       item.width = parseInt(item.width * SCALE);
+    //     });
+    //   } else {
+    //     state.currentChartList.forEach((item) => {
+    //       item.x = parseInt(item.x / SCALE);
+    //       item.y = parseInt(item.y / SCALE);
+    //       item.height = parseInt(item.height / SCALE);
+    //       item.width = parseInt(item.width / SCALE);
+    //     });
+    //   }
+    // },
   },
   actions: {},
 };

+ 1 - 1
src/store/index.js

@@ -48,7 +48,7 @@ export const store = new Vuex.Store({
         "auth",
         "settings",
         "themes",
-        "menuTag", // 指定需要存储的模块,排除 dragChart
+        "menuTag", // 指定需要持久化存储的模块,排除 dragChart
       ],
     }),
     vuexIndexedDBPlugin,

+ 0 - 4
src/utils/indexedDb.js

@@ -97,10 +97,8 @@ export async function getDataFromIndexedDB() {
 export async function clearAllDataFromIndexedDB() {
   return new Promise((resolve, reject) => {
     const versionRequest = indexedDB.open("FileDataDB");
-
     versionRequest.onsuccess = (event) => {
       const db = event.target.result;
-
       // 检查对象存储是否存在
       if (!db.objectStoreNames.contains("files")) {
         console.log("Object store 'files' does not exist. No action needed.");
@@ -122,7 +120,6 @@ export async function clearAllDataFromIndexedDB() {
           console.log("All data cleared from IndexedDB.");
           resolve();
         };
-
         clearRequest.onerror = (event) => {
           console.error(
             "Failed to clear data from IndexedDB:",
@@ -131,7 +128,6 @@ export async function clearAllDataFromIndexedDB() {
           reject(event.target.error);
         };
       };
-
       request.onerror = (event) => {
         console.error("Failed to open IndexedDB:", event.target.error);
         reject(event.target.error);

+ 4 - 3
src/views/performance/assetssDetail.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2024-05-27 09:25:45
- * @LastEditTime: 2024-10-09 09:11:01
+ * @LastEditTime: 2024-12-24 10:49:20
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/views/performance/assetssDetail.vue
@@ -119,6 +119,7 @@
         <el-table-column prop="engine_name" label="风机名称"> </el-table-column>
         <el-table-column prop="yaw_error1" label="误差值"> </el-table-column>
       </el-table>
+      <!-- 需要在这里添加三个分析类型排版布局 ,分析详情中 -->
       <div v-else>
         <el-card class="box-card analysisType" v-if="generalFiles.length > 0">
           <div slot="header" class="clearfix">
@@ -380,7 +381,7 @@ import {
   downloadFile,
 } from "@/api/performance";
 import CreateNewChart from "./createNewChart.vue";
-import DetailCharts from "./components/DetailCharts.vue";
+// import DetailCharts from "./components/DetailCharts.vue";
 import BoxLineCharts from "./components/chartsCom/BoxLineCharts";
 import HeatmapCharts from "./components/chartsCom/HeatmapCharts.vue";
 import WindRoseChart from "./components/chartsCom/WindRoseChart.vue";
@@ -395,7 +396,7 @@ import Papa from "papaparse";
 import axios from "axios";
 export default {
   components: {
-    DetailCharts,
+    // DetailCharts,
     WindRoseChart,
     // JsonMarkerCharts,
     HeatmapCharts,

+ 1 - 0
src/views/performance/components/DetailCharts.vue

@@ -1,5 +1,6 @@
 <template>
   <div>
+    <!-- 废弃页面 -->
     <div id="mainChart"></div>
     <div
       v-for="(engine, index) in data.data"

+ 3 - 2
src/views/performance/components/EditAnalysis.vue

@@ -1,12 +1,13 @@
 <!--
  * @Author: your name
  * @Date: 2024-05-29 09:14:23
- * @LastEditTime: 2024-09-30 16:28:49
- * @LastEditors: milo-MacBook-Pro.local
+ * @LastEditTime: 2024-12-24 10:48:23
+ * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/views/performance/components/EditAnalysis.vue
 -->
 <template>
+  <!-- 分析编辑页面 -->
   <div v-loading="loading">
     <el-form ref="form" :model="form" label-width="120px">
       <el-collapse v-model="activeNames">

+ 2 - 1
src/views/performance/components/JsonMarkerCharts.vue

@@ -1,12 +1,13 @@
 <!--
  * @Author: your name
  * @Date: 2024-08-16 16:19:19
- * @LastEditTime: 2024-09-30 09:30:43
+ * @LastEditTime: 2024-12-24 10:47:21
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/views/performance/components/JsonMarkerCharts.vue
 -->
 <template>
+  <!-- json 数据渲染plotly散点图  废弃页面-->
   <div>
     <div ref="chart" style="width: 100%; height: 500px"></div>
   </div>

+ 1 - 0
src/views/performance/components/abnormalDetail.vue

@@ -1,5 +1,6 @@
 <template>
   <div v-loading="loading">
+    <!-- 异常描述页面 -->
     <div class="newly">
       <el-button type="primary" @click="addRow" size="small">新增</el-button>
     </div>

+ 2 - 1
src/views/performance/components/analysisEvent.vue

@@ -1,12 +1,13 @@
 <!--
  * @Author: your name
  * @Date: 2024-05-29 09:13:51
- * @LastEditTime: 2024-09-30 16:12:20
+ * @LastEditTime: 2024-12-24 10:49:55
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/views/performance/components/analysisEvent.vue
 -->
 <template>
+  <!-- 分析事件页面 -->
   <div v-loading="loading">
     <el-form
       ref="form"

+ 63 - 67
src/views/performance/components/custonAsCom/dragChart/components/chartConfig/form/chartLogic/modules/scatter.js

@@ -21,7 +21,6 @@ export function handleScatterChartLogic(
           : val;
       }),
     }));
-
     const filterList = filterResult.map((filteredItem, index) => {
       const filter = formFilterAlign[index];
       const { filterType1, filterType2, number1, number2 } = filter;
@@ -110,78 +109,75 @@ export function handleScatterChartLogic(
     });
 
     // 记录选中的散点
-    const selectedPoints = [];
-
-    // 点击事件的处理函数
-    function handleClick(event) {
-      const selectedIndex = event.dataIndex;
-      const scatterData = item.option.series[0].data;
-
-      // 获取点击点的坐标
-      const xClick = event.data[0];
-      const yClick = event.data[1];
-
-      // 判断该点是否已经被选中
-      const existingIndex = selectedPoints.findIndex(
-        (point) => point.index === selectedIndex
-      );
-
-      if (existingIndex === -1) {
-        // 如果没有选中,则加入
-        selectedPoints.push({
-          index: selectedIndex,
-          x: xClick,
-          y: yClick,
-        });
-      } else {
-        // 如果已经选中,则取消选中
-        selectedPoints.splice(existingIndex, 1);
-      }
-
-      // 更新选中点的样式
-      const newColors = scatterData.map((point, index) => {
-        // 如果该点在 selectedPoints 中,则改变其颜色
-        if (
-          selectedPoints.some((selectedPoint) => selectedPoint.index === index)
-        ) {
-          return "red"; // 选中点为红色
-        }
-        return point[0] && point[1] ? "#000" : "transparent"; // 默认颜色,未选中点为黑色
-      });
-
-      const newSizes = scatterData.map((point, index) => {
-        // 如果该点在 selectedPoints 中,则增大其大小
-        if (
-          selectedPoints.some((selectedPoint) => selectedPoint.index === index)
-        ) {
-          return 10; // 选中点大小为 10
-        }
-        return 5; // 默认大小
-      });
-
-      // 更新图表的颜色和大小
-      item.option.series[0].itemStyle = {
-        color: newColors,
-        size: newSizes,
-      };
-
-      // 通过重新设置 `option` 来更新图表
-      if (item.chartInstance) {
-        item.chartInstance.setOption(item.option);
-      }
-    }
-
+    // const selectedPoints = [];
+    // // 点击事件的处理函数
+    // function handleClick(event) {
+    //   const selectedIndex = event.dataIndex;
+    //   const scatterData = item.option.series[0].data;
+
+    //   // 获取点击点的坐标
+    //   const xClick = event.data[0];
+    //   const yClick = event.data[1];
+
+    //   // 判断该点是否已经被选中
+    //   const existingIndex = selectedPoints.findIndex(
+    //     (point) => point.index === selectedIndex
+    //   );
+
+    //   if (existingIndex === -1) {
+    //     // 如果没有选中,则加入
+    //     selectedPoints.push({
+    //       index: selectedIndex,
+    //       x: xClick,
+    //       y: yClick,
+    //     });
+    //   } else {
+    //     // 如果已经选中,则取消选中
+    //     selectedPoints.splice(existingIndex, 1);
+    //   }
+
+    //   // 更新选中点的样式
+    //   const newColors = scatterData.map((point, index) => {
+    //     // 如果该点在 selectedPoints 中,则改变其颜色
+    //     if (
+    //       selectedPoints.some((selectedPoint) => selectedPoint.index === index)
+    //     ) {
+    //       return "red"; // 选中点为红色
+    //     }
+    //     return point[0] && point[1] ? "#000" : "transparent"; // 默认颜色,未选中点为黑色
+    //   });
+
+    //   const newSizes = scatterData.map((point, index) => {
+    //     // 如果该点在 selectedPoints 中,则增大其大小
+    //     if (
+    //       selectedPoints.some((selectedPoint) => selectedPoint.index === index)
+    //     ) {
+    //       return 10; // 选中点大小为 10
+    //     }
+    //     return 5; // 默认大小
+    //   });
+
+    //   // 更新图表的颜色和大小
+    //   item.option.series[0].itemStyle = {
+    //     color: newColors,
+    //     size: newSizes,
+    //   };
+
+    //   // 通过重新设置 `option` 来更新图表
+    //   if (item.chartInstance) {
+    //     item.chartInstance.setOption(item.option);
+    //   }
+    // }
     // 绑定点击事件
     item.option.series[0].emphasis = {
       itemStyle: {
         color: "red",
       },
     };
-
     // 添加点击事件
-    if (item.chartInstance) {
-      item.chartInstance.off("click"); // 先移除之前的事件
-      item.chartInstance.on("click", handleClick); // 然后绑定新的点击事件
-    }
+    // if (item.chartInstance) {
+    //   item.chartInstance.off("click"); // 先移除之前的事件
+    //   item.chartInstance.on("click", handleClick); // 然后绑定新的点击事件
+    // }
   }
 }

+ 2 - 2
src/views/performance/components/custonAsCom/dragChart/components/chartsContent.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2024-11-01 10:14:11
- * @LastEditTime: 2024-11-12 15:05:25
+ * @LastEditTime: 2024-12-24 14:35:12
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/views/performance/components/custonAsCom/dragChart/components/chartsContent.vue
@@ -122,7 +122,7 @@ export default {
   },
   methods: {
     ...mapMutations("dragChart", [
-      "scaleScreen",
+      // "scaleScreen",
       "setCurrentChartList",
       "addChart",
       "updateChart",

+ 1 - 0
src/views/performance/components/map.vue

@@ -1,5 +1,6 @@
 <template>
   <div class="map-ditu">
+    <!-- 分析事件中 风场信息展示地图组件 -->
     <Tmap
       ref="map"
       :windEngineGroupByFieldCodeDetail="windEngineGroupByFieldCodeDetail"

+ 16 - 11
src/views/performance/customAnalysis.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="content" v-loading="loading">
+  <div class="content">
     <el-tabs
       ref="tabs"
       tab-position="left"
@@ -126,7 +126,9 @@
     <el-dialog
       title="数据列表特征计算函数"
       :visible.sync="dialogVisible"
+      element-loading-background="rgba(0, 0, 0, 0.8)"
       width="600px"
+      v-loading="loading"
       :before-close="handleClose"
     >
       <el-form
@@ -293,7 +295,6 @@ export default {
       "setTriggerGetData",
       "setUpdateTriggerGetData",
     ]),
-
     async initDB() {
       return new Promise((resolve, reject) => {
         const request = indexedDB.open("FileDataDB", 2); // 使用较高版本
@@ -333,6 +334,7 @@ export default {
       console.log(this.options, "调用数据");
     },
     async submitComputedFn(formName) {
+      this.loading = true;
       try {
         // 1. 验证表单
         if (!(await this.validateForm(formName))) return;
@@ -340,6 +342,7 @@ export default {
           this.$message.error("开始行不可以大于结束行");
           return;
         }
+
         // 2. 获取 IndexedDB 数据
         const indexeddbData = await getDataFromIndexedDB();
         const region = this.getRegionData(indexeddbData);
@@ -348,8 +351,14 @@ export default {
           console.warn("当前选择的列未找到数据");
           return;
         }
-
+        if (region[0].length > 1000 && this.ruleForm.type.length > 2) {
+          this.$message.warning(
+            "由于列数据过长,为了保证页面操作流畅,每次最多选择2个特征值进行计算。请分批次选择。"
+          );
+          return;
+        }
         // 3. 调用算法接口
+        // console.log(region, "region[0]");
         const resData = await this.fetchAlgorithmData(region[0]);
 
         // 4. 筛选和处理数据
@@ -359,9 +368,12 @@ export default {
         const resObj = this.buildExportData(indexeddbData, filteredData);
         this.storeData(resObj);
         this.resetForm();
-        console.log(resObj, "resObj");
+        this.$message.success("成功");
+        this.loading = false;
       } catch (error) {
         console.error("提交过程中发生错误:", error);
+        this.$message.error(error);
+        this.loading = false;
       }
     },
 
@@ -466,7 +478,6 @@ export default {
 
       return resObj;
     },
-
     resetForm() {
       this.ruleForm = {
         max: "",
@@ -502,7 +513,6 @@ export default {
         this.activeName = tab.name;
       }
     },
-
     // 自定义上传方法
     customUpload(file) {
       const formData = new FormData();
@@ -510,7 +520,6 @@ export default {
       // 使用 axios 自定义上传逻辑
       console.log("自定义上传", file.name);
     },
-
     // 验证并处理文件变化
     validateAndHandleChange(fileList) {
       // 判断 fileList 是否为数组(多个文件)还是单个文件
@@ -528,7 +537,6 @@ export default {
         }
       }
     },
-
     // 检查文件类型&多个文件选择,但多个文件总数大小不能超过50KB
     checkFileType(file) {
       // 判断文件类型
@@ -544,7 +552,6 @@ export default {
         this.$message.error("只能上传csv文件或xlsx或xls文件");
         return false; // 返回false,阻止上传
       }
-
       // 判断文件大小(以字节为单位,50KB = 51200字节)
       const maxSize = 50 * 1024; // 50KB
       if (file.size > maxSize) {
@@ -593,7 +600,6 @@ export default {
         const reader = new FileReader();
         reader.onload = (e) => {
           const data = new Uint8Array(e.target.result);
-
           // 读取 Excel 文件
           const workbook = XLSX.read(data, { type: "array" });
 
@@ -604,7 +610,6 @@ export default {
                 defval: "", // 确保空值不会导致错误
               }
             );
-
             const fileData = {
               filename:
                 format(new Date(), "yyyyMMdd-HH:mm:ss") + "_" + ind + file.name,