Browse Source

导入excel,因添加计价规范调整

MaiXinRong 5 years ago
parent
commit
81b6c53037
2 changed files with 4 additions and 3 deletions
  1. 2 1
      app/controller/ledger_controller.js
  2. 2 2
      app/service/ledger.js

+ 2 - 1
app/controller/ledger_controller.js

@@ -474,7 +474,8 @@ module.exports = app => {
                 const compressData = ctx.request.body.data;
                 const compressData = ctx.request.body.data;
                 const data = JSON.parse(LzString.decompressFromUTF16(compressData));
                 const data = JSON.parse(LzString.decompressFromUTF16(compressData));
                 const responseData = { err: 0, msg: '', data: {}, };
                 const responseData = { err: 0, msg: '', data: {}, };
-                await ctx.service.ledger.importExcel(data);
+                const templateId = await this.ctx.service.valuation.getValuationTemplate(this.ctx.tender.data.valuation);
+                await ctx.service.ledger.importExcel(templateId, data);
                 responseData.data.bills = await ctx.service.ledger.getData(ctx.tender.id);
                 responseData.data.bills = await ctx.service.ledger.getData(ctx.tender.id);
                 responseData.data.pos = await ctx.service.pos.getPosData({tid: this.ctx.tender.id});
                 responseData.data.pos = await ctx.service.pos.getPosData({tid: this.ctx.tender.id});
                 ctx.body = responseData;
                 ctx.body = responseData;

+ 2 - 2
app/service/ledger.js

@@ -819,11 +819,11 @@ module.exports = app => {
          * @param excelData
          * @param excelData
          * @returns {Promise<void>}
          * @returns {Promise<void>}
          */
          */
-        async importExcel(excelData) {
+        async importExcel(templateId, excelData) {
             //console.time('analysis');
             //console.time('analysis');
             const AnalysisExcel = require('../lib/analysis_excel');
             const AnalysisExcel = require('../lib/analysis_excel');
             const analysisExcel = new AnalysisExcel(this.ctx);
             const analysisExcel = new AnalysisExcel(this.ctx);
-            const tempData = await this.ctx.service.tenderNodeTemplate.getData(true);
+            const tempData = await this.ctx.service.tenderNodeTemplate.getData(templateId, true);
             const cacheTree = analysisExcel.analysisData(excelData, tempData);
             const cacheTree = analysisExcel.analysisData(excelData, tempData);
             const cacheKey = keyPre + this.ctx.tender.id;
             const cacheKey = keyPre + this.ctx.tender.id;
             const orgMaxId = parseInt(await this.cache.get(cacheKey));
             const orgMaxId = parseInt(await this.cache.get(cacheKey));