diff --git a/public/assets/js/bootstrap-table-commonsearch.js b/public/assets/js/bootstrap-table-commonsearch.js
index 428f707fe08b12626e4daf4fac07dd1cb48a4d62..7a7d02d98705aef51a829ab355d73413325b61f1 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') {
@@ -294,7 +294,7 @@
var isAjax = typeof list === 'object' && typeof list.then === 'function';
if (isFunction) {
list = list();
- } else if (isAjax) {
+ } else if (isAjax && vObjCol) {
$.when(list).done(function (ret) {
// 兼容旧版本在data中返回searchlist
if (typeof ret.data.searchlist !== 'undefined') {
@@ -302,7 +302,21 @@
} else {
list = ret;
}
+ let optionList = [];
+ $.each(list, function (key, val) {
+ if (typeof val !== 'undefined' && val.constructor === Object) {
+ key = val.id;
+ vObjCol.nameKey = typeof vObjCol.nameKey === 'undefined' ? 'name' : vObjCol.nameKey
+ val = val[vObjCol.nameKey];
+ } else {
+ key = isArray ? val : key;
+ }
+ vObjCol.defaultValue = typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue
+ 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') {
@@ -313,7 +327,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;
}