From 377cc49d0bfc8c0a383e959e4d4a3f0a888b539b Mon Sep 17 00:00:00 2001 From: augushong Date: Wed, 24 Aug 2022 15:53:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=9F=8E=E6=A1=88?= =?UTF-8?q?=E4=BE=8B=E4=BB=A3=E7=A0=81=EF=BC=9B=E8=A1=A8=E6=A0=BC=E7=94=B1?= =?UTF-8?q?reload=E6=94=B9=E4=B8=BAreloadData?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/mall/Goods.php | 25 +++++++++++++++++ public/static/plugs/easy-admin/easy-admin.js | 28 ++++++++++---------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/app/admin/controller/mall/Goods.php b/app/admin/controller/mall/Goods.php index 10b4b9d..4bc6698 100644 --- a/app/admin/controller/mall/Goods.php +++ b/app/admin/controller/mall/Goods.php @@ -93,4 +93,29 @@ class Goods extends AdminController return $this->fetch(); } + + /** + * @NodeAnotation(title="导出") + */ + public function export() + { + list($page, $limit, $where) = $this->buildTableParames(); + + $this->model = $this->model + ->withJoin('cate', 'LEFT'); + + $fields = $this->request->param('fields', '{}', null); + $image_fields = $this->request->param('image_fields', '{}', null); + $select_fields = $this->request->param('select_fields', '{}', null); + $date_fields = $this->request->param('date_fields', '{}', null); + + $fields = json_decode($fields, true); + $image_fields = json_decode($image_fields, true); + $select_fields = json_decode($select_fields, true); + $date_fields = json_decode($date_fields, true); + + $content = \app\common\tools\ExportTools::excel($this->model, $where, $fields, $image_fields, $select_fields, $date_fields); + + return download($content, $this->model->getName() . date('YmdHis') . '.xlsx', true); + } } diff --git a/public/static/plugs/easy-admin/easy-admin.js b/public/static/plugs/easy-admin/easy-admin.js index 2d0db52..de4a38c 100644 --- a/public/static/plugs/easy-admin/easy-admin.js +++ b/public/static/plugs/easy-admin/easy-admin.js @@ -1180,7 +1180,7 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick op: JSON.stringify(formatOp) } lastTableWhere[tableId] = where - table.reload(tableId, { + table.reloadData(tableId, { page: { curr: 1 } @@ -1214,14 +1214,14 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick data: data, }, function (res) { if (option.modifyReload) { - table.reload(option.tableId); + table.reloadData(option.tableId); } }, function (res) { admin.msg.error(res.msg, function () { - table.reload(option.tableId); + table.reloadData(option.tableId); }); }, function () { - table.reload(option.tableId); + table.reloadData(option.tableId); }); } }); @@ -1235,7 +1235,7 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick lastWhere.sort = {} lastWhere.sort[obj.field] = obj.type; - table.reload(option.id, { + table.reloadData(option.id, { initSort: obj //记录初始排序,如果不设的话,将无法标记表头的排序状态。 , where: lastWhere }); @@ -1280,14 +1280,14 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick data: _data, }, function (res) { if (modifyReload) { - table.reload(tableId); + table.reloadData(tableId); } }, function (res) { admin.msg.error(res.msg, function () { - table.reload(tableId); + table.reloadData(tableId); }); }, function () { - table.reload(tableId); + table.reloadData(tableId); }); }); } @@ -1619,7 +1619,7 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick if (tableId === undefined || tableId === '' || tableId == null) { tableId = init.table_render_id; } - table.reload(tableId); + table.reloadData(tableId); }); // 监听搜索表格重置 @@ -1632,7 +1632,7 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick filter: '{}', op: '{}' }; - table.reload(tableId, { + table.reloadData(tableId, { page: { curr: 1 } @@ -1684,7 +1684,7 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick data: postData, }, function (res) { admin.msg.success(res.msg, function () { - table.reload(tableId); + table.reloadData(tableId); }); }) }); @@ -1717,7 +1717,7 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick }, }, function (res) { admin.msg.success(res.msg, function () { - table.reload(tableId); + table.reloadData(tableId); }); }); }); @@ -1760,7 +1760,7 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick var index = parent.layer.getFrameIndex(window.name); parent.layer.close(index); if (option.refreshTable !== false) { - parent.layui.table.reload(option.refreshTable); + parent.layui.table.reloadData(option.refreshTable); } if (option.refreshFrame) { parent.location.reload(); @@ -1773,7 +1773,7 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick }, refreshTable: function (tableName) { tableName = tableName || 'currentTableRenderId'; - table.reload(tableName); + table.reloadData(tableName); }, formRequired: function () { var verifyList = document.querySelectorAll("[lay-verify]");