|  | @@ -596,31 +596,37 @@ module.exports = app => {
 | 
	
		
			
				|  |  |              if (!financialPermission.pay_show) {
 | 
	
		
			
				|  |  |                  throw '没有查看权限';
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            const tenders = await ctx.service.tender.getAllDataByCondition({ where: { spid: ctx.subProject.id }, columns: ['id', 'name'] });
 | 
	
		
			
				|  |  | +            const fptAudits = await ctx.service.financialPayTenderAudit.getAllDataByCondition({ where: { spid: ctx.subProject.id, uid: ctx.session.sessionUser.accountId } });
 | 
	
		
			
				|  |  | +            const fptAuditTids = ctx.helper._.map(fptAudits, 'tid');
 | 
	
		
			
				|  |  | +            const tenders = await ctx.service.tender.getAllDataByCondition({ where: { spid: ctx.subProject.id, id: fptAuditTids }, columns: ['id', 'name'] });
 | 
	
		
			
				|  |  |              const filter = JSON.parse(JSON.stringify(auditConst.financial.filter));
 | 
	
		
			
				|  |  | +            const filterTids = tid === null ? (ctx.session.sessionUser.is_admin ? null : fptAuditTids) : [tid];
 | 
	
		
			
				|  |  |              filter.count = [];
 | 
	
		
			
				|  |  | -            filter.count[filter.status.pending] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.pending, tid, used);// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
 | 
	
		
			
				|  |  | -            filter.count[filter.status.uncheck] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.uncheck, tid, used);// await ctx.service.change.checkingDatas(tender.id, ctx.session.sessionUser.accountId);
 | 
	
		
			
				|  |  | -            filter.count[filter.status.checking] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.checking, tid, used);// await ctx.service.change.checkedDatas(tender.id, ctx.session.sessionUser.accountId);
 | 
	
		
			
				|  |  | -            filter.count[filter.status.checked] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.checked, tid, used);// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
 | 
	
		
			
				|  |  | -            const payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, status, tid, used);
 | 
	
		
			
				|  |  | +            filter.count[filter.status.pending] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.pending, filterTids, used);// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
 | 
	
		
			
				|  |  | +            filter.count[filter.status.uncheck] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.uncheck, filterTids, used);// await ctx.service.change.checkingDatas(tender.id, ctx.session.sessionUser.accountId);
 | 
	
		
			
				|  |  | +            filter.count[filter.status.checking] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.checking, filterTids, used);// await ctx.service.change.checkedDatas(tender.id, ctx.session.sessionUser.accountId);
 | 
	
		
			
				|  |  | +            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 fptAudits = await ctx.service.financialPayTenderAudit.getAllDataByCondition({ where: { spid: ctx.subProject.id, uid: ctx.session.sessionUser.accountId, is_report: 1 } });
 | 
	
		
			
				|  |  | -            const fptAuditTids = ctx.helper._.map(fptAudits, 'tid');
 | 
	
		
			
				|  |  |              const payTenders = await ctx.service.financialPayTender.getAllDataByCondition({ where: { spid: ctx.subProject.id } });
 | 
	
		
			
				|  |  |              for (const t of tenders) {
 | 
	
		
			
				|  |  | +                const fptReportTids = ctx.helper._.map(ctx.helper._.filter(fptAudits, { is_report: 1 }), 'tid');
 | 
	
		
			
				|  |  |                  const info = await ctx.service.tenderInfo.getDataByCondition({ tid: t.id });
 | 
	
		
			
				|  |  |                  t.pay_account = info && info.pay_account ? JSON.parse(info.pay_account).project : '';
 | 
	
		
			
				|  |  |                  const pt = ctx.helper._.find(payTenders, { tid: t.id });
 | 
	
		
			
				|  |  |                  t.pt = pt ? pt : { id: 0, tid: t.id, name: '', bank: '', bank_account: '', contact: '', phone: '' };
 | 
	
		
			
				|  |  | -                if (ctx.session.sessionUser.is_admin || ctx.helper._.includes(fptAuditTids, t.id)) {
 | 
	
		
			
				|  |  | +                if (ctx.session.sessionUser.is_admin || ctx.helper._.includes(fptReportTids, t.id)) {
 | 
	
		
			
				|  |  |                      t.dealCode = info && info.deal_info ? JSON.parse(info.deal_info).dealCode : '';
 | 
	
		
			
				|  |  |                      const lastPay = await ctx.service.financialPay.getAllDataByCondition({ where: { spid: ctx.subProject.id, tid: t.id }, columns: ['code'], orders: [['id', 'desc']], limit: 1 });
 | 
	
		
			
				|  |  | -                    t.startNum = lastPay.length > 0 ? parseInt(lastPay[0].code.split('-')[2]) + 1 : 1;
 | 
	
		
			
				|  |  | +                    t.startNum = 1;
 | 
	
		
			
				|  |  | +                    if (lastPay.length > 0) {
 | 
	
		
			
				|  |  | +                        const startArray = lastPay[0].code.split('-');
 | 
	
		
			
				|  |  | +                        t.startNum = parseInt(startArray[startArray.length - 1]) + 1;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              for (const pay of payList) {
 |