-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #255 from 4x99/develop
v1.6.
- Loading branch information
Showing
11 changed files
with
147 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* 导出数据 | ||
*/ | ||
Ext.define('plugin.export', { | ||
extend: 'Ext.Button', | ||
text: '导出数据', | ||
iconCls: 'icon-excel', | ||
onClick: function () { | ||
var data = this.getData(); | ||
this.saveCsv(data); | ||
}, | ||
// 读取数据 | ||
getData: function () { | ||
var header = [], value = []; | ||
var grid = this.up('gridpanel'); | ||
var store = grid.store; | ||
var columns = grid.columns ? grid.columns : grid.columnManager.columns; | ||
Ext.each(store.getData().items, function (record, index) { | ||
var row = []; | ||
if (store.filters && !store.filters.filterFn(record)) { | ||
return true; | ||
} | ||
Ext.each(columns, function (column) { | ||
if (column.hidden || column.xtype === 'widgetcolumn') { | ||
return true; | ||
} | ||
if (index === 0) { | ||
header.push(column.text); | ||
} | ||
var value = record.get(column.dataIndex); | ||
if (column.renderer) { | ||
value = column.renderer(value, {}, record); | ||
} | ||
value = String(value).replace(/\n+|(<br\s*\/?>)+/ig, ' '); // 去除换行 | ||
value = Ext.util.Format.stripTags(value); | ||
row.push(`"${value}"`); | ||
}); | ||
value.push(row.join(',')); | ||
}); | ||
return header.join(',') + '\n' + value.join('\n'); | ||
}, | ||
// 保存 CSV 文件 | ||
saveCsv: function (data) { | ||
const blob = new Blob([data], {type: 'text/csv'}); | ||
const url = window.URL.createObjectURL(blob) | ||
const a = document.createElement('a') | ||
a.href = url; | ||
a.download = Ext.Date.format(new Date(), 'YmdHis') + '.csv' | ||
a.click() | ||
a.remove(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.6.3 | ||
1.6.4 |