Procházet zdrojové kódy

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

TonyKang před 4 roky
rodič
revize
92578609ff

+ 12 - 7
app/controller/change_controller.js

@@ -778,13 +778,18 @@ module.exports = app => {
                 if (changeData.status !== audit.flow.status.checked || ctx.session.sessionUser.accountId !== auditInfo.uid) {
                     throw '您无权进行该操作';
                 }
-                const code = ctx.request.body.code;
-                const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
-                const cacheKey = 'smsCode:' + ctx.session.sessionUser.accountId;
-                const cacheCode = await app.redis.get(cacheKey);
-                // console.log(cacheCode);
-                if (cacheCode === null || code === undefined || cacheCode !== (code + pa.auth_mobile)) {
-                    throw '验证码不正确!';
+                if (ctx.session.sessionUser.loginStatus === 0) {
+                    const code = ctx.request.body.code;
+                    const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
+                    if (!pa.auth_mobile) {
+                        throw '未绑定手机号';
+                    }
+                    const cacheKey = 'smsCode:' + ctx.session.sessionUser.accountId;
+                    const cacheCode = await app.redis.get(cacheKey);
+                    // console.log(cacheCode);
+                    if (cacheCode === null || code === undefined || cacheCode !== (code + pa.auth_mobile)) {
+                        throw '验证码不正确!';
+                    }
                 }
 
                 // 重新审批

+ 1 - 0
app/controller/report_controller.js

@@ -31,6 +31,7 @@ module.exports = app => {
          * @private
          */
         async _getStageAuditViewData(ctx) {
+            if (!ctx.stage) return;
             const times = ctx.stage.status === auditConst.stage.status.checkNo ? ctx.stage.times - 1 : ctx.stage.times;
 
             ctx.stage.user = await ctx.service.projectAccount.getAccountInfoById(ctx.stage.user_id);

+ 4 - 1
app/controller/stage_controller.js

@@ -1063,9 +1063,12 @@ module.exports = app => {
                 if (ctx.query.confirm !== undefined && ctx.query.confirm !== '确认设置终审审批') {
                     throw '请输入正确的文本信息';
                 }
-                if (ctx.query.confirm === undefined || (!ctx.query.confirm && ctx.session.sessionUser.loginStatus === 1)) {
+                if (ctx.session.sessionUser.loginStatus === 0) {
                     const code = ctx.query.code;
                     const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
+                    if (!pa.auth_mobile) {
+                        throw '未绑定手机号';
+                    }
                     const cacheKey = 'smsCode:' + ctx.session.sessionUser.accountId;
                     const cacheCode = await app.redis.get(cacheKey);
                     // console.log(cacheCode);

+ 5 - 2
app/lib/pay_calc.js

@@ -130,8 +130,9 @@ class PayCalculate {
      * 累计 计量等数据
      */
     async _getAddCalcRela() {
-        // todo 获取截止上期数据
-        this.pre = this.stage.order > 1 ? await this.ctx.service.stageBillsFinal.getSumTotalPrice(this.stage.tid, this.stage.order - 1) : null;
+        if (this.cur && this.add) return;
+
+        this.pre = this.stage.order > 1 ? await this.ctx.service.stageBillsFinal.getSumTotalPrice(this.stage.tid, this.stage.order - 1) : {};
         this.cur = await this.ctx.service.stageBills.getSumTotalPrice(this.stage);
         this.add = {};
         if (this.pre) {
@@ -231,6 +232,8 @@ class PayCalculate {
     }
 
     async calculateAll(pays) {
+        await this.getCalcBase();
+        await this._getAddCalcRela();
         await this.calculateStartRangePrice(pays);
         await this.calculate(pays);
     }

+ 11 - 3
app/view/change/info_modal.ejs

@@ -692,7 +692,7 @@
     </div>
 </div>
 <% if (auditStatus === 4 && ctx.session.sessionUser.accountId === auditList[auditList.length-1].uid && stageChangeNum === 0) { %>
-<% if (!authMobile) { %>
+<% if (!authMobile && ctx.session.sessionUser.loginStatus === 0) { %>
     <!--终审重新审批-->
     <div class="modal fade" id="sp-down-back" data-backdrop="static">
         <div class="modal-dialog" role="document">
@@ -721,6 +721,7 @@
             </div>
             <div class="modal-body">
                 <h5>确认由「终审-<%= auditList[auditList.length-1].name %>」重新审批「<%= change.code %>」?</h5>
+                <% if (ctx.session.sessionUser.loginStatus === 0) { %>
                 <div class="form-group">
                     <label>重审需要验证码确认,验证码将发送至尾号<%- authMobile.slice(-4) %>的手机</label>
                     <div class="input-group input-group-sm mb-3">
@@ -730,12 +731,13 @@
                         </div>
                     </div>
                 </div>
+                <% } %>
             </div>
             <div class="modal-footer">
                 <input type="hidden" name="cid" value="<%= change.cid %>">
                 <input type="hidden" name="_csrf" value="<%= ctx.csrf %>" />
                 <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
-                <button type="button" id="re-shenpi-btn" class="btn btn-warning btn-sm" disabled>确定重审</button>
+                <button type="button" id="re-shenpi-btn" class="btn btn-warning btn-sm" <% if (ctx.session.sessionUser.loginStatus === 0) { %>disabled<% } %>>确定重审</button>
             </div>
         </form>
     </div>
@@ -789,6 +791,10 @@
     });
 
     $('#re-shenpi-btn').click(function () {
+        const data = {
+            cid: '<%- change.cid %>',
+        };
+        <% if (ctx.session.sessionUser.loginStatus === 0) { %>
         const code = $("#againForm input[name='code']").val();
         if ($(this).hasClass('disabled')) {
             return false;
@@ -798,10 +804,12 @@
             toast('请填写正确的验证码', 'error');
             return false;
         }
+        data.code = code;
+        <% } %>
         $.ajax({
             url: '/tender/<%- tender.id %>/change/check/again?_csrf=' + csrf,
             type: 'post',
-            data: { code: code, cid: '<%- change.cid %>' },
+            data: data,
             dataTye: 'json',
             success: function(response) {
                 if (response.err === 0) {

+ 20 - 13
app/view/stage/audit_modal.ejs

@@ -1,4 +1,4 @@
-<% if (ctx.stage.status === auditConst.status.uncheck || ctx.stage.status === auditConst.status.checkNo) { %>
+<% if (ctx.stage && (ctx.stage.status === auditConst.status.uncheck || ctx.stage.status === auditConst.status.checkNo)) { %>
     <% if (ctx.session.sessionUser.accountId === ctx.stage.user_id) {%>
         <!--上报审批-->
         <div class="modal fade" id="sub-sp" data-backdrop="static">
@@ -75,7 +75,7 @@
         </div>
     <% } %>
 <% } %>
-<% if (ctx.stage.status === auditConst.status.checking) { %>
+<% if (ctx.stage && (ctx.stage.status === auditConst.status.checking)) { %>
     <% if (ctx.stage.curAuditor && ctx.stage.curAuditor.aid === ctx.session.sessionUser.accountId) { %>
         <!--审批通过-->
         <div class="modal fade sp-location-list" id="sp-done" data-backdrop="static">
@@ -565,7 +565,7 @@
             </div>
         </div>
     <% } %>
-<% } else if (ctx.stage.status === auditConst.status.checked) { %>
+<% } else if (ctx.stage && (ctx.stage.status === auditConst.status.checked)) { %>
     <!--审批流程/结果-->
     <div class="modal fade" id="sp-list" data-backdrop="static">
         <div class="modal-dialog modal-lg" role="document">
@@ -718,7 +718,7 @@
             </div>
         </div>
     </div>
-<% } else if (ctx.stage.status === auditConst.status.checkNo) { %>
+<% } else if (ctx.stage && (ctx.stage.status === auditConst.status.checkNo)) { %>
     <!--审批流程/结果-->
     <div class="modal fade" id="sp-list" data-backdrop="static">
         <div class="modal-dialog modal-lg" role="document">
@@ -948,7 +948,7 @@
             </div>
         </div>
     <% } %>
-<% } else if (ctx.stage.status === auditConst.status.checkNoPre) { %>
+<% } else if (ctx.stage && (ctx.stage.status === auditConst.status.checkNoPre)) { %>
     <!--审批流程/结果-->
     <div class="modal fade" id="sp-list" data-backdrop="static">
         <div class="modal-dialog modal-lg" role="document">
@@ -1435,7 +1435,7 @@
         </div>
     <% } %>
 <% } %>
-<% if (ctx.stage.auditors !== undefined && ctx.stage.auditors.length !== 0 && ctx.stage.auditors[ctx.stage.auditors.length-1].aid === ctx.session.sessionUser.accountId && ctx.stage.status === auditConst.status.checked && ctx.stage.order === ctx.stage.highOrder) { %>
+<% if (ctx.stage && ctx.stage.auditors !== undefined && ctx.stage.auditors.length !== 0 && ctx.stage.auditors[ctx.stage.auditors.length-1].aid === ctx.session.sessionUser.accountId && ctx.stage.status === auditConst.status.checked && ctx.stage.order === ctx.stage.highOrder) { %>
     <% if (ctx.stage.hadMaterial) { %>
     <div class="modal fade" id="sp-down-back" data-backdrop="static">
         <div class="modal-dialog" role="document">
@@ -1452,7 +1452,7 @@
             </div>
         </div>
     </div>
-    <% } else if (!authMobile) { %>
+    <% } else if (ctx.stage && !authMobile && ctx.session.sessionUser.loginStatus === 0) { %>
         <!--终审重新审批-->
         <div class="modal fade" id="sp-down-back" data-backdrop="static">
             <div class="modal-dialog" role="document">
@@ -1471,7 +1471,7 @@
                 </div>
             </div>
         </div>
-    <% } else { %>
+    <% } else if(ctx.stage) { %>
     <div class="modal fade" id="sp-down-back" data-backdrop="static">
         <div class="modal-dialog" role="document">
             <div class="modal-content">
@@ -1480,6 +1480,7 @@
                 </div>
                 <div class="modal-body">
                     <h5>确认由「终审-<%= ctx.stage.auditors[ctx.stage.auditors.length-1].name %>」重新审批「第<%= ctx.stage.order %>期」?</h5>
+                    <% if (ctx.session.sessionUser.loginStatus === 0) { %>
                     <div class="form-group">
                         <label>重审需要验证码确认,验证码将发送至尾号<%- authMobile.slice(-4) %>的手机</label>
                         <div class="input-group input-group-sm mb-3">
@@ -1489,18 +1490,19 @@
                             </div>
                         </div>
                     </div>
+                    <% } %>
                 </div>
                 <div class="modal-footer">
                     <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
                     <!--<a href="<%- preUrl %>/audit/check/again" disabled class="btn btn-warning btn-sm">确定重审</a>-->
-                    <button disabled id="re-shenpi-btn" class="btn btn-warning btn-sm">确定重审</button>
+                    <button <% if (ctx.session.sessionUser.loginStatus === 0) { %>disabled<% } %> id="re-shenpi-btn" class="btn btn-warning btn-sm">确定重审</button>
                 </div>
             </div>
         </div>
     </div>
     <% } %>
 <% } %>
-<% if (ctx.stage.user_id === ctx.session.sessionUser.accountId && ctx.stage.order === ctx.stage.highOrder && (ctx.stage.status === auditConst.status.checkNo || ctx.stage.status === auditConst.status.uncheck)) { %>
+<% if (ctx.stage && ctx.stage.user_id === ctx.session.sessionUser.accountId && ctx.stage.order === ctx.stage.highOrder && (ctx.stage.status === auditConst.status.checkNo || ctx.stage.status === auditConst.status.uncheck)) { %>
     <!--删除期-->
     <% if (ctx.stage.hadMaterial) { %>
         <div class="modal fade" id="del-qi" data-backdrop="static">
@@ -1546,7 +1548,7 @@
     const authMobile = '<%= authMobile %>';
 </script>
 <script>
-    <% if (ctx.url !== '/tender/' + ctx.tender.id + '/measure/stage/' + ctx.stage.order) { %>
+    <% if (ctx.stage && ctx.url !== '/tender/' + ctx.tender.id + '/measure/stage/' + ctx.stage.order) { %>
     const dataChecker = DataChecker({
         checkUrl: '/tender/<%- ctx.tender.id %>/measure/stage/<%- ctx.stage.order %>/check',
         errorList: $.cs_errorList({
@@ -1654,7 +1656,10 @@
 
     // 重新审批按钮
     $("#re-shenpi-btn").click(function() {
-        const code = $("input[name='code']").val();
+        const data = {
+        };
+        <% if (ctx.session.sessionUser.loginStatus === 0) { %>
+        const code = $("#sp-down-back input[name='code']").val();
         if ($(this).hasClass('disabled')) {
             return false;
         }
@@ -1663,10 +1668,12 @@
             toast('请填写正确的验证码', 'error');
             return false;
         }
+        data.code = code;
+        <% } %>
         $.ajax({
             url: '<%- preUrl %>/audit/check/again',
             type: 'get',
-            data: { code: code },
+            data: data,
             dataTye: 'json',
             success: function(response) {
                 if (response.err === 0) {

+ 1 - 1
app/view/stage/manager_modal.ejs

@@ -97,7 +97,7 @@
             </div>
         </div>
     </div>
-<% } else if (!authMobile) { %>
+<% } else if (!authMobile && ctx.session.sessionUser.loginStatus === 0) { %>
     <!--终审重新审批-->
     <div class="modal fade" id="pass" data-backdrop="static">
         <div class="modal-dialog" role="document">

+ 1 - 0
config/web.js

@@ -657,6 +657,7 @@ const JsFiles = {
                     '/public/js/spreadjs_rela/spreadjs_zh.js',
                     '/public/js/shares/tenders2tree.js',
                     '/public/report/js/rpt_custom.js',
+                    '/public/js/stage_audit.js',
                 ],
                 mergeFile: 'report_main',
             },