Browse Source

报表归档,同步档案系统

MaiXinRong 2 years ago
parent
commit
88c9199213

+ 1 - 0
app/const/spec_3f.js

@@ -13,6 +13,7 @@ const pushTiming = [
     { value:'stage.checked', name: '期-审批通过' },
     { value:'stage.checked', name: '期-审批通过' },
     { value:'stage.flow', name: '期-上报/审批' },
     { value:'stage.flow', name: '期-上报/审批' },
     { value:'revise.checked', name: '台账修订-审批通过' },
     { value:'revise.checked', name: '台账修订-审批通过' },
+    { value:'report.file', name: '报表-推送归档' },
 ];
 ];
 
 
 const pushOperate = (function () {
 const pushOperate = (function () {

+ 1 - 0
app/const/tender_info.js

@@ -172,6 +172,7 @@ const defaultInfo = {
         same_code: true,
         same_code: true,
         sibling: true,
         sibling: true,
         over: true,
         over: true,
+        banMinusChangeBills: false,
     },
     },
     fun_rela: {
     fun_rela: {
         hintOver: true,
         hintOver: true,

+ 24 - 0
app/controller/report_archive_controller.js

@@ -16,6 +16,7 @@ const signConst = require('../const/sign');
 const shenpiConst = require('../const/shenpi');
 const shenpiConst = require('../const/shenpi');
 const accountGroup = require('../const/account_group').group;
 const accountGroup = require('../const/account_group').group;
 const sendToWormhole = require('stream-wormhole');
 const sendToWormhole = require('stream-wormhole');
+const pushOperate = require('../const/spec_3f').pushOperate;
 
 
 module.exports = app => {
 module.exports = app => {
     class ReportArchiveController extends app.BaseController {
     class ReportArchiveController extends app.BaseController {
@@ -116,6 +117,7 @@ module.exports = app => {
                 const groupList = accountList.filter(item => item.account_group === idx);
                 const groupList = accountList.filter(item => item.account_group === idx);
                 return { groupName: item, groupList };
                 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 renderData = {
             const renderData = {
@@ -144,6 +146,7 @@ module.exports = app => {
                 accountGroup: newAccountGroup,
                 accountGroup: newAccountGroup,
                 accountList,
                 accountList,
                 isAdmin,
                 isAdmin,
+                needFileMsg,
             };
             };
             if (stage_id === -1) {
             if (stage_id === -1) {
                 await this.layout('report/index_archive.ejs', renderData, 'report/archive_popup.ejs');
                 await this.layout('report/index_archive.ejs', renderData, 'report/archive_popup.ejs');
@@ -787,6 +790,27 @@ module.exports = app => {
             }
             }
             return response;
             return response;
         }
         }
+
+        async sendFileMsg(ctx) {
+            try {
+                if (this.ctx.session.sessionUser.accountId !== ctx.tender.data.user_id) throw '您无权操作';
+
+                const needFileMsg = await this.ctx.service.specMsg.tenderNeedMsg(this.ctx.session.sessionProject.id, this.ctx.tender.id, pushOperate.report.file);
+                if (!needFileMsg) throw '该标段暂不可进行该操作';
+
+                const waitingMsg = await this.ctx.service.specMsg.getDataByCondition({ tid: this.ctx.tender.id, timing: pushOperate.report.file, status: [0, 1] });
+                if (waitingMsg) throw '上一次归档完成,未执行完毕,请稍后再试';
+
+                const data = JSON.parse(ctx.request.body.data);
+                const stage = await this.ctx.service.stage.getDataById(data.sid);
+
+                await this.ctx.service.specMsg.addReportMsg(null, this.ctx.session.sessionProject.id, this.ctx.tender.data, stage, pushOperate.report.file);
+                ctx.body = { err: 0, msg: '提交成功,稍后将同步至档案系统', data: null };
+            } catch(err) {
+                this.ctx.log(err);
+                this.ctx.ajaxErrorBody(err, '操作失败');
+            }
+        }
     }
     }
     return ReportArchiveController;
     return ReportArchiveController;
 };
 };

+ 2 - 2
app/controller/stage_controller.js

@@ -196,7 +196,7 @@ module.exports = app => {
                 // 收方单附件删除权限
                 // 收方单附件删除权限
                 renderData.sfAttDelPower = ctx.session.sessionUser.accountId === ctx.stage.user_id || ctx.helper._.findIndex(ctx.stage.auditors2, { aid: ctx.session.sessionUser.accountId }) !== -1;
                 renderData.sfAttDelPower = ctx.session.sessionUser.accountId === ctx.stage.user_id || ctx.helper._.findIndex(ctx.stage.auditors2, { aid: ctx.session.sessionUser.accountId }) !== -1;
                 renderData.hintOver = projectFunInfo.hintOver && ctx.tender.info.fun_rela.hintOver;
                 renderData.hintOver = projectFunInfo.hintOver && ctx.tender.info.fun_rela.hintOver;
-                renderData.hintMinusCb = projectFunInfo.banMinusChangeBills;
+                renderData.hintMinusCb = projectFunInfo.banMinusChangeBills && ctx.tender.info.ledger_check.banMinusChangeBills;
                 renderData.categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
                 renderData.categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
                 await this.layout('stage/index.ejs', renderData, 'stage/modal.ejs');
                 await this.layout('stage/index.ejs', renderData, 'stage/modal.ejs');
             } catch (err) {
             } catch (err) {
@@ -422,7 +422,7 @@ module.exports = app => {
                     { qty: 'contract_qty', tp: 'contract_tp' }, { qty: 'qc_qty', tp: 'qc_tp' },
                     { qty: 'contract_qty', tp: 'contract_tp' }, { qty: 'qc_qty', tp: 'qc_tp' },
                 ], this.ctx.tender.info.decimal, x => { return x.is_tp; });
                 ], this.ctx.tender.info.decimal, x => { return x.is_tp; });
                 checkData.checkBillsQty(['contract_qty', 'qc_qty']);
                 checkData.checkBillsQty(['contract_qty', 'qc_qty']);
-                if (projRela.banMinusChangeBills) {
+                if (projRela.banMinusChangeBills && ctx.tender.info.ledger_check.banMinusChangeBills) {
                     const change = await this.ctx.service.change.getAllChangeHasMinus(ctx.tender.id);
                     const change = await this.ctx.service.change.getAllChangeHasMinus(ctx.tender.id);
                     if (change.length > 0) {
                     if (change.length > 0) {
                         const cid = change.map(x => { return x.cid; });
                         const cid = change.map(x => { return x.cid; });

+ 3 - 1
app/router.js

@@ -422,7 +422,7 @@ module.exports = app => {
     app.post('/tender/report_api/getMultiRoleRelationships', sessionAuth, 'signatureController.getMultiRoleRptRels');
     app.post('/tender/report_api/getMultiRoleRelationships', sessionAuth, 'signatureController.getMultiRoleRptRels');
     app.post('/tender/report_api/createRoleRelationship', sessionAuth, 'signatureController.createRoleRel');
     app.post('/tender/report_api/createRoleRelationship', sessionAuth, 'signatureController.createRoleRel');
     app.post('/tender/report_api/updateCustNode', sessionAuth, 'reportController.updateCustNode');
     app.post('/tender/report_api/updateCustNode', sessionAuth, 'reportController.updateCustNode');
-    app.post('/report/cDefine', sessionAuth, 'reportController.setCustomDefine');
+    app.post('/report/cDefine', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportController.setCustomDefine');
 
 
     app.post('/tender/report_api/addArchive/:prjId/:stgId/:rptId', sessionAuth, 'reportArchiveController.addReportArchive');
     app.post('/tender/report_api/addArchive/:prjId/:stgId/:rptId', sessionAuth, 'reportArchiveController.addReportArchive');
     app.post('/tender/report_api/updateArchive/:prjId/:stgId/:rptId/:orgName', sessionAuth, 'reportArchiveController.updateReportArchive');
     app.post('/tender/report_api/updateArchive/:prjId/:stgId/:rptId/:orgName', sessionAuth, 'reportArchiveController.updateReportArchive');
@@ -431,6 +431,8 @@ module.exports = app => {
     app.post('/tender/report_api/addArchiveEncryption', sessionAuth, 'reportArchiveController.addReportArchiveEncryption');
     app.post('/tender/report_api/addArchiveEncryption', sessionAuth, 'reportArchiveController.addReportArchiveEncryption');
     app.post('/tender/report_api/updateArchiveEncryption', sessionAuth, 'reportArchiveController.updateReportArchiveEncryption');
     app.post('/tender/report_api/updateArchiveEncryption', sessionAuth, 'reportArchiveController.updateReportArchiveEncryption');
     app.post('/tender/report_api/removeArchiveEncryption', sessionAuth, 'reportArchiveController.removeReportArchiveEncryption');
     app.post('/tender/report_api/removeArchiveEncryption', sessionAuth, 'reportArchiveController.removeReportArchiveEncryption');
+    app.post('/tender/:id/sendReportFileMsg', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportArchiveController.sendFileMsg');
+    app.get('/tender/:id/measure/stage/:order/sendReportFileMsg', sessionAuth, tenderCheck, uncheckTenderCheck, stageCheck, 'reportArchiveController.sendFileMsg');
 
 
     // 电子签名
     // 电子签名
     app.get('/tender/:id/signReport', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportArchiveController.signReport');
     app.get('/tender/:id/signReport', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportArchiveController.signReport');

+ 23 - 7
app/service/spec_msg.js

@@ -21,37 +21,53 @@ module.exports = app => {
             this.tableName = 's2b_spec_msg';
             this.tableName = 's2b_spec_msg';
         }
         }
 
 
-        async tenderNeedMsg(pid, tid) {
+        async tenderNeedMsg(pid, tid, timing) {
             const specProj = await this.db.get('zh_s2b_spec_proj', { id: pid });
             const specProj = await this.db.get('zh_s2b_spec_proj', { id: pid });
             if (!specProj || !specProj.is_push) return false;
             if (!specProj || !specProj.is_push) return false;
+
             switch (specProj.push_tender_type) {
             switch (specProj.push_tender_type) {
-                case 0: return true;
                 case 1:
                 case 1:
                     const filter = specProj.filter_tender ? specProj.filter_tender.split(',') : [];
                     const filter = specProj.filter_tender ? specProj.filter_tender.split(',') : [];
-                    return filter.indexOf(tid + '') < 0;
+                    if (filter.indexOf(tid + '') >= 0) return false;
+                    break;
                 case 2:
                 case 2:
                     const access = specProj.access_tender ? specProj.access_tender.split(',') : [];
                     const access = specProj.access_tender ? specProj.access_tender.split(',') : [];
-                    return access.indexOf(tid + '') >= 0;
+                    if (access.indexOf(tid + '') < 0) return false;
+                    break;
             }
             }
+
+            const soleTender = await this.db.get('zh_s2b_spec_tender', { id: tid, is_valid: 1 });
+            const specPush = await this.db.get('zh_s2b_spec_push', { pid, tid: soleTender ? tid : 0, valid: 1, push_timing: timing });
+            return !!specPush;
         }
         }
 
 
         async addLedgerMsg(transaction, pid, tender, timing) {
         async addLedgerMsg(transaction, pid, tender, timing) {
-            const needMsg = await this.tenderNeedMsg(pid, tender.id);
+            const needMsg = await this.tenderNeedMsg(pid, tender.id, timing);
             if (!needMsg) return;
             if (!needMsg) return;
             await transaction.insert(this.tableName, { pid, tid: tender.id, timing });
             await transaction.insert(this.tableName, { pid, tid: tender.id, timing });
         }
         }
 
 
         async addReviseMsg(transaction, pid, revise, timing) {
         async addReviseMsg(transaction, pid, revise, timing) {
-            const needMsg = await this.tenderNeedMsg(pid, revise.tid);
+            const needMsg = await this.tenderNeedMsg(pid, revise.tid, timing);
             if (!needMsg) return;
             if (!needMsg) return;
             await transaction.insert(this.tableName, { pid, tid: revise.tid, rid: revise.id, timing });
             await transaction.insert(this.tableName, { pid, tid: revise.tid, rid: revise.id, timing });
         }
         }
 
 
         async addStageMsg(transaction, pid, stage, timing) {
         async addStageMsg(transaction, pid, stage, timing) {
-            const needMsg = await this.tenderNeedMsg(pid, stage.tid);
+            const needMsg = await this.tenderNeedMsg(pid, stage.tid, timing);
             if (!needMsg) return;
             if (!needMsg) return;
             await transaction.insert(this.tableName, { pid, tid: stage.tid, sid: stage.id, timing });
             await transaction.insert(this.tableName, { pid, tid: stage.tid, sid: stage.id, timing });
         }
         }
+
+        async addReportMsg(transaction, pid, tender, stage, timing) {
+            const needMsg = await this.tenderNeedMsg(pid, stage.tid, timing);
+            if (!needMsg) return;
+            if (transaction) {
+                await transaction.insert(this.tableName, { pid, tid: tender.id, sid: stage ? stage.id : 0, timing });
+            } else {
+                await this.db.insert(this.tableName, { pid, tid: tender.id, sid: stage ? stage.id : 0, timing });
+            }
+        }
     }
     }
 
 
     return SpecPull;
     return SpecPull;

+ 12 - 0
app/view/report/index_archive.ejs

@@ -18,6 +18,11 @@
                         <div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="optionSelectableStages"></div>
                         <div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="optionSelectableStages"></div>
                     </div>
                     </div>
                 </div>
                 </div>
+                <% 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>
+                </div>
+                <% } %>
             </div>
             </div>
             <div>
             <div>
             </div>
             </div>
@@ -314,6 +319,13 @@
         );
         );
     }
     }
 
 
+
+    function sendReportFileMsg() {
+        postData('sendReportFileMsg', { sid: current_stage_id, sorder: current_stage_order }, function (result, msg) {
+            toastr.success(msg);
+        });
+    }
+
     $(function () {
     $(function () {
         //阻止事件冒泡
         //阻止事件冒泡
         //不仅仅要stopPropagation,还要preventDefault
         //不仅仅要stopPropagation,还要preventDefault

+ 6 - 0
app/view/tender/detail_modal.ejs

@@ -1847,6 +1847,10 @@
                         <input type="checkbox" class="custom-control-input" id="lc_over" checked="">
                         <input type="checkbox" class="custom-control-input" id="lc_over" checked="">
                         <label class="custom-control-label" for="lc_over">超计判断</label>
                         <label class="custom-control-label" for="lc_over">超计判断</label>
                     </div>
                     </div>
+                    <div class="custom-control custom-checkbox mb-2">
+                        <input type="checkbox" class="custom-control-input" id="lc_banMinusChangeBills" checked="">
+                        <label class="custom-control-label" for="lc_banMinusChangeBills">强制调用负变更(限制上报审批/审批通过)</label>
+                    </div>
                 </div>
                 </div>
             </div>
             </div>
             <div class="modal-footer">
             <div class="modal-footer">
@@ -1904,6 +1908,7 @@
         $('#lc_same_code')[0].checked = property.ledger_check.same_code;
         $('#lc_same_code')[0].checked = property.ledger_check.same_code;
         $('#lc_sibling')[0].checked = property.ledger_check.sibling;
         $('#lc_sibling')[0].checked = property.ledger_check.sibling;
         $('#lc_over')[0].checked = property.ledger_check.over;
         $('#lc_over')[0].checked = property.ledger_check.over;
+        $('#lc_banMinusChangeBills')[0].check = property.ledger_check.banMinusChangeBills;
     };
     };
 
 
     $('#bd-set-10').on('show.bs.modal', function () {
     $('#bd-set-10').on('show.bs.modal', function () {
@@ -1916,6 +1921,7 @@
                 same_code: $('#lc_same_code')[0].checked,
                 same_code: $('#lc_same_code')[0].checked,
                 sibling: $('#lc_sibling')[0].checked,
                 sibling: $('#lc_sibling')[0].checked,
                 over: $('#lc_over')[0].checked,
                 over: $('#lc_over')[0].checked,
+                banMinusChangeBills: $('lc_banMinusChangeBills')[0].checked,
             },
             },
         };
         };
         const tenderId = window.location.pathname.split('/')[2];
         const tenderId = window.location.pathname.split('/')[2];

+ 0 - 1
app/view/tender/info.ejs

@@ -9,7 +9,6 @@
 </div>
 </div>
 <script>
 <script>
     const tenders = JSON.parse(unescape('<%- escape(JSON.stringify(tenderList)) %>'));
     const tenders = JSON.parse(unescape('<%- escape(JSON.stringify(tenderList)) %>'));
-    console.log(tenders);
     const categoryType = JSON.parse('<%- JSON.stringify(settingConst.cType) %>');
     const categoryType = JSON.parse('<%- JSON.stringify(settingConst.cType) %>');
     const category = JSON.parse(unescape('<%- escape(JSON.stringify(categoryData)) %>'));
     const category = JSON.parse(unescape('<%- escape(JSON.stringify(categoryData)) %>'));
     const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
     const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');