MaiXinRong 2 месяцев назад
Родитель
Сommit
b3c79ac282
3 измененных файлов с 38 добавлено и 2 удалено
  1. 24 2
      app/lib/ybp.js
  2. 6 0
      app/public/js/cost_stage_book.js
  3. 8 0
      app/public/js/cost_stage_ledger.js

+ 24 - 2
app/lib/ybp.js

@@ -34,6 +34,19 @@ const Decrypt = function(str) {
 
 class ybp {
     parseSubject(str) {
+        let billsParts = [];
+        if (str.indexOf(billsSpr) >= 0) {
+            const parts = str.split(billsSpr);
+            str = parts[0];
+            billsParts = parts.slice(1);
+        }
+        let qtyCalcParts = [];
+        if (str.indexOf(qtyCalcSpr) >= 0) {
+            const parts = str.split(qtyCalcSpr);
+            str = parts[0];
+            qtyCalcParts = parts.slice(1);
+        }
+        let result;
         if (str.indexOf(rationSpr) >= 0) {
             const arr = str.split(rationSpr);
             const subject = JSON.parse(LzString.decompressFromBase64(arr[0]));
@@ -41,10 +54,19 @@ class ybp {
                 const ration = JSON.parse(LzString.decompressFromBase64(arr[i]));
                 subject.rations.push(...ration);
             }
-            return subject;
+            result = subject;
         } else {
-            return JSON.parse(LzString.decompressFromBase64(str));
+            result = JSON.parse(LzString.decompressFromBase64(str));
         }
+        if (billsParts.length > 0) {
+            if (!result.bills) result.bills = [];
+            for (const part of billsParts) {
+                const bills = JSON.parse(LzString.decompressFromBase64(part));
+                result.bills.push(...bills);
+            }
+        }
+        // todo 暂不考虑算量数据
+        return result;
     }
     decryptBuffer(buffer) {
         const arr = buffer.split(ybpSpr);

+ 6 - 0
app/public/js/cost_stage_book.js

@@ -18,6 +18,12 @@ $(document).ready(function() {
                 rootId: -1,
                 calcFields: ['yf_tp', 'sf_tp', 'end_yf_tp', 'end_sf_tp', 'in_tp', 'in_excl_tax_tp', 'end_in_tp', 'end_in_excl_tax_tp'],
                 keys: ['id', 'stage_id', 'tree_id'],
+                calcFun: function(node) {
+                    node.end_yf_tp = ZhCalc.div(node.yf_tp, node.pre_yf_tp);
+                    node.end_sf_tp = ZhCalc.div(node.sf_tp, node.pre_sf_tp);
+                    node.end_in_tp = ZhCalc.div(node.in_tp, node.pre_in_tp);
+                    node.end_in_excl_tax_tp = ZhCalc.div(node.in_excl_tax_tp, node.pre_in_excl_tax_tp);
+                },
             };
             this.tree = createNewPathTree('ledger', this.treeSetting);
             this.spreadSetting = {

+ 8 - 0
app/public/js/cost_stage_ledger.js

@@ -18,6 +18,14 @@ $(document).ready(function() {
                 rootId: -1,
                 calcFields: ['yf_tp', 'sf_tp', 'pay_tp', 'cut_tp', 'yf_excl_tax_tp', 'sf_excl_tax_tp', 'end_yf_tp', 'end_sf_tp', 'end_pay_tp', 'end_cut_tp', 'end_yf_excl_tax_tp', 'end_sf_excl_tax_tp'],
                 keys: ['id', 'stage_id', 'tree_id'],
+                calcFun: function(node) {
+                    node.end_yf_tp = ZhCalc.div(node.yf_tp, node.pre_yf_tp);
+                    node.end_yf_excl_tax_tp = ZhCalc.div(node.yf_excl_tax_tp, node.pre_yf_excl_tax_tp);
+                    node.end_sf_tp = ZhCalc.div(node.sf_tp, node.pre_sf_tp);
+                    node.end_sf_excl_tax_tp = ZhCalc.div(node.sf_excl_tax_tp, node.pre_sf_excl_tax_tp);
+                    node.end_pay_tp = ZhCalc.div(node.pay_tp, node.pre_pay_tp);
+                    node.end_cut_tp = ZhCalc.div(node.cut_tp, node.pre_cut_tp);
+                },
             };
             this.tree = createNewPathTree('ledger', this.treeSetting);
             this.spreadSetting = {