Pārlūkot izejas kodu

修复合同管理bug

ellisran 9 mēneši atpakaļ
vecāks
revīzija
51e03556e5
1 mainītis faili ar 17 papildinājumiem un 1 dzēšanām
  1. 17 1
      app/public/js/contract_detail.js

+ 17 - 1
app/public/js/contract_detail.js

@@ -451,6 +451,17 @@ $(document).ready(function() {
                 $('#add-cons-btn').hide();
             }
         },
+        cleanData: function (result) {
+            if (result && result.update && result.update.length > 0) {
+                for (const r of result.update) {
+                    if (!r.c_code) {
+                        r.total_price = null;
+                        r.yf_price = null;
+                    }
+                }
+            }
+            return result;
+        },
         /**
          * 新增节点
          * @param spread
@@ -523,6 +534,7 @@ $(document).ready(function() {
                         count: type === 'add' ? addCount : count,
                     }
                 }, function (result) {
+                    self.cleanData(result);
                     const refreshData = tree.loadPostData(result);
                     self.refreshTree(sheet, refreshData);
                     if (['up-move', 'down-move'].indexOf(type) > -1) {
@@ -1744,7 +1756,7 @@ $(document).ready(function() {
             toastr.error('该合同已结算,不能修改');
             return;
         }
-        const sf_price = $('#cons-addpay input[name="sf_price"]').val() || 0;
+        let sf_price = $('#cons-addpay input[name="sf_price"]').val() || 0;
         const pay_price = $('#cons-addpay input[name="pay_price"]').val() || 0;
         const debit_price = $('#cons-addpay input[name="debit_price"]').val() || 0;
         const yf_price = ZhCalc.sub(pay_price, debit_price);
@@ -1766,6 +1778,10 @@ $(document).ready(function() {
                 $('#cons-addpay .yf-tips').text('');
             }
         } else {
+            if (name !== 'sf_price') {
+                $('#cons-addpay input[name="sf_price"]').val(yf_price);
+                sf_price = yf_price;
+            }
             if (parseFloat(sf_price) > ZhCalc.sub(ZhCalc.add(node.yf_price, yf_price), node.sf_price)) {
                 $('#cons-addpay .sf-tips').text(' ≤ ' + ZhCalc.sub(ZhCalc.add(node.yf_price, yf_price), node.sf_price));
             } else {