fix: 数据导出精度修复、redis数据操作优化

This commit is contained in:
meilin.huang
2023-08-29 21:31:08 +08:00
parent 1e5b1868ab
commit 537b179e78
2 changed files with 105 additions and 38 deletions

View File

@@ -6,6 +6,11 @@ export function exportCsv(filename: string, columns: string[], datas: []) {
let dataValueArr: any = [];
for (let column of columns) {
let val: any = data[column];
if (val == null || val == undefined) {
dataValueArr.push('');
continue;
}
if (typeof val == 'string' && val) {
// csv格式如果有逗号整体用双引号括起来如果里面还有双引号就替换成两个双引号这样导出来的格式就不会有问题了
if (val.indexOf(',') != -1) {
@@ -16,9 +21,9 @@ export function exportCsv(filename: string, columns: string[], datas: []) {
// 再将逗号转义
val = `"${val}"`;
}
dataValueArr.push(val);
dataValueArr.push(val + '\t');
} else {
dataValueArr.push(val);
dataValueArr.push(val + '\t');
}
}
cvsData.push(dataValueArr);