Browse Source

变更令、变更方案、变更申请,同步档案系统

MaiXinRong 1 year ago
parent
commit
412bf55cff

+ 1 - 2
app/controller/report_archive_controller.js

@@ -106,9 +106,8 @@ module.exports = app => {
                 const groupList = accountList.filter(item => item.account_group === idx);
                 return { groupName: item, groupList };
             });
-            const needFileMsg = await this.ctx.service.specMsg.tenderNeedMsg(this.ctx.session.sessionProject.id, this.ctx.tender.id, pushOperate.report.file);
+            const needFileMsg = await this.ctx.service.specMsg.reportNeedMsg(this.ctx.session.sessionProject.id, this.ctx.tender.id);
 
-            //
             const renderData = {
                 tender: tender.data,
                 rpt_tpl_data: JSON.stringify(treeNodes),

+ 1 - 1
app/router.js

@@ -499,7 +499,7 @@ module.exports = app => {
     app.post('/tender/report_api/removeArchiveEncryption', sessionAuth, 'reportArchiveController.removeReportArchiveEncryption');
     app.post('/tender/:id/sendReportFileMsg', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportArchiveController.sendFileMsg');
     app.post('/tender/:id/measure/stage/:order/sendReportFileMsg', sessionAuth, tenderCheck, uncheckTenderCheck, stageCheck, 'reportArchiveController.sendFileMsg');
-    app.post('/tender/:id/sendReportFileMsg', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportArchiveController.sendOtherFileMsg');
+    app.post('/tender/:id/sendOtherReportFileMsg', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportArchiveController.sendOtherFileMsg');
 
     // 电子签名
     app.get('/tender/:id/signReport', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportArchiveController.signReport');

+ 9 - 0
app/service/spec_msg.js

@@ -42,6 +42,15 @@ module.exports = app => {
             return !!specPush;
         }
 
+        async reportNeedMsg(pid, tid) {
+            const reportMsg = {};
+            reportMsg.stage = { valid: await this.tenderNeedMsg(pid, tid, pushOperate.report.file), key: pushOperate.report.file};
+            reportMsg.change = { valid: await this.tenderNeedMsg(pid, tid, pushOperate.report.change_file), key: pushOperate.report.change_file };
+            reportMsg.change_plan = { valid: await this.tenderNeedMsg(pid, tid, pushOperate.report.change_plan_file), key: pushOperate.report.change_plan_file };
+            reportMsg.change_apply = { valid: await this.tenderNeedMsg(pid, tid, pushOperate.report.change_apply_file), key: pushOperate.report.change_apply_file };
+            return reportMsg;
+        }
+
         async addLedgerMsg(transaction, pid, tender, timing) {
             const needMsg = await this.tenderNeedMsg(pid, tender.id, timing);
             if (!needMsg) return;

+ 36 - 0
app/view/report/archive_popup.ejs

@@ -14,3 +14,39 @@
         </div>
     </div>
   </div>
+  <!--弹出选择变更令的页面-->
+  <div class="modal fade" id="change-select" data-backdrop="static">
+      <div class="modal-dialog modal-lg" role="document">
+          <div class="modal-content">
+              <div class="modal-header">
+                  <h5 class="modal-title">选择推送数据</h5>
+              </div>
+              <div class="modal-body pb-1">
+                  <div class="d-inline-flex">
+                      <h6 class="mr-2 mt-1">当前时间之后:</h6>
+                      <div class="mx-2 mb-2">
+                          <div class="input-group input-group-sm">
+                              <input id="change-select-date" class="datepicker-here form-control form-control-sm" placeholder="点击选择筛选时间" data-date-format="yyyy-MM-dd" data-language="zh" type="text">
+                          </div>
+                      </div>
+                  </div>
+                  <div class="scroll-y" style="height: 400px;">
+                      <table class="table table-bordered mb-1" >
+                          <thead>
+                          <tr><th width="40px">选择</th><th>编号</th><th>名称</th><th width="150px">创建时间</th></tr>
+                          </thead>
+                          <tbody id="change-select-list">
+                          </tbody>
+                      </table>
+                  </div>
+                  <div class="d-flex justify-content-between  align-items-center">
+                      <div class="text-danger"><span>最多选择10条数据</span></div>
+                  </div>
+              </div>
+              <div class="modal-footer">
+                  <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
+                  <button class="btn btn-sm btn-primary" id="change-select-ok">确定</button>
+              </div>
+          </div>
+      </div>
+  </div>

+ 74 - 5
app/view/report/index_archive.ejs

@@ -38,9 +38,9 @@
                         <div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="optionSelectableChanges"></div>
                     </div>
                 </div>
-                <% if (ctx.session.sessionUser.accountId === ctx.tender.data.user_id && needFileMsg) { %>
+                <% if (ctx.session.sessionUser.accountId === ctx.tender.data.user_id) { %>
                 <div class="d-inline-block">
-                    <button class="btn btn-sm btn-primary" type="button" onclick="sendReportFileMsg();">同步档案系统</button>
+                    <button id="file-msg" class="btn btn-sm btn-primary" type="button" onclick="sendReportFileMsg();" <% if (!needFileMsg.stage.valid) { %>style="display: none;"<% } %>>同步档案系统</button>
                 </div>
                 <% } %>
             </div>
@@ -171,12 +171,16 @@
 <script type="text/javascript" src="/public/report/js/rpt_main.js"></script>
 <script type="text/javascript" src="/public/report/js/rpt_cfg_const.js"></script>
 
+<script type="text/javascript" src="/public/js/datepicker/datepicker.min.js"></script>
+<script type="text/javascript" src="/public/js/datepicker/datepicker.zh.js"></script>
+
 <!--
 <script type="text/javascript" src="/public/report/js/rpt_custom.js"></script>
 -->
 
 
 <script type="text/javascript">
+    const needFileMsg = JSON.parse('<%- JSON.stringify(needFileMsg) %>');
     let current_stage_order = -1;
     let current_stage_id = -1;
     let current_stage_status = -1;
@@ -390,10 +394,54 @@
 
 
     function sendReportFileMsg() {
-        postData('sendReportFileMsg', { sid: current_stage_id, sorder: current_stage_order }, function (result, msg) {
+        if (!needFileMsg[business_type] || !needFileMsg[business_type].valid) return;
+
+        if (business_type === 'stage') {
+            postData('sendReportFileMsg', { sid: current_stage_id, sorder: current_stage_order }, function (result, msg) {
+                toastr.success(msg);
+            });
+        } else {
+            if (CHANGE_LIST.length === 0) {
+                toastr.warning('暂无任何归档数据');
+                return;
+            }
+            loadChangeSelect(CHANGE_LIST);
+            $('#change-select').modal('show');
+        }
+    }
+
+    function loadChangeSelect(changes) {
+        const html = [];
+        for (const c of changes) {
+            html.push('<tr>');
+            html.push(`<td><input cid="${c.cid || c.id}" type="checkbox" ${(c.selected ? "checked" : '')}></td>`);
+            html.push(`<td>${c.code}</td>`);
+            html.push(`<td>${c.name}</td>`);
+            html.push(`<td>${moment(c.in_time).format('YYYY-MM-DD')}</td>`);
+            html.push('</tr>');
+        }
+        $('#change-select-list').html(html.join(''));
+    }
+
+    $('body').on('change', '#change-select input[type=checkbox]', function() {
+        if ($('#change-select input:checked').length > 10) {
+            this.checked = false;
+            toastr.warning('最多选择10条数据');
+        }
+    });
+    $('body').on('click', '#change-select-ok', function() {
+        if (!needFileMsg[business_type]) return;
+
+        const select = $('#change-select input:checked');
+        const id = [];
+        for (const s of select) {
+            id.push(s.getAttribute('cid'));
+        }
+        postData('sendOtherReportFileMsg', { id, msgType: needFileMsg[business_type].key }, function (result, msg) {
             toastr.success(msg);
+            $('change-select').modal('hide');
         });
-    }
+    });
 
     $(function () {
         //阻止事件冒泡
@@ -479,11 +527,32 @@
                    }
                );
            }
-
+           if (needFileMsg[type] && needFileMsg[type].valid) {
+               $('#file-msg').show();
+           } else {
+               $('#file-msg').hide();
+           }
         });
     })
 
     rptArchiveObj.iniPage();
 
+    $(document).ready(() => {
+        $('#change-select-date').datepicker({
+            onSelect: function(selectedDate) {
+                const rows = $('#change-select-list tr');
+                for (const r of rows) {
+                    const cid = $(r).find('input').attr('cid');
+                    const change = CHANGE_LIST.find(x => { return x.cid ? x.cid === cid : c.id === cid; });
+                    if (moment(selectedDate).isBefore(change.in_time)) {
+                        $(r).show();
+                    } else {
+                        $(r).hide();
+                    }
+                }
+            }
+        });
+    });
+
 </script>