瀏覽代碼

refactor: 预付款功能回滚到比例动态计算

lanjianrong 4 年之前
父節點
當前提交
cb6a321014

+ 5 - 0
app/public/js/advance.js

@@ -9,6 +9,11 @@
  */
 
 $(document).ready(function () {
+
+    if (!advancePayTotal) {
+        $('#erro').modal('show');
+    }
+
     $('#advance_add').click(function() {
         postData(`${window.location.pathname}/${type}/create`, {}, res => {
             const html = `<tr>

+ 11 - 9
app/public/js/advance_audit.js

@@ -10,22 +10,22 @@
 
 $(document).ready(function () {
     autoFlashHeight()
-    if (!advancePayTotal) {
-        $('#sub-ts').modal('show');
-    }
+
     let oldVal = null
     let timer = null
     let oldSearchVal = null
     handleFileList(fileList)
+
     // 控制上报弹窗的文案
     function checkModal(isHide) {
+        console.log($('#start-modal'))
+        $('#start-modal').empty()
         if (isHide) {
-            $('#tm-fail').show()
-            $('#tm-success').hide()
+            // 隐藏上传按钮
+            $('#start-modal').append('<p class="text-danger">无法上报,请设置审批流程。</p>')
             $('#tm-submit').hide()
         } else {
-            $('#tm-fail').hide()
-            $('#tm-success').show()
+            $('#start-modal').append(`<p>确认上报第${advance.order}期${advance.type === 0 ? '开工' : '材料'}预付款?</p>`)
             $('#tm-submit').show()
         }
     }
@@ -144,6 +144,8 @@ $(document).ready(function () {
             case '#sub-sp':
                 if ($('#auditors')[0].children.length) {
                     checkModal(false)
+                } else {
+                    checkModal(true)
                 }
                 break;
             default:
@@ -209,7 +211,7 @@ $(document).ready(function () {
             cur_amount = val
             pay_a_input.val(pay_ratio)
             // 截止本期金额文案更新
-            $('#p_total2').text(formatMoney(ZhCalc.add(val, p_amount), ',', decimal))
+            $('#p_total2').text(formatMoney(ZhCalc.add(val, p_amount), ',', decimal) + '元')
         } else {
             if (val.toFixed(1) === max.toFixed(1)) {
                 val = max
@@ -221,7 +223,7 @@ $(document).ready(function () {
             pay_ratio = val
             cur_m_input.val(cur_amount.toFixed(decimal))
             // 截止本期金额文案更新
-            $('#p_total2').text(formatMoney(ZhCalc.add(cur_amount, p_amount), ',', decimal))
+            $('#p_total2').text(formatMoney(ZhCalc.add(cur_amount, p_amount), ',', decimal) + '元')
         }
         const data = {
             pay_ratio,

+ 5 - 18
app/view/advance/detail.ejs

@@ -28,39 +28,26 @@
                             </tr>
                         </thead>
                         <tbody id="pay-content">
-                            <% if(isEdited && ctx.session.sessionUser.accountId === ctx.advance.uid) { %>
                             <tr>
                                 <th width="150" class="text-center">支付比例</th>
                                 <td class="text-right" width="405">
                                     <div class="input-group input-group-sm">
                                         <input type="number" class="pay-input form-control nospin text-right"
-                                            max="<%- max_pr %>" min="1" step="0.01" placeholder="请填写支付比例,将自动计算本期金额" data-type="0"
-                                            value="<%- advance.status === auditConst.status.uncheck || advance.status === auditConst.status.checkNo ? advance.pay_ratio : (advance.cur_amount && ctx.helper.mul(ctx.helper.div(advance.cur_amount, advancePayTotal), 100, 2) || 0) %>">
+                                            max="<%- max_pr %>" min="1" step="0.01" placeholder="请填写支付比例,将自动计算本期金额" data-type="0" <%- isEdited && ctx.session.sessionUser.accountId === ctx.advance.uid ? '' : 'disabled' %>
+                                            value="<%- advance.cur_amount && ctx.helper.mul(ctx.helper.div(advance.cur_amount, advancePayTotal), 100, 2) || 0 %>">
                                         <div class="input-group-append"><span class="input-group-text">%</span></div>
                                     </div>
                                 </td>
                                 <th width="150" class="text-center">本期金额</th>
                                 <td class="text-right" width="405">
                                     <div class="input-group input-group-sm">
-                                        <input type="number" class="pay-input form-control nospin text-right" min="1"
+                                        <input type="number" class="pay-input form-control nospin text-right" min="1" <%- isEdited && ctx.session.sessionUser.accountId === ctx.advance.uid ? '' : 'disabled' %>
                                             placeholder="请填写本期金额,将自动计算支付比例" data-type="1"
-                                            value="<%- advance.status === auditConst.status.uncheck || advance.status === auditConst.status.checkNo ? ctx.helper.mul(advancePayTotal, ctx.helper.div(advance.pay_ratio, 100)).toFixed(decimal) : (advance.cur_amount && advance.cur_amount.toFixed(decimal)) %>">
+                                            value="<%- advance.cur_amount && advance.cur_amount.toFixed(decimal) %>">
                                         <div class="input-group-append"><span class="input-group-text">元</span></div>
                                     </div>
                                 </td>
                             </tr>
-                            <% } else {%>
-                            <tr>
-                                <th width="150" class="text-center">支付比例</th>
-                                <td class="text-right" width="405">
-                                    <%- advance.cur_amount && ctx.helper.mul(ctx.helper.div(advance.cur_amount, advancePayTotal), 100, 2) || 0 %>%
-                                </td>
-                                <th width="150" class="text-center">本期金额</th>
-                                <td class="text-right" width="405">
-                                    <%- ctx.helper.formatMoney((advance.cur_amount || 0), ',', decimal) %>
-                                </td>
-                            </tr>
-                            <% } %>
                             <tr>
                                 <th class="text-center">截止上期</th>
                                 <td class="text-right" id="p_total1" width="405">
@@ -68,7 +55,7 @@
                                 </td>
                                 <th class="text-center">截止本期金额</th>
                                 <td class="text-right" id="p_total2" width="405">
-                                    <%- ctx.helper.formatMoney(advance.status === auditConst.status.uncheck || advance.status === auditConst.status.checkNo ? ctx.helper.add(ctx.helper.mul(advancePayTotal, ctx.helper.div(advance.pay_ratio, 100, decimal), decimal), (prevAdvance && prevAdvance.prev_total_amount || 0)) : (prevAdvance && prevAdvance.prev_total_amount + advance.cur_amount || (advance.cur_amount || 0)), ',', decimal) %>元
+                                    <%- ctx.helper.formatMoney((prevAdvance && prevAdvance.prev_total_amount + advance.cur_amount || (advance.cur_amount || 0)), ',', decimal) %>元
                                 </td>
                             </tr>
                             <tr>

+ 4 - 12
app/view/advance/index.ejs

@@ -59,19 +59,10 @@
                         <% advanceList.forEach(item => { %>
                             <tr>
                                 <td><a href="/tender/<%- ctx.tender.id %>/advance/<%- item.id %>/detail" data-id="<%- item.id %>">第<%- item.order %>期</a></td>
-                                <% if (item.status === auditConst.status.uncheck || item.status === auditConst.status.checkNo) { %>
-                                    <td><%- item.pay_ratio || 0%>%</td>
-                                    <td class="text-right"><%- ctx.helper.mul(advancePayTotal, ctx.helper.div(item.pay_ratio, 100, decimal), decimal) %></td>
-                                <% } else {%>
-                                    <td><%- item.cur_amount && ctx.helper.mul(ctx.helper.div(item.cur_amount, advancePayTotal), 100).toFixed(2) || 0 %>%</td>
-                                    <td class="text-right"><%- ctx.helper.formatMoney(item.cur_amount, ',', decimal)%></td>
-                                <% } %>
+                                <td><%- item.cur_amount && ctx.helper.mul(ctx.helper.div(item.cur_amount, advancePayTotal), 100).toFixed(2) || 0 %>%</td>
+                                <td class="text-right"><%- ctx.helper.formatMoney(item.cur_amount, ',', decimal)%></td>
                                 <td class="text-right"><%- ctx.helper.formatMoney(item.prev_amount, ',', decimal)%></td>
-                                <% if (item.status === auditConst.status.uncheck || item.status === auditConst.status.checkNo) { %>
-                                    <td class="text-right"><%- ctx.helper.formatMoney(ctx.helper.add(ctx.helper.mul(advancePayTotal, ctx.helper.div(item.pay_ratio, 100, decimal), decimal), item.prev_amount), ',', decimal)%></td>
-                                <% } else {%>
-                                    <td class="text-right"><%- ctx.helper.formatMoney(item.prev_total_amount, ',', decimal)%></td>
-                                <% } %>
+                                <td class="text-right"><%- ctx.helper.formatMoney(item.prev_total_amount, ',', decimal)%></td>
                                 <td><a class="btn btn-sm" href="#file" data-toggle="modal" data-target="#file" data-id="<%- item.id %>"><i
                                             class="fa fa-paperclip"></i> <%- item.fileList.length %></a></td>
                                 <td>
@@ -105,4 +96,5 @@
     const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
     const advanceList = JSON.parse('<%- JSON.stringify(advanceList) %>');
     const decimal = parseInt('<%- decimal %>');
+    const advancePayTotal  = parseFloat('<%- advancePayTotal  %>');
 </script>

+ 17 - 1
app/view/advance/modal.ejs

@@ -1,4 +1,20 @@
-
+<!--无总金额首次使用-->
+<div class="modal fade" id="erro" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">提示</h5>
+            </div>
+            <div class="modal-body">
+                <p>预付款金额未填写,无法使用「预付款」,请先填写预付款金额;</p>
+                <p>进入「标段概况」打开「合同参数」填写预付款金额。</p>
+            </div>
+            <div class="modal-footer">
+              <a href="/tender/<%- ctx.tender.id %>" class="btn btn-sm btn-primary">标段概况</a>
+            </div>
+        </div>
+    </div>
+</div>
 <!--附件-->
 <div class="modal fade" id="file" data-backdrop="static">
     <div class="modal-dialog" role="document">

+ 1 - 20
app/view/advance/modal_audit.ejs

@@ -1,19 +1,3 @@
-<!-- 初始化 预付款为0的时候提醒 -->
-<div class="modal fade" id="sub-ts" data-backdrop="static">
-    <div class="modal-dialog" role="document">
-        <div class="modal-content">
-            <div class="modal-header">
-                <h5 class="modal-title">温馨提示</h5>
-            </div>
-            <div class="modal-body">
-                <h5 id="tm-fail" class="text-danger">签约<%- advance.type === 0 ? '开工' : '材料' %>预付款为0元,请在“标段概况-合同参数”输入签约<%- advance.type === 0 ? '开工' : '材料' %>预付款金额。</h5>
-            </div>
-            <div class="modal-footer">
-                <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
-            </div>
-        </div>
-    </div>
-</div>
 <!--上报审批-->
 <div class="modal fade" id="sub-sp" data-backdrop="static">
     <div class="modal-dialog" role="document">
@@ -21,10 +5,7 @@
             <div class="modal-header">
                 <h5 class="modal-title">上报审批</h5>
             </div>
-            <div class="modal-body">
-                <h5 id="tm-success" style="display: none;">
-                    确认上报第<%- advance.order %>期<%- advance.type === 0 ? '开工' : '材料' %>预付款?</h5>
-                <h5 id="tm-fail" class="text-danger">无法上报,请设置审批流程。</h5>
+            <div class="modal-body" id="start-modal">
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>