| 
					
				 | 
			
			
				@@ -62,12 +62,21 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          * @return {void} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         async getDataByTenderIdAndStageId(tid, sid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sql = 'SELECT att.id, att.lid, att.uid, att.filename, att.fileext, att.filesize, att.re_upload, att.remark, att.in_time,' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const { ctx } = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const sql = 'SELECT att.id, att.lid, att.uid, att.filepath, att.filename, att.fileext, att.filesize, att.re_upload, att.remark, att.in_time,' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ' pa.name as `username`, leg.name as `lname`, leg.code as `code`, leg.ledger_id as `ledger_id`, leg.b_code as `b_code`' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ' FROM ?? AS att,?? AS pa,?? AS leg' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ' WHERE leg.id = att.lid AND pa.id = att.uid AND att.tid = ? AND att.sid = ? ORDER BY att.id DESC'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.ctx.service.ledger.tableName, tid, sid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return await this.db.query(sql, sqlParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const result = await this.db.query(sql, sqlParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return result.map(item => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (!ctx.helper.canPreview(item.fileext)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    item.filepath = `/tender/${ctx.tender.id}/measure/stage/${ctx.params.order}/download/file/${item.id}`; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    item.filepath = '/' + item.filepath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return item; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -77,12 +86,16 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          * @return {void} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         async getDataByFid(id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sql = 'SELECT att.id, att.lid, att.uid, att.filename, att.re_upload, att.fileext, att.filesize, att.remark, att.in_time,' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const { ctx } = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const sql = 'SELECT att.id, att.lid, att.uid, att.filepath, att.filename, att.re_upload, att.fileext, att.filesize, att.remark, att.in_time,' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ' pa.name as `username`, leg.name as `lname`, leg.code as `code`, leg.ledger_id as `ledger_id`,leg.b_code as `b_code`' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ' FROM ?? AS att,?? AS pa,?? AS leg' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ' WHERE leg.id = att.lid AND pa.id = att.uid AND att.id = ? ORDER BY att.in_time DESC'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.ctx.service.ledger.tableName, id]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return await this.db.queryOne(sql, sqlParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const result = await this.db.queryOne(sql, sqlParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!ctx.helper.canPreview(result.fileext)) result.filepath = `/tender/${ctx.tender.id}/measure/stage/${ctx.params.order}/download/file/${result.id}`; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else result.filepath = '/' + result.filepath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |