|
@@ -30,7 +30,7 @@ class ExcelService extends CrudService {
|
|
|
*/
|
|
|
async toExcel({ data = [], meta, fn = 'excel导出结果' } = {}) {
|
|
|
const nowDate = new Date().getTime();
|
|
|
- const filename = `${fn}.xlsx`;
|
|
|
+ const filename = `${fn}-${nowDate}.xlsx`;
|
|
|
const path = `${this.root_path}${this.file_type}${this.excel_path}`;
|
|
|
if (!path) {
|
|
|
throw new BusinessError(ErrorCode.BUSINESS, '服务端没有设置存储路径');
|
|
@@ -45,7 +45,6 @@ class ExcelService extends CrudService {
|
|
|
sheet.columns = meta;
|
|
|
sheet.addRows(data);
|
|
|
} else {
|
|
|
-
|
|
|
for (const row of data) {
|
|
|
const { scell, ecell, content, alignment, font } = row;
|
|
|
if (scell && ecell) {
|
|
@@ -54,7 +53,6 @@ class ExcelService extends CrudService {
|
|
|
if (alignment) sheet.getCell(ecell).alignment = alignment;
|
|
|
if (font) sheet.getCell(ecell).font = font;
|
|
|
} else {
|
|
|
- console.log('in function:');
|
|
|
if (_.isObject(content)) {
|
|
|
const keys = Object.keys(content);
|
|
|
for (const cell of keys) {
|
|
@@ -71,6 +69,8 @@ class ExcelService extends CrudService {
|
|
|
const filepath = `${path}${filename}`;
|
|
|
if (data.length <= 0) return;
|
|
|
await workbook.xlsx.writeFile(filepath);
|
|
|
+
|
|
|
+ return `/file-zhwl/excel/${filename}`;
|
|
|
}
|
|
|
|
|
|
numberToLetter(num) {
|