Browse Source

[update]:表格冻结列实现

dev
youjianchi 8 months ago
parent
commit
077fff1112
  1. 322
      ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js
  2. 1
      ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.min.js
  3. 211
      ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.js
  4. 7
      ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js
  5. 33
      ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css
  6. 12
      ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js
  7. 170
      ruoyi-admin/src/main/resources/templates/demo/table/fixedColumns.html
  8. 2
      ruoyi-admin/src/main/resources/templates/erp/material/material.html
  9. 2
      ruoyi-admin/src/main/resources/templates/include.html

322
ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js

@ -0,0 +1,322 @@
/**
* 基于bootstrap-table-fixed-columns修改
* 支持左右列冻结支持固定高度
* Copyright (c) 2019 ruoyi
*/
(function ($) {
'use strict';
$.extend($.fn.bootstrapTable.defaults, {
fixedColumns: false,
fixedNumber: 1,
rightFixedColumns: false,
rightFixedNumber: 1
});
var BootstrapTable = $.fn.bootstrapTable.Constructor,
_initHeader = BootstrapTable.prototype.initHeader,
_initBody = BootstrapTable.prototype.initBody,
_resetView = BootstrapTable.prototype.resetView;
BootstrapTable.prototype.initFixedColumns = function () {
this.timeoutHeaderColumns_ = 0;
this.timeoutBodyColumns_ = 0;
if (this.options.fixedColumns) {
this.$fixedHeader = $([
'<div class="left-fixed-table-columns">',
'<table>',
'<thead></thead>',
'</table>',
'</div>'].join(''));
this.$fixedHeader.find('table').attr('class', this.$el.attr('class'));
this.$fixedHeaderColumns = this.$fixedHeader.find('thead');
this.$tableHeader.before(this.$fixedHeader);
this.$fixedBody = $([
'<div class="left-fixed-body-columns">',
'<table>',
'<tbody></tbody>',
'</table>',
'</div>'].join(''));
this.$fixedBody.find('table').attr('class', this.$el.attr('class'));
this.$fixedBodyColumns = this.$fixedBody.find('tbody');
this.$tableBody.before(this.$fixedBody);
}
if (this.options.rightFixedColumns) {
this.$rightfixedBody = $([
'<div class="right-fixed-table-columns">',
'<table>',
'<thead></thead>',
'<tbody style="background-color: #fff;"></tbody>',
'</table>',
'</div>'].join(''));
this.$rightfixedBody.find('table').attr('class', this.$el.attr('class'));
this.$rightfixedHeaderColumns = this.$rightfixedBody.find('thead');
this.$rightfixedBodyColumns = this.$rightfixedBody.find('tbody');
this.$tableBody.before(this.$rightfixedBody);
if (this.options.fixedColumns) {
$('.right-fixed-table-columns').attr('style','right:0px');
}
}
};
BootstrapTable.prototype.initHeader = function () {
_initHeader.apply(this, Array.prototype.slice.apply(arguments));
if (!this.options.fixedColumns && !this.options.rightFixedColumns){
return;
}
this.initFixedColumns();
var $ltr = this.$header.find('tr:eq(0)').clone(true),
$rtr = this.$header.find('tr:eq(0)').clone(),
$lths = $ltr.clone(true).find('th'),
$rths = $rtr.clone().find('th');
$ltr.html('');
$rtr.html('');
//右边列冻结
if (this.options.rightFixedColumns) {
for (var i = 0; i < this.options.rightFixedNumber; i++) {
$rtr.append($rths.eq($rths.length - this.options.rightFixedNumber + i).clone());
}
this.$rightfixedHeaderColumns.html('').append($rtr);
}
//左边列冻结
if (this.options.fixedColumns) {
for (var i = 0; i < this.options.fixedNumber; i++) {
$ltr.append($lths.eq(i).clone(true));
}
this.$fixedHeaderColumns.html('').append($ltr);
this.$selectAll = $ltr.find('[name="btSelectAll"]');
this.$selectAll.on('click', function () {
var checked = $(this).prop('checked');
$(".left-fixed-body-columns input[name=btSelectItem]").filter(':enabled').prop('checked', checked);
$('.fixed-table-body input[name=btSelectItem]').closest('tr').removeClass('selected');
});
}
};
BootstrapTable.prototype.initBody = function () {
_initBody.apply(this, Array.prototype.slice.apply(arguments));
if (!this.options.fixedColumns && !this.options.rightFixedColumns) {
return;
}
var that = this;
if (this.options.fixedColumns) {
this.$fixedBodyColumns.html('');
this.$body.find('> tr[data-index]').each(function () {
var $tr = $(this).clone(true),
$tds = $tr.clone(true).find('td');
$tr.html('');
for (var i = 0; i < that.options.fixedNumber; i++) {
$tr.append($tds.eq(i).clone(true));
}
that.$fixedBodyColumns.append($tr);
});
}
if (this.options.rightFixedColumns) {
this.$rightfixedBodyColumns.html('');
this.$body.find('> tr[data-index]').each(function () {
var $tr = $(this).clone(),
$tds = $tr.clone().find('td');
$tr.html('');
for (var i = 0; i < that.options.rightFixedNumber; i++) {
var indexTd = $tds.length - that.options.rightFixedNumber + i;
var oldTd = $tds.eq(indexTd);
var fixTd = oldTd.clone();
var buttons = fixTd.find('button');
//事件转移:冻结列里面的事件转移到实际按钮的事件
buttons.each(function (key, item) {
$(item).click(function () {
that.$body.find("tr[data-index=" + $tr.attr('data-index') + "] td:eq(" + indexTd + ") button:eq(" + key + ")").click();
});
});
$tr.append(fixTd);
}
that.$rightfixedBodyColumns.append($tr);
});
}
};
BootstrapTable.prototype.resetView = function () {
_resetView.apply(this, Array.prototype.slice.apply(arguments));
if (!this.options.fixedColumns && !this.options.rightFixedColumns) {
return;
}
clearTimeout(this.timeoutHeaderColumns_);
this.timeoutHeaderColumns_ = setTimeout($.proxy(this.fitHeaderColumns, this), this.$el.is(':hidden') ? 100 : 0);
clearTimeout(this.timeoutBodyColumns_);
this.timeoutBodyColumns_ = setTimeout($.proxy(this.fitBodyColumns, this), this.$el.is(':hidden') ? 100 : 0);
};
BootstrapTable.prototype.fitHeaderColumns = function () {
var that = this,
visibleFields = this.getVisibleFields(),
headerWidth = 0;
if (that.options.fixedColumns) {
this.$body.find('tr:first-child:not(.no-records-found) > *').each(function (i) {
var $this = $(this),
index = i;
if (i >= that.options.fixedNumber) {
return false;
}
if (that.options.detailView && !that.options.cardView) {
index = i - 1;
}
that.$fixedHeader.find('thead th[data-field="' + visibleFields[index] + '"]')
.find('.fht-cell').width($this.innerWidth());
headerWidth += $this.outerWidth();
});
this.$fixedHeader.width(headerWidth + 2).show();
}
if (that.options.rightFixedColumns) {
this.$body.find('tr:first-child:not(.no-records-found) > *').each(function (i) {
var $this = $(this),
index = i;
if (i >= visibleFields.length - that.options.rightFixedNumber) {
return false;
if (that.options.detailView && !that.options.cardView) {
index = i - 1;
}
that.$rightfixedBody.find('thead th[data-field="' + visibleFields[index] + '"]')
.find('.fht-cell').width($this.innerWidth() - 1);
headerWidth += $this.outerWidth();
}
});
this.$rightfixedBody.width(headerWidth - 1).show();
}
};
BootstrapTable.prototype.fitBodyColumns = function () {
var that = this,
top = -(parseInt(this.$el.css('margin-top'))),
height = this.$tableBody.height();
if (that.options.fixedColumns) {
if (!this.$body.find('> tr[data-index]').length) {
this.$fixedBody.hide();
return;
}
if (!this.options.height) {
top = this.$fixedHeader.height()- 1;
height = height - top;
}
this.$fixedBody.css({
width: this.$fixedHeader.width(),
height: height,
top: top + 1
}).show();
this.$body.find('> tr').each(function (i) {
that.$fixedBody.find('tr:eq(' + i + ')').height($(this).height() - 0.5);
var thattds = this;
that.$fixedBody.find('tr:eq(' + i + ')').find('td').each(function (j) {
$(this).width($($(thattds).find('td')[j]).width() + 1);
});
});
$("#" + table.options.id).on("check.bs.table uncheck.bs.table", function (e, rows, $element) {
var index= $element.data('index');
$(this).find('.bs-checkbox').find('input[data-index="' + index + '"]').prop("checked", true);
var selectFixedItem = $('.left-fixed-body-columns input[name=btSelectItem]');
var checkAll = selectFixedItem.filter(':enabled').length &&
selectFixedItem.filter(':enabled').length ===
selectFixedItem.filter(':enabled').filter(':checked').length;
$(".left-fixed-table-columns input[name=btSelectAll]").prop('checked', checkAll);
$('.fixed-table-body input[name=btSelectItem]').closest('tr').removeClass('selected');
});
$("#" + table.options.id).off('click', '.fixed-table-body').on('click', '.th-inner', function (event) {
$.each(that.$fixedHeader.find('th'), function (i, th) {
$(th).find('.sortable').removeClass('desc asc').addClass('both');
});
});
// events
this.$fixedHeader.off('click', '.th-inner').on('click', '.th-inner', function (event) {
var target = $(this);
var $this = event.type === "keypress" ? $(event.currentTarget) : $(event.currentTarget).parent(), $this_ = that.$header.find('th').eq($this.index());
var sortOrder = "";
if (table.options.sortName === $this.data('field')) {
sortOrder = table.options.sortOrder === 'asc' ? 'desc' : 'asc';
} else {
sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc';
}
table.options.sortOrder = sortOrder;
var sortName = $this.data('sortName') ? $this.data('sortName') : $this.data('field');
if (target.parent().data().sortable) {
$.each(that.$fixedHeader.find('th'), function (i, th) {
$(th).find('.sortable').removeClass('desc asc').addClass(($(th).data('field') === sortName || $(th).data('sortName') === sortName) ? sortOrder : 'both');
});
}
});
this.$tableBody.on('scroll', function () {
that.$fixedBody.find('table').css('top', -$(this).scrollTop());
});
this.$body.find('> tr[data-index]').off('hover').hover(function () {
var index = $(this).data('index');
that.$fixedBody.find('tr[data-index="' + index + '"]').addClass('hover');
}, function () {
var index = $(this).data('index');
that.$fixedBody.find('tr[data-index="' + index + '"]').removeClass('hover');
});
this.$fixedBody.find('tr[data-index]').off('hover').hover(function () {
var index = $(this).data('index');
that.$body.find('tr[data-index="' + index + '"]').addClass('hover');
}, function () {
var index = $(this).data('index');
that.$body.find('> tr[data-index="' + index + '"]').removeClass('hover');
});
}
if (that.options.rightFixedColumns) {
if (!this.$body.find('> tr[data-index]').length) {
this.$rightfixedBody.hide();
return;
}
this.$body.find('> tr').each(function (i) {
that.$rightfixedBody.find('tbody tr:eq(' + i + ')').height($(this).height());
});
//// events
this.$tableBody.on('scroll', function () {
that.$rightfixedBody.find('table').css('top', -$(this).scrollTop());
});
this.$body.find('> tr[data-index]').off('hover').hover(function () {
var index = $(this).data('index');
that.$rightfixedBody.find('tr[data-index="' + index + '"]').addClass('hover');
}, function () {
var index = $(this).data('index');
that.$rightfixedBody.find('tr[data-index="' + index + '"]').removeClass('hover');
});
this.$rightfixedBody.find('tr[data-index]').off('hover').hover(function () {
var index = $(this).data('index');
that.$body.find('tr[data-index="' + index + '"]').addClass('hover');
}, function () {
var index = $(this).data('index');
that.$body.find('> tr[data-index="' + index + '"]').removeClass('hover');
});
}
};
})(jQuery);

