Bläddra i källkod

feat: 新增weapp修订控制器及相关路由,优化修订审核逻辑

caipin 15 timmar sedan
förälder
incheckning
52853f062e

+ 60 - 0
app/controller/weapp_revise_controller.js

@@ -0,0 +1,60 @@
+'use strict';
+
+const audit = require('../const/audit');
+
+module.exports = app => {
+    class WeappReviseController extends app.BaseController {
+
+        async index(ctx) {
+            try {
+                const tenderId = ctx.params.id;
+                const show_revise_invalid = 1;
+                const ledgerRevise = await ctx.service.ledgerRevise.getReviseList(tenderId, show_revise_invalid);
+                ctx.body = { code: 0, msg: '', data: ledgerRevise };
+            } catch (err) {
+                this.log(err);
+                ctx.body = { code: -1, msg: err.toString(), data: null };
+            }
+        }
+
+        async check(ctx) {
+            try {
+                const reviseId = ctx.params.rid;
+                const revise = await ctx.service.ledgerRevise.getDataById(reviseId);
+                if (!revise) {
+                    ctx.body = { code: -1, msg: '修订不存在', data: null };
+                    return;
+                }
+                if (revise.status !== audit.revise.status.checking) {
+                    ctx.body = {
+                        code: -1,
+                        msg: `修订状态不正确,当前状态为"${audit.revise.statusString[revise.status] || '未知'}",无法审批`,
+                        data: { currentStatus: revise.status }
+                    };
+                    return;
+                }
+                revise.curHis = revise.his_id ? await ctx.service.ledgerHistory.getDataById(revise.his_id) : null;
+                const curAudits = await ctx.service.reviseAudit.getCurAuditors(revise.id, revise.times);
+                const curAuditorIds = curAudits.map(x => { return x.audit_id; });
+                if (curAuditorIds.indexOf(ctx.session.sessionUser.accountId) < 0) {
+                    ctx.body = { code: -1, msg: '您不是当前审批人,无权进行该操作', data: null };
+                    return;
+                }
+                const data = ctx.request.body;
+                const checkType = parseInt(data.checkType);
+                if (!checkType || isNaN(checkType)) {
+                    ctx.body = { code: -1, msg: '提交数据错误:缺少审批类型参数', data: null };
+                    return;
+                }
+                const opinion = data.opinion || '';
+                await ctx.service.reviseAudit.check(revise, checkType, opinion, revise.times);
+                ctx.body = { code: 0, msg: '审批成功', data: null };
+            } catch (err) {
+                ctx.body = { code: -1, msg: err.toString(), data: null };
+            }
+        }
+
+    }
+
+    return WeappReviseController;
+};

+ 53 - 2
app/controller/weapp_tender_controller.js

@@ -185,7 +185,7 @@ module.exports = app => {
                 }
             }
 
-            advance.advancePayTotal = this.ctx.tender.info.deal_param[ advanceConst.typeCol[advance.type].key + 'Advance'];
+            advance.advancePayTotal = this.ctx.tender.info.deal_param[advanceConst.typeCol[advance.type].key + 'Advance'];
             if (advance.status === auditConst.advance.status.checkNo) {
                 advance.curAuditor = await this.service.advanceAudit.getAuditorByStatus(advance.id, advance.status, times);
                 advance.auditHistory = await this.service.advanceAudit.getAuditors(advance.id, times);
@@ -306,6 +306,56 @@ module.exports = app => {
                 await ctx.service.reviseAudit.loadReviseUser(revise);
                 await ctx.service.reviseAudit.loadReviseAuditViewData(revise);
 
+                revise.auditHistory = revise.auditors.reduce((prev, curr, idx) => {
+                    if (idx === 0) {
+                        const reportor = {
+                            audit_id: revise.uid,
+                            audit_order: 0,
+                            audit_type: 1,
+                            status: revise.status === auditConst.revise.status.uncheck ? auditConst.revise.status.uncheck : auditConst.revise.status.checked,
+                            times: curr.times,
+                            begin_time: revise.in_time,
+                            end_time: revise.auditors.length ? revise.auditors[0].begin_time : null,
+                            name: revise.user.name,
+                            company: revise.user.company,
+                            role: revise.user.role,
+                            mobile: '',
+                            opinion: '',
+
+                        };
+                        prev.push({
+                            name: '原报',
+                            status: reportor.status,
+                            audit_type: reportor.audit_type,
+                            auditors: [reportor],
+                        });
+                    }
+                    const currentOrder = curr.audit_order;
+                    prev.push(
+                        {
+                            name: currentOrder === curr.max_sort ? '终审' : `${currentOrder}审`,
+                            status: curr.status,
+                            audit_type: 1,
+                            auditors: [{
+                                audit_id: curr.audit_id,
+                                audit_order: curr.audit_order,
+                                audit_type: curr.audit_type,
+                                status: curr.status,
+                                max_sort: curr.max_sort,
+                                begin_time: curr.begin_time,
+                                end_time: curr.end_time,
+                                name: curr.name,
+                                company: curr.company,
+                                mobile: curr.mobile,
+                                opinion: curr.opinion,
+                                role: curr.role,
+                                times: curr.times,
+                            }],
+                        }
+                    );
+                    return prev;
+                }, []);
+
                 const GclGather = require('../lib/gcl_gather');
                 const gclGatherModal = new GclGather.gclCompareGather(this.ctx);
                 const spec = { zlj: stdConst.zlj, jrg: stdConst.jrg };
@@ -325,7 +375,8 @@ module.exports = app => {
                 revise.chapterList = gclGatherModal.chapterData();
                 revise.new_tp = gclGatherModal.otherChapter.hj.new_total_price || 0;
                 revise.org_tp = gclGatherModal.otherChapter.hj.org_total_price || 0;
-
+                console.log(ctx.tender.data.name);
+                revise.tenderName = ctx.tender.data.name;
                 ctx.body = { code: 0, msg: '', data: { revise } };
             } catch (error) {
                 ctx.log(error);

+ 1 - 1
app/middleware/weapp_tender_check.js

@@ -9,7 +9,7 @@ module.exports = options => {
             const tenderId = ctx.request.body.tenderId || ctx.request.query.tenderId || ctx.params.tenderId;
             const accountId = ctx.session.sessionUser.accountId;
             // 读取标段数据
-            const tender = { id: tenderId };
+            const tender = { id: Number(tenderId) };
             if (!tender.id) {
                 throw '当前未打开标段';
             }

+ 2 - 1
app/router.js

@@ -1249,7 +1249,8 @@ module.exports = app => {
     app.post('/wx/weapp/attention/unfollow', weappAuth, 'weappAttentionController.unfollow');
     app.get('/wx/weapp/attention/list', weappAuth, 'weappAttentionController.followedList');
     app.get('/wx/weapp/attention/check', weappAuth, 'weappAttentionController.checkFollowing');
-    // app.get('/wx/weapp/tender/:id/revise', weappAuth, 'weappReviseController.index');
+    app.get('/wx/weapp/tender/:id/revise', weappAuth, 'weappReviseController.index');
+    app.post('/wx/weapp/tender/:tenderId/revise/:rid/check', weappAuth, weappTenderCheck, 'weappReviseController.check');
     app.get('/wx/weapp/tender/detail', weappAuth, weappTenderCheck, 'weappTenderController.detail');
     app.get('/wx/weapp/tender/list/manage', weappAuth, 'weappTenderController.listManage');
     app.get('/wx/weapp/tender/:id/measure/stage', weappAuth, 'weappMeasureController.stage');