소스 검색

计算1计算问题

MaiXinRong 2 달 전
부모
커밋
0378eb8d4f
3개의 변경된 파일43개의 추가작업 그리고 11개의 파일을 삭제
  1. 2 2
      app/controller/stage_controller.js
  2. 1 1
      app/public/js/ledger.js
  3. 40 8
      app/service/pos.js

+ 2 - 2
app/controller/stage_controller.js

@@ -217,7 +217,7 @@ module.exports = app => {
             this.ledgerColumn = [
                 'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',
                 'code', 'b_code', 'name', 'unit', 'unit_price',
-                'quantity', 'total_price', 'deal_qty', 'deal_tp', 'memo', 'features', 'drawing_code', 'node_type'];
+                'quantity', 'total_price', 'deal_qty', 'deal_tp', 'ex_qty1', 'ex_tp1', 'memo', 'features', 'drawing_code', 'node_type'];
             // if (tender.data.measure_type === measureType.gcl.value) this.ledgerColumn.push('deal_qty', 'deal_tp');
             if (tender.info.display.ledger.dgnQty) this.ledgerColumn.push('dgn_qty1', 'dgn_qty2');
 
@@ -226,7 +226,7 @@ module.exports = app => {
             if (this.ctx.session.sessionProject.dagl) this.ledgerExtraColumn.push('dagl_status', 'dagl_url', 'dagl_limit');
             this.ledgerMemoColumn = ['memo'];
 
-            this.posColumn = ['id', 'tid', 'lid', 'name', 'position', 'porder', 'sgfh_qty', 'quantity', 'add_stage_order', 'drawing_code'];
+            this.posColumn = ['id', 'tid', 'lid', 'name', 'position', 'porder', 'sgfh_qty', 'quantity', 'ex_qty1', 'add_stage_order', 'drawing_code'];
             if (tender.info.display.stage.realComplete) this.posColumn.push('real_qty');
 
             this.posExtraColumn = [];

+ 1 - 1
app/public/js/ledger.js

@@ -107,7 +107,7 @@ $(document).ready(function() {
         // markFoldSubKey: window.location.pathname.split('/')[2],
         markExpandKey: 'bills-expand',
         markExpandSubKey: window.location.pathname.split('/')[2],
-        calcFields: ['deal_tp', 'sgfh_tp', 'sjcl_tp', 'qtcl_tp', 'total_price'],
+        calcFields: ['deal_tp', 'sgfh_tp', 'sjcl_tp', 'qtcl_tp', 'total_price', 'ex_tp1'],
     };
     treeSetting.calcFun = function (node) {
         node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);

+ 40 - 8
app/service/pos.js

@@ -28,7 +28,7 @@ module.exports = app => {
             return await this.db.select(this.departTableName(condition.tid), {
                 where: condition,
                 columns: column || ['id', 'tid', 'lid', 'name', 'quantity', 'position', 'drawing_code', 'sgfh_qty', 'sjcl_qty',
-                    'qtcl_qty', 'in_time', 'porder', 'add_stage', 'add_stage_order', 'sgfh_expr', 'sjcl_expr', 'qtcl_expr', 'real_qty',
+                    'qtcl_qty', 'in_time', 'porder', 'add_stage', 'add_stage_order', 'sgfh_expr', 'sjcl_expr', 'qtcl_expr', 'real_qty', 'ex_qty1',
                     'ex_memo1', 'ex_memo2', 'ex_memo3'],
                 order: [['porder', 'ASC']],
             });
@@ -38,7 +38,7 @@ module.exports = app => {
             if (!condition.tid) throw '查询计量单元缺少必要信息';
             const sql = 'SELECT id, tid, lid, name, quantity, position, drawing_code,' +
                 '    sgfh_qty, sjcl_qty, qtcl_qty, porder, add_stage, add_times, add_user, add_stage_order,' +
-                '    sgfh_expr, sjcl_expr, qtcl_expr, real_qty, ex_memo1, ex_memo2, ex_memo3' +
+                '    sgfh_expr, sjcl_expr, qtcl_expr, real_qty, ex_qty1, ex_memo1, ex_memo2, ex_memo3' +
                 '  FROM ' + this.departTableName(condition.tid) + this.ctx.helper.whereSql(condition);
             return await this.db.query(sql);
         }
@@ -46,7 +46,7 @@ module.exports = app => {
         async getPosDataByIds(tid, ids) {
             if (ids instanceof Array && ids.length > 0) {
                 const sql = 'SELECT id, tid, lid, name, quantity, position, drawing_code,' +
-                    '    sgfh_qty, sjcl_qty, qtcl_qty, add_stage, add_times, add_user, sgfh_expr, sjcl_expr, qtcl_expr, real_qty,' +
+                    '    sgfh_qty, sjcl_qty, qtcl_qty, add_stage, add_times, add_user, sgfh_expr, sjcl_expr, qtcl_expr, real_qty, ex_qty1' +
                     '    ex_memo1, ex_memo2, ex_memo3' +
                     '  FROM ' + this.departTableName(tid) +
                     '  WHERE id in (' + this.ctx.helper.getInArrStrSqlFilter(ids) + ')';
@@ -117,6 +117,7 @@ module.exports = app => {
                 updateBills.sjcl_qty = this.ctx.helper.add(updateBills.sjcl_qty, bp.sjcl_qty);
                 updateBills.qtcl_qty = this.ctx.helper.add(updateBills.qtcl_qty, bp.qtcl_qty);
                 updateBills.quantity = this.ctx.helper.add(updateBills.quantity, bp.quantity);
+                updateBills.ex_qty1 = this.ctx.helper.add(updateBills.ex_qty1, bp.ex_qty1);
             }
             for (const d of datas) {
                 if (d.sgfh_qty) {
@@ -133,12 +134,17 @@ module.exports = app => {
                 }
                 d.quantity = this.ctx.helper.sum([d.sgfh_qty, d.qtcl_qty, d.sjcl_qty]);
                 updateBills.quantity = this.ctx.helper.add(updateBills.quantity, d.quantity);
+                if (d.ex_qty1) {
+                    d.ex_qty1 = this.ctx.helper.round(d.ex_qty1, precision.value);
+                    updateBills.qtcl_qty = this.ctx.helper.add(updateBills.qtcl_qty, d.qtcl_qty);
+                }
             }
             const info = this.ctx.tender.info;
             updateBills.sgfh_tp = this.ctx.helper.mul(updateBills.sgfh_qty, bills.unit_price, info.decimal.tp);
             updateBills.sjcl_tp = this.ctx.helper.mul(updateBills.sjcl_qty, bills.unit_price, info.decimal.tp);
             updateBills.qtcl_tp = this.ctx.helper.mul(updateBills.qtcl_qty, bills.unit_price, info.decimal.tp);
             updateBills.total_price = this.ctx.helper.mul(updateBills.quantity, bills.unit_price, info.decimal.tp);
+            updateBills.ex_tp1 = this.ctx.helper.mul(updateBills.ex_qty1, bills.unit_price, info.decimal.tp);
             return updateBills;
         }
 
@@ -148,12 +154,12 @@ module.exports = app => {
                 for (const d of data) {
                     this._completeInsertPosData(tid, d);
                 }
-                if (data[0].sgfh_qty !== undefined || data[0].sjcl_qty !== undefined || data[0].qtcl_qty !== undefined) {
+                if (data[0].sgfh_qty !== undefined || data[0].sjcl_qty !== undefined || data[0].qtcl_qty !== undefined || data[0].ex_qty1 !== undefined) {
                     updateBills = await this._getUpdateBills(data);
                 }
             } else {
                 this._completeInsertPosData(tid, data);
-                if (data.sgfh_qty !== undefined || data.sjcl_qty !== undefined || data.qtcl_qty !== undefined) {
+                if (data.sgfh_qty !== undefined || data.sjcl_qty !== undefined || data.qtcl_qty !== undefined || data.ex_qty1 !== undefined) {
                     updateBills = await this._getUpdateBills(data);
                 }
             }
@@ -178,7 +184,7 @@ module.exports = app => {
         }
 
         async _updatePosData(tid, data) {
-            if (data.sgfh_qty !== undefined || data.sjcl_qty !== undefined || data.qtcl_qty !== undefined) {
+            if (data.sgfh_qty !== undefined || data.sjcl_qty !== undefined || data.qtcl_qty !== undefined || data.ex_qty1 !== undefined) {
                 const op = await this.getDataById(data.id);
                 const bills = await this.ctx.service.ledger.getDataById(op.lid);
                 if (!bills) throw '数据错误';
@@ -201,6 +207,11 @@ module.exports = app => {
                     data.qtcl_qty = op.qtcl_qty;
                 }
                 data.quantity = this.ctx.helper.sum([data.sgfh_qty, data.qtcl_qty, data.sjcl_qty]);
+                if (data.ex_qty1 !== undefined) {
+                    data.ex_qty1 = this.round(data.ex_qty1, precision.value);
+                } else if (op) {
+                    data.ex_qty1 = op.ex_qty1;
+                }
 
                 const updateBills = {id: bills.id};
                 for (const bp of billsPos) {
@@ -209,12 +220,14 @@ module.exports = app => {
                     updateBills.sjcl_qty = this.ctx.helper.add(updateBills.sjcl_qty, calcData.sjcl_qty);
                     updateBills.qtcl_qty = this.ctx.helper.add(updateBills.qtcl_qty, calcData.qtcl_qty);
                     updateBills.quantity = this.ctx.helper.add(updateBills.quantity, calcData.quantity);
+                    updateBills.ex_qty1 = this.ctx.helper.add(updateBills.ex_qty1, calcData.ex_qty1);
                 }
                 const info = this.ctx.tender.info;
                 updateBills.sgfh_tp = this.ctx.helper.mul(updateBills.sgfh_qty, bills.unit_price, info.decimal.tp);
                 updateBills.sjcl_tp = this.ctx.helper.mul(updateBills.sjcl_qty, bills.unit_price, info.decimal.tp);
                 updateBills.qtcl_tp = this.ctx.helper.mul(updateBills.qtcl_qty, bills.unit_price, info.decimal.tp);
                 updateBills.total_price = this.ctx.helper.mul(updateBills.quantity, bills.unit_price, info.decimal.tp);
+                updateBills.ex_tp1 = this.ctx.helper.mul(updateBills.ex_qty1, bills.unit_price, info.decimal.tp);
 
                 const transaction = await this.db.beginTransaction();
                 try {
@@ -244,7 +257,7 @@ module.exports = app => {
             const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
             let needUpdateBills;
             for (const d of data) {
-                if (d.sgfh_qty !== undefined || d.sjcl_qty !== undefined || d.qtcl_qty !== undefined) {
+                if (d.sgfh_qty !== undefined || d.sjcl_qty !== undefined || d.qtcl_qty !== undefined || d.ex_qty1 !== undefined) {
                     if (d.sgfh_qty !== undefined) {
                         d.sgfh_qty = this.round(d.sgfh_qty, precision.value);
                     } else if (op) {
@@ -261,6 +274,11 @@ module.exports = app => {
                         d.qtcl_qty = op.qtcl_qty;
                     }
                     d.quantity = this.ctx.helper.sum([d.sgfh_qty, d.qtcl_qty, d.sjcl_qty]);
+                    if (d.ex_qty1 !== undefined) {
+                        d.ex_qty1 = this.round(d.ex_qty1, precision.value);
+                    } else if (op) {
+                        d.ex_qty1 = op.ex_qty1;
+                    }
                     needUpdateBills = true;
                 }
             }
@@ -280,12 +298,16 @@ module.exports = app => {
                     updateBills.quantity = newPos && newPos.quantity !== undefined
                         ? this.ctx.helper.add(updateBills.quantity, newPos.quantity)
                         : this.ctx.helper.add(updateBills.quantity, bp.quantity);
+                    updateBills.ex_qty1 = newPos && newPos.ex_qty1 !== undefined
+                        ? this.ctx.helper.add(updateBills.ex_qty1, newPos.ex_qty1)
+                        : this.ctx.helper.add(updateBills.ex_qty1, bp.ex_qty1);
                 }
                 const info = this.ctx.tender.info;
                 updateBills.sgfh_tp = this.ctx.helper.mul(updateBills.sgfh_qty, bills.unit_price, info.decimal.tp);
                 updateBills.sjcl_tp = this.ctx.helper.mul(updateBills.sjcl_qty, bills.unit_price, info.decimal.tp);
                 updateBills.qtcl_tp = this.ctx.helper.mul(updateBills.qtcl_qty, bills.unit_price, info.decimal.tp);
                 updateBills.total_price = this.ctx.helper.mul(updateBills.quantity, bills.unit_price, info.decimal.tp);
+                updateBills.ex_tp1 = this.ctx.helper.mul(updateBills.ex_qty1, bills.unit_price, info.decimal.tp);
             }
 
             const transaction = await this.db.beginTransaction();
@@ -314,19 +336,21 @@ module.exports = app => {
 
             const bills = await this.ctx.service.ledger.getDataById(pos[0].lid);
             const billsPos = await this.getAllDataByCondition({ where: {tid: tid, lid: bills.id} });
-            const updateBills = {id: bills.id, sgfh_qty: null, sjcl_qty: null, qtcl_qty: null, quantity: null};
+            const updateBills = {id: bills.id, sgfh_qty: 0, sjcl_qty: 0, qtcl_qty: 0, quantity: 0, ex_qty1: 0};
             for (const bp of billsPos) {
                 if (data.indexOf(bp.id) >= 0) continue;
                 updateBills.sgfh_qty = this.ctx.helper.add(updateBills.sgfh_qty, bp.sgfh_qty);
                 updateBills.sjcl_qty = this.ctx.helper.add(updateBills.sjcl_qty, bp.sjcl_qty);
                 updateBills.qtcl_qty = this.ctx.helper.add(updateBills.qtcl_qty, bp.qtcl_qty);
                 updateBills.quantity = this.ctx.helper.add(updateBills.quantity, bp.quantity);
+                updateBills.ex_qty1 = this.ctx.helper.add(updateBills.ex_qty1, bp.ex_qty1);
             }
             const info = this.ctx.tender.info;
             updateBills.sgfh_tp = this.ctx.helper.mul(updateBills.sgfh_qty, bills.unit_price, info.decimal.tp);
             updateBills.sjcl_tp = this.ctx.helper.mul(updateBills.sjcl_qty, bills.unit_price, info.decimal.tp);
             updateBills.qtcl_tp = this.ctx.helper.mul(updateBills.qtcl_qty, bills.unit_price, info.decimal.tp);
             updateBills.total_price = this.ctx.helper.mul(updateBills.quantity, bills.unit_price, info.decimal.tp);
+            updateBills.ex_tp1 = this.ctx.helper.mul(updateBills.ex_qty1, bills.unit_price, info.decimal.tp);
 
             const transaction = await this.db.beginTransaction();
             try {
@@ -438,6 +462,7 @@ module.exports = app => {
                 updateBills.sjcl_qty = this.ctx.helper.add(updateBills.sjcl_qty, bp.sjcl_qty);
                 updateBills.qtcl_qty = this.ctx.helper.add(updateBills.qtcl_qty, bp.qtcl_qty);
                 updateBills.quantity = this.ctx.helper.add(updateBills.quantity, bp.quantity);
+                updateBills.ex_qty1 = this.ctx.helper.add(updateBills.ex_qty1, bp.ex_qty1);
             }
 
             try {
@@ -464,6 +489,12 @@ module.exports = app => {
                     updateBills.qtcl_qty = this.ctx.helper.add(updateBills.qtcl_qty, d.qtcl_qty);
                     d.quantity = this.ctx.helper.sum([d.sgfh_qty, d.qtcl_qty, d.sjcl_qty]);
                     updateBills.quantity = this.ctx.helper.add(updateBills.quantity, d.quantity);
+                    if (d.ex_qty1) {
+                        d.ex_qty1 = this.round(d.ex_qty1, precision.value);
+                    } else if (op) {
+                        d.ex_qty1 = op.ex_qty1;
+                    }
+                    updateBills.ex_qty1 = this.ctx.helper.add(updateBills.ex_qty1, d.ex_qty1);
 
                     if (d.id) {
                         await transaction.update(this.tableName, d);
@@ -478,6 +509,7 @@ module.exports = app => {
                 updateBills.sjcl_tp = this.ctx.helper.mul(updateBills.sjcl_qty, bills.unit_price, info.decimal.tp);
                 updateBills.qtcl_tp = this.ctx.helper.mul(updateBills.qtcl_qty, bills.unit_price, info.decimal.tp);
                 updateBills.total_price = this.ctx.helper.mul(updateBills.quantity, bills.unit_price, info.decimal.tp);
+                updateBills.ex_tp1 = this.ctx.helper.mul(updateBills.ex_qty1, bills.unit_price, info.decimal.tp);
                 await transaction.update(this.ctx.service.ledger.tableName, updateBills);
                 updateBills.ledger_id = bills.ledger_id;
                 await transaction.commit();