ellisran 2 hete
szülő
commit
cdf3b249d6

+ 6 - 2
app/controller/financial_controller.js

@@ -1179,10 +1179,14 @@ module.exports = app => {
             const categoryData = await this.ctx.service.category.getAllCategory(ctx.subProject);
             const tenders = hadTender ? await ctx.service.tender.getAllDataByCondition({ where: tenderCondition, columns: ['id', 'name', 'category'] }) : [];
             const transfersCondition = { spid: ctx.subProject.id };
+            let notTids = false;
             if (filterTids) {
+                if (filterTids.length === 0) {
+                    notTids = true;
+                }
                 transfersCondition.tid = filterTids;
             }
-            const allTransfers = await ctx.service.financialTransferTender.getAllDataByCondition({ where: transfersCondition });
+            const allTransfers = !notTids ? await ctx.service.financialTransferTender.getAllDataByCondition({ where: transfersCondition }) : [];
             const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject, ['id', 'account', 'name', 'company', 'company_id', 'role', 'enable', 'is_admin', 'account_group', 'mobile']);
             const user = accountList.find(item => item.id === ctx.session.sessionUser.accountId) || null;
             const userCompany = user ? ctx.helper._.find(unitList, { name: user.company }) : null;
@@ -1361,7 +1365,7 @@ module.exports = app => {
                 await this.layout('financial/pay_detail.ejs', renderData, 'financial/pay_detail_modal.ejs');
             } catch (err) {
                 this.log(err);
-                ctx.redirect(`/sp/${ctx.subProject.id}/financial/pay`);
+                ctx.redirect(`/sp/${ctx.subProject.id}/financial/pay/stage`);
             }
         }
 

+ 1 - 1
app/middleware/sub_project_check.js

@@ -53,7 +53,7 @@ module.exports = options => {
             if (financialPermission.transfer_show) {
                 this.subProject.financialToUrl = 'transfer';
             } else if (financialPermission.pay_show) {
-                this.subProject.financialToUrl = 'pay';
+                this.subProject.financialToUrl = 'pay/stage';
             } else if (!financialPermission.transfer_show && !financialPermission.pay_show) {
                 this.subProject.financialToUrl = 'transfer';
             }

+ 7 - 5
app/service/financial_pay.js

@@ -46,14 +46,16 @@ module.exports = app => {
                 fpsid = fpsid instanceof Array ? fpsid : [fpsid];
                 addSql += ' AND a.fpsid in (' + this.ctx.helper.getInArrStrSqlFilter(fpsid) + ')';
             } else if (!this.ctx.session.sessionUser.is_admin && this._.includes([0, 5, 3], status)) {
-                addSql += ` AND (a.id in(SELECT b.fpid FROM ${this.ctx.service.financialPayAudit.tableName} as b WHERE b.spid = '${spid}' AND b.aid = ${this.ctx.session.sessionUser.accountId}) OR a.uid = ${this.ctx.session.sessionUser.accountId}`;
+                addSql += ` AND (a.id in (SELECT b.fpid FROM ${this.ctx.service.financialPayAudit.tableName} as b WHERE b.spid = '${spid}' AND b.aid = ${this.ctx.session.sessionUser.accountId}) OR a.uid = ${this.ctx.session.sessionUser.accountId}`;
                 if (allfpsid !== null) {
-                    allfpsid = fpsid instanceof Array ? allfpsid : [allfpsid];
-                    addSql += ' OR a.fpsid in (' + this.ctx.helper.getInArrStrSqlFilter(allfpsid) + ')';
+                    allfpsid = allfpsid instanceof Array ? allfpsid : [allfpsid];
+                    console.log('allfpsid', allfpsid);
+                    addSql += allfpsid.length > 0 ? ' OR a.fpsid in (' + this.ctx.helper.getInArrStrSqlFilter(allfpsid) + ')' : '';
                 }
                 addSql += ')';
             }
             if (tid !== null) {
+                console.log(tid);
                 if (tid.length === 0) {
                     return [];
                 }
@@ -131,8 +133,8 @@ module.exports = app => {
             } else if (!this.ctx.session.sessionUser.is_admin && this._.includes([0, 5, 3], status)) {
                 addSql += ` AND (a.id in(SELECT b.fpid FROM ${this.ctx.service.financialPayAudit.tableName} as b WHERE b.spid = '${spid}' AND b.aid = ${this.ctx.session.sessionUser.accountId}) OR a.uid = ${this.ctx.session.sessionUser.accountId}`;
                 if (allfpsid !== null) {
-                    allfpsid = fpsid instanceof Array ? allfpsid : [allfpsid];
-                    addSql += ' OR a.fpsid in (' + this.ctx.helper.getInArrStrSqlFilter(allfpsid) + ')';
+                    allfpsid = allfpsid instanceof Array ? allfpsid : [allfpsid];
+                    addSql += allfpsid.length > 0 ? ' OR a.fpsid in (' + this.ctx.helper.getInArrStrSqlFilter(allfpsid) + ')' : '';
                 }
                 addSql += ')';
             }