Browse Source

数据过滤,null问题

MaiXinRong 4 years ago
parent
commit
3c87f0475c
1 changed files with 3 additions and 48 deletions
  1. 3 48
      app/lib/rpt_data_analysis.js

+ 3 - 48
app/lib/rpt_data_analysis.js

@@ -49,14 +49,13 @@ const valueCheck = {
         }
         }
     },
     },
     _checkString(ctx, value, condition) {
     _checkString(ctx, value, condition) {
-        if (!value) return false;
         switch (condition.operate) {
         switch (condition.operate) {
             case '=':
             case '=':
                 return value === condition.value;
                 return value === condition.value;
             case 'part':
             case 'part':
-                return !ctx.helper._.isNil(value) ? value.indexOf(condition.value) >= 0 : false;
+                return value ? value.indexOf(condition.value) >= 0 : false;
             case 'enum':
             case 'enum':
-                return (!ctx.helper._.isNil(value) && condition.value instanceof Array) ? condition.value.indexOf(value) >= 0 : false;
+                return (value && condition.value instanceof Array) ? condition.value.indexOf(value) >= 0 : false;
             default:
             default:
                 return true;
                 return true;
         }
         }
@@ -662,7 +661,6 @@ const gatherChapter = {
             return (x.visible !== undefined && x.visible !== null) ? x.visible : true;
             return (x.visible !== undefined && x.visible !== null) ? x.visible : true;
 
 
         });
         });
-        console.log(data[fieldsKey[0].table])
     },
     },
 };
 };
 const join = {
 const join = {
@@ -785,52 +783,10 @@ const filter = {
         str: '_checkString',
         str: '_checkString',
         num: '_checkNumber',
         num: '_checkNumber',
     },
     },
-    _checkBoolean(ctx, value, condition) {
-        switch (condition.value) {
-            case 'true':
-                return !!value;
-            case 'false':
-                return !value;
-            default:
-                return true;
-        }
-    },
-    _checkNumber(ctx, value, condition) {
-        // if (ctx.helper._.isNil(value)) value = 0;
-        switch (condition.operate) {
-            case 'non-zero':
-                return !ctx.helper.checkZero(value);
-            case '=':
-                return !ctx.helper._.isNil(value) ? value === condition.value : false;
-            case '>':
-                return !ctx.helper._.isNil(value) ? value > condition.value : false;
-            case '<':
-                return !ctx.helper._.isNil(value) ? value < condition.value : false;
-            case '>=':
-                return !ctx.helper._.isNil(value) ? value >= condition.value : false;
-            case '<=':
-                return !ctx.helper._.isNil(value) ? value <= condition.value : false;
-            default:
-                return true;
-        }
-    },
-    _checkString(ctx, value, condition) {
-        switch (condition.operate) {
-            case '=':
-                return value === condition.value;
-            case 'part':
-                return !ctx.helper._.isNil(value) ? value.indexOf(condition.value) >= 0 : false;
-            case 'enum':
-                return (!ctx.helper._.isNil(value) && condition.value instanceof Array) ? condition.value.indexOf(value) >= 0 : false;
-            default:
-                return true;
-        }
-    },
     fun(ctx, data, fields, options) {
     fun(ctx, data, fields, options) {
         if (!options || !options.table || !options.condition) return;
         if (!options || !options.table || !options.condition) return;
 
 
-        const fData = data[options.table],
-            self = this;
+        const fData = data[options.table];
         if (!fData) return;
         if (!fData) return;
 
 
         valueCheck.loadTypeFun(options.condition);
         valueCheck.loadTypeFun(options.condition);
@@ -848,7 +804,6 @@ const filter = {
                 return result;
                 return result;
             }
             }
             return true;
             return true;
-
         });
         });
     },
     },
 };
 };