From 07bd18699562c00501ba1fca1cee5914d0379df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Tue, 9 May 2023 13:29:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=9B=B4=E6=96=B0=E5=8D=87?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SQL01-数据表结构.sql | 2 ++ public/static/admin.js | 2 +- public/static/plugs/admin/excel.js | 51 ++++++++++++++++++++++++++++-- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/SQL01-数据表结构.sql b/SQL01-数据表结构.sql index be749a339..f5959afaf 100644 --- a/SQL01-数据表结构.sql +++ b/SQL01-数据表结构.sql @@ -827,6 +827,7 @@ CREATE TABLE `system_file` ( `mime` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '文件类型', `size` bigint(20) NULL DEFAULT 0 COMMENT '文件大小', `uuid` bigint(20) NULL DEFAULT 0 COMMENT '用户编号', + `unid` bigint(20) NULL DEFAULT 0 COMMENT '会员编号', `isfast` tinyint(1) NULL DEFAULT 0 COMMENT '是否秒传', `issafe` tinyint(1) NULL DEFAULT 0 COMMENT '安全模式', `status` tinyint(1) NULL DEFAULT 1 COMMENT '上传状态(1悬空,2落地)', @@ -836,6 +837,7 @@ CREATE TABLE `system_file` ( INDEX `idx_system_file_type`(`type`) USING BTREE, INDEX `idx_system_file_hash`(`hash`) USING BTREE, INDEX `idx_system_file_uuid`(`uuid`) USING BTREE, + INDEX `idx_system_file_unid`(`unid`) USING BTREE, INDEX `idx_system_file_xext`(`xext`) USING BTREE, INDEX `idx_system_file_status`(`status`) USING BTREE, INDEX `idx_system_file_issafe`(`issafe`) USING BTREE, diff --git a/public/static/admin.js b/public/static/admin.js index 8f8f75327..5b0f9b7e5 100644 --- a/public/static/admin.js +++ b/public/static/admin.js @@ -678,7 +678,7 @@ $(function () { // 实例并绑定事件 $table.data('this', layui.table.render(bindData(option))); $table.bind('reload render reloadData', function (evt, opts) { - if (option.page === false) opts.page = false; + if (option.page === false) (opts || {}).page = false; data = $.extend({}, data, (opts || {}).where || {}); opts = bindData($.extend({}, opts || {}, {loading: true})); if (evt.type.indexOf('reload') > -1) { diff --git a/public/static/plugs/admin/excel.js b/public/static/plugs/admin/excel.js index a2bd5834c..8c27b7f26 100644 --- a/public/static/plugs/admin/excel.js +++ b/public/static/plugs/admin/excel.js @@ -41,8 +41,8 @@ define(function () { if (sortField.length > 0 && sortType.length > 0) { location += (location.indexOf('?') > -1 ? '&' : '?') + '_order_=' + sortType + '&_field_=' + sortField; } - that.load(location, form.serialize(), method).then(function (ret) { - that.export(done.call(that, ret, []), name); + that.load(location, form.serialize(), method).then(function (data) { + that.export(done.call(that, data, []), name); }).fail(function (ret) { $.msg.tips(ret || '文件导出失败'); }); @@ -52,7 +52,7 @@ define(function () { /*! 加载导出的文档 */ Excel.prototype.load = function (url, data, method) { return (function (defer, lists, loaded) { - loaded = $.msg.loading("正在加载 0.00%"); + loaded = $.msg.loading('正在加载 0.00%'); return (lists = []), LoadNextPage(1, 1), defer; function LoadNextPage(curPage, maxPage, urlParams) { @@ -73,6 +73,51 @@ define(function () { })($.Deferred()); }; + /** + * 设置表格导出样式 + */ + Excel.prototype.withStyle = function (data, colsWidth, defaultWidth, defaultHeight) { + // 自动计算列序 + var idx, colN = 0, defaC = {}, lastCol; + for (idx in data[0]) defaC[lastCol = layui.excel.numToTitle(++colN)] = defaultWidth || 99; + defaC[lastCol] = 160; + + // 设置表头样式 + layui.excel.setExportCellStyle(data, 'A1:' + lastCol + '1', { + s: { + font: {sz: 12, bold: true, color: {rgb: "FFFFFF"}, name: '微软雅黑', shadow: true}, + fill: {bgColor: {indexed: 64}, fgColor: {rgb: '5FB878'}}, + alignment: {vertical: 'center', horizontal: 'center'} + } + }); + + // 设置内容样式 + (function (style1, style2) { + layui.excel.setExportCellStyle(data, 'A2:' + lastCol + data.length, {s: style1}, function (rawCell, newCell, row, config, curRow) { + typeof rawCell !== 'object' && (rawCell = {v: rawCell}); + rawCell.s = Object.assign({}, style2, rawCell.s || {}); + return (curRow % 2 === 0) ? newCell : rawCell; + }); + })({ + font: {sz: 10, shadow: true, name: '微软雅黑'}, + fill: {bgColor: {indexed: 64}, fgColor: {rgb: "EAEAEA"}}, + alignment: {vertical: 'center', horizontal: 'center'} + }, { + font: {sz: 10, shadow: true, name: '微软雅黑'}, + fill: {bgColor: {indexed: 64}, fgColor: {rgb: "FFFFFF"}}, + alignment: {vertical: 'center', horizontal: 'center'} + }); + + // 设置表格行宽高,需要设置最后的行或列宽高,否则部分不生效 ??? + var rowsC = {1: 33}, colsC = Object.assign({}, defaC, {A: 60}, colsWidth || {}); + rowsC[data.length] = defaultHeight || 28, this.options.extend = { + '!cols': layui.excel.makeColConfig(colsC, defaultWidth || 99), + '!rows': layui.excel.makeRowConfig(rowsC, defaultHeight || 28), + }; + + return data; + } + /*! 直接推送表格内容 */ Excel.prototype.push = function (url, sheet, cols, filter) { var loaded, $input;