From f883cad61317953d67aaddc4b9d78636e074ce3d 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:58:45 +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=20=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=EF=BC=8C=E5=90=8C?=
=?UTF-8?q?=E6=97=B6=E8=BF=98=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=8F=AF=E8=87=AA?=
=?UTF-8?q?=E5=AE=9A=E4=B9=89=20name=E4=B8=8B=E6=A0=87=E7=9A=84nameKey?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: 还俗二师兄 <505097558@qq.com>
---
public/assets/js/bootstrap-table-commonsearch.js | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/public/assets/js/bootstrap-table-commonsearch.js b/public/assets/js/bootstrap-table-commonsearch.js
index 428f707f..56874e0e 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') {