Browse Source

修复通用搜索在启用自定义搜索时的BUG

Karson 6 years ago
parent
commit
b65452c7c3

+ 2 - 0
application/admin/lang/zh-cn.php

@@ -95,6 +95,8 @@ return [
     'Flag'                                                  => '标志',
     'Drag to sort'                                          => '拖动进行排序',
     'Redirect now'                                          => '立即跳转',
+    'Key'                                                   => '键',
+    'Value'                                                 => '值',
     'Common search'                                         => '普通搜索',
     'Search %s'                                             => '搜索 %s',
     'View %s'                                               => '查看 %s',

+ 6 - 5
public/assets/js/bootstrap-table-commonsearch.js

@@ -178,14 +178,15 @@
             if (obj.size() == 0)
                 return true;
             var vObjCol = ColumnsForSearch[i];
+            var process = !that.options.searchFormTemplate && vObjCol && typeof vObjCol.process == 'function' ? vObjCol.process : null;
             if (obj.size() > 1) {
                 if (/BETWEEN$/.test(sym)) {
                     var value_begin = $.trim($("[name='" + name + "']:first", that.$commonsearch).val()),
                         value_end = $.trim($("[name='" + name + "']:last", that.$commonsearch).val());
                     if (value_begin.length || value_end.length) {
-                        if (typeof vObjCol.process === 'function') {
-                            value_begin = vObjCol.process(value_begin, 'begin');
-                            value_end = vObjCol.process(value_end, 'end');
+                        if (process) {
+                            value_begin = process(value_begin, 'begin');
+                            value_end = process(value_end, 'end');
                         }
                         value = value_begin + ',' + value_end;
                     } else {
@@ -197,10 +198,10 @@
                     }
                 } else {
                     value = $("[name='" + name + "']:checked", that.$commonsearch).val();
-                    value = (vObjCol && typeof vObjCol.process === 'function') ? vObjCol.process(value) : value;
+                    value = process ? process(value) : value;
                 }
             } else {
-                value = (vObjCol && typeof vObjCol.process === 'function') ? vObjCol.process(obj.val()) : obj.val();
+                value = process ? process(obj.val()) : obj.val();
             }
             if (removeempty && (value == '' || value == null || ($.isArray(value) && value.length == 0)) && !sym.match(/null/i)) {
                 return true;

+ 6 - 5
public/assets/js/require-backend.min.js

@@ -9068,14 +9068,15 @@ define('form',['jquery', 'bootstrap', 'upload', 'validator'], function ($, undef
             if (obj.size() == 0)
                 return true;
             var vObjCol = ColumnsForSearch[i];
+            var process = !that.options.searchFormTemplate && vObjCol && typeof vObjCol.process == 'function' ? vObjCol.process : null;
             if (obj.size() > 1) {
                 if (/BETWEEN$/.test(sym)) {
                     var value_begin = $.trim($("[name='" + name + "']:first", that.$commonsearch).val()),
                         value_end = $.trim($("[name='" + name + "']:last", that.$commonsearch).val());
                     if (value_begin.length || value_end.length) {
-                        if (typeof vObjCol.process === 'function') {
-                            value_begin = vObjCol.process(value_begin, 'begin');
-                            value_end = vObjCol.process(value_end, 'end');
+                        if (process) {
+                            value_begin = process(value_begin, 'begin');
+                            value_end = process(value_end, 'end');
                         }
                         value = value_begin + ',' + value_end;
                     } else {
@@ -9087,10 +9088,10 @@ define('form',['jquery', 'bootstrap', 'upload', 'validator'], function ($, undef
                     }
                 } else {
                     value = $("[name='" + name + "']:checked", that.$commonsearch).val();
-                    value = (vObjCol && typeof vObjCol.process === 'function') ? vObjCol.process(value) : value;
+                    value = process ? process(value) : value;
                 }
             } else {
-                value = (vObjCol && typeof vObjCol.process === 'function') ? vObjCol.process(obj.val()) : obj.val();
+                value = process ? process(obj.val()) : obj.val();
             }
             if (removeempty && (value == '' || value == null || ($.isArray(value) && value.length == 0)) && !sym.match(/null/i)) {
                 return true;