Ver código fonte

修改健康指数

chenbaoxin 4 meses atrás
pai
commit
a798ce8cdb
1 arquivos alterados com 24 adições e 16 exclusões
  1. 24 16
      src/views/HealthSettings/index.vue

+ 24 - 16
src/views/HealthSettings/index.vue

@@ -226,25 +226,33 @@ recordValue.value=val
 }
 const saveEdit = (row, column,rowIndex) => {
   console.log("Saving data:", row, column);
-      // 确保值不超过后面所有输入框的值
-  // for (let i = rowIndex + 1; i < tableData.value.length; i++) {
-  //   const nextValue = parseFloat(tableData.value[i].deviation_value[0]);
-  //   if (!isNaN(nextValue) && parseFloat(row.deviation_value[0]) > nextValue) {
-  //      tableData.value[rowIndex].deviation_value[0]=recordValue.value
-  //       return false;
+    let pos = column.split('-')[1];
+  let value = parseFloat(row.deviation_value[pos]);
 
-  //   }
-  // }
+  // 确保值不超过后面所有输入框的值
+  for (let i = rowIndex + 1; i < tableData.value.length; i++) {
+    for (let j = 0; j < tableData.value[i].deviation_value.length; j++) {
+      const nextValue = parseFloat(tableData.value[i].deviation_value[j]);
+      if (!isNaN(nextValue) && value > nextValue) {
+        row.deviation_value[pos] = tableData.value[i].deviation_value[j];
+        ElMessage.error("输入值不能大于后面的值");
+        return;
+      }
+    }
+  }
 
-  // // 确保值不小于前面所有输入框的值
-  // for (let i = rowIndex - 1; i >= 0; i--) {
-  //   const prevValue = parseFloat(tableData.value[i].deviation_value[1]);
-  //   if (!isNaN(prevValue) && parseFloat(row.deviation_value[1]) < prevValue) {
-  //           tableData.value[rowIndex].deviation_value[1]=recordValue.value
+  // 确保值不小于前面所有输入框的值
+  for (let i = rowIndex - 1; i >= 0; i--) {
+    for (let j = 0; j < tableData.value[i].deviation_value.length; j++) {
+      const prevValue = parseFloat(tableData.value[i].deviation_value[j]);
+      if (!isNaN(prevValue) && value < prevValue) {
+        row.deviation_value[pos] = tableData.value[i].deviation_value[j];
+        ElMessage.error("输入值不能小于前面的值");
+        return;
+      }
+    }
+  }
 
-  //     return false;
-  //   }
-  // }
   // 在这里处理保存逻辑,例如发送请求到服务器
   editingCell.value = { row: null, column: null };
   healthySetUpdate({