695593266@qq.com 4 месяцев назад
Родитель
Сommit
64b5796d7c

+ 15 - 61
src/views/produce/components/qualityInspection/components/selfInspectionReporting.vue

@@ -720,66 +720,16 @@
         return true;
       },
 
-      // calcCheckResult(row, field) {
-      //   const value = Number(row[field]);
-
-      //   // 不是数字直接跳过
-      //   if (isNaN(value)) return;
-
-      //   let pass = true;
-
-      //   if (row.textType == 3) {
-      //     const min = Number(row.minValue);
-      //     const max = Number(row.maxValue);
-
-      //     if (!isNaN(min) && value < min) pass = false;
-      //     if (!isNaN(max) && value > max) pass = false;
-      //   } else {
-      //     const defaultVal = Number(row.defaultValue);
-
-      //     if (isNaN(defaultVal)) return;
-
-      //     switch (row.symbol) {
-      //       case '>':
-      //         pass = value > defaultVal;
-      //         break;
-      //       case '<':
-      //         pass = value < defaultVal;
-      //         break;
-      //       case '>=':
-      //         pass = value >= defaultVal;
-      //         break;
-      //       case '<=':
-      //         pass = value <= defaultVal;
-      //         break;
-      //       case '=':
-      //         pass = value == defaultVal;
-      //         break;
-      //     }
-      //   }
-      //   if (this.type == 1) {
-      //     row.selfCheckResult = pass ? 1 : 2;
-      //   }
-
-      //   if (this.type == 2) {
-      //     row.specialCheckResult = pass ? 1 : 2;
-      //   }
-      // },
-
       calcCheckResult(row, field) {
         const rawValue = row[field];
+
         if (rawValue === '' || rawValue === null || rawValue === undefined) {
-          if (this.type == 1) {
-            row.selfCheckResult = 1;
-          }
-          if (this.type == 2) {
-            row.specialCheckResult = 1;
-          }
+          if (this.type == 1) row.selfCheckResult = 1;
+          if (this.type == 2) row.specialCheckResult = 1;
           return;
         }
 
         const value = Number(rawValue);
-
         if (isNaN(value)) return;
 
         let pass = true;
@@ -793,9 +743,17 @@
 
         const symbol = symbolMap[row.symbol] || row.symbol;
 
+        // ⭐⭐⭐ 区间判断
         if (row.textType == 3) {
-          const min = Number(row.minValue);
-          const max = Number(row.maxValue);
+          let min = Number(row.minValue);
+          let max = Number(row.maxValue);
+
+          if (isNaN(min) && isNaN(max)) return;
+
+          // 自动排序区间
+          if (!isNaN(min) && !isNaN(max) && min > max) {
+            [min, max] = [max, min];
+          }
 
           if (!isNaN(min) && value < min) pass = false;
           if (!isNaN(max) && value > max) pass = false;
@@ -822,12 +780,8 @@
           }
         }
 
-        if (this.type == 1) {
-          row.selfCheckResult = pass ? 1 : 2;
-        }
-        if (this.type == 2) {
-          row.specialCheckResult = pass ? 1 : 2;
-        }
+        if (this.type == 1) row.selfCheckResult = pass ? 1 : 2;
+        if (this.type == 2) row.specialCheckResult = pass ? 1 : 2;
       },
 
       async getData() {