From 20dd8c6ac9a743e51640196c9a6df4497cf6e472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=98=E4=BF=97=E4=BA=8C=E5=B8=88=E5=85=84?= <505097558@qq.com> Date: Sat, 25 Apr 2026 19:45:12 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DsearchList=E4=BD=BF=E7=94=A8$?= =?UTF-8?q?.getJSON=E7=AD=89=E5=BC=82=E6=AD=A5=E8=8E=B7=E5=8F=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BC=82=E5=B8=B8=E4=BF=AE=E5=A4=8DsearchList?= =?UTF-8?q?=E4=BD=BF=E7=94=A8$.getJSON=E7=AD=89=E5=BC=82=E6=AD=A5=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8=20=E5=B0=81?= =?UTF-8?q?=E8=A3=85=E7=9A=84combineSearchList=20=E4=B8=AD=20$.when(list)?= =?UTF-8?q?=20=E5=BC=82=E6=AD=A5=E6=89=A7=E8=A1=8C=EF=BC=8C=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=8B=BC=E8=A3=85option=EF=BC=8C=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E8=BF=94=E5=9B=9E=E4=BA=86jq=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E7=BB=84=EF=BC=8C=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 还俗二师兄 <505097558@qq.com> --- .../assets/js/bootstrap-table-commonsearch.js | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/public/assets/js/bootstrap-table-commonsearch.js b/public/assets/js/bootstrap-table-commonsearch.js index 428f707f..42f20c07 100644 --- a/public/assets/js/bootstrap-table-commonsearch.js +++ b/public/assets/js/bootstrap-table-commonsearch.js @@ -134,7 +134,7 @@ var createOptionList = function (searchList, vObjCol, that) { var optionList = []; optionList.push(sprintf('', that.options.formatCommonChoose())); - searchList = $.fn.bootstrapTable.utils.combineSearchList(searchList); + searchList = $.fn.bootstrapTable.utils.combineSearchList(searchList, vObjCol, that); $.each(searchList, function (key, value) { optionList.push(sprintf("", key == vObjCol.defaultValue ? 'selected' : '')); }); @@ -286,7 +286,7 @@ _initSearch = BootstrapTable.prototype.initSearch; // 定义通用searchList处理方法 - $.fn.bootstrapTable.utils.combineSearchList = function (list) { + $.fn.bootstrapTable.utils.combineSearchList = function (list, vObjCol, that) { var searchList = {}; if (typeof list !== 'undefined') { @@ -302,7 +302,19 @@ } else { list = ret; } + let optionList = []; + $.each(list, function (key, val) { + if (typeof val !== 'undefined' && val.constructor === Object) { + key = val.id; + val = val[vObjCol.nameKey || 'name']; + } else { + key = isArray ? val : key; + } + optionList.push(sprintf("", key == vObjCol.defaultValue && vObjCol.defaultValue !='' ? 'selected' : '')); + }); + $("form.form-commonsearch select[name='" + vObjCol.field + "']", that.$container).append(optionList.join('')).trigger("change"); }); + list = ''; } // 兼容旧版本searchList返回字符串直接渲染自定义搜索栏 if (typeof list === 'string') { @@ -438,3 +450,16 @@ }) : this.data; }; }(jQuery); +/** + * FastAdmin通用搜索 + * + * @author: pppscn <35696959@qq.com> + * @update 2017-05-07 + * + * @author: Karson + * @update 2018-04-05 + */ +… return true; + }) : this.data; + }; +}(jQuery);