改进普通搜索插件——支持传入css样式、延时隐藏避免宽度不正确

pull/98/head
PPPSCN 2019-02-16 17:49:54 +08:00
parent 5182cf28c9
commit 779f5d63ef
3 changed files with 34 additions and 11 deletions

View File

@ -113,9 +113,16 @@ html.ios-fix body {
table.table-template {
overflow: hidden;
}
.sp_container .msg-box {
.pp_container {
border: none;
margin: 0;
padding: 0;
position: relative;
vertical-align: middle;
}
.sp_container .msg-box,.pp_container .msg-box {
position: absolute;
right: 0;
left: 0;
top: 0;
}
.toast-top-right-index {

View File

@ -6,6 +6,9 @@
*
* @author: Karson <karsonzhang@163.com>
* @update 2018-04-05 <https://gitee.com/karson/fastadmin>
*
* @author: pppscn <35696959@qq.com>
* @update 2019-02-16 <https://gitee.com/pp/fastadmin>
*/
!function ($) {
@ -18,12 +21,17 @@
var initCommonSearch = function (pColumns, that) {
var vFormCommon = createFormCommon(pColumns, that);
var vModal = sprintf("<div class=\"commonsearch-table %s\">", that.options.searchFormVisible ? "" : "hidden");
var vModal = "<div class=\"commonsearch-table\">";
vModal += vFormCommon;
vModal += "</div>";
that.$container.prepend($(vModal));
that.$commonsearch = $(".commonsearch-table", that.$container);
var form = $("form.form-commonsearch", that.$commonsearch);
if(!that.options.searchFormVisible){
setTimeout(function () {
that.$commonsearch.addClass('hidden');
},100);
}
require(['form'], function (Form) {
Form.api.bindevent(form);
@ -51,7 +59,7 @@
return Template(that.options.searchFormTemplate, {columns: pColumns, table: that});
}
var htmlForm = [];
htmlForm.push(sprintf('<form class="form-horizontal form-commonsearch" novalidate method="post" action="%s" >', that.options.actionForm));
htmlForm.push(sprintf('<form class="%s" novalidate method="post" action="%s">', that.options.searchFormCss.form, that.options.actionForm));
htmlForm.push('<fieldset>');
if (that.options.titleForm.length > 0)
htmlForm.push(sprintf("<legend>%s</legend>", that.options.titleForm));
@ -66,9 +74,9 @@
vObjCol.operate = that.options.renderDefault && operate ? operate : (typeof vObjCol.operate === 'undefined' ? '=' : vObjCol.operate);
ColumnsForSearch.push(vObjCol);
htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
htmlForm.push(sprintf('<label for="%s" class="control-label col-xs-4">%s</label>', vObjCol.field, vObjCol.title));
htmlForm.push('<div class="col-xs-8">');
htmlForm.push(sprintf('<div class="%s">', that.options.searchFormCss.form_group));
htmlForm.push(sprintf('<label for="%s" class="%s">%s</label>', vObjCol.field, that.options.searchFormCss.label, vObjCol.title));
htmlForm.push(sprintf('<div class="%s">', that.options.searchFormCss.container));
vObjCol.operate = vObjCol.operate ? vObjCol.operate.toUpperCase() : '=';
htmlForm.push(sprintf('<input type="hidden" class="form-control operate" name="%s-operate" data-name="%s" value="%s" readonly>', vObjCol.field, vObjCol.field, vObjCol.operate));
@ -120,7 +128,8 @@
htmlForm.push('</div>');
}
}
htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
htmlForm.push(sprintf('<div class="%s">', that.options.searchFormCss.form_group));
htmlForm.push(sprintf('<label class="%s">&nbsp;</label>', that.options.searchFormCss.label_btn));
htmlForm.push(createFormBtn(that).join(''));
htmlForm.push('</div>');
htmlForm.push('</div>');
@ -134,7 +143,7 @@
var htmlBtn = [];
var searchSubmit = that.options.formatCommonSubmitButton();
var searchReset = that.options.formatCommonResetButton();
htmlBtn.push('<div class="col-sm-8 col-xs-offset-4">');
htmlBtn.push(sprintf('<div class="%s">', that.options.searchFormCss.container));
htmlBtn.push(sprintf('<button type="submit" class="btn btn-success" formnovalidate>%s</button> ', searchSubmit));
htmlBtn.push(sprintf('<button type="reset" class="btn btn-default" >%s</button> ', searchReset));
htmlBtn.push('</div>');
@ -380,8 +389,8 @@
[value, item, i], value);
if (!($.inArray(key, that.header.fields) !== -1 &&
(typeof value === 'string' || typeof value === 'number') &&
(value + '').toLowerCase().indexOf(fval) !== -1)) {
(typeof value === 'string' || typeof value === 'number') &&
(value + '').toLowerCase().indexOf(fval) !== -1)) {
return false;
}
}

View File

@ -44,6 +44,13 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
import_url: '',
multi_url: '',
dragsort_url: 'ajax/weigh',
},
searchFormCss: {
form: 'form-commonsearch',
form_group: 'form-group col-xs-12 col-sm-6 col-md-4 col-lg-3',
label: 'control-label',
label_btn: 'control-label hidden-xs',
container: 'pp_container',
}
},
// Bootstrap-table 列配置