Browse Source

导入分项清单excel调整

MaiXinRong 4 years ago
parent
commit
217684484c

+ 1 - 1
app/controller/ledger_controller.js

@@ -538,7 +538,7 @@ module.exports = app => {
                     case 'tz':
                         const templateId = await this.ctx.service.valuation.getValuationTemplate(
                             this.ctx.tender.data.valuation, this.ctx.tender.data.measure_type);
-                        responseData.data = await ctx.service.ledger.importExcel(templateId, data);
+                        responseData.data = await ctx.service.ledger.importExcel(templateId, data.sheet, data.filter);
                         break;
                     case 'gcl2xmj':
                         responseData.data = await ctx.service.ledger.importGclExcel(data.id, data.sheet);

+ 5 - 1
app/lib/analysis_excel.js

@@ -547,6 +547,9 @@ class AnalysisExcelTree {
         } else {
             node.total_price = null;
         }
+        if (this.filter && !node.quantity && !node.total_price) {
+            return this.filter;
+        }
         return this.cacheTree.addGclNode(node);
     }
     /**
@@ -610,7 +613,8 @@ class AnalysisExcelTree {
      * @param {Array} tempData - 新建项目使用的清单模板
      * @returns {ImportBaseTree}
      */
-    analysisData(sheet, tempData) {
+    analysisData(sheet, tempData, filter) {
+        this.filter = filter;
         this.colsDef = null;
         this.cacheTree = this._getNewCacheTree(tempData);
         this.errorData = [];

+ 3 - 2
app/public/js/ledger.js

@@ -1436,8 +1436,9 @@ $(document).ready(function() {
                         hint: '0号台账',
                         url: '/template/导入分项清单EXCEL格式.xls',
                     },
-                    callback: function (sheet) {
-                        postDataCompress(window.location.pathname + '/upload-excel/tz', sheet, function (result) {
+                    filter: true,
+                    callback: function (sheet, filter) {
+                        postDataCompress(window.location.pathname + '/upload-excel/tz', {sheet, filter}, function (result) {
                             ledgerTree.loadDatas(result.bills);
                             treeCalc.calculateAll(ledgerTree);
                             SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), 'tree', ledgerTree);

+ 2 - 2
app/service/ledger.js

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

+ 11 - 3
app/view/ledger/explode_modal.ejs

@@ -16,9 +16,17 @@
                     <h6>选择导入的工作表</h6>
                 </div>
             </div>
-            <div class="modal-footer">
-                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
-                <button type="button" class="btn btn-primary btn-sm" id="upload-ledger-ok">确认上传</button>
+            <div class="modal-footer d-flex justify-content-between">
+                <div class="">
+                    <div class="custom-control custom-checkbox custom-control-inline">
+                        <input type="radio" class="custom-control-input" name="customRadioInline1" id="customCheck3" checked="">
+                        <label class="custom-control-label" for="customCheck3">过滤清单数量和单价为0项</label>
+                    </div>
+                </div>
+                <div>
+                    <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
+                    <button type="button" class="btn btn-primary btn-sm" id="upload-ledger-ok">确认上传</button>
+                </div>
             </div>
         </div>
     </div>

+ 17 - 4
app/view/shares/import_excel_modal.ejs

@@ -17,9 +17,17 @@
                     <h6>选择导入的工作表</h6>
                 </div>
             </div>
-            <div class="modal-footer">
-                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
-                <button type="button" class="btn btn-primary btn-sm" id="import-excel-ok">确认上传</button>
+            <div class="modal-footer d-flex justify-content-between">
+                <div>
+                    <div class="custom-control custom-checkbox custom-control-inline" id="filter-excel">
+                        <input type="radio" class="custom-control-input" name="customRadioInline1" id="filter-qty-price" checked="">
+                        <label class="custom-control-label" for="filter-qty-price">过滤清单数量和单价为0项</label>
+                    </div>
+                </div>
+                <div>
+                    <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
+                    <button type="button" class="btn btn-primary btn-sm" id="import-excel-ok">确认上传</button>
+                </div>
             </div>
         </div>
     </div>
@@ -90,7 +98,7 @@
                         rows: xlsxUtils.getSheetByName(sheetName, {header: 1}),
                         merge: xlsxUtils._wb.Sheets[sheetName]["!merges"]
                     };
-                    if (callback) callback(sheet);
+                    if (callback) callback(sheet, $('#filter-qty-price')[0].checked);
                 }
                 $('#import-excel').modal('hide');
             }
@@ -103,6 +111,11 @@
             } else {
                 $('#import-template').hide();
             }
+            if (setting.filter) {
+                $('#filter-excel').show();
+            } else {
+                $('#filter-excel').hide();
+            }
             $('#import-excel').modal('show');
             callback = setting.callback;
             u_type = setting.u_type ? setting.u_type : uploadType.data;

+ 3 - 0
sql/update.sql

@@ -63,3 +63,6 @@ CREATE TABLE `zh_s2b_proj_push` (
 
 ALTER TABLE `zh_s2b_c_proj`
 ADD COLUMN `push_tender`  varchar(1000) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '推送的标段' AFTER `base_data`;
+
+ALTER TABLE `zh_s2b_proj`
+ADD COLUMN `filter_tender`  varchar(1000) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '过滤标段' AFTER `merge_code`;