|
@@ -1,7 +1,7 @@
|
|
|
import {ElMessage} from "element-plus";
|
|
|
import {encode} from 'iconv-lite'
|
|
|
|
|
|
-export function exportCSV(data, field, fileName, separator) {
|
|
|
+export function exportCSV(data, field, fileName, separator,encoding) {
|
|
|
if (!data || data.length === 0) {
|
|
|
ElMessage({
|
|
|
message: '没有可以导出的数据!',
|
|
@@ -29,10 +29,12 @@ export function exportCSV(data, field, fileName, separator) {
|
|
|
}
|
|
|
csvContent += trim(row, separator) + '\n'
|
|
|
}
|
|
|
-
|
|
|
- const arrBuffer = new Int8Array(encode(csvContent, 'GBK'))
|
|
|
+ if(encoding === null || encoding === undefined){
|
|
|
+ encoding = 'GBK'
|
|
|
+ }
|
|
|
+ const arrBuffer = new Int8Array(encode(csvContent, encoding))
|
|
|
const blob = new Blob([arrBuffer], {
|
|
|
- type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=GBK'
|
|
|
+ type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset='+encoding
|
|
|
})
|
|
|
|
|
|
let link = document.createElement('a')
|