@gingkoo/base-server 0.0.4-alpha.19 → 0.0.4-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -337,7 +337,45 @@ function getSheetData(worksheet, mapping, linkColumn, linkWorksheetMap, linkMapp
337
337
  }
338
338
 
339
339
  /**
340
- * 导入多 sheet
340
+ * 导入多 sheet 他只负责拿数据 给业务那边处理
341
+ * @param {string} filePath
342
+ */
343
+ const _excelImportMultisheet2 = async (filePath = '') => {
344
+ var workbook = new ExcelJS.Workbook();
345
+ await workbook.xlsx.readFile(filePath);
346
+ let result = [];
347
+
348
+ workbook.eachSheet((worksheet, sheetId) => {
349
+ let sheetInfo = {
350
+ sheetName: worksheet.name,
351
+ worksheet,
352
+ header: [], // string[]
353
+ data: [], // stirng[][]
354
+ };
355
+
356
+ worksheet.eachRow((row, rowNumber) => {
357
+ let rowData = [];
358
+ row.eachCell((cell, colNumber) => {
359
+ let colValue = cell.value;
360
+
361
+ if (rowNumber == 1) {
362
+ sheetInfo.header.push(colValue);
363
+ } else {
364
+ rowData[colNumber - 1] = colValue;
365
+ }
366
+ });
367
+
368
+ rowNumber > 1 && sheetInfo.data.push(rowData);
369
+ });
370
+
371
+ result.push(sheetInfo);
372
+ });
373
+
374
+ return result;
375
+ };
376
+
377
+ /**
378
+ * 导入多 sheet 结构
341
379
  * @param {string} filePath
342
380
  * @param {string} mainSheetName 主sheet
343
381
  * @param {string} linkColumn 其他 sheet 和 主sheet 关联的列
@@ -348,8 +386,8 @@ const _excelImportMultisheet = async (
348
386
  filePath = '',
349
387
  mainSheetName = '',
350
388
  linkColumn = '',
351
- mainMapping = [],
352
- linkMapping = '',
389
+ mainMapping = {},
390
+ linkMapping = {},
353
391
  ) => {
354
392
  var workbook = new ExcelJS.Workbook();
355
393
  await workbook.xlsx.readFile(filePath);
@@ -717,6 +755,8 @@ module.exports = {
717
755
  _excelImport,
718
756
  _excelExport,
719
757
  _excelImportMultisheet,
758
+ _excelImportMultisheet2,
720
759
  _excelExportMultisheet,
721
760
  ExcelHelper,
761
+ getSheetData,
722
762
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gingkoo/base-server",
3
- "version": "0.0.4-alpha.19",
3
+ "version": "0.0.4-alpha.20",
4
4
  "description": "",
5
5
  "main": "app.js",
6
6
  "scripts": {