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 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DsearchList=E4=BD=BF?= =?UTF-8?q?=E7=94=A8$.getJSON=E7=AD=89=E5=BC=82=E6=AD=A5=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8=20=E4=BF=AE=E5=A4=8Dsearch?= =?UTF-8?q?List=E4=BD=BF=E7=94=A8$.getJSON=E7=AD=89=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8=EF=BC=8C?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E8=BF=98=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=8F=AF?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=20name=E4=B8=8B=E6=A0=87=E7=9A=84na?= =?UTF-8?q?meKey?= 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') { -- Gitee From 23919a8754b316b9112b8a1082faf86e0d68d5b6 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: Sun, 26 Apr 2026 02:53:22 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E9=80=82=E9=85=8DnameKey=20=E9=80=82?= =?UTF-8?q?=E9=85=8DnameKey?= 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/assets/js/bootstrap-table-commonsearch.js b/public/assets/js/bootstrap-table-commonsearch.js index 56874e0e..094906db 100644 --- a/public/assets/js/bootstrap-table-commonsearch.js +++ b/public/assets/js/bootstrap-table-commonsearch.js @@ -325,7 +325,7 @@ $.each(list, function (key, val) { if (typeof val !== 'undefined' && val.constructor === Object) { key = val.id; - val = val.name; + val = val[vObjCol.nameKey || 'name']; } else { key = isArray ? val : key; } -- Gitee