浏览代码

支付审批路由问题

ellisran 4 月之前
父节点
当前提交
7a2520390b

+ 4 - 4
app/controller/payment_controller.js

@@ -31,7 +31,7 @@ module.exports = app => {
          */
         async index(ctx) {
             try {
-                if (!ctx.session.sessionProject.showPayment) {
+                if (!ctx.subProject.showPayment) {
                     throw '该功能已关闭或无法查看';
                 }
                 const auditPermission = await ctx.service.subProjPermission.getPaymentPermission(ctx.subProject.permission.payment_permission);
@@ -101,7 +101,7 @@ module.exports = app => {
 
         async permissionSave(ctx) {
             try {
-                if (!ctx.session.sessionProject.showPayment) {
+                if (!ctx.subProject.showPayment) {
                     throw '该功能已关闭或无法查看';
                 }
                 if (ctx.session.sessionUser.is_admin === 0) throw '没有设置权限';
@@ -168,7 +168,7 @@ module.exports = app => {
 
         async paymentInfoSave(ctx) {
             try {
-                if (!ctx.session.sessionProject.showPayment) {
+                if (!ctx.subProject.showPayment) {
                     throw '该功能已关闭或无法查看';
                 }
                 const data = JSON.parse(ctx.request.body.data);
@@ -188,7 +188,7 @@ module.exports = app => {
 
         async save(ctx) {
             try {
-                if (!ctx.session.sessionProject.showPayment) {
+                if (!ctx.subProject.showPayment) {
                     throw '该功能已关闭或无法查看';
                 }
                 const projectId = ctx.session.sessionProject.id;

+ 1 - 1
app/middleware/payment_tender_check.js

@@ -23,7 +23,7 @@ module.exports = options => {
      */
     return function* paymentTenderCheck(next) {
         try {
-            if (!this.session.sessionProject.showPayment) {
+            if (!this.subProject.showPayment) {
                 throw '该功能已关闭或无法查看';
             }
             if (!this.params.pid) {

+ 0 - 55
app/middleware/session_auth.js

@@ -38,61 +38,6 @@ module.exports = options => {
             this.session.sessionProject.dataCollect = projectData.data_collect;
             this.session.sessionProject.customType = projectData.customType;
             this.session.sessionProject.funSet = projectData.fun_set ? JSON.parse(projectData.fun_set) : null;
-            // todo 迁移至subProject内部
-            // 判断是否有权限查看决策大屏
-            // let showDataCollect = 0;
-            // if (projectData.data_collect && this.session.sessionProject.page_show.openDataCollect) {
-            //     if (sessionUser.is_admin) {
-            //         showDataCollect = 1;
-            //     } else {
-            //         const auditInfo = yield this.service.datacollectAudit.getDataByCondition({ pid: projectData.id, uid: accountInfo.id });
-            //         if (auditInfo) {
-            //             showDataCollect = 1;
-            //         } else {
-            //             let companyInfo = null;
-            //             if (accountInfo.company_id) {
-            //                 companyInfo = yield this.service.datacollectAudit.getDataByCondition({
-            //                     pid: projectData.id,
-            //                     company_id: accountInfo.company_id,
-            //                 });
-            //             } else {
-            //                 const cuInfo = yield this.service.constructionUnit.getDataByCondition({
-            //                     pid: projectData.id,
-            //                     name: accountInfo.company,
-            //                 });
-            //                 if (cuInfo) {
-            //                     companyInfo = yield this.service.datacollectAudit.getDataByCondition({
-            //                         pid: projectData.id,
-            //                         company_id: cuInfo.id,
-            //                     });
-            //                     yield this.service.projectAccount.update({ company_id: cuInfo.id }, { id: accountInfo.id });
-            //                 }
-            //             }
-            //             if (companyInfo) {
-            //                 showDataCollect = 1;
-            //             } else {
-            //                 const grounpInfo = yield this.service.datacollectAudit.getGroupInfo(projectData.id, accountInfo.account_group);
-            //                 if (grounpInfo) {
-            //                     showDataCollect = 1;
-            //                 }
-            //             }
-            //         }
-            //     }
-            // }
-            // this.session.sessionProject.showDataCollect = showDataCollect;
-            // // 判断是否有权限查看支付审批
-            // let showPayment = 0;
-            // if (sessionUser.is_admin) {
-            //     showPayment = this.session.sessionProject.page_show.openPayment ? 1 : 0;
-            // } else {
-            //     if (this.session.sessionProject.page_show.openPayment) {
-            //         const auditInfo = yield this.service.subProjPermission.showPayment(sessionUser.accountId);
-            //         if (auditInfo) {
-            //             showPayment = 1;
-            //         }
-            //     }
-            // }
-            // this.session.sessionProject.showPayment = showPayment;
 
             // 同步消息
             yield this.service.notify.syncNotifyData();

+ 57 - 0
app/middleware/sub_project_check.js

@@ -49,6 +49,63 @@ module.exports = options => {
                 this.subProject.financialToUrl = 'transfer';
             }
 
+            // 判断是否有权限查看决策大屏
+            // const accountInfo = yield this.service.projectAccount.getDataById(this.session.sessionUser.accountId);
+            // const projectData = yield this.service.project.getDataById(this.session.sessionProject.id);
+            // let showDataCollect = 0;
+            // if (projectData.data_collect && this.subProject.page_show.openDataCollect) {
+            //     if (this.session.sessionUser.is_admin) {
+            //         showDataCollect = 1;
+            //     } else {
+            //         const auditInfo = yield this.service.datacollectAudit.getDataByCondition({ pid: projectData.id, uid: accountInfo.id });
+            //         if (auditInfo) {
+            //             showDataCollect = 1;
+            //         } else {
+            //             let companyInfo = null;
+            //             if (accountInfo.company_id) {
+            //                 companyInfo = yield this.service.datacollectAudit.getDataByCondition({
+            //                     pid: projectData.id,
+            //                     company_id: accountInfo.company_id,
+            //                 });
+            //             } else {
+            //                 const cuInfo = yield this.service.constructionUnit.getDataByCondition({
+            //                     pid: projectData.id,
+            //                     name: accountInfo.company,
+            //                 });
+            //                 if (cuInfo) {
+            //                     companyInfo = yield this.service.datacollectAudit.getDataByCondition({
+            //                         pid: projectData.id,
+            //                         company_id: cuInfo.id,
+            //                     });
+            //                     yield this.service.projectAccount.update({ company_id: cuInfo.id }, { id: accountInfo.id });
+            //                 }
+            //             }
+            //             if (companyInfo) {
+            //                 showDataCollect = 1;
+            //             } else {
+            //                 const grounpInfo = yield this.service.datacollectAudit.getGroupInfo(projectData.id, accountInfo.account_group);
+            //                 if (grounpInfo) {
+            //                     showDataCollect = 1;
+            //                 }
+            //             }
+            //         }
+            //     }
+            // }
+            // this.session.sessionProject.showDataCollect = showDataCollect;
+            // 判断是否有权限查看支付审批
+            let showPayment = 0;
+            if (this.session.sessionUser.is_admin) {
+                showPayment = this.subProject.page_show.openPayment ? 1 : 0;
+            } else {
+                if (this.subProject.page_show.openPayment) {
+                    const auditInfo = yield this.service.subProjPermission.showPayment(this.session.sessionUser.accountId, this.subProject.id);
+                    if (auditInfo) {
+                        showPayment = 1;
+                    }
+                }
+            }
+            this.subProject.showPayment = showPayment;
+
             if (this.helper.isAjax(this.request) || this.method === 'POST' || this.service.subProjPermission.checkViewPermission(this)) {
                 yield next;
             } else {

+ 5 - 4
app/service/sub_proj_permission.js

@@ -135,8 +135,9 @@ module.exports = app => {
             }
         }
 
-        async showSubTab(uid, type) {
-            const sql = `SELECT count(*) as count FROM ${this.tableName} WHERE ${type}_permission <> '' AND uid = ?`;
+        async showSubTab(uid, type, spid = null) {
+            const spidSql = spid ? ` AND spid = ${spid}` : '';
+            const sql = `SELECT count(*) as count FROM ${this.tableName} WHERE ${type}_permission <> '' AND uid = ?` + spidSql;
             const result = await this.db.queryOne(sql, [uid]);
             return result.count;
         }
@@ -146,8 +147,8 @@ module.exports = app => {
         async showFile(uid) {
             return await this.showSubTab(uid, 'file');
         }
-        async showPayment(uid) {
-            return await this.showSubTab(uid, 'payment');
+        async showPayment(uid, spid) {
+            return await this.showSubTab(uid, 'payment', spid);
         }
 
         parsePermission(data) {