Browse Source

概算控制,导入数据,不检查计量单元列是否存在

MaiXinRong 3 years ago
parent
commit
49a14c422b
2 changed files with 7 additions and 5 deletions
  1. 1 2
      app/base/base_budget_service.js
  2. 6 3
      app/lib/analysis_excel.js

+ 1 - 2
app/base/base_budget_service.js

@@ -408,9 +408,8 @@ class BaseBudget extends TreeService {
 
 
     async importExcel(templateId, excelData, needGcl, filter) {
-        console.log(needGcl);
         const AnalysisExcel = require('../lib/analysis_excel').AnalysisExcelTree;
-        const analysisExcel = new AnalysisExcel(this.ctx, this.setting);
+        const analysisExcel = new AnalysisExcel(this.ctx, this.setting, needGcl ? ['code', 'b_code'] : ['code']);
         const tempData = await this.ctx.service.tenderNodeTemplate.getData(templateId, true);
         const cacheTree = analysisExcel.analysisData(excelData, tempData, {
             filterZeroGcl: filter, filterPos: true, filterGcl: !needGcl, filterCalc: true,

+ 6 - 3
app/lib/analysis_excel.js

@@ -482,7 +482,7 @@ class AnalysisExcelTree {
     /**
      * 构造函数
      */
-    constructor(ctx, setting) {
+    constructor(ctx, setting, needCols) {
         this.ctx = ctx;
         this.setting = setting;
         if (ctx.tender) {
@@ -511,6 +511,7 @@ class AnalysisExcelTree {
             drawing_code: {value: ['图号'], type: colDefineType.match},
             memo: {value: ['备注'], type: colDefineType.match},
         };
+        this.needCols = needCols || ['code', 'b_code', 'pos'];
     }
 
     _isMatch11(tempData) {
@@ -646,9 +647,11 @@ class AnalysisExcelTree {
      */
     checkColHeader(row) {
         const colsDef = aeUtils.checkColHeader(row, this.colHeaderMatch);
-        if (colsDef.code && colsDef.b_code && colsDef.pos) {
-            this.colsDef = colsDef;
+        let check = true;
+        for (const col of this.needCols) {
+            if (!colsDef[col]) check = false;
         }
+        if (check) this.colsDef = colsDef;
     }
 
     /**