فهرست منبع

台账修订,总分包更新,新增导入单价选项

MaiXinRong 7 ماه پیش
والد
کامیت
0e5a3f11e6

+ 1 - 1
app/controller/tender_controller.js

@@ -1466,7 +1466,7 @@ module.exports = app => {
                         ctx.body = {err: 0, msg: '', data: refreshData};
                         break;
                     case 'revise':
-                        const reviseData = await this.ctx.service.reviseBills.sumLoad(data.lid, this.ctx.revise.id, data.tenders);
+                        const reviseData = await this.ctx.service.reviseBills.sumLoad(data.lid, this.ctx.revise.id, data.tenders, data.subUp);
                         ctx.body = {err: 0, msg: '', data: reviseData};
                         break;
                     case 'stage':

+ 9 - 4
app/lib/sum_load.js

@@ -31,6 +31,7 @@ class loadGclBaseTree {
         this.ignoreParent = setting.ignoreParent;
         this.ignoreNotFind = setting.ignoreNotFind;
         this.loadChange = setting.loadChange;
+        this.useSubUp = setting.useSubUp;
 
         // 缓存
         this.keyNodeId = setting.maxId ? setting.maxId + 1 : 1;
@@ -145,6 +146,7 @@ class loadGclBaseTree {
                 quantity: 0,
                 is_leaf: source.is_leaf,
                 hasPos: false,
+                sub_up: source.unit_price || 0,
             };
             this.keyNodeId += 1;
             parent.children.push(node);
@@ -186,8 +188,11 @@ class loadGclBaseTree {
 
             if (!node.unit_price) {
                 const db = dealBills.find(x => { return x.code === node.b_code && x.name === node.name && x.unit === node.unit });
-                if (!db) return;
-                node.unit_price = db.unit_price;
+                if (db) {
+                    node.unit_price = db.unit_price;
+                } else if (this.useSubUp) {
+                    node.unit_price = this.ctx.helper.round(node.sub_up, this.ctx.tender.info.decimal.up);
+                }
             }
             node.deal_tp = this.ctx.helper.mul(node.deal_qty, node.unit_price, this.ctx.tender.info.decimal.tp);
             node.sgfh_tp = this.ctx.helper.mul(node.sgfh_qty, node.unit_price, this.ctx.tender.info.decimal.tp);
@@ -482,9 +487,9 @@ class sumLoad {
         }
     }
 
-    async loadGatherGcl(select, maxId, tenders, defaultData) {
+    async loadGatherGcl(select, maxId, tenders, defaultData, subUp) {
         this.loadTree = new loadLedgerGclTree(this.ctx, {
-            parent: select, maxId, type: 'ledger', defaultData,
+            parent: select, maxId, type: 'ledger', defaultData, subUp,
         });
         for (const tender of tenders) {
             const billsData = await this.ctx.service.ledger.getData(tender.tid);

+ 10 - 3
app/public/js/shares/tender_select.js

@@ -175,9 +175,14 @@ const TenderSelect = function (setting) {
             this.tenderSpread.bind(spreadNS.Events.ButtonClicked, tsObj.tsButtonClicked);
             if (this.setting.type === 'stage') {
                 this.resultSpread.bind(spreadNS.Events.EditEnded, tsObj.trEditEnded);
-                $('#tender-select-option').show();
-            } else {
-                $('#tender-select-option').hide();
+                $('#stage-select-option').show();
+                $('#ledger-select-option').hide();
+            } else if (this.setting.type === 'revise') {
+                $('#stage-select-option').hide();
+                $('#ledger-select-option').show();
+            } else if (this.setting.type === 'ledger') {
+                $('#stage-select-option').hide();
+                $('#ledger-select-option').hide();
             }
 
             $('#tender-select-ok').click(() => {
@@ -186,6 +191,8 @@ const TenderSelect = function (setting) {
                     updateData.cover = $('#ts-cover')[0].checked;
                     updateData.ignore = $('#ts-ignore')[0].checked;
                     updateData.change = $('#ts-change')[0].checked;
+                } else if (tsObj.setting.type === 'revise') {
+                    updateData.subUp = $('#ts-subUp')[0].checked;
                 }
                 if (updateData.tenders.length > 0) {
                     postData(window.location.pathname + '/sumLoad', updateData, result => {

+ 2 - 2
app/service/revise_bills.js

@@ -236,7 +236,7 @@ module.exports = app => {
             return result;
         }
 
-        async sumLoad(lid, rid, tenders) {
+        async sumLoad(lid, rid, tenders, subUp) {
             const conn = await this.db.beginTransaction();
             try {
                 const maxId = await this._getMaxLid(this.ctx.tender.id);
@@ -244,7 +244,7 @@ module.exports = app => {
                 const sumLoad = new SumLoad(this.ctx);
                 const loadTree = await sumLoad.updateGatherGcl(select, maxId, tenders, {
                     crid: rid,
-                });
+                }, subUp);
                 const result = loadTree.getUpdateData();
                 if (result.errors.length > 100) throw '您导入的数据存在大量数据错误,请您仔细检查';
 

+ 20 - 11
app/view/shares/tender_select_modal.ejs

@@ -18,18 +18,27 @@
                         <h5>已选标段 </h5>
                         <div class="modal-height-300" id="ts-result-spread">
                         </div>
-                        <div id="tender-select-option" style="display: none;">
-                            <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="checkbox" id="ts-cover">
-                                <label class="form-check-label" for="ts-cover">覆盖数据</label>
+                        <div id="tender-select-option">
+                            <div id="ledger-select-option" type="ledger" style="display: none;">
+                                <div class="form-check form-check-inline">
+                                    <input class="form-check-input" type="checkbox" id="ts-subUp">
+                                    <label class="form-check-label" for="ts-subUp">总包无签约单价时使用分包单价</label>
+                                </div>
                             </div>
-                            <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="checkbox" id="ts-ignore">
-                                <label class="form-check-label" for="ts-ignore">以本标段清单为准</label>
-                            </div>
-                            <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="checkbox" id="ts-change" checked>
-                                <label class="form-check-label" for="ts-change">含变更</label>
+                            <div id="stage-select-option" type="stage" style="display: none;">
+                                <div class="form-check form-check-inline">
+                                    <input class="form-check-input" type="checkbox" id="ts-cover">
+                                    <label class="form-check-label" for="ts-cover">覆盖数据</label>
+                                </div>
+                                <div class="form-check form-check-inline">
+                                    <input class="form-check-input" type="checkbox" id="ts-ignore">
+                                    <label class="form-check-label" for="ts-ignore">以本标段清单为准</label>
+                                </div>
+                                <div class="form-check form-check-inline">
+                                    <input class="form-check-input" type="checkbox" id="ts-change" checked>
+                                    <label class="form-check-label" for="ts-change">含变更</label>
+                                </div>
+
                             </div>
                         </div>
                     </div>