Browse Source

合同支付,允许不关联期&关联多期

MaiXinRong 5 days ago
parent
commit
0db90d960c

+ 1 - 3
app/controller/pay_controller.js

@@ -64,14 +64,12 @@ module.exports = app => {
                 const date = ctx.request.body.date;
                 if (!date) throw '请选择支付年月';
                 const stage = ctx.request.body.stage;
-                if (!stage) throw '请选择计量期';
                 const memo = ctx.request.body.memo;
 
                 const pays = await ctx.service.phasePay.getAllPhasePay(ctx.tender.id, 'DESC');
                 const unCompleteCount = pays.filter(s => { return s.status !== audit.common.status.checked; }).length;
                 if (unCompleteCount.length > 0) throw `最新一起未审批通过,请审批通过后再新增`;
-                // 预留可以关联多期
-                const stages = await ctx.service.stage.getAllDataByCondition({ where: { tid: ctx.tender.id, order: stage } });
+                const stages = stage ? await ctx.service.stage.getAllDataByCondition({ where: { tid: ctx.tender.id, order: stage } }) : [];
 
                 const newPhase = await ctx.service.phasePay.add(ctx.tender.id, stages, date, memo);
                 if (!newPhase) throw '新增期失败';

+ 7 - 0
app/public/js/phase_pay_list.js

@@ -153,4 +153,11 @@ $(document).ready(() => {
             autoFlashHeight();
         }
     });
+
+    $('select[name=stage]').select2({
+        language: 'zh-CN',
+        width: '100%',
+        multiple: true,
+        maximumSelectionlength: 6,
+    });
 });

+ 3 - 1
app/view/phase_pay/index.ejs

@@ -6,7 +6,7 @@
             <h2>
                 合同支付列表
             </h2>
-            <% if (ctx.session.sessionUser.accountId === ctx.tender.data.user_id && (phasePays.length === 0 || phasePays[0].audit_status === auditConst.status.checked) && validStages.length > 0) { %>
+            <% if (ctx.session.sessionUser.accountId === ctx.tender.data.user_id && (phasePays.length === 0 || phasePays[0].audit_status === auditConst.status.checked)) { %>
             <div class="ml-auto">
                 <a href="#add-qi" data-toggle="modal" data-target="#add-qi" class="btn btn-primary btn-sm">开始新一期</a>
             </div>
@@ -88,6 +88,8 @@
         </div>
     </div>
 </div>
+<link href="/public/css/bootstrap/select2.min.css" rel="stylesheet" />
+<script src="/public/js/bootstrap/select2.min.js"></script>
 <script>
     const phasePays = JSON.parse('<%- JSON.stringify(phasePays) %>');
     const auditType = JSON.parse('<%- JSON.stringify(auditType) %>');

+ 1 - 6
app/view/phase_pay/modal.ejs

@@ -18,7 +18,7 @@
                     <label>计量期</label>
                     <select class="form-control form-control-sm" name="stage">
                         <% for (const s of validStages) { %>
-                            <option value="<%- s.order %>" <%- (s.order === validStages[0].order ? 'selected' : '') %>>第 <%- s.order %> 期</option>
+                            <option value="<%- s.order %>">第 <%- s.order %> 期</option>
                         <% } %>
                     </select>
                 </div>
@@ -98,11 +98,6 @@
             toastr.error('请选择计量年月');
             return false;
         }
-
-        if ($('[name=stage]', '#add-qi').val() == '') {
-            toastr.error('请选择计量期');
-            return false;
-        }
     }
     const checkEditValid = function() {
         if ($('[name=date]', '#edit-qi').val() == '') {