From 2b6c80b63c626a0e87ffd9c7a197f7872da6c629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Sun, 10 Dec 2023 08:50:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20Excel.js=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=AF=BC=E5=87=BA=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/static/plugs/admin/excel.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/public/static/plugs/admin/excel.js b/public/static/plugs/admin/excel.js index 291ded488..3e604aee7 100644 --- a/public/static/plugs/admin/excel.js +++ b/public/static/plugs/admin/excel.js @@ -23,9 +23,9 @@ define(function () { Excel.prototype.options = {writeOpt: {bookSST: true}}; /*! 导出 Excel 文件 */ - Excel.prototype.export = function (data, name) { + Excel.prototype.export = function (data, name, options) { if (name.substring(0, -5).toLowerCase() !== '.xlsx') name += '.xlsx'; - layui.excel.exportExcel(data, name, 'xlsx', this.options || {writeOpt: {bookSST: true}}); + layui.excel.exportExcel(data, name, 'xlsx', options || this.options || {writeOpt: {bookSST: true}}); }; /*! 绑定导出的事件 */ @@ -38,9 +38,8 @@ define(function () { // Excel.bind(DONE1,FILENAME1,'#EXPORT1') // Excel.bind(DONE2,FILENAME2,'#EXPORT2') // - Excel.prototype.bind = function (done, filename, selector) { + Excel.prototype.bind = function (done, filename, selector, options) { let that = this; - this.options = {}; // {writeOpt: {bookSST: true}}; $('body').off('click', selector || '[data-form-export]').on('click', selector || '[data-form-export]', function () { let form = $(this).parents('form'); let name = this.dataset.filename || filename; @@ -51,7 +50,7 @@ define(function () { location += (location.indexOf('?') > -1 ? '&' : '?') + '_order_=' + sortType + '&_field_=' + sortField; } that.load(location, form.serialize(), method).then(function (data) { - that.export(done.call(that, data, []), name); + that.export(done.call(that, data, []), name, options || {}); }).fail(function (ret) { $.msg.tips(ret || '文件导出失败'); });