Kaynağa Gözat

查询可选择的账号调整,单位显示根据可选择账号过滤

MaiXinRong 5 ay önce
ebeveyn
işleme
3f23f23719

+ 2 - 5
app/controller/advance_controller.js

@@ -86,16 +86,13 @@ module.exports = app => {
             if ((ctx.advance.status === auditConst.status.uncheck || ctx.advance.status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === ctx.advance.uid) {
                 // data.accountGroup = accountGroup;
                 // 获取所有项目参与者
-                const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                    where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                });
+                const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                 data.accountList = accountList;
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                 data.accountGroup = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { groupName: item.name, groupList };
-                });
+                }).filter(x => { return x.groupList.length > 0; });
                 data.auditorList = await ctx.service.advanceAudit.getAuditors(ctx.advance.id, ctx.advance.times);
             }
             // data.fileList = await ctx.service.advanceFile.getAdvanceFiles({ vid: ctx.advance.id });

+ 10 - 25
app/controller/change_controller.js

@@ -346,16 +346,13 @@ module.exports = app => {
                             responseData.data.spGroupList = await ctx.service.shenpiGroup.getGroupListByChangeType(ctx.tender.id, shenpiConst.sp_type.change, 'change');
                         } else {
                             // 获取所有项目参与者
-                            const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                                where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                                columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                            });
+                            const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                             responseData.data.accountList = accountList;
                             const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                             responseData.data.accountGroup = unitList.map(item => {
                                 const groupList = accountList.filter(item1 => item1.company === item.name);
                                 return { groupName: item.name, groupList };
-                            });
+                            }).filter(x => { return x.groupList.length > 0; });
                         }
                         break;
                     case 'get_shenpi_list':
@@ -508,15 +505,12 @@ module.exports = app => {
                 renderData.changeUnits = changeConst.units;
                 if (!change.readOnly || ctx.session.sessionUser.is_admin) {
                     // 获取所有项目参与者
-                    const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                        where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                        columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                    });
+                    const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                     renderData.accountList = accountList;
                     renderData.accountGroup = unitList.map(item => {
                         const groupList = accountList.filter(item1 => item1.company === item.name);
                         return { groupName: item.name, groupList };
-                    });
+                    }).filter(x => { return x.groupList.length > 0; });
                     // 获取公司列表
                     const companyList = await ctx.service.changeCompany.getAllDataByCondition({ where: { tid: ctx.tender.id } });
                     renderData.companyList = companyList;
@@ -2266,16 +2260,13 @@ module.exports = app => {
                 // if ((ctx.change.status === audit.changeProject.status.uncheck || ctx.change.status === audit.changeProject.status.back) && (ctx.session.sessionUser.accountId === ctx.change.uid || ctx.tender.isTourist)) {
                     // data.accountGroup = accountGroup;
                     // 获取所有项目参与者
-                const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                    where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                });
+                const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                 renderData.accountList = accountList;
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                 renderData.accountGroup = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { groupName: item.name, groupList };
-                });
+                }).filter(x => { return x.groupList.length > 0; });
                 // 获取固定审批流列表
                 if (ctx.tender.info.shenpi.change === shenpiConst.sp_status.gdspl) {
                     renderData.spGroupList = await ctx.service.shenpiGroup.getGroupListByChangeType(ctx.tender.id, shenpiConst.sp_type.change, 'changeProject');
@@ -3126,16 +3117,13 @@ module.exports = app => {
                 // if ((ctx.change.status === audit.changeApply.status.uncheck || ctx.change.status === audit.changeApply.status.checkNo || ctx.change.status === audit.changeApply.status.revise) && (ctx.session.sessionUser.accountId === ctx.change.uid || ctx.tender.isTourist)) {
                 // data.accountGroup = accountGroup;
                 // 获取所有项目参与者
-                const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                    where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                });
+                const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                 renderData.accountList = accountList;
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                 renderData.accountGroup = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { groupName: item.name, groupList };
-                });
+                }).filter(x => { return x.groupList.length > 0; });
                 // }
                 // 获取固定审批流列表
                 if (ctx.tender.info.shenpi.change === shenpiConst.sp_status.gdspl) {
@@ -3960,16 +3948,13 @@ module.exports = app => {
                 // if ((ctx.change.status === audit.changePlan.status.uncheck || ctx.change.status === audit.changePlan.status.checkNo || ctx.change.status === audit.changePlan.status.revise) && (ctx.session.sessionUser.accountId === ctx.change.uid || ctx.tender.isTourist)) {
                     // data.accountGroup = accountGroup;
                     // 获取所有项目参与者
-                const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                    where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                });
+                const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                 renderData.accountList = accountList;
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                 renderData.accountGroup = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { groupName: item.name, groupList };
-                });
+                }).filter(x => { return x.groupList.length > 0; });
                 // 获取固定审批流列表
                 if (ctx.tender.info.shenpi.change === shenpiConst.sp_status.gdspl) {
                     renderData.spGroupList = await ctx.service.shenpiGroup.getGroupListByChangeType(ctx.tender.id, shenpiConst.sp_type.change, 'changePlan');

+ 4 - 10
app/controller/construction_controller.js

@@ -47,15 +47,12 @@ module.exports = app => {
                 if (ctx.session.sessionUser.is_admin) {
                     const projectId = ctx.session.sessionProject.id;
                     // 获取所有项目参与者
-                    const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                        where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                        columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                    });
+                    const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                     const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: projectId } });
                     const accountGroupList = unitList.map(item => {
                         const groupList = accountList.filter(item1 => item1.company === item.name);
                         return { groupName: item.name, groupList };
-                    });
+                    }).filter(x => { return x.groupList.length > 0; });
                     renderData.accountList = accountList;
                     renderData.accountGroup = accountGroupList;
                 }
@@ -281,15 +278,12 @@ module.exports = app => {
                 if (ctx.session.sessionUser.accountId === logInfo.report_uid && logInfo.status === constructionConst.status.uncheck) {
                     const projectId = ctx.session.sessionProject.id;
                     // 获取所有项目参与者
-                    const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                        where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                        columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                    });
+                    const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                     const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: projectId } });
                     const accountGroupList = unitList.map(item => {
                         const groupList = accountList.filter(item1 => item1.company === item.name);
                         return { groupName: item.name, groupList };
-                    });
+                    }).filter(x => { return x.groupList.length > 0; });
                     renderData.accountList = accountList;
                     renderData.accountGroup = accountGroupList;
                 }

+ 7 - 16
app/controller/contract_controller.js

@@ -49,16 +49,13 @@ module.exports = app => {
                         t.income_yf_price = incomeList.reduce((total, item) => ctx.helper.add(total, item.yf_price), 0);
                     }
                 }
-                const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                    where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                });
+                const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                 renderData.accountList = accountList;
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({where: {pid: ctx.session.sessionProject.id}});
                 renderData.accountGroup = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { groupName: item.name, groupList };
-                });
+                }).filter(x => { return x.groupList.length > 0; });
                 // renderData.permissionConst = ctx.service.subProjPermission.PermissionConst;
                 renderData.categoryData = await this.ctx.service.category.getAllCategory(ctx.subProject);
                 renderData.companys = await this.ctx.service.constructionUnit.getAllDataByCondition({where: {pid: ctx.session.sessionProject.id}});
@@ -130,15 +127,12 @@ module.exports = app => {
                 if (ctx.session.sessionUser.is_admin) {
                     const projectId = ctx.session.sessionProject.id;
                     // 获取所有项目参与者
-                    const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                        where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                        columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                    });
+                    const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                     const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: projectId } });
                     const accountGroupList = unitList.map(item => {
                         const groupList = accountList.filter(item1 => item1.company === item.name);
                         return { groupName: item.name, groupList };
-                    });
+                    }).filter(x => { return x.groupList.length > 0; });
                     renderData.accountList = accountList;
                     renderData.accountGroup = accountGroupList;
                 }
@@ -229,16 +223,13 @@ module.exports = app => {
                     whiteList,
                 };
                 if (ctx.session.sessionUser.is_admin) {
-                    const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                        where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                        columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                    });
+                    const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                     renderData.accountList = accountList;
                     const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                     renderData.accountGroup = unitList.map(item => {
                         const groupList = accountList.filter(item1 => item1.company === item.name);
                         return { groupName: item.name, groupList };
-                    });
+                    }).filter(x => { return x.groupList.length > 0; });
                 }
                 await this.layout('contract/detail.ejs', renderData, 'contract/detail_modal.ejs');
             } catch (err) {
@@ -272,7 +263,7 @@ module.exports = app => {
                     const accountGroup = unitList.map(item => {
                         const groupList = contractAudits.filter(item1 => item1.company === item.name);
                         return { groupName: item.name, groupList };
-                    });
+                    }).filter(x => { return x.groupList.length > 0; });
                     responseData.data.contractAudits = contractAudits;
                     responseData.data.accountGroup = ctx.helper._.filter(accountGroup, function (item) {
                         return item.groupList.length > 0;

+ 4 - 10
app/controller/financial_controller.js

@@ -36,10 +36,7 @@ module.exports = app => {
                     auditConst,
                 };
                 renderData.projectList = await ctx.service.subProject.getSubProjectByFinancial(ctx.session.sessionProject.id, ctx.session.sessionUser.accountId, ctx.session.sessionUser.is_admin);
-                const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                    where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                });
+                const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                 for (const proj of renderData.projectList) {
                     const financialPermission = await ctx.service.financialAudit.getPermission(proj.id, ctx.session.sessionUser.accountId);
                     if (financialPermission.transfer_show) {
@@ -55,7 +52,7 @@ module.exports = app => {
                 renderData.accountGroup = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { groupName: item.name, groupList };
-                });
+                }).filter(x => { return x.groupList.length > 0; });
                 // renderData.permissionConst = ctx.service.subProjPermission.PermissionConst;
                 renderData.categoryData = await this.ctx.service.category.getAllCategory(ctx.subProject);
                 renderData.companys = await this.ctx.service.constructionUnit.getAllDataByCondition({where: {pid: ctx.session.sessionProject.id}});
@@ -620,10 +617,7 @@ module.exports = app => {
             filter.count[filter.status.checked] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.checked, filterTids, used);// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
             const payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, status, filterTids, used);
             // 获取所有项目参与者
-            const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                columns: ['id', 'account', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-            });
+            const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject, ['id', 'account', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile']);
             const payTenders = await ctx.service.financialPayTender.getAllDataByCondition({ where: { spid: ctx.subProject.id } });
             for (const t of tenders) {
                 const info = await ctx.service.tenderInfo.getDataByCondition({ tid: t.id });
@@ -687,7 +681,7 @@ module.exports = app => {
                 renderData.accountGroup = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { groupName: item.name, groupList };
-                });
+                }).filter(x => { return x.groupList.length > 0; });
                 renderData.auditType = auditConst.auditType;
                 renderData.shenpi = shenpiConst;
             }

+ 2 - 5
app/controller/ledger_controller.js

@@ -154,16 +154,13 @@ module.exports = app => {
                 if ((tender.data.ledger_status !== auditConst.status.checked && ctx.session.sessionUser.is_admin) ||
                     ((tender.data.ledger_status === auditConst.status.uncheck || tender.data.ledger_status === auditConst.status.checkNo) && tender.data.user_id === ctx.session.sessionUser.accountId)) {
                     // 获取所有项目参与者
-                    const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                        where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                        columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                    });
+                    const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                     renderData.accountList = accountList;
                     const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                     renderData.accountGroup = unitList.map(item => {
                         const groupList = accountList.filter(item1 => item1.company === item.name);
                         return { groupName: item.name, groupList };
-                    });
+                    }).filter(x => { return x.groupList.length > 0; });
                     renderData.auditorList = await ctx.service.ledgerAudit.getAuditors(tender.id, tender.data.ledger_times);
                 }
 

+ 2 - 5
app/controller/material_controller.js

@@ -311,16 +311,13 @@ module.exports = app => {
             if ((ctx.material.status === auditConst.status.uncheck || ctx.material.status === auditConst.status.checkNo) && (ctx.session.sessionUser.accountId === ctx.material.user_id || ctx.tender.isTourist) || ctx.session.sessionUser.is_admin) {
                 // data.accountGroup = accountGroup;
                 // 获取所有项目参与者
-                const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                    where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                });
+                const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                 data.accountList = accountList;
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                 data.accountGroup = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { groupName: item.name, groupList };
-                });
+                }).filter(x => { return x.groupList.length > 0; });
             }
             data.tenderMenu.back.children[0].url = '/tender/' + ctx.tender.id + '/measure/material';
             return data;

+ 2 - 5
app/controller/pay_controller.js

@@ -155,15 +155,12 @@ module.exports = app => {
                 const calcBase = this.ctx.service.phasePay.getPhasePayCalcBase(ctx.phasePay, ctx.tender.info);
                 const projectFunInfo = this.ctx.subProject.fun_rela;
                 const lastStage = await this.ctx.service.stage.getLastestCompleteStage(ctx.tender.id);
-                const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                    where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                });
+                const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                 const accountGroup = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { groupName: item.name, groupList };
-                });
+                }).filter(x => { return x.groupList.length > 0; });
                 // 是否已验证手机短信
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const renderData = {

+ 5 - 5
app/controller/payment_controller.js

@@ -56,7 +56,7 @@ module.exports = app => {
                     const accountGroupList = unitList.map(item => {
                         const groupList = accountList.filter(item1 => item1.company === item.name);
                         return { groupName: item.name, groupList };
-                    });
+                    }).filter(x => { return x.groupList.length > 0; });
                     // const accountGroupList = accountGroup.map((item, idx) => {
                     //     const groupList = accountList.filter(item => item.account_group === idx);
                     //     return { groupName: item, groupList };
@@ -512,7 +512,7 @@ module.exports = app => {
                     const accountGroupList = unitList.map(item => {
                         const groupList = accountList.filter(item1 => item1.company === item.name);
                         return { groupName: item.name, groupList };
-                    });
+                    }).filter(x => { return x.groupList.length > 0; });
                     renderData.accountGroup = accountGroupList;
                 }
                 await this.layout('payment/detail.ejs', renderData, 'payment/detail_modal.ejs');
@@ -722,7 +722,7 @@ module.exports = app => {
                 const accountGroupList = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { groupName: item.name, groupList };
-                });
+                }).filter(x => { return x.groupList.length > 0; });
                 const renderData = {
                     tender: ctx.paymentTender,
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.payment.process),
@@ -913,7 +913,7 @@ module.exports = app => {
                         const accountGroupList = unitList.map(item => {
                             const groupList = accountList.filter(item1 => item1.company === item.name);
                             return { groupName: item.name, groupList };
-                        });
+                        }).filter(x => { return x.groupList.length > 0; });
                         renderData.accountList = accountList;
                         renderData.accountGroup = accountGroupList;
                     }
@@ -1209,7 +1209,7 @@ module.exports = app => {
                     const accountGroupList = unitList.map(item => {
                         const groupList = accountList.filter(item1 => item1.company === item.name);
                         return { groupName: item.name, groupList };
-                    });
+                    }).filter(x => { return x.groupList.length > 0; });
                     renderData.accountGroup = accountGroupList;
                 }
                 await this.layout('payment_safe/index.ejs', renderData, 'payment_safe/modal.ejs');

+ 1 - 4
app/controller/report_archive_controller.js

@@ -101,10 +101,7 @@ module.exports = app => {
             // 获取用户权限
             const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
             // 获取所有项目参与者
-            const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-            });
+            const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
             const newAccountGroup = accountGroup.map((item, idx) => {
                 const groupList = accountList.filter(item => item.account_group === idx);
                 return { groupName: item, groupList };

+ 2 - 5
app/controller/revise_controller.js

@@ -341,15 +341,12 @@ module.exports = app => {
             renderData.historyRevise = [];
             // 添加审批人相关
             // renderData.accountGroup = accountGroup;
-            renderData.accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-            });
+            renderData.accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
             const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
             renderData.accountGroup = unitList.map(item => {
                 const groupList = renderData.accountList.filter(item1 => item1.company === item.name);
                 return { groupName: item.name, groupList };
-            });
+            }).filter(x => { return x.groupList.length > 0; });
             renderData.categoryData = await this.ctx.service.category.getAllCategory(ctx.subProject);
             renderData.preUrl = ctx.url.replace('/info', '');
             await this.layout('revise/info.ejs', renderData, 'revise/info_modal.ejs');

+ 2 - 5
app/controller/settle_controller.js

@@ -175,16 +175,13 @@ module.exports = app => {
             data.authMobile = pa.auth_mobile;
 
             // 获取所有项目参与者
-            const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-            });
+            const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
             data.accountList = accountList;
             const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
             data.accountGroup = unitList.map(item => {
                 const groupList = accountList.filter(item1 => item1.company === item.name);
                 return { groupName: item.name, groupList };
-            });
+            }).filter(x => { return x.groupList.length > 0; });
             return data;
         }
 

+ 2 - 5
app/controller/stage_controller.js

@@ -70,16 +70,13 @@ module.exports = app => {
             if (((ctx.stage.status === auditConst.status.uncheck || ctx.stage.status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === ctx.stage.user_id) || ctx.session.sessionUser.is_admin) {
                 // data.accountGroup = accountGroup;
                 // 获取所有项目参与者
-                const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                    where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                });
+                const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                 data.accountList = accountList;
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                 data.accountGroup = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { groupName: item.name, groupList };
-                });
+                }).filter(x => { return x.groupList.length > 0; });
             }
             data.tenderMenu.back.children[0].url = '/tender/' + ctx.tender.id + '/measure/stage';
 

+ 2 - 5
app/controller/sub_proj_controller.js

