mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2026-06-10 13:38:11 +08:00
fix: 增加 Excel.loadAll 方法,加载待所有导出数据
This commit is contained in:
parent
035ceabd1f
commit
c9601938c9
@ -42,22 +42,33 @@ define(function () {
|
|||||||
Excel.prototype.bind = function (done, filename, selector, options) {
|
Excel.prototype.bind = function (done, filename, selector, options) {
|
||||||
let that = this;
|
let that = this;
|
||||||
this.options = options || {}
|
this.options = options || {}
|
||||||
|
this.loadAll(function (data) {
|
||||||
|
that.export(data, this.dataset.filename || filename, options);
|
||||||
|
}, selector);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载所有数据
|
||||||
|
* @param done
|
||||||
|
* @param selector
|
||||||
|
*/
|
||||||
|
Excel.prototype.loadAll = function (done, selector) {
|
||||||
|
let that = this;
|
||||||
$('body').off('click', selector || '[data-form-export]').on('click', selector || '[data-form-export]', function () {
|
$('body').off('click', selector || '[data-form-export]').on('click', selector || '[data-form-export]', function () {
|
||||||
let form = $(this).parents('form');
|
let button = this, form = $(button).parents('form');
|
||||||
let name = this.dataset.filename || filename;
|
let method = button.dataset.method || form.attr('method') || 'get';
|
||||||
let method = this.dataset.method || form.attr('method') || 'get';
|
let location = button.dataset.excel || button.dataset.formExport || form.attr('action') || '';
|
||||||
let location = this.dataset.excel || this.dataset.formExport || form.attr('action') || '';
|
let sortType = $(button).attr('data-sort-type') || '', sortField = $(button).attr('data-sort-field') || '';
|
||||||
let sortType = $(this).attr('data-sort-type') || '', sortField = $(this).attr('data-sort-field') || '';
|
|
||||||
if (sortField.length > 0 && sortType.length > 0) {
|
if (sortField.length > 0 && sortType.length > 0) {
|
||||||
location += (location.indexOf('?') > -1 ? '&' : '?') + '_order_=' + sortType + '&_field_=' + sortField;
|
location += (location.indexOf('?') > -1 ? '&' : '?') + '_order_=' + sortType + '&_field_=' + sortField;
|
||||||
}
|
}
|
||||||
that.load(location, form.serialize(), method).then(function (data) {
|
that.load(location, form.serialize(), method).then(function (data) {
|
||||||
that.export(done.call(that, data, []), name);
|
done.call(button, data, []);
|
||||||
}).fail(function (ret) {
|
}).fail(function (ret) {
|
||||||
$.msg.tips(ret || '文件导出失败');
|
$.msg.tips(ret || '数据加载失败');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/*! 加载导出的文档 */
|
/*! 加载导出的文档 */
|
||||||
Excel.prototype.load = function (url, data, method) {
|
Excel.prototype.load = function (url, data, method) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user