From beccee081136da604e7f2a25d03503c135291dec Mon Sep 17 00:00:00 2001 From: Karson Date: Thu, 13 Aug 2020 10:46:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Enull=E6=88=96=E7=A9=BA?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=AD=9B=E9=80=89=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=E8=A1=A8=E6=A0=BC=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=AD=97=E6=AE=B5renderDefault=E6=8E=A7=E5=88=B6=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/controller/Backend.php | 11 +++++++++++ public/assets/js/bootstrap-table-commonsearch.js | 11 ++++++----- public/assets/js/require-backend.min.js | 11 ++++++----- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/application/common/controller/Backend.php b/application/common/controller/Backend.php index 40d2a60c..12d17835 100644 --- a/application/common/controller/Backend.php +++ b/application/common/controller/Backend.php @@ -296,6 +296,17 @@ class Backend extends Controller } $v = !is_array($v) ? trim($v) : $v; $sym = strtoupper(isset($op[$k]) ? $op[$k] : $sym); + //null和空字符串特殊处理 + if (!is_array($v)) { + if (in_array(strtoupper($v), ['NULL', 'NOT NULL'])) { + $sym = strtoupper($v); + } + if (in_array($v, ['""', "''"])) { + $v = ''; + $sym = '='; + } + } + switch ($sym) { case '=': case '<>': diff --git a/public/assets/js/bootstrap-table-commonsearch.js b/public/assets/js/bootstrap-table-commonsearch.js index a0d535bd..d340f26d 100644 --- a/public/assets/js/bootstrap-table-commonsearch.js +++ b/public/assets/js/bootstrap-table-commonsearch.js @@ -64,8 +64,9 @@ var query = Fast.api.query(vObjCol.field); var operate = Fast.api.query(vObjCol.field + "-operate"); - vObjCol.defaultValue = that.options.renderDefault && query ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue); - vObjCol.operate = that.options.renderDefault && operate ? operate : (typeof vObjCol.operate === 'undefined' ? '=' : vObjCol.operate); + var renderDefault = that.options.renderDefault && (typeof vObjCol.renderDefault == 'undefined' || vObjCol.renderDefault); + vObjCol.defaultValue = renderDefault && query ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue); + vObjCol.operate = renderDefault && operate ? operate : (typeof vObjCol.operate === 'undefined' ? '=' : vObjCol.operate); ColumnsForSearch.push(vObjCol); htmlForm.push('
'); @@ -333,7 +334,7 @@ } else if (obj.size() > 1) { $("form [name='" + $(this).data("field") + "'][value='" + value + "']", that.$commonsearch).prop("checked", true); } else { - obj.val(value); + obj.val(value + ""); } obj.trigger("change"); $("form", that.$commonsearch).trigger("submit"); @@ -382,8 +383,8 @@ [value, item, i], value); if (!($.inArray(key, that.header.fields) !== -1 && - (typeof value === 'string' || typeof value === 'number') && - (value + '').toLowerCase().indexOf(fval) !== -1)) { + (typeof value === 'string' || typeof value === 'number') && + (value + '').toLowerCase().indexOf(fval) !== -1)) { return false; } } diff --git a/public/assets/js/require-backend.min.js b/public/assets/js/require-backend.min.js index b58113ac..9b2aaeb5 100644 --- a/public/assets/js/require-backend.min.js +++ b/public/assets/js/require-backend.min.js @@ -10565,8 +10565,9 @@ define('form',['jquery', 'bootstrap', 'upload', 'validator'], function ($, undef var query = Fast.api.query(vObjCol.field); var operate = Fast.api.query(vObjCol.field + "-operate"); - vObjCol.defaultValue = that.options.renderDefault && query ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue); - vObjCol.operate = that.options.renderDefault && operate ? operate : (typeof vObjCol.operate === 'undefined' ? '=' : vObjCol.operate); + var renderDefault = that.options.renderDefault && (typeof vObjCol.renderDefault == 'undefined' || vObjCol.renderDefault); + vObjCol.defaultValue = renderDefault && query ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue); + vObjCol.operate = renderDefault && operate ? operate : (typeof vObjCol.operate === 'undefined' ? '=' : vObjCol.operate); ColumnsForSearch.push(vObjCol); htmlForm.push('
'); @@ -10834,7 +10835,7 @@ define('form',['jquery', 'bootstrap', 'upload', 'validator'], function ($, undef } else if (obj.size() > 1) { $("form [name='" + $(this).data("field") + "'][value='" + value + "']", that.$commonsearch).prop("checked", true); } else { - obj.val(value); + obj.val(value + ""); } obj.trigger("change"); $("form", that.$commonsearch).trigger("submit"); @@ -10883,8 +10884,8 @@ define('form',['jquery', 'bootstrap', 'upload', 'validator'], function ($, undef [value, item, i], value); if (!($.inArray(key, that.header.fields) !== -1 && - (typeof value === 'string' || typeof value === 'number') && - (value + '').toLowerCase().indexOf(fval) !== -1)) { + (typeof value === 'string' || typeof value === 'number') && + (value + '').toLowerCase().indexOf(fval) !== -1)) { return false; } }