', columnClass, (typeof vObjCol.searchVisible === 'undefined' || vObjCol.searchVisible) ? '' : 'hidden'));
htmlForm.push(sprintf('
', vObjCol.field, vObjCol.title));
htmlForm.push('
');
@@ -86,23 +87,7 @@
if (typeof vObjCol.searchList === 'function') {
htmlForm.push(vObjCol.searchList.call(this, vObjCol));
} else {
- var optionList = [sprintf('', that.options.formatCommonChoose())];
- if (typeof vObjCol.searchList === 'object' && typeof vObjCol.searchList.then === 'function') {
- (function (vObjCol, that) {
- $.when(vObjCol.searchList).done(function (ret) {
- var searchList = [];
- if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) {
- searchList = ret.data.searchlist;
- } else if (ret.constructor === Array || ret.constructor === Object) {
- searchList = ret;
- }
- var optionList = createOptionList(searchList, vObjCol, that);
- $("form.form-commonsearch select[name='" + vObjCol.field + "']", that.$container).html(optionList.join('')).trigger("change");
- });
- })(vObjCol, that);
- } else {
- optionList = createOptionList(vObjCol.searchList, vObjCol, that);
- }
+ var optionList = createOptionList(vObjCol.searchList, vObjCol, that);
htmlForm.push(sprintf('', addClass, vObjCol.field, style, extend, optionList.join('')));
}
} else {
@@ -125,7 +110,7 @@
htmlForm.push('
');
}
}
- htmlForm.push('
');
@@ -147,16 +132,10 @@
};
var createOptionList = function (searchList, vObjCol, that) {
- var isArray = searchList.constructor === Array;
var optionList = [];
optionList.push(sprintf('
', that.options.formatCommonChoose()));
+ searchList = $.fn.bootstrapTable.utils.combineSearchList(searchList);
$.each(searchList, function (key, value) {
- if (value.constructor === Object) {
- key = value.id;
- value = value.name;
- } else {
- key = isArray ? value : key;
- }
optionList.push(sprintf("
", key == vObjCol.defaultValue ? 'selected' : ''));
});
return optionList;
@@ -306,6 +285,43 @@
_load = BootstrapTable.prototype.load,
_initSearch = BootstrapTable.prototype.initSearch;
+ // 定义通用searchList处理方法
+ $.fn.bootstrapTable.utils.combineSearchList = function (list) {
+ var searchList = {};
+
+ if (typeof list !== 'undefined') {
+ var isFunction = list.constructor === Function;
+ var isAjax = typeof list === 'object' && typeof list.then === 'function';
+ if (isFunction) {
+ list = list();
+ } else if (isAjax) {
+ $.when(list).done(function (ret) {
+ // 兼容旧版本在data中返回searchlist
+ if (typeof ret.data.searchlist !== 'undefined') {
+ list = ret.data.searchlist;
+ } else {
+ list = ret;
+ }
+ });
+ }
+ // 兼容旧版本searchList返回字符串直接渲染自定义搜索栏
+ if (typeof list === 'string') {
+ return searchList;
+ }
+ var isArray = list.constructor === Array;
+ var i = 0;
+ $.each(list, function (key, val) {
+ if (typeof val !== 'undefined' && val.constructor === Object) {
+ key = val.id;
+ val = val.name;
+ } else {
+ key = isArray ? val : key;
+ }
+ searchList[key] = val;
+ });
+ }
+ return searchList;
+ };
BootstrapTable.prototype.initHeader = function () {
_initHeader.apply(this, Array.prototype.slice.apply(arguments));
this.$header.find('th[data-field]').each(function (i) {
diff --git a/public/assets/js/require-form.js b/public/assets/js/require-form.js
index ac125a8f..e46d928b 100755
--- a/public/assets/js/require-form.js
+++ b/public/assets/js/require-form.js
@@ -295,7 +295,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
}
}
var result = urlArr.join(",");
- inputObj.val(result).trigger("change").trigger("validate");
+ inputObj.val(result).trigger("change", [data]).trigger("validate");
} else if (input_id) {
var url = Config.upload.fullmode ? Fast.api.cdnurl(data.url, true) : data.url;
$("#" + input_id).val(url).trigger("change").trigger("validate");
diff --git a/public/assets/js/require-table.js b/public/assets/js/require-table.js
index bed68dae..cb52c49a 100644
--- a/public/assets/js/require-table.js
+++ b/public/assets/js/require-table.js
@@ -244,7 +244,13 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
if (options.dblClickToEdit) {
//当双击单元格时
table.on('dbl-click-row.bs.table', function (e, row, element, field) {
- $(Table.config.editonebtn, element).trigger("click");
+ var editone = $(Table.config.editonebtn, element);
+ if (editone.length > 0) {
+ editone.trigger("click");
+ } else if (options.extend.edit_url) {
+ // 判断是否允许双击编辑
+ Table.api.events.operate['click .btn-editone'].call(element, e, undefined, row, element.index());
+ }
});
}
//渲染内容前
@@ -855,13 +861,14 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
}
value = row[this.field] || value;
value = value == null || value.length === 0 ? '' : value.toString();
+ this.searchList = $.fn.bootstrapTable.utils.combineSearchList(this.searchList);
var keys = typeof this.searchList === 'object' ? Object.keys(this.searchList) : [];
- var index = keys.indexOf(value);
+ var keyIndex = keys.indexOf(value);
var color = value && typeof custom[value] !== 'undefined' ? custom[value] : null;
var display = index > -1 ? this.searchList[value] : null;
var icon = typeof this.icon !== 'undefined' ? this.icon : null;
if (!color) {
- color = index > -1 && typeof colorArr[index] !== 'undefined' ? colorArr[index] : 'primary';
+ color = keyIndex > -1 && typeof colorArr[keyIndex] !== 'undefined' ? colorArr[keyIndex] : 'primary';
}
if (!display) {
display = __(value.charAt(0).toUpperCase() + value.slice(1));
@@ -938,25 +945,9 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
value = Fast.api.escape(customValue);
field = this.customField;
}
- if (typeof that.searchList === 'object' && typeof that.searchList.then === 'function') {
- $.when(that.searchList).done(function (ret) {
- if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) {
- that.searchList = ret.data.searchlist;
- } else if (ret.constructor === Array || ret.constructor === Object) {
- that.searchList = ret;
- }
- })
- }
- if (typeof that.searchList === 'object' && typeof that.custom === 'undefined') {
- var i = 0;
- var searchValues = Object.values(colorArr);
- $.each(that.searchList, function (key, val) {
- if (typeof colorArr[key] == 'undefined') {
- colorArr[key] = searchValues[i];
- i = typeof searchValues[i + 1] === 'undefined' ? 0 : i + 1;
- }
- });
- }
+
+ //优化searchList
+ that.searchList = $.fn.bootstrapTable.utils.combineSearchList(that.searchList);
//渲染Flag
var html = [];
@@ -967,7 +958,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
if (value === '')
return true;
color = value && typeof colorArr[value] !== 'undefined' ? colorArr[value] : 'primary';
- display = typeof that.searchList !== 'undefined' && typeof that.searchList[value] !== 'undefined' ? that.searchList[value] : __(value.charAt(0).toUpperCase() + value.slice(1));
+ display = typeof that.searchList[value] !== 'undefined' ? that.searchList[value] : __(value.charAt(0).toUpperCase() + value.slice(1));
value = Fast.api.escape(value);
display = Fast.api.escape(display);
label = '
' + display + '';