优化通用搜索表单重置

优化标签渲染
pull/305/MERGE
Karson 2021-06-04 14:57:03 +08:00
parent 4e657d1f25
commit 8130a49fab
2 changed files with 29 additions and 4 deletions

View File

@ -40,6 +40,7 @@
// 重置搜索
form.on("click", "button[type=reset]", function (event) {
form[0].reset();
setTimeout(function () {
that.onCommonSearch();
}, 0);
@ -329,13 +330,19 @@
});
that.$container.on("click", "." + that.options.searchClass, function () {
var obj = $("form [name='" + $(this).data("field") + "']", that.$commonsearch);
var value = $(this).data("value");
var field = $(this).data("field");
var ul = that.$container.closest(".panel-intro").find("ul[data-field='" + field + "']");
if (ul.length > 0) {
$('li a[data-value="' + value + '"][data-toggle="tab"]', ul).trigger('click');
return;
}
var obj = $("form [name='" + field + "']", that.$commonsearch);
if (obj.size() > 0) {
var value = $(this).data("value");
if (obj.is("select")) {
$("option[value='" + value + "']", obj).prop("selected", true);
} else if (obj.size() > 1) {
$("form [name='" + $(this).data("field") + "'][value='" + value + "']", that.$commonsearch).prop("checked", true);
$("form [name='" + field + "'][value='" + value + "']", that.$commonsearch).prop("checked", true);
} else {
obj.val(value + "");
}

View File

@ -285,7 +285,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
$(Table.config.disabledbtn, toolbar).toggleClass('disabled', !options.selectedIds.length);
});
// 绑定TAB事件
$('.panel-heading [data-field] a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
$('.panel-heading [data-field] a[data-toggle="tab"]', table.closest(".panel-intro")).on('shown.bs.tab', function (e) {
var field = $(this).closest("[data-field]").data("field");
var value = $(this).data("value");
var object = $("[name='" + field + "']", table.closest(".bootstrap-table").find(".commonsearch-table"));
@ -298,6 +298,14 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
table.bootstrapTable('refresh', {pageNumber: 1});
return false;
});
// 修复重置事件
$("form", table.closest(".bootstrap-table").find(".commonsearch-table")).on('reset', function () {
setTimeout(function () {
// $('.panel-heading [data-field] li.active a[data-toggle="tab"]').trigger('shown.bs.tab');
}, 0);
$('.panel-heading [data-field] li', table.closest(".panel-intro")).removeClass('active');
$('.panel-heading [data-field] li:first', table.closest(".panel-intro")).addClass('active');
});
// 刷新按钮事件
toolbar.on('click', Table.config.refreshbtn, function () {
table.bootstrapTable('refresh');
@ -734,6 +742,16 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
value = row[this.customField];
field = this.customField;
}
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;
}
});
}
//渲染Flag
var html = [];