Procházet zdrojové kódy

材料调差wap页审批及待办页功能

ellisran před 3 týdny
rodič
revize
ec306e09a1

+ 8 - 6
app/controller/material_controller.js

@@ -1317,10 +1317,12 @@ module.exports = app => {
                 if (ctx.material.curAuditorIds.indexOf(ctx.session.sessionUser.accountId) < 0) {
                     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)) {
                     throw '提交数据错误';
                 }
@@ -1332,11 +1334,11 @@ module.exports = app => {
 
                 await ctx.service.materialAudit.check(ctx.material.id, data, ctx.material.times);
 
-                ctx.redirect(ctx.request.header.referer);
+                ctx.body = { err: 0, msg: '', data: [] };
             } catch (err) {
                 this.log(err);
+                ctx.body = this.ajaxErrorBody(err, '提交失败');
                 ctx.session.postError = err.toString();
-                ctx.redirect(ctx.request.header.referer);
             }
         }
 

+ 26 - 1
app/view/material/audit_modal.ejs

@@ -263,7 +263,7 @@
         <!--审批通过-->
         <div class="modal fade sp-location-list" 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">
                     <div class="modal-header">
                         <h5 class="modal-title">审批通过</h5>
                     </div>
@@ -988,6 +988,31 @@
         return false;
     }
 
+    $('#audit-check0').submit(function (e) {
+        if (auditCheck(0)) {
+            const data = {
+                opinion: $('[name=opinion]', this).val(),
+                checkType: parseInt($('[name=checkType]', this).val()),
+            };
+            postData(this.action, data, function () {
+                window.location.reload();
+            });
+        }
+        return false;
+    });
+    $('#audit-check1').submit(function (e) {
+        if (auditCheck(1)) {
+            const data = {
+                opinion: $('[name=opinion]', this).val(),
+                checkType: parseInt($('[name=checkType]:checked', this).val()),
+            };
+            postData(this.action, data, function () {
+                window.location.reload();
+            });
+        }
+        return false;
+    });
+
     // 展开历史审核记录
     $('.modal-body #fold-btn').click(function () {
         const type = $(this).data('target')