1
ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.min.js

File diff suppressed because one or more lines are too long

211
ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.js

@ -0,0 +1,211 @@
/**
* @author: aperez <aperez@datadec.es>
* @version: v2.0.0
*
* @update Dennis Hernández <http://djhvscf.github.io/Blog>
*/
!function($) {
'use strict';
var firstLoad = false;
var sprintf = $.fn.bootstrapTable.utils.sprintf;
var showAvdSearch = function(pColumns, searchTitle, searchText, that) {
if (!$("#avdSearchModal" + "_" + that.options.idTable).hasClass("modal")) {
var vModal = sprintf("<div id=\"avdSearchModal%s\" class=\"modal fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"mySmallModalLabel\" aria-hidden=\"true\">", "_" + that.options.idTable);
vModal += "<div class=\"modal-dialog modal-xs\">";
vModal += " <div class=\"modal-content\">";
vModal += " <div class=\"modal-header\">";
vModal += " <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\" >&times;</button>";
vModal += sprintf(" <h4 class=\"modal-title\">%s</h4>", searchTitle);
vModal += " </div>";
vModal += " <div class=\"modal-body modal-body-custom\">";
vModal += sprintf(" <div class=\"container-fluid\" id=\"avdSearchModalContent%s\" style=\"padding-right: 0px;padding-left: 0px;\" >", "_" + that.options.idTable);
vModal += " </div>";
vModal += " </div>";
vModal += " </div>";
vModal += " </div>";
vModal += "</div>";
$("body").append($(vModal));
var vFormAvd = createFormAvd(pColumns, searchText, that),
timeoutId = 0;;
$('#avdSearchModalContent' + "_" + that.options.idTable).append(vFormAvd.join(''));
$('#' + that.options.idForm).off('keyup blur', 'input').on('keyup blur', 'input', function (event) {
clearTimeout(timeoutId);
timeoutId = setTimeout(function () {
that.onColumnAdvancedSearch(event);
}, that.options.searchTimeOut);
});
$("#btnCloseAvd" + "_" + that.options.idTable).click(function() {
$("#avdSearchModal" + "_" + that.options.idTable).modal('hide');
});
$("#avdSearchModal" + "_" + that.options.idTable).modal();
} else {
$("#avdSearchModal" + "_" + that.options.idTable).modal();
}
};
var createFormAvd = function(pColumns, searchText, that) {
var htmlForm = [];
htmlForm.push(sprintf('<form class="form-horizontal" id="%s" action="%s" >', that.options.idForm, that.options.actionForm));
for (var i in pColumns) {
var vObjCol = pColumns[i];
if (!vObjCol.checkbox && vObjCol.visible && vObjCol.searchable) {
htmlForm.push('<div class="form-group">');
htmlForm.push(sprintf('<label class="col-sm-4 control-label">%s</label>', vObjCol.title));
htmlForm.push('<div class="col-sm-6">');
htmlForm.push(sprintf('<input type="text" class="form-control input-md" name="%s" placeholder="%s" id="%s">', vObjCol.field, vObjCol.title, vObjCol.field));
htmlForm.push('</div>');
htmlForm.push('</div>');
}
}
htmlForm.push('<div class="form-group">');
htmlForm.push('<div class="col-sm-offset-9 col-sm-3">');
htmlForm.push(sprintf('<button type="button" id="btnCloseAvd%s" class="btn btn-default" >%s</button>', "_" + that.options.idTable, searchText));
htmlForm.push('</div>');
htmlForm.push('</div>');
htmlForm.push('</form>');
return htmlForm;
};
$.extend($.fn.bootstrapTable.defaults, {
advancedSearch: false,
idForm: 'advancedSearch',
actionForm: '',
idTable: undefined,
onColumnAdvancedSearch: function (field, text) {
return false;
}
});
$.extend($.fn.bootstrapTable.defaults.icons, {
advancedSearchIcon: 'glyphicon-chevron-down'
});
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
'column-advanced-search.bs.table': 'onColumnAdvancedSearch'
});
$.extend($.fn.bootstrapTable.locales, {
formatAdvancedSearch: function() {
return 'Advanced search';
},
formatAdvancedCloseButton: function() {
return "Close";
}
});
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
var BootstrapTable = $.fn.bootstrapTable.Constructor,
_initToolbar = BootstrapTable.prototype.initToolbar,
_load = BootstrapTable.prototype.load,
_initSearch = BootstrapTable.prototype.initSearch;
BootstrapTable.prototype.initToolbar = function() {
_initToolbar.apply(this, Array.prototype.slice.apply(arguments));
if (!this.options.search) {
return;
}
if (!this.options.advancedSearch) {
return;
}
if (!this.options.idTable) {
return;
}
var that = this,
html = [];
html.push(sprintf('<div class="columns columns-%s btn-group pull-%s" role="group">', this.options.buttonsAlign, this.options.buttonsAlign));
html.push(sprintf('<button class="btn btn-default%s' + '" type="button" name="advancedSearch" title="%s">', that.options.iconSize === undefined ? '' : ' btn-' + that.options.iconSize, that.options.formatAdvancedSearch()));
html.push(sprintf('<i class="%s %s"></i>', that.options.iconsPrefix, that.options.icons.advancedSearchIcon))
html.push('</button></div>');
that.$toolbar.prepend(html.join(''));
that.$toolbar.find('button[name="advancedSearch"]')
.off('click').on('click', function() {
showAvdSearch(that.columns, that.options.formatAdvancedSearch(), that.options.formatAdvancedCloseButton(), that);
});
};
BootstrapTable.prototype.load = function(data) {
_load.apply(this, Array.prototype.slice.apply(arguments));
if (!this.options.advancedSearch) {
return;
}
if (typeof this.options.idTable === 'undefined') {
return;
} else {
if (!firstLoad) {
var height = parseInt($(".bootstrap-table").height());
height += 10;
$("#" + this.options.idTable).bootstrapTable("resetView", {height: height});
firstLoad = true;
}
}
};
BootstrapTable.prototype.initSearch = function () {
_initSearch.apply(this, Array.prototype.slice.apply(arguments));
if (!this.options.advancedSearch) {
return;
}
var that = this;
var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial;
this.data = fp ? $.grep(this.data, function (item, i) {
for (var key in fp) {
var fval = fp[key].toLowerCase();
var value = item[key];
value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header,
that.header.formatters[$.inArray(key, that.header.fields)],
[value, item, i], value);
if (!($.inArray(key, that.header.fields) !== -1 &&
(typeof value === 'string' || typeof value === 'number') &&
(value + '').toLowerCase().indexOf(fval) !== -1)) {
return false;
}
}
return true;
}) : this.data;
};
BootstrapTable.prototype.onColumnAdvancedSearch = function (event) {
var text = $.trim($(event.currentTarget).val());
var $field = $(event.currentTarget)[0].id;
if ($.isEmptyObject(this.filterColumnsPartial)) {
this.filterColumnsPartial = {};
}
if (text) {
this.filterColumnsPartial[$field] = text;
} else {
delete this.filterColumnsPartial[$field];
}
this.options.pageNumber = 1;
this.onSearch(event);
this.updatePagination();
this.trigger('column-advanced-search', $field, text);
};
}(jQuery);

7
ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js

@ -0,0 +1,7 @@
/*
* bootstrap-table - v1.11.0 - 2016-07-02
* https://github.com/wenzhixin/bootstrap-table
* Copyright (c) 2016 zhixin wen
* Licensed MIT License
*/
!function(a){"use strict";var b=!1,c=a.fn.bootstrapTable.utils.sprintf,d=function(b,d,f,g){if(a("#avdSearchModal_"+g.options.idTable).hasClass("modal"))a("#avdSearchModal_"+g.options.idTable).modal();else{var h=c('<div id="avdSearchModal%s" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">',"_"+g.options.idTable);h+='<div class="modal-dialog modal-xs">',h+=' <div class="modal-content">',h+=' <div class="modal-header">',h+=' <button type="button" class="close" data-dismiss="modal" aria-hidden="true" >&times;</button>',h+=c(' <h4 class="modal-title">%s</h4>',d),h+=" </div>",h+=' <div class="modal-body modal-body-custom">',h+=c(' <div class="container-fluid" id="avdSearchModalContent%s" style="padding-right: 0px;padding-left: 0px;" >',"_"+g.options.idTable),h+=" </div>",h+=" </div>",h+=" </div>",h+=" </div>",h+="</div>",a("body").append(a(h));var i=e(b,f,g),j=0;a("#avdSearchModalContent_"+g.options.idTable).append(i.join("")),a("#"+g.options.idForm).off("keyup blur","input").on("keyup blur","input",function(a){clearTimeout(j),j=setTimeout(function(){g.onColumnAdvancedSearch(a)},g.options.searchTimeOut)}),a("#btnCloseAvd_"+g.options.idTable).click(function(){a("#avdSearchModal_"+g.options.idTable).modal("hide")}),a("#avdSearchModal_"+g.options.idTable).modal()}},e=function(a,b,d){var e=[];e.push(c('<form class="form-horizontal" id="%s" action="%s" >',d.options.idForm,d.options.actionForm));for(var f in a){var g=a[f];!g.checkbox&&g.visible&&g.searchable&&(e.push('<div class="form-group">'),e.push(c('<label class="col-sm-4 control-label">%s</label>',g.title)),e.push('<div class="col-sm-6">'),e.push(c('<input type="text" class="form-control input-md" name="%s" placeholder="%s" id="%s">',g.field,g.title,g.field)),e.push("</div>"),e.push("</div>"))}return e.push('<div class="form-group">'),e.push('<div class="col-sm-offset-9 col-sm-3">'),e.push(c('<button type="button" id="btnCloseAvd%s" class="btn btn-default" >%s</button>',"_"+d.options.idTable,b)),e.push("</div>"),e.push("</div>"),e.push("</form>"),e};a.extend(a.fn.bootstrapTable.defaults,{advancedSearch:!1,idForm:"advancedSearch",actionForm:"",idTable:void 0,onColumnAdvancedSearch:function(){return!1}}),a.extend(a.fn.bootstrapTable.defaults.icons,{advancedSearchIcon:"glyphicon-chevron-down"}),a.extend(a.fn.bootstrapTable.Constructor.EVENTS,{"column-advanced-search.bs.table":"onColumnAdvancedSearch"}),a.extend(a.fn.bootstrapTable.locales,{formatAdvancedSearch:function(){return"Advanced search"},formatAdvancedCloseButton:function(){return"Close"}}),a.extend(a.fn.bootstrapTable.defaults,a.fn.bootstrapTable.locales);var f=a.fn.bootstrapTable.Constructor,g=f.prototype.initToolbar,h=f.prototype.load,i=f.prototype.initSearch;f.prototype.initToolbar=function(){if(g.apply(this,Array.prototype.slice.apply(arguments)),this.options.search&&this.options.advancedSearch&&this.options.idTable){var a=this,b=[];b.push(c('<div class="columns columns-%s btn-group pull-%s" role="group">',this.options.buttonsAlign,this.options.buttonsAlign)),b.push(c('<button class="btn btn-default%s" type="button" name="advancedSearch" title="%s">',void 0===a.options.iconSize?"":" btn-"+a.options.iconSize,a.options.formatAdvancedSearch())),b.push(c('<i class="%s %s"></i>',a.options.iconsPrefix,a.options.icons.advancedSearchIcon)),b.push("</button></div>"),a.$toolbar.prepend(b.join("")),a.$toolbar.find('button[name="advancedSearch"]').off("click").on("click",function(){d(a.columns,a.options.formatAdvancedSearch(),a.options.formatAdvancedCloseButton(),a)})}},f.prototype.load=function(){if(h.apply(this,Array.prototype.slice.apply(arguments)),this.options.advancedSearch&&"undefined"!=typeof this.options.idTable&&!b){var c=parseInt(a(".bootstrap-table").height());c+=10,a("#"+this.options.idTable).bootstrapTable("resetView",{height:c}),b=!0}},f.prototype.initSearch=function(){if(i.apply(this,Array.prototype.slice.apply(arguments)),this.options.advancedSearch){var b=this,c=a.isEmptyObject(this.filterColumnsPartial)?null:this.filterColumnsPartial;this.data=c?a.grep(this.data,function(d,e){for(var f in c){var g=c[f].toLowerCase(),h=d[f];if(h=a.fn.bootstrapTable.utils.calculateObjectValue(b.header,b.header.formatters[a.inArray(f,b.header.fields)],[h,d,e],h),-1===a.inArray(f,b.header.fields)||"string"!=typeof h&&"number"!=typeof h||-1===(h+"").toLowerCase().indexOf(g))return!1}return!0}):this.data}},f.prototype.onColumnAdvancedSearch=function(b){var c=a.trim(a(b.currentTarget).val()),d=a(b.currentTarget)[0].id;a.isEmptyObject(this.filterColumnsPartial)&&(this.filterColumnsPartial={}),c?this.filterColumnsPartial[d]=c:delete this.filterColumnsPartial[d],this.options.pageNumber=1,this.onSearch(b),this.updatePagination(),this.trigger("column-advanced-search",d,c)}}(jQuery);

33
ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css

@ -915,6 +915,7 @@ table.rc-table-resizing thead > th > a {
z-index: 1;
}
/*
.fixed-columns {
left: 0;
}
@ -930,6 +931,38 @@ table.rc-table-resizing thead > th > a {
.fixed-columns-right .fixed-table-body {
overflow-x: hidden !important;
}
*/
/** 表格冻结列样式 **/
.left-fixed-table-columns, .left-fixed-body-columns {
position: absolute;
background-color: #fff;
display: none;
box-sizing: border-box;
overflow: hidden;
}
.left-fixed-table-columns .table, .left-fixed-body-columns .table {
border-right: 1px solid #ddd;
}
.left-fixed-table-columns .table.table-no-bordered, .left-fixed-body-columns .table.table-no-bordered {
border-right: 1px solid transparent;
}
.left-fixed-body-columns table {
position: absolute;
animation: none;
}
.right-fixed-table-columns{
position: absolute;
right:63px;
border-left:1px solid #ddd;
display: none;
z-index:100;
}
.bootstrap-table .table-hover > tbody > tr.hover > td {
background-color: #f5f5f5;

12
ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js

@ -66,9 +66,10 @@ var table = {
mobileResponsive: true,
maintainSelected: false,
rememberSelected: false,
fixedColumns: true,
fixedColumns: false,
fixedNumber: 0,
fixedRightNumber: 1,
rightFixedColumns: false,
fixedRightNumber: 0,
queryParams: $.table.queryParams,
rowStyle: {},
};
@ -129,9 +130,10 @@ var table = {
onPostBody: options.onPostBody, // 渲染完成后执行的事件
maintainSelected: options.maintainSelected, // 前端翻页时保留所选行
rememberSelected: options.rememberSelected, // 启用翻页记住前面的选择
fixedColumns: options.fixedColumns, // 是否启用冻结列(左侧)
fixedNumber: options.fixedRightNumber, // 列冻结的个数(左侧)
fixedRightNumber: options.fixedRightNumber, // 列冻结的个数(右侧)
fixedColumns: options.fixedColumns, // 是否启用冻结列(左侧)
fixedNumber: options.fixedRightNumber, // 列冻结的个数(左侧)
rightFixedColumns: options.rightFixedColumns, // 是否启用冻结列(右侧)
fixedRightNumber: options.fixedRightNumber, // 列冻结的个数(右侧)
onReorderRow: options.onReorderRow, // 当拖拽结束后处理函数
queryParams: options.queryParams, // 传递参数(*)
rowStyle: options.rowStyle, // 通过自定义函数设置行样式

170
ruoyi-admin/src/main/resources/templates/demo/table/fixedColumns.html

@ -4,142 +4,142 @@
<th:block th:include="include :: header('冻结列')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success">
<i class="fa fa-plus"></i> 新增
</a>
<a class="btn btn-primary single disabled">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled">
<i class="fa fa-remove"></i> 删除
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
<div class="container-div">
<div class="row">
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success">
<i class="fa fa-plus"></i> 新增
</a>
<a class="btn btn-primary single disabled">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled">
<i class="fa fa-remove"></i> 删除
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
<div th:include="include :: footer"></div>
<th:block th:include="include :: bootstrap-table-fixed-columns-js" />
<script th:inline="javascript">
var prefix = ctx + "demo/table";
var datas = [[${@dict.getType('sys_normal_disable')}]];
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
var prefix = ctx + "demo/table";
var datas = [[${@dict.getType('sys_normal_disable')}]];
$(function() {
var options = {
url: prefix + "/list",
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
fixedColumns: true,
fixedNumber: 3,
fixedRightNumber: 3,
columns: [{
checkbox: true
},
{
field : 'userId',
$(function() {
var options = {
url: prefix + "/list",
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
// fixedColumns: true, // 启用冻结左列
// fixedNumber: 3, // 冻结左列个数
rightFixedColumns: true, // 启用冻结右列
rightFixedNumber: 1, // 冻结右列个数
columns: [{
checkbox: true
},
{
field : 'userId',
title : '用户ID'
},
{
field : 'userCode',
field : 'userCode',
title : '用户编号'
},
{
field : 'userName',
field : 'userName',
title : '用户姓名'
},
{
field : 'userPhone',
field : 'userPhone',
title : '用户手机'
},
{
field : 'userEmail',
field : 'userEmail',
title : '用户邮箱'
},
{
field : 'userBalance',
title : '用户余额'
field : 'userBalance',
title : '用户余额'
},
{
field: 'status',
title: '用户状态',
align: 'center',
formatter: function(value, row, index) {
return $.table.selectDictLabel(datas, value);
}
},
field: 'status',
title: '用户状态',
align: 'center',
formatter: function(value, row, index) {
return $.table.selectDictLabel(datas, value);
}
},
{
field : 'userBalance',
title : '测试1'
field : 'userBalance',
title : '测试1'
},
{
field : 'userBalance',
title : '测试2'
field : 'userBalance',
title : '测试2'
},
{
field : 'userBalance',
title : '测试3'
field : 'userBalance',
title : '测试3'
},
{
field : 'userBalance',
title : '测试4'
field : 'userBalance',
title : '测试4'
},
{
field : 'userBalance',
title : '测试5'
field : 'userBalance',
title : '测试5'
},
{
field : 'userBalance',
title : '测试6'
field : 'userBalance',
title : '测试6'
},
{
field : 'userBalance',
title : '测试7'
field : 'userBalance',
title : '测试7'
},
{
field : 'userBalance',
title : '测试8'
field : 'userBalance',
title : '测试8'
},
{
field : 'userBalance',
title : '测试9'
field : 'userBalance',
title : '测试9'
},
{
field : 'userBalance',
title : '测试10'
field : 'userBalance',
title : '测试10'
},
{
field : 'userBalance',
title : '测试11'
field : 'userBalance',
title : '测试11'
},
{
field : 'userBalance',
title : '测试12'
field : 'userBalance',
title : '测试12'
},
{
field : 'userBalance',
title : '测试13'
field : 'userBalance',
title : '测试13'
},
{
field : 'userBalance',
title : '测试14'
field : 'userBalance',
title : '测试14'
},
{
field : 'userBalance',
title : '测试15'
field : 'userBalance',
title : '测试15'
},
{
field : 'userBalance',
title : '测试16'
field : 'userBalance',
title : '测试16'
}]
};
$.table.init(options);
});
</script>
};
$.table.init(options);
});
</script>
</body>
</html>

2
ruoyi-admin/src/main/resources/templates/erp/material/material.html

@ -432,6 +432,8 @@
exportUrl: prefix + "/export",
detailUrl: prefix + "/edit/{id}",
modalName: "物料信息",
rightFixedColumns: true, // 启用冻结右列
rightFixedNumber: 1, // 冻结右列个数
columns: [{
checkbox: true
},

2
ruoyi-admin/src/main/resources/templates/include.html

@ -35,6 +35,8 @@
<script th:src="@{/ajax/libs/bootstrap-table/bootstrap-table.min.js?v=20210202}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=20210202}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js?v=20210202}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js?v=20210202}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js?v=20210202}"></script>
<!-- jquery-validate 表单验证插件 -->
<script th:src="@{/ajax/libs/validate/jquery.validate.min.js}"></script>
<script th:src="@{/ajax/libs/validate/messages_zh.min.js}"></script>

Loading…
Cancel
Save