Browse Source

计量审批,检查计算相关

MaiXinRong 5 years ago
parent
commit
8cdcff5ad2

+ 13 - 8
app/controller/stage_controller.js

@@ -1033,27 +1033,32 @@ module.exports = app => {
                 if (!this.ctx.stage.curAuditor || this.ctx.stage.curAuditor.aid !== ctx.session.sessionUser.accountId) {
                     throw '您无权进行该操作';
                 }
-                const data = {
-                    checkType: parseInt(ctx.request.body.checkType),
-                    opinion: ctx.request.body.opinion,
-                };
+                const data = JSON.parse(ctx.request.body.data);
+                //data.checkType = parseInt(data.checkType);
+                // const data = {
+                //     checkType: parseInt(ctx.request.body.checkType),
+                //     opinion: ctx.request.body.opinion,
+                // };
                 if (!data.checkType || isNaN(data.checkType)) {
+                    console.log('error1');
                     throw '提交数据错误';
                 }
                 if (data.checkType === auditConst.status.checkNo) {
                     if (!data.checkType || isNaN(data.checkType)) {
+                        console.log('error2');
                         throw '提交数据错误';
                     }
                 }
 
                 await ctx.service.stageAudit.check(ctx.stage.id, data, ctx.stage.times);
 
-                ctx.redirect(ctx.request.header.referer);
+                ctx.body = {err: 0, msg: '', data: []};//ctx.redirect(ctx.request.header.referer);
             } catch (err) {
-                console.log(err);
+                //console.log(err);
                 this.log(err);
-                ctx.session.postError = err.toString();
-                ctx.redirect(ctx.request.header.referer);
+                ctx.body = this.ajaxErrorBody(err, '提交失败');
+                // ctx.session.postError = err.toString();
+                // ctx.redirect(ctx.request.header.referer);
             }
         }
         /**

+ 1 - 2
app/public/js/ledger.js

@@ -2594,8 +2594,7 @@ $(document).ready(function() {
     $('[name=audit-start]').submit(function (e) {
         if (checkAuditorFrom()) {
             $(this).parent().parent().parent().modal('hide');
-            const formData = new FormData();
-            dataChecker.checkAndPost(this.action, formData);
+            dataChecker.checkAndPost(this.action, {});
             $('#hide-all').hide();
         }
         return false;

+ 1 - 2
app/public/js/revise.js

@@ -2196,8 +2196,7 @@ $(document).ready(() => {
     $('[name=revise-start]').submit(function (e) {
         if (checkAuditorFrom()) {
             $(this).parent().parent().parent().modal('hide');
-            const formData = new FormData();
-            dataChecker.checkAndPost(this.action, formData);
+            dataChecker.checkAndPost(this.action, {});
             $('#hide-all').hide();
         }
         return false;

+ 53 - 2
app/public/js/stage.js

@@ -2905,8 +2905,59 @@ $(document).ready(() => {
     $('[name=stage-start]').submit(function (e) {
         if (checkAuditorFrom()) {
             $(this).parent().parent().parent().modal('hide');
-            const formData = new FormData();
-            dataChecker.checkAndPost(this.action, formData);
+            dataChecker.checkAndPost(this.action, {});
+            $('#hide-all').hide();
+        }
+        return false;
+    });
+    $('#audit-check0').submit(function (e) {
+        if (auditCheck(0)) {
+            $(this).parent().parent().modal('hide');
+            const data = {
+                opinion: $('[name=opinion]', this).val(),
+                checkType: parseInt($('[name=checkType]', this).val()),
+            };
+            dataChecker.checkAndPost(this.action, data);
+            $('#hide-all').hide();
+        }
+        return false;
+    });
+    $('#audit-check1').submit(function (e) {
+        if (auditCheck(1)) {
+            $(this).parent().parent().modal('hide');
+            const data = {
+                opinion: $('[name=opinion]', this).val(),
+                checkType: parseInt($('[name=checkType]:checked', this).val()),
+            };
+            postData(this.action, data, function () {
+                window.location.reload();
+            });
+            $('#hide-all').hide();
+        }
+        return false;
+    });
+    $('#audit-check2').submit(function (e) {
+        if (auditCheck(2)) {
+            $(this).parent().parent().modal('hide');
+            const data = {
+                opinion: $('[name=opinion]', this).val(),
+                checkType: parseInt($('[name=checkType]', this).val()),
+            };
+            dataChecker.checkAndPost(this.action, data);
+            $('#hide-all').hide();
+        }
+        return false;
+    });
+    $('#audit-check3').submit(function (e) {
+        if (auditCheck(3)) {
+            $(this).parent().parent().modal('hide');
+            const data = {
+                opinion: $('[name=opinion]', this).val(),
+                checkType: parseInt($('[name=checkType]:checked', this).val()),
+            };
+            postData(this.action, data, function () {
+                window.location.reload();
+            });
             $('#hide-all').hide();
         }
         return false;

+ 2 - 2
app/view/shares/check_data_modal.ejs

@@ -78,7 +78,7 @@
             progress(100);
             clearInterval(progressInterval);
         }
-        const checkAndPost = async function (postUrl, postForm) {
+        const checkAndPost = async function (url, data) {
             $('#check').modal('show');
             fakeProgress();
             postData(setting.checkUrl, setting.checkData ? setting.checkData : {}, function (result) {
@@ -93,7 +93,7 @@
                     stopFakeProgess();
                     setTimeout(function () {
                         setting.errorList.clearErrorData();
-                        postDataWithFile(postUrl, postForm, function () {
+                        postData(url, data, function () {
                             window.location.reload();
                         });
                     }, 300);

+ 4 - 4
app/view/stage/audit_modal.ejs

@@ -80,7 +80,7 @@
         <!--审批通过-->
         <div class="modal fade" id="sp-done" data-backdrop="static">
             <div class="modal-dialog modal-lg" role="document">
-                <form class="modal-content" action="<%- preUrl %>/audit/check" method="post" onsubmit="return auditCheck(0);">
+                <form class="modal-content" action="<%- preUrl %>/audit/check" method="post" id="audit-check0" onsubmit="return auditCheck(0);">
                     <div class="modal-header">
                         <h5 class="modal-title">审批通过</h5>
                     </div>
@@ -238,7 +238,7 @@
         <!--审批退回-->
         <div class="modal fade" id="sp-back" data-backdrop="static">
             <div class="modal-dialog modal-lg" role="document">
-                <form class="modal-content modal-lg" action="<%- preUrl %>/audit/check" method="post" onsubmit="return auditCheck(1);">
+                <form class="modal-content modal-lg" action="<%- preUrl %>/audit/check" method="post" id="audit-check1" onsubmit="return auditCheck(1);">
                     <div class="modal-header">
                         <h5 class="modal-title">审批退回</h5>
                     </div>
@@ -1103,7 +1103,7 @@
         <!--审批通过-->
         <div class="modal fade" id="sp-done" data-backdrop="static">
             <div class="modal-dialog modal-lg" role="document">
-                <form class="modal-content" action="<%- preUrl %>/audit/check" method="post" onsubmit="return auditCheck(2);">
+                <form class="modal-content" action="<%- preUrl %>/audit/check" method="post" id="audit-check2" onsubmit="return auditCheck(2);">
                     <div class="modal-header">
                         <h5 class="modal-title">审批通过</h5>
                     </div>
@@ -1261,7 +1261,7 @@
         <!--审批退回-->
         <div class="modal fade" id="sp-back" data-backdrop="static">
             <div class="modal-dialog modal-lg" role="document">
-                <form class="modal-content" action="<%- preUrl %>/audit/check" method="post" onsubmit="return auditCheck(3);">
+                <form class="modal-content" action="<%- preUrl %>/audit/check" method="post" id="audit-check3" onsubmit="return auditCheck(3);">
                     <div class="modal-header">
                         <h5 class="modal-title">审批退回</h5>
                     </div>