作者 Karson

优化列表导出功能

修复导出全部BUG
优化移动端列表展示
优化iOS移动端展示
... ... @@ -262,7 +262,7 @@ class Backend extends Controller
$sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id');
$order = $this->request->get("order", "DESC");
$offset = $this->request->get("offset/d", 0);
$limit = $this->request->get("limit/d", 10);
$limit = $this->request->get("limit/d", 999999);
//新增自动计算页码
$page = $limit ? intval($offset / $limit) + 1 : 1;
if ($this->request->has("page")) {
... ... @@ -390,7 +390,7 @@ class Backend extends Controller
$relation = Loader::parseName($tableArr[0], 1, false);
$this->model->alias([$this->model->$relation()->getTable() => $tableArr[0]]);
}
$where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' time', $arr];
$where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' TIME', $arr];
break;
case 'NULL':
case 'IS NULL':
... ... @@ -471,7 +471,7 @@ class Backend extends Controller
$ishtml = $this->request->request("isHtml", 0);
if ($istree) {
$word = [];
$pagesize = 99999;
$pagesize = 999999;
}
$order = [];
foreach ($orderby as $k => $v) {
... ... @@ -482,7 +482,7 @@ class Backend extends Controller
//如果有primaryvalue,说明当前是初始化传值
if ($primaryvalue !== null) {
$where = [$primarykey => ['in', $primaryvalue]];
$pagesize = 99999;
$pagesize = 999999;
} else {
$where = function ($query) use ($word, $andor, $field, $searchfield, $custom) {
$logic = $andor == 'AND' ? '&' : '|';
... ...
... ... @@ -244,6 +244,7 @@ class User extends Frontend
];
$msg = [
'renewpassword.confirm' => __('Password and confirm password don\'t match')
];
$data = [
'oldpassword' => $oldpassword,
... ...
... ... @@ -54,6 +54,7 @@ return [
'New email' => '新邮箱',
'New mobile' => '新手机号',
'Change password successful' => '修改密码成功',
'Password and confirm password don\'t match' => '两次输入的密码不一致',
'Captcha is incorrect' => '验证码不正确',
'Logged in successful' => '登录成功',
'Logout successful' => '退出成功',
... ...
... ... @@ -9,7 +9,7 @@
"jquery": "^2.1.4",
"bootstrap": "^3.3.7",
"font-awesome": "^4.6.1",
"bootstrap-table": "fastadmin-bootstraptable#~1.11.3",
"bootstrap-table": "fastadmin-bootstraptable#~1.11.5",
"jstree": "~3.3.2",
"moment": "^2.20.1",
"toastr": "~2.1.3",
... ...
... ... @@ -42,6 +42,13 @@ html.ios-fix body {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
html.ios-fix .wrapper,
html.ios-fix body .wrapper,
html.ios-fix .tab-pane,
html.ios-fix body .tab-pane {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
.wrapper {
height: 100%;
}
... ... @@ -973,8 +980,32 @@ table.table-nowrap thead > tr > th {
#firstnav .navbar-nav > .user-menu .user-image {
margin-top: -3px;
}
.fixed-table-toolbar .columns-right.btn-group {
display: none;
.fixed-table-toolbar > .bs-bars {
float: none !important;
}
.fixed-table-toolbar .toolbar a.btn-refresh,
.fixed-table-toolbar .toolbar a.btn-del,
.fixed-table-toolbar .toolbar a.btn-add,
.fixed-table-toolbar .toolbar a.btn-edit,
.fixed-table-toolbar .toolbar a.btn-import,
.fixed-table-toolbar .toolbar a.btn-more,
.fixed-table-toolbar .toolbar a.btn-recyclebin,
.fixed-table-toolbar .toolbar a.btn-mini-xs {
font-size: 0;
}
.fixed-table-toolbar .toolbar a.btn-refresh .fa,
.fixed-table-toolbar .toolbar a.btn-del .fa,
.fixed-table-toolbar .toolbar a.btn-add .fa,
.fixed-table-toolbar .toolbar a.btn-edit .fa,
.fixed-table-toolbar .toolbar a.btn-import .fa,
.fixed-table-toolbar .toolbar a.btn-more .fa,
.fixed-table-toolbar .toolbar a.btn-recyclebin .fa,
.fixed-table-toolbar .toolbar a.btn-mini-xs .fa {
font-size: initial;
}
.fixed-table-toolbar .search {
max-width: 110px;
float: left !important;
}
.fixed .content-wrapper,
.fixed .right-side {
... ... @@ -1085,7 +1116,7 @@ table.table-nowrap thead > tr > th {
min-height: 41px;
background-color: #fff;
box-sizing: border-box;
z-index: 1;
z-index: 2;
box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.08);
}
.fixed-columns .fixed-table-body,
... ...
... ... @@ -14,10 +14,16 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索
idTable: 'commonTable',
showExport: true,
exportDataType: "all",
exportDataType: "auto",
exportTypes: ['json', 'xml', 'csv', 'txt', 'doc', 'excel'],
exportOptions: {
fileName: 'export_' + Moment().format("YYYY-MM-DD"),
preventInjection: false,
mso: {
onMsoNumberFormat: function (cell, row, col) {
return !isNaN($(cell).text()) ? '\\@' : '';
},
},
ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列
},
pageSize: localStorage.getItem("pagesize") || 10,
... ... @@ -39,6 +45,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
paginationNextText: __("Next"),
paginationLastText: __("Last"),
cardView: false, //卡片视图
iosCardView: true, //ios卡片视图
checkOnInit: true, //是否在初始化时判断
escape: true, //是否对内容进行转义
selectedIds: [],
... ... @@ -103,10 +110,6 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
defaults = defaults ? defaults : {};
columnDefaults = columnDefaults ? columnDefaults : {};
locales = locales ? locales : {};
// 如果是iOS设备则启用卡片视图
if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
Table.defaults.cardView = true;
}
$.fn.bootstrapTable.Constructor.prototype.getSelectItem = function () {
return this.$selectItem;
};
... ... @@ -135,6 +138,11 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
return __('Go');
}
}, locales);
// 如果是iOS设备则判断是否启用卡片视图
if ($.fn.bootstrapTable.defaults.iosCardView && navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
Table.defaults.cardView = true;
$.fn.bootstrapTable.defaults.cardView = true;
}
if (typeof defaults.exportTypes != 'undefined') {
$.fn.bootstrapTable.defaults.exportTypes = defaults.exportTypes;
}
... ... @@ -227,9 +235,14 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
checkboxtd.drop("start", function () {
Table.api.toggleattr(this);
}).drop(function () {
Table.api.toggleattr(this);
}).drop("end", function () {
Table.api.toggleattr(this);
// Table.api.toggleattr(this);
}).drop("end", function (e) {
var that = this;
setTimeout(function () {
if (e.type === 'mousemove') {
Table.api.toggleattr(that);
}
}, 0);
});
$.drop({
multi: true
... ... @@ -237,6 +250,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
});
}
});
var exportDataType = options.exportDataType;
// 处理选中筛选框后按钮的状态统一变更
table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table post-body.bs.table', function (e) {
var allIds = table.bootstrapTable("getData").map(function (item) {
... ... @@ -262,8 +276,11 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
options.selectedIds = selectedIds;
options.selectedData = selectedData;
}
//如果导出类型为auto时则自动判断
if (exportDataType === 'auto') {
options.exportDataType = selectedIds.length > 0 ? 'selected' : 'all';
}
$(Table.config.disabledbtn, toolbar).toggleClass('disabled', !options.selectedIds.length);
});
// 绑定TAB事件
$('.panel-heading [data-field] a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
... ...
... ... @@ -59,6 +59,11 @@ html.ios-fix, html.ios-fix body {
height: 100%;
overflow: auto;
-webkit-overflow-scrolling: touch;
.wrapper, .tab-pane {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
}
.wrapper {
... ... @@ -1205,8 +1210,23 @@ table.table-nowrap {
}
.fixed-table-toolbar {
.columns-right.btn-group {
display: none;
> .bs-bars {
float: none !important;
}
.toolbar {
a.btn-refresh, a.btn-del, a.btn-add, a.btn-edit, a.btn-import, a.btn-more, a.btn-recyclebin, a.btn-mini-xs {
font-size: 0;
.fa {
font-size: initial;
}
}
}
.search {
max-width: 110px;
float: left !important;
}
}
... ... @@ -1349,7 +1369,7 @@ table.table-nowrap {
min-height: 41px;
background-color: #fff;
box-sizing: border-box;
z-index: 1;
z-index: 2;
box-shadow: 0 -1px 8px rgba(0, 0, 0, .08);
.fixed-table-body {
... ... @@ -1390,3 +1410,4 @@ table.table-nowrap {
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
}
... ...