@@ -30,16 +30,13 @@ module.exports = app => {
                 renderData.budgetStd = await ctx.service.budgetStd.getDataByProjectId(ctx.session.sessionProject.id);
                 renderData.projectList = await ctx.service.subProject.getSubProject(ctx.session.sessionProject.id, ctx.session.sessionUser.accountId, ctx.session.sessionUser.is_admin);
                 renderData.tenderList = await ctx.service.tender.getManageTenderList(ctx.session.sessionProject.id);
-                const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                    where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                });
+                const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                 renderData.accountList = accountList;
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                 renderData.accountGroup = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { groupName: item.name, groupList };
-                });
+                }).filter(x => { return x.groupList.length > 0; });
                 renderData.permissionConst = ctx.service.subProjPermission.PermissionConst;
                 renderData.companys = await this.ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                 renderData.templates = await this.ctx.service.filingTemplateList.getAllTemplate(ctx.session.sessionProject.id);

+ 2 - 8
app/controller/sub_proj_setting_controller.js

@@ -303,10 +303,7 @@ module.exports = app => {
                 if (ctx.session.sessionUser.is_admin === 0) throw '没有访问权限';
                 const dataCollectAudits = await ctx.service.datacollectAudit.getList(ctx.subProject.project_id);
                 // 获取所有项目参与者
-                const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                    where: {project_id: ctx.session.sessionProject.id, enable: 1},
-                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                });
+                const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({where: {pid: ctx.session.sessionProject.id}});
                 const accountGroupList = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
@@ -451,10 +448,7 @@ module.exports = app => {
                 const categoryData = []; // await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
 
                 // 获取所有项目参与者
-                const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                    where: {project_id: ctx.session.sessionProject.id, enable: 1},
-                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                });
+                const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({where: {pid: ctx.session.sessionProject.id}});
                 const accountGroupList = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);

+ 5 - 11
app/controller/tender_controller.js

@@ -619,15 +619,12 @@ module.exports = app => {
                         t.permission = await ctx.service.tenderTourist.getTouristPermission(t);
                     }
                     // 获取所有项目参与者
-                    const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                        where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                        columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-                    });
+                    const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
                     const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                     const accountGroupList = unitList.map(item => {
                         const groupList = accountList.filter(item1 => item1.company === item.name);
                         return { groupName: item.name, groupList };
-                    });
+                    }).filter(x => { return x.groupList.length > 0; });
                     renderData.accountList = accountList;
                     renderData.accountGroup = accountGroupList;
                 }
@@ -966,15 +963,12 @@ module.exports = app => {
                 ctx.request.headers.referer ? ctx.redirect(ctx.request.headers.referer) : ctx.redirect('/list');
             }
             // 获取所有项目参与者
-            const accountList = await ctx.service.projectAccount.getAllDataByCondition({
-                where: { project_id: ctx.session.sessionProject.id, enable: 1 },
-                columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
-            });
+            const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
             const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
             const accountGroupList = unitList.map(item => {
                 const groupList = accountList.filter(item1 => item1.company === item.name);
                 return { groupName: item.name, groupList };
-            });
+            }).filter(x => { return x.groupList.length > 0; });
             // 获取固定审批流 or 固定终审
             const spConst = ctx.helper._.cloneDeep(shenpiConst);
             for (const sp of spConst.sp_lc) {
@@ -1192,7 +1186,7 @@ module.exports = app => {
                 renderData.accountGroup = unitList.map(item => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { groupName: item.name, groupList };
-                });
+                }).filter(x => { return x.groupList.length > 0; });
                 await this.layout('tender/cert.ejs', renderData, 'tender/cert_modal.ejs');
             } catch (err) {
                 this.log(err);

+ 9 - 0
app/service/project_account.js

@@ -1035,6 +1035,15 @@ module.exports = app => {
         async saveDskProjects(id, projects) {
             return await this.db.update(this.tableName, { id, dsk_projects: JSON.stringify(projects) });
         }
+
+        async getAllSubProjectAccount(subProject, columns) {
+            const defaultColumns = ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile', 'company_id'];
+            const columnsSql = columns
+                ? columns.map(x => { return 'pa.`' + x + '`'; }).join(', ')
+                : defaultColumns.map(x => { return 'pa.`' + x + '`'; }).join(', ');
+            const sql = `SELECT ${columnsSql} FROM ${this.ctx.service.subProjPermission.tableName} spp LEFT JOIN ${this.tableName} pa ON spp.uid = pa.id WHERE spp.spid = ? and pa.enable = 1`;
+            return await this.db.query(sql, [subProject.id]);
+        }
     }
 
     return ProjectAccount;