doExport(){ this.exprotLoading = true; let params = {} this.preChangeRankService .getPreInvestRankingExport(params).subscribe(res=>{ this.downloadService.download(res, '预投入转化排名'); this.exprotLoading = false; }) }
时间: 2023-05-18 20:02:56 浏览: 88
这段代码是一个Angular组件中的一个方法,它通过调用preChangeRankService服务的getPreInvestRankingExport方法来获取数据,并通过downloadService服务下载数据。在下载数据之前,将exprotLoading设置为true,下载完成后将其设置为false。
相关问题
如何在以下代码中加入分页的功能 后端代码:@Query( "select approvalRecord from ApprovalRecord approvalRecord inner join ApprovalRecordItem approvalRecordItem on approvalRecord = approvalRecordItem.approvalRecord where approvalRecordItem.status <> 'AUDITING' and approvalRecordItem.createdBy.login = ?#{principal.username} order by approvalRecordItem.id desc" ) List<ApprovalRecord> findAuditedByCurrentUser(); @GetMapping("/approval-records/my-created") public List<ApprovalRecord> getAllCreatedApprovalRecords() { log.debug("REST request to get all getAllCreatedApprovalRecords"); return approvalRecordRepository.findByCreatedByIsCurrentUser(); } 前段代码: queryAuditing(req?: any): Observable<EntityArrayResponseType> { const options = createRequestOption(req); return this.http .get<IApprovalRecord[]>(`${this.resourceUrl}/my-auditing`, { params: options, observe: 'response' }) .pipe(map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res))); } loadAll(): void { this.approvalRecordService.queryAuditing().subscribe((res: HttpResponse<IApprovalRecord[]>) => { this.auditingApprovalRecords = res.body ?? []; });
您可以在后端代码中添加分页参数,如下所示:
```java
@Query("select approvalRecord from ApprovalRecord approvalRecord inner join ApprovalRecordItem approvalRecordItem on approvalRecord = approvalRecordItem.approvalRecord where approvalRecordItem.status <> 'AUDITING' and approvalRecordItem.createdBy.login = ?#{principal.username} order by approvalRecordItem.id desc")
List<ApprovalRecord> findAuditedByCurrentUser(Pageable pageable);
```
然后,在前端代码中将分页参数传递到后端,如下所示:
```typescript
queryAuditing(req?: any): Observable<EntityArrayResponseType> {
const options = createRequestOption(req);
return this.http.get<IApprovalRecord[]>(`${this.resourceUrl}/my-auditing`, { params: options, observe: 'response' })
.pipe(map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res)));
}
loadAll(page: number): void {
this.approvalRecordService.queryAuditing({ page }).subscribe((res: HttpResponse<IApprovalRecord[]>) => {
this.auditingApprovalRecords = res.body ?? [];
});
}
```
这样,您就可以在前端代码中通过传递 `page` 参数来进行分页了。
阅读全文