|  | @@ -732,6 +732,33 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                  const dealBills = await ctx.service.dealBills.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });
 | 
	
		
			
				|  |  |                  // const settleStatus = ctx.service.settle.settleStatus;
 | 
	
		
			
				|  |  |                  const settleBills = readySettle ? await this.ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: readySettle.id } }) : [];
 | 
	
		
			
				|  |  | +                const stages = data.from === 'revise' ? await ctx.service.stage.getAllDataByCondition({
 | 
	
		
			
				|  |  | +                    where: { tid: ctx.tender.id },
 | 
	
		
			
				|  |  | +                    orders: [['order', 'desc']],
 | 
	
		
			
				|  |  | +                }) : [];
 | 
	
		
			
				|  |  | +                if (stages.length > 0) {
 | 
	
		
			
				|  |  | +                    const usedBills = [], usedPos = [];
 | 
	
		
			
				|  |  | +                    for (const s of stages) {
 | 
	
		
			
				|  |  | +                        if (s.status === audit.stage.status.checked) {
 | 
	
		
			
				|  |  | +                            const usedPreBills = await ctx.service.stageBillsFinal.getUsedBills(ctx.tender.id, s.order);
 | 
	
		
			
				|  |  | +                            usedBills.push(...usedPreBills);
 | 
	
		
			
				|  |  | +                            const usedPrePos = await ctx.service.stagePosFinal.getUsedPos(ctx.tender.id, s.order);
 | 
	
		
			
				|  |  | +                            usedPos.push(...usedPrePos);
 | 
	
		
			
				|  |  | +                            break;
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            const usedCurBills = await ctx.service.stageBills.getStageUsedBills(ctx.tender.id, s.id);
 | 
	
		
			
				|  |  | +                            usedBills.push(...usedCurBills);
 | 
	
		
			
				|  |  | +                            const usedCurPos = await ctx.service.stagePos.getStageUsedPos(ctx.tender.id, s.id);
 | 
	
		
			
				|  |  | +                            usedPos.push(...usedCurPos);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    for (const b of ledgerData) {
 | 
	
		
			
				|  |  | +                        b.used = usedBills.indexOf(b.id) >= 0;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    for (const p of posData) {
 | 
	
		
			
				|  |  | +                        p.used = usedPos.indexOf(p.id) >= 0;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |                  ctx.helper.assignRelaData(ledgerData, [
 | 
	
		
			
				|  |  |                      { data: settleBills, fields: ['settle_status'], prefix: '', relaId: 'lid' },
 | 
	
		
			
				|  |  |                  ]);
 |