Browse Source

优化筛选

ellisran 3 weeks ago
parent
commit
83949ccac5
2 changed files with 9 additions and 9 deletions
  1. 5 5
      app/controller/financial_controller.js
  2. 4 4
      app/service/financial_pay_stage.js

+ 5 - 5
app/controller/financial_controller.js

@@ -618,9 +618,9 @@ module.exports = app => {
             if (!userCompany) {
                 throw '请联系管理员添加用户所在单位信息';
             }
-            const userOrderList = await ctx.service.financialPayStage.getUserOrderList(ctx.subProject.id, userCompany ? userCompany.id : 0);
-            const userCompanyList = await ctx.service.financialPayStage.getUserCompanyList(ctx.subProject.id, userCompany ? userCompany.id : 0, unitList);
             const companyInfo = company ? ctx.helper._.find(unitList, { name: company }) : null;
+            const userOrderList = await ctx.service.financialPayStage.getUserOrderList(ctx.subProject.id, userCompany ? userCompany.id : 0, companyInfo ? companyInfo.id : null);
+            const userCompanyList = await ctx.service.financialPayStage.getUserCompanyList(ctx.subProject.id, userCompany ? userCompany.id : 0, unitList, qi);
             const payList = await ctx.service.financialPayStage.getListByStatus(ctx.subProject.id, companyInfo ? companyInfo.id : null, userCompany ? userCompany.id : 0, qi);
             const total = await ctx.service.financialPayStage.getCountByStatus(ctx.subProject.id, companyInfo ? companyInfo.id : null, userCompany ? userCompany.id : 0, qi);
             // 分页相关
@@ -1026,12 +1026,12 @@ module.exports = app => {
             if (!userCompany) {
                 throw '请联系管理员添加用户所在单位信息';
             }
-            const userOrderList = await ctx.service.financialPayStage.getUserOrderList(ctx.subProject.id, userCompany ? userCompany.id : 0);
-            const userCompanyList = await ctx.service.financialPayStage.getUserCompanyList(ctx.subProject.id, userCompany ? userCompany.id : 0, unitList);
+            const companyInfo = company ? ctx.helper._.find(unitList, { name: company }) : null;
+            const userCompanyList = await ctx.service.financialPayStage.getUserCompanyList(ctx.subProject.id, userCompany ? userCompany.id : 0, unitList, qi);
+            const userOrderList = await ctx.service.financialPayStage.getUserOrderList(ctx.subProject.id, userCompany ? userCompany.id : 0, companyInfo ? companyInfo.id : null);
             const userTenderList = await ctx.service.financialPay.getUserTenderList(ctx.subProject.id, ctx.session.sessionUser.accountId);
             let fpsidList = [];
             if (company || qi) {
-                const companyInfo = company ? ctx.helper._.find(unitList, { name: company }) : null;
                 const fpstageList = await ctx.service.financialPayStage.getListByStatus(ctx.subProject.id, companyInfo ? companyInfo.id : null, userCompany ? userCompany.id : 0, qi, 0);
                 fpsidList = ctx.helper._.map(fpstageList, 'id');
             }

+ 4 - 4
app/service/financial_pay_stage.js

@@ -30,12 +30,12 @@ module.exports = app => {
             return await this.db.queryOne(sql, sqlParam);
         }
 
-        async getUserCompanyList(spid, user_company_id, unitList) {
+        async getUserCompanyList(spid, user_company_id, unitList, qi = null) {
             let userCompanyList = [];
             if (this.ctx.session.sessionUser.is_admin) {
                 userCompanyList = unitList;
             } else {
-                let addSql = '';
+                let addSql = qi ? ' AND a.order = ' + qi : '';
                 let notAdminSql = '';
                 if (!this.ctx.session.sessionUser.is_admin) {
                     notAdminSql += '(a.id in (SELECT fpsid FROM ' + this.ctx.service.financialPay.tableName + ' WHERE uid = ' + this.ctx.session.sessionUser.accountId + ' GROUP BY fpsid)' +
@@ -60,8 +60,8 @@ module.exports = app => {
             return userCompanyList;
         }
 
-        async getUserOrderList(spid, user_company_id) {
-            let addSql = '';
+        async getUserOrderList(spid, user_company_id, company_id = null) {
+            let addSql = company_id ? ' AND a.company_id = ' + company_id : '';
             let notAdminSql = '';
             if (!this.ctx.session.sessionUser.is_admin) {
                 notAdminSql += '(a.id in (SELECT fpsid FROM ' + this.ctx.service.financialPay.tableName + ' WHERE uid = ' + this.ctx.session.sessionUser.accountId + ' GROUP BY fpsid)' +