优化列表导出功能

修复导出全部BUG
优化移动端列表展示
优化iOS移动端展示
pull/226/MERGE
Karson 2020-09-17 15:01:16 +08:00
parent d0f71f4f1d
commit b277d31c60
11 changed files with 187 additions and 116 deletions

View File

@ -262,7 +262,7 @@ class Backend extends Controller
$sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id'); $sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id');
$order = $this->request->get("order", "DESC"); $order = $this->request->get("order", "DESC");
$offset = $this->request->get("offset/d", 0); $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; $page = $limit ? intval($offset / $limit) + 1 : 1;
if ($this->request->has("page")) { if ($this->request->has("page")) {
@ -390,7 +390,7 @@ class Backend extends Controller
$relation = Loader::parseName($tableArr[0], 1, false); $relation = Loader::parseName($tableArr[0], 1, false);
$this->model->alias([$this->model->$relation()->getTable() => $tableArr[0]]); $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; break;
case 'NULL': case 'NULL':
case 'IS NULL': case 'IS NULL':
@ -471,7 +471,7 @@ class Backend extends Controller
$ishtml = $this->request->request("isHtml", 0); $ishtml = $this->request->request("isHtml", 0);
if ($istree) { if ($istree) {
$word = []; $word = [];
$pagesize = 99999; $pagesize = 999999;
} }
$order = []; $order = [];
foreach ($orderby as $k => $v) { foreach ($orderby as $k => $v) {
@ -482,7 +482,7 @@ class Backend extends Controller
//如果有primaryvalue,说明当前是初始化传值 //如果有primaryvalue,说明当前是初始化传值
if ($primaryvalue !== null) { if ($primaryvalue !== null) {
$where = [$primarykey => ['in', $primaryvalue]]; $where = [$primarykey => ['in', $primaryvalue]];
$pagesize = 99999; $pagesize = 999999;
} else { } else {
$where = function ($query) use ($word, $andor, $field, $searchfield, $custom) { $where = function ($query) use ($word, $andor, $field, $searchfield, $custom) {
$logic = $andor == 'AND' ? '&' : '|'; $logic = $andor == 'AND' ? '&' : '|';

View File

@ -244,6 +244,7 @@ class User extends Frontend
]; ];
$msg = [ $msg = [
'renewpassword.confirm' => __('Password and confirm password don\'t match')
]; ];
$data = [ $data = [
'oldpassword' => $oldpassword, 'oldpassword' => $oldpassword,

View File

@ -54,6 +54,7 @@ return [
'New email' => '新邮箱', 'New email' => '新邮箱',
'New mobile' => '新手机号', 'New mobile' => '新手机号',
'Change password successful' => '修改密码成功', 'Change password successful' => '修改密码成功',
'Password and confirm password don\'t match' => '两次输入的密码不一致',
'Captcha is incorrect' => '验证码不正确', 'Captcha is incorrect' => '验证码不正确',
'Logged in successful' => '登录成功', 'Logged in successful' => '登录成功',
'Logout successful' => '退出成功', 'Logout successful' => '退出成功',

View File

@ -9,7 +9,7 @@
"jquery": "^2.1.4", "jquery": "^2.1.4",
"bootstrap": "^3.3.7", "bootstrap": "^3.3.7",
"font-awesome": "^4.6.1", "font-awesome": "^4.6.1",
"bootstrap-table": "fastadmin-bootstraptable#~1.11.3", "bootstrap-table": "fastadmin-bootstraptable#~1.11.5",
"jstree": "~3.3.2", "jstree": "~3.3.2",
"moment": "^2.20.1", "moment": "^2.20.1",
"toastr": "~2.1.3", "toastr": "~2.1.3",

View File

@ -42,6 +42,13 @@ html.ios-fix body {
overflow: auto; overflow: auto;
-webkit-overflow-scrolling: touch; -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 { .wrapper {
height: 100%; height: 100%;
} }
@ -973,8 +980,32 @@ table.table-nowrap thead > tr > th {
#firstnav .navbar-nav > .user-menu .user-image { #firstnav .navbar-nav > .user-menu .user-image {
margin-top: -3px; margin-top: -3px;
} }
.fixed-table-toolbar .columns-right.btn-group { .fixed-table-toolbar > .bs-bars {
display: none; 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 .content-wrapper,
.fixed .right-side { .fixed .right-side {
@ -1085,7 +1116,7 @@ table.table-nowrap thead > tr > th {
min-height: 41px; min-height: 41px;
background-color: #fff; background-color: #fff;
box-sizing: border-box; box-sizing: border-box;
z-index: 1; z-index: 2;
box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.08); box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.08);
} }
.fixed-columns .fixed-table-body, .fixed-columns .fixed-table-body,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -14,10 +14,16 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索 titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索
idTable: 'commonTable', idTable: 'commonTable',
showExport: true, showExport: true,
exportDataType: "all", exportDataType: "auto",
exportTypes: ['json', 'xml', 'csv', 'txt', 'doc', 'excel'], exportTypes: ['json', 'xml', 'csv', 'txt', 'doc', 'excel'],
exportOptions: { exportOptions: {
fileName: 'export_' + Moment().format("YYYY-MM-DD"), fileName: 'export_' + Moment().format("YYYY-MM-DD"),
preventInjection: false,
mso: {
onMsoNumberFormat: function (cell, row, col) {
return !isNaN($(cell).text()) ? '\\@' : '';
},
},
ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列 ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列
}, },
pageSize: localStorage.getItem("pagesize") || 10, pageSize: localStorage.getItem("pagesize") || 10,
@ -39,6 +45,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
paginationNextText: __("Next"), paginationNextText: __("Next"),
paginationLastText: __("Last"), paginationLastText: __("Last"),
cardView: false, //卡片视图 cardView: false, //卡片视图
iosCardView: true, //ios卡片视图
checkOnInit: true, //是否在初始化时判断 checkOnInit: true, //是否在初始化时判断
escape: true, //是否对内容进行转义 escape: true, //是否对内容进行转义
selectedIds: [], selectedIds: [],
@ -103,10 +110,6 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
defaults = defaults ? defaults : {}; defaults = defaults ? defaults : {};
columnDefaults = columnDefaults ? columnDefaults : {}; columnDefaults = columnDefaults ? columnDefaults : {};
locales = locales ? locales : {}; locales = locales ? locales : {};
// 如果是iOS设备则启用卡片视图
if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
Table.defaults.cardView = true;
}
$.fn.bootstrapTable.Constructor.prototype.getSelectItem = function () { $.fn.bootstrapTable.Constructor.prototype.getSelectItem = function () {
return this.$selectItem; return this.$selectItem;
}; };
@ -135,6 +138,11 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
return __('Go'); return __('Go');
} }
}, locales); }, 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') { if (typeof defaults.exportTypes != 'undefined') {
$.fn.bootstrapTable.defaults.exportTypes = defaults.exportTypes; $.fn.bootstrapTable.defaults.exportTypes = defaults.exportTypes;
} }
@ -227,9 +235,14 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
checkboxtd.drop("start", function () { checkboxtd.drop("start", function () {
Table.api.toggleattr(this); Table.api.toggleattr(this);
}).drop(function () { }).drop(function () {
Table.api.toggleattr(this); // Table.api.toggleattr(this);
}).drop("end", function () { }).drop("end", function (e) {
Table.api.toggleattr(this); var that = this;
setTimeout(function () {
if (e.type === 'mousemove') {
Table.api.toggleattr(that);
}
}, 0);
}); });
$.drop({ $.drop({
multi: true 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) { 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) { 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.selectedIds = selectedIds;
options.selectedData = selectedData; options.selectedData = selectedData;
} }
//如果导出类型为auto时则自动判断
if (exportDataType === 'auto') {
options.exportDataType = selectedIds.length > 0 ? 'selected' : 'all';
}
$(Table.config.disabledbtn, toolbar).toggleClass('disabled', !options.selectedIds.length); $(Table.config.disabledbtn, toolbar).toggleClass('disabled', !options.selectedIds.length);
}); });
// 绑定TAB事件 // 绑定TAB事件
$('.panel-heading [data-field] a[data-toggle="tab"]').on('shown.bs.tab', function (e) { $('.panel-heading [data-field] a[data-toggle="tab"]').on('shown.bs.tab', function (e) {

View File

@ -59,6 +59,11 @@ html.ios-fix, html.ios-fix body {
height: 100%; height: 100%;
overflow: auto; overflow: auto;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
.wrapper, .tab-pane {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
} }
.wrapper { .wrapper {
@ -1205,8 +1210,23 @@ table.table-nowrap {
} }
.fixed-table-toolbar { .fixed-table-toolbar {
.columns-right.btn-group { > .bs-bars {
display: none; 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; min-height: 41px;
background-color: #fff; background-color: #fff;
box-sizing: border-box; box-sizing: border-box;
z-index: 1; z-index: 2;
box-shadow: 0 -1px 8px rgba(0, 0, 0, .08); box-shadow: 0 -1px 8px rgba(0, 0, 0, .08);
.fixed-table-body { .fixed-table-body {
@ -1390,3 +1410,4 @@ table.table-nowrap {
-o-transform: rotate(-90deg); -o-transform: rotate(-90deg);
transform: rotate(-90deg); transform: rotate(-90deg);
} }