支持自定义排序
This commit is contained in:
parent
88fd16929d
commit
43417c319d
|
|
@ -85,14 +85,16 @@ public class ExecutorPageMethodInterceptor implements Interceptor
|
||||||
// System.out.println(count);
|
// System.out.println(count);
|
||||||
PageUtilEntity pageUtilEntity = null;
|
PageUtilEntity pageUtilEntity = null;
|
||||||
if (parameterObject instanceof PageUtilEntity)
|
if (parameterObject instanceof PageUtilEntity)
|
||||||
{ // 参数就是Page实体
|
{
|
||||||
|
// 参数就是Page实体
|
||||||
pageUtilEntity = (PageUtilEntity) parameterObject;
|
pageUtilEntity = (PageUtilEntity) parameterObject;
|
||||||
pageUtilEntity.setEntityOrField(true);
|
pageUtilEntity.setEntityOrField(true);
|
||||||
pageUtilEntity.setTotalResult(count);
|
pageUtilEntity.setTotalResult(count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // 参数为某个实体,该实体拥有Page属性
|
{
|
||||||
Field pageField = ReflectHelper.getFieldByFieldName(parameterObject, "page");
|
// 参数为某个实体,该实体拥有Page属性
|
||||||
|
Field pageField = ReflectHelper.getFieldByFieldName(parameterObject, "PageUtilEntity");
|
||||||
if (pageField != null)
|
if (pageField != null)
|
||||||
{
|
{
|
||||||
pageUtilEntity = (PageUtilEntity) ReflectHelper.getValueByFieldName(parameterObject, "PageUtilEntity");
|
pageUtilEntity = (PageUtilEntity) ReflectHelper.getValueByFieldName(parameterObject, "PageUtilEntity");
|
||||||
|
|
@ -102,7 +104,7 @@ public class ExecutorPageMethodInterceptor implements Interceptor
|
||||||
}
|
}
|
||||||
pageUtilEntity.setEntityOrField(false);
|
pageUtilEntity.setEntityOrField(false);
|
||||||
pageUtilEntity.setTotalResult(count);
|
pageUtilEntity.setTotalResult(count);
|
||||||
ReflectHelper.setValueByFieldName(parameterObject, "page", pageUtilEntity); // 通过反射,对实体对象设置分页对象
|
ReflectHelper.setValueByFieldName(parameterObject, "PageUtilEntity", pageUtilEntity); // 通过反射,对实体对象设置分页对象
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -200,6 +202,10 @@ public class ExecutorPageMethodInterceptor implements Interceptor
|
||||||
if ("mysql".equals(dialect))
|
if ("mysql".equals(dialect))
|
||||||
{
|
{
|
||||||
pageSql.append(sql);
|
pageSql.append(sql);
|
||||||
|
if(StringUtils.isNotEmpty(pageUtilEntity.getOrderByColumn()))
|
||||||
|
{
|
||||||
|
pageSql.append(" order by " + pageUtilEntity.getOrderByColumn() + " " + pageUtilEntity.getIsAsc());
|
||||||
|
}
|
||||||
pageSql.append(" limit " + pageUtilEntity.getPage() + "," + pageUtilEntity.getSize());
|
pageSql.append(" limit " + pageUtilEntity.getPage() + "," + pageUtilEntity.getSize());
|
||||||
}
|
}
|
||||||
else if ("oracle".equals(dialect))
|
else if ("oracle".equals(dialect))
|
||||||
|
|
|
||||||
146
src/main/resources/static/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable.js
vendored
Normal file
146
src/main/resources/static/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable.js
vendored
Normal file
|
|
@ -0,0 +1,146 @@
|
||||||
|
/**
|
||||||
|
* @author zhixin wen <wenzhixin2010@gmail.com>
|
||||||
|
* extensions: https://github.com/vitalets/x-editable
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function($) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
$.extend($.fn.bootstrapTable.defaults, {
|
||||||
|
editable: true,
|
||||||
|
onEditableInit: function() {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
onEditableSave: function(field, row, oldValue, $el) {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
onEditableShown: function(field, row, $el, editable) {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
onEditableHidden: function(field, row, $el, reason) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
||||||
|
'editable-init.bs.table': 'onEditableInit',
|
||||||
|
'editable-save.bs.table': 'onEditableSave',
|
||||||
|
'editable-shown.bs.table': 'onEditableShown',
|
||||||
|
'editable-hidden.bs.table': 'onEditableHidden'
|
||||||
|
});
|
||||||
|
|
||||||
|
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
||||||
|
_initTable = BootstrapTable.prototype.initTable,
|
||||||
|
_initBody = BootstrapTable.prototype.initBody;
|
||||||
|
|
||||||
|
BootstrapTable.prototype.initTable = function() {
|
||||||
|
var that = this;
|
||||||
|
_initTable.apply(this, Array.prototype.slice.apply(arguments));
|
||||||
|
|
||||||
|
if (!this.options.editable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.each(this.columns, function(i, column) {
|
||||||
|
if (!column.editable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var editableOptions = {},
|
||||||
|
editableDataMarkup = [],
|
||||||
|
editableDataPrefix = 'editable-';
|
||||||
|
|
||||||
|
var processDataOptions = function(key, value) {
|
||||||
|
// Replace camel case with dashes.
|
||||||
|
var dashKey = key.replace(/([A-Z])/g, function($1) {
|
||||||
|
return "-" + $1.toLowerCase();
|
||||||
|
});
|
||||||
|
if (dashKey.slice(0, editableDataPrefix.length) == editableDataPrefix) {
|
||||||
|
var dataKey = dashKey.replace(editableDataPrefix, 'data-');
|
||||||
|
editableOptions[dataKey] = value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.each(that.options, processDataOptions);
|
||||||
|
|
||||||
|
column.formatter = column.formatter || function(value, row, index) {
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
column._formatter = column._formatter ? column._formatter : column.formatter;
|
||||||
|
column.formatter = function(value, row, index) {
|
||||||
|
var result = column._formatter ? column._formatter(value, row, index) : value;
|
||||||
|
|
||||||
|
$.each(column, processDataOptions);
|
||||||
|
|
||||||
|
$.each(editableOptions, function(key, value) {
|
||||||
|
editableDataMarkup.push(' ' + key + '="' + value + '"');
|
||||||
|
});
|
||||||
|
|
||||||
|
var _dont_edit_formatter = false;
|
||||||
|
if (column.editable.hasOwnProperty('noeditFormatter')) {
|
||||||
|
_dont_edit_formatter = column.editable.noeditFormatter(value, row, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_dont_edit_formatter === false) {
|
||||||
|
return ['<a href="javascript:void(0)"',
|
||||||
|
' data-name="' + column.field + '"',
|
||||||
|
' data-pk="' + row[that.options.idField] + '"',
|
||||||
|
' data-value="' + result + '"',
|
||||||
|
editableDataMarkup.join(''),
|
||||||
|
'>' + '</a>'
|
||||||
|
].join('');
|
||||||
|
} else {
|
||||||
|
return _dont_edit_formatter;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
BootstrapTable.prototype.initBody = function() {
|
||||||
|
var that = this;
|
||||||
|
_initBody.apply(this, Array.prototype.slice.apply(arguments));
|
||||||
|
|
||||||
|
if (!this.options.editable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.each(this.columns, function(i, column) {
|
||||||
|
if (!column.editable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable)
|
||||||
|
.off('save').on('save', function(e, params) {
|
||||||
|
var data = that.getData(),
|
||||||
|
index = $(this).parents('tr[data-index]').data('index'),
|
||||||
|
row = data[index],
|
||||||
|
oldValue = row[column.field];
|
||||||
|
|
||||||
|
$(this).data('value', params.submitValue);
|
||||||
|
row[column.field] = params.submitValue;
|
||||||
|
that.trigger('editable-save', column.field, row, oldValue, $(this));
|
||||||
|
that.resetFooter();
|
||||||
|
});
|
||||||
|
that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable)
|
||||||
|
.off('shown').on('shown', function(e, editable) {
|
||||||
|
var data = that.getData(),
|
||||||
|
index = $(this).parents('tr[data-index]').data('index'),
|
||||||
|
row = data[index];
|
||||||
|
|
||||||
|
that.trigger('editable-shown', column.field, row, $(this), editable);
|
||||||
|
});
|
||||||
|
that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable)
|
||||||
|
.off('hidden').on('hidden', function(e, reason) {
|
||||||
|
var data = that.getData(),
|
||||||
|
index = $(this).parents('tr[data-index]').data('index'),
|
||||||
|
row = data[index];
|
||||||
|
|
||||||
|
that.trigger('editable-hidden', column.field, row, $(this), reason);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.trigger('editable-init');
|
||||||
|
};
|
||||||
|
|
||||||
|
})(jQuery);
|
||||||
|
|
@ -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";a.extend(a.fn.bootstrapTable.defaults,{editable:!0,onEditableInit:function(){return!1},onEditableSave:function(){return!1},onEditableShown:function(){return!1},onEditableHidden:function(){return!1}}),a.extend(a.fn.bootstrapTable.Constructor.EVENTS,{"editable-init.bs.table":"onEditableInit","editable-save.bs.table":"onEditableSave","editable-shown.bs.table":"onEditableShown","editable-hidden.bs.table":"onEditableHidden"});var b=a.fn.bootstrapTable.Constructor,c=b.prototype.initTable,d=b.prototype.initBody;b.prototype.initTable=function(){var b=this;c.apply(this,Array.prototype.slice.apply(arguments)),this.options.editable&&a.each(this.columns,function(c,d){if(d.editable){var e={},f=[],g="editable-",h=function(a,b){var c=a.replace(/([A-Z])/g,function(a){return"-"+a.toLowerCase()});if(c.slice(0,g.length)==g){var d=c.replace(g,"data-");e[d]=b}};a.each(b.options,h),d.formatter=d.formatter||function(a){return a},d._formatter=d._formatter?d._formatter:d.formatter,d.formatter=function(c,g,i){var j=d._formatter?d._formatter(c,g,i):c;a.each(d,h),a.each(e,function(a,b){f.push(" "+a+'="'+b+'"')});var k=!1;return d.editable.hasOwnProperty("noeditFormatter")&&(k=d.editable.noeditFormatter(c,g,i)),k===!1?['<a href="javascript:void(0)"',' data-name="'+d.field+'"',' data-pk="'+g[b.options.idField]+'"',' data-value="'+j+'"',f.join(""),"></a>"].join(""):k}}})},b.prototype.initBody=function(){var b=this;d.apply(this,Array.prototype.slice.apply(arguments)),this.options.editable&&(a.each(this.columns,function(c,d){d.editable&&(b.$body.find('a[data-name="'+d.field+'"]').editable(d.editable).off("save").on("save",function(c,e){var f=b.getData(),g=a(this).parents("tr[data-index]").data("index"),h=f[g],i=h[d.field];a(this).data("value",e.submitValue),h[d.field]=e.submitValue,b.trigger("editable-save",d.field,h,i,a(this)),b.resetFooter()}),b.$body.find('a[data-name="'+d.field+'"]').editable(d.editable).off("shown").on("shown",function(c,e){var f=b.getData(),g=a(this).parents("tr[data-index]").data("index"),h=f[g];b.trigger("editable-shown",d.field,h,a(this),e)}),b.$body.find('a[data-name="'+d.field+'"]').editable(d.editable).off("hidden").on("hidden",function(c,e){var f=b.getData(),g=a(this).parents("tr[data-index]").data("index"),h=f[g];b.trigger("editable-hidden",d.field,h,a(this),e)}))}),this.trigger("editable-init"))}}(jQuery);
|
||||||
|
|
@ -3,25 +3,25 @@
|
||||||
// 初始化表格
|
// 初始化表格
|
||||||
function initTable(_columns, _url) {
|
function initTable(_columns, _url) {
|
||||||
$('.bootstrap-table').bootstrapTable({
|
$('.bootstrap-table').bootstrapTable({
|
||||||
method: 'GET',
|
method: 'get', // 请求方式(*)
|
||||||
dataType: "json",
|
dataType: "json", // 返回格式(*)
|
||||||
contentType: 'application/x-www-form-urlencoded',
|
url: _url, // 请求后台的URL(*)
|
||||||
url: _url,
|
pagination: true, // 是否显示分页(*)
|
||||||
// search: true, // 是否显示搜索框功能
|
pageSize: 10, // 每页的记录行数(*)
|
||||||
striped: true, // 是否显示行间隔色
|
pageNumber: 1, // 初始化加载第一页,默认第一页
|
||||||
pagination: true, // 是否分页
|
pageList: [10, 25, 50], // 可供选择的每页的行数(*)
|
||||||
showColumns: false, // 是否显示隐藏某列下拉框
|
search: true, // 是否显示搜索框功能
|
||||||
singleSelect: false, // 是否单选复选框
|
singleSelect: false, // 是否禁止多选
|
||||||
iconSize: 'outline', // 图标大小:undefined默认的按钮尺寸 xs超小按钮sm小按钮lg大按钮
|
iconSize: 'outline', // 图标大小:undefined默认的按钮尺寸 xs超小按钮sm小按钮lg大按钮
|
||||||
toolbar: '#tableToolbar', // 指定工作栏
|
toolbar: '#tableToolbar', // 指定工作栏
|
||||||
pageSize: 10, // 每页显示10条记录
|
|
||||||
pageNumber: 1, // 默认第1页
|
|
||||||
pageList: [10, 25, 50], // 可供选择的每页的行数
|
|
||||||
sidePagination: "server", // 启用服务端分页
|
sidePagination: "server", // 启用服务端分页
|
||||||
|
showRefresh: true, // 是否显示刷新按钮
|
||||||
|
showColumns: true, // 是否显示隐藏某列下拉框
|
||||||
|
showToggle: true, // 是否显示详细视图和列表视图的切换按钮
|
||||||
cache: false, // 是否使用缓存
|
cache: false, // 是否使用缓存
|
||||||
queryParams: function(params) {
|
queryParams: function(params) {
|
||||||
return {
|
return {
|
||||||
// 查询参数
|
// 传递参数查询参数
|
||||||
limit: params.limit,
|
limit: params.limit,
|
||||||
offset: params.offset,
|
offset: params.offset,
|
||||||
search: params.search,
|
search: params.search,
|
||||||
|
|
@ -41,6 +41,6 @@ function refresh() {
|
||||||
// 获取选中数组
|
// 获取选中数组
|
||||||
function getIdSelections(_id) {
|
function getIdSelections(_id) {
|
||||||
return $.map($('.bootstrap-table').bootstrapTable('getSelections'), function (row) {
|
return $.map($('.bootstrap-table').bootstrapTable('getSelections'), function (row) {
|
||||||
return row[_id]
|
return row[_id];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -17,8 +17,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class="bootstrap-table" data-mobile-responsive="true"
|
<table class="bootstrap-table" data-mobile-responsive="true"
|
||||||
data-search="true" data-show-refresh="true"
|
data-sort-name="last_access_time" data-sort-order="desc">
|
||||||
data-sort-name="last_access_time" data-order="desc">
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<!-- <a shiro:hasPermission="system:user:list" href="#">测试菜单</a> -->
|
<!-- <a shiro:hasPermission="system:user:list" href="#">测试菜单</a> -->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue