Bläddra i källkod

#668 首页参数运行曲线的选择显示参数弹窗加保存按钮

zhangchuang 3 månader sedan
förälder
incheckning
8de485aa76
1 ändrade filer med 60 tillägg och 8 borttagningar
  1. 60 8
      src/views/HealthStatusAnalysis/mock.vue

+ 60 - 8
src/views/HealthStatusAnalysis/mock.vue

@@ -433,6 +433,7 @@
         >
           {{ item }}
         </div>
+        <el-button class="btns" type="primary" @click="saveAttr">保存</el-button>
       </div>
     </div>
     <!-- 模态框内容插槽 -->
@@ -622,7 +623,7 @@ const pageInit = async () => {
   mockCacheData({}).then((res: any) => {
     // 检测 res.data 是否不为空对象
     if (res.data && Object.keys(res.data).length !== 0) {
-      lineParamsAllRef.value = res.data.map((its: any) => {
+      lineParamsAllRef.value = res.data.realtime.map((its: any) => {
         return {
           data: its,
         };
@@ -865,7 +866,7 @@ const mockStart = async (state: boolean = false) => {
   if (state) {
     let resultCatch = await mockCacheData({});
     if (resultCatch.data && Object.keys(resultCatch.data).length !== 0) {
-      lineParamsAllRef.value = resultCatch.data.map((its: any) => {
+      lineParamsAllRef.value = resultCatch.data.realtime.map((its: any) => {
         return {
           data: its,
         };
@@ -956,7 +957,30 @@ watch(
   { deep: true }
 );
 // const setParams = ref(convertObjectToArray(COLUMN_MAP));
+// const changeAttr = (valArr: string[]) => {
+//   btnIndex.value == 5
+//     ? (showYAxisLabels.value = false)
+//     : (showYAxisLabels.value = true);
+//   let val = setParams.value.filter((element) => valArr.includes(element));
+//   if (val.length > 5) {
+//     ElMessage({
+//       message: `最多选择5个参数`,
+//       type: "error",
+//     });
+//     checkedParams.value = val.slice(0, 5);
+//   } else {
+//     checkedParams.value = val;
+//   }
+//   localStorage.setItem(
+//     "OE_checked_params",
+//     JSON.stringify(checkedParams.value)
+//   );
+//   localStorage.setItem("btnIndex", btnIndex.value);
+//   localStorage.setItem("btnBigIndex", btnBigIndex.value);
+// };
+
 const changeAttr = (valArr: string[]) => {
+  checkedChange.value = checkedParams.value;
   btnIndex.value == 5
     ? (showYAxisLabels.value = false)
     : (showYAxisLabels.value = true);
@@ -967,17 +991,27 @@ const changeAttr = (valArr: string[]) => {
       type: "error",
     });
     checkedParams.value = val.slice(0, 5);
+    return
   } else {
-    checkedParams.value = val;
+    checkedChange.value = val;
   }
+  // localStorage.setItem(
+  //   `OE_checked_params_${props.data.id}`,
+  //   JSON.stringify(checkedParams.value)
+  // );
+  //   localStorage.setItem("btnIndex", btnIndex.value);
+  //   localStorage.setItem("btnBigIndex", btnBigIndex.value);
+};
+const saveAttr = () => {
+  checkedParams.value = checkedChange.value
   localStorage.setItem(
-    "OE_checked_params",
+    'OE_checked_params',
     JSON.stringify(checkedParams.value)
   );
-  localStorage.setItem("btnIndex", btnIndex.value);
-  localStorage.setItem("btnBigIndex", btnBigIndex.value);
-};
-
+  onClickStart();
+  runLineParams();
+  showModal.value = false;
+}
 onUnmounted(() => {
   wsMockClient.onClose();
 });
@@ -1040,6 +1074,7 @@ const showParamsModel = () => {
   showModal.value = true;
 };
 const checkedParams = ref([]);
+const checkedChange = ref([]);
 // 设备参数全
 // 参数运行示例数据
 // 横坐标轴时间点
@@ -1362,6 +1397,23 @@ const workChange = () => {
   chartData.value = transformData(lastResult);
 };
 
+const runLineParams = () => {
+  let newDataValue = lineParamsAllRef.value;
+  if (lineParamsAllRef.value.length == 0) {
+    const result: Array<AnyObject> = convertToChartData(
+      newDataValue,
+      checkedParams.value
+    );
+    setLineparames(newDataValue, result);
+    return false;
+  }
+  const result: Array<AnyObject> = convertToChartData(
+    newDataValue,
+    checkedParams.value
+  );
+  setLineparames(newDataValue, result);
+};
+
 // 健康状态
 const goResult = () => {
   // router.push({