Преглед изворни кода

合同管理增加金额提示

ellisran пре 8 месеци
родитељ
комит
20958c5147
2 измењених фајлова са 47 додато и 2 уклоњено
  1. 45 0
      app/public/js/contract_detail.js
  2. 2 2
      app/view/contract/detail_modal.ejs

+ 45 - 0
app/public/js/contract_detail.js

@@ -1308,6 +1308,8 @@ $(document).ready(function() {
         $('#cons-addpay input[name="sf_price"]').val(cpInfo ? cpInfo.sf_price : '');
         $('#cons-addpay select[name="pay_type"]').val(cpInfo ? cpInfo.pay_type : $('#cons-addpay select[name="pay_type"] option:first').text());
         $('#cons-addpay textarea[name="remark"]').val(cpInfo ? cpInfo.remark : '');
+        $('#cons-addpay .yf-tips').text('');
+        $('#cons-addpay .sf-tips').text('');
 
     }
 
@@ -1685,11 +1687,54 @@ $(document).ready(function() {
 
     $('#cons-addpay input[type="number"]').change(function () {
         const name = $(this).attr('name');
+        const node = SpreadJsObj.getSelectObject(contractSheet);
+        if (!node || !node.c_code) {
+            toastr.error('请选择一个合同节点');
+            return;
+        }
+        if (node.uid !== user_id) {
+            toastr.error('只能修改自己的合同' + contractConst.typeName[contract_type]);
+            return;
+        }
+        if (node.settle_code) {
+            toastr.error('该合同已结算,不能修改');
+            return;
+        }
         if (name === 'pay_price' || name === 'debit_price') {
             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);
             $('#cons-addpay input[name="yf_price"]').val(yf_price);
+            $('#cons-addpay .yf-tips').text('');
+            if (parseFloat(yf_price) > ZhCalc.sub(node.total_price, node.yf_price)) {
+                $('#cons-addpay .yf-tips').text(' ≤ ' + ZhCalc.sub(node.total_price, node.yf_price));
+            } else {
+                $('#cons-addpay .yf-tips').text('');
+            }
+        }
+        if (name === 'sf_price') {
+            const 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);
+            const cpid = $('#cons-addpay input[name="cpid"]').val();
+            if (cpid) {
+                const cpInfo = _.find(contractPays, { id: parseInt(cpid) });
+                const newNodePayPrice = ZhCalc.add(ZhCalc.sub(node.pay_price, cpInfo.pay_price), parseFloat(pay_price));
+                const newNodeDebitPrice = ZhCalc.add(ZhCalc.sub(node.debit_price, cpInfo.debit_price), parseFloat(debit_price));
+                const newNodeYfPrice = ZhCalc.sub(newNodePayPrice, newNodeDebitPrice);
+                if (parseFloat(sf_price) > ZhCalc.sub(newNodeYfPrice, node.sf_price)) {
+                    $('#cons-addpay .sf-tips').text(' ≤ ' + ZhCalc.sub(newNodeYfPrice, node.sf_price));
+                } else {
+                    $('#cons-addpay .sf-tips').text('');
+                }
+            } else {
+                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 {
+                    $('#cons-addpay .sf-tips').text('');
+                }
+            }
         }
     });
 

+ 2 - 2
app/view/contract/detail_modal.ejs

@@ -159,11 +159,11 @@
                     <input class="form-control form-control-sm" name="debit_price" placeholder="请输入扣款金额" type="number">
                 </div>
                 <div class="form-group">
-                        <label>应<% if (ctx.contract_type === contractConst.type.expenses) { %>付<% } else if (ctx.contract_type === contractConst.type.income) { %>回<% } %>金额</label>
+                        <label>应<% if (ctx.contract_type === contractConst.type.expenses) { %>付<% } else if (ctx.contract_type === contractConst.type.income) { %>回<% } %>金额<span class="text-danger yf-tips"></span></label>
                     <input class="form-control form-control-sm" name="yf_price" placeholder="<% if (ctx.contract_type === contractConst.type.expenses) { %>付<% } else if (ctx.contract_type === contractConst.type.income) { %>回<% } %>款-扣款" type="number" readonly>
                 </div>
                 <div class="form-group">
-                    <label>实<% if (ctx.contract_type === contractConst.type.expenses) { %>付<% } else if (ctx.contract_type === contractConst.type.income) { %>回<% } %>金额</label>
+                    <label>实<% if (ctx.contract_type === contractConst.type.expenses) { %>付<% } else if (ctx.contract_type === contractConst.type.income) { %>回<% } %>金额<span class="text-danger sf-tips"></span></label>
                     <input class="form-control form-control-sm" name="sf_price" placeholder="请输入实<% if (ctx.contract_type === contractConst.type.expenses) { %>付<% } else if (ctx.contract_type === contractConst.type.income) { %>回<% } %>金额" type="number">
                 </div>
                 <div class="form-group">