|
@@ -1,7 +1,7 @@
|
|
|
import {ElMessage} from "element-plus";
|
|
|
import {encode} from 'iconv-lite'
|
|
|
|
|
|
-export function exportCSV(data, field, fileName) {
|
|
|
+export function exportCSV(data, field, fileName, separator) {
|
|
|
if (!data || data.length === 0) {
|
|
|
ElMessage({
|
|
|
message: '没有可以导出的数据!',
|
|
@@ -13,10 +13,10 @@ export function exportCSV(data, field, fileName) {
|
|
|
let csvContent = ''
|
|
|
let jsonColumns = []
|
|
|
for (let key in field) {
|
|
|
- csvContent += field[key] + ','
|
|
|
+ csvContent += field[key] + separator
|
|
|
jsonColumns.push(key)
|
|
|
}
|
|
|
- csvContent = trim(csvContent, ',') + '\n'
|
|
|
+ csvContent = trim(csvContent, separator) + '\n'
|
|
|
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
let row = ''
|
|
@@ -25,9 +25,9 @@ export function exportCSV(data, field, fileName) {
|
|
|
if (val === null || val === undefined) {
|
|
|
val = ''
|
|
|
}
|
|
|
- row += `${val},`
|
|
|
+ row += `${val}${separator}`
|
|
|
}
|
|
|
- csvContent += trim(row, ',') + '\n'
|
|
|
+ csvContent += trim(row, separator) + '\n'
|
|
|
}
|
|
|
|
|
|
const arrBuffer = new Int8Array(encode(csvContent, 'GBK'))
|