1 pièce(s) jointe(s)
[Angular 2] Totaux d'un tableau
Bonjour,
Je veux calculer des totaux d'un tableau obtenu avec *ngFor d'angular 4. Je me demande s'il n'y a pas un truc sur angular 4 qui me permet de le faire sans forcement passé par une lib externe.
Voici un extrait du tableau.
Pièce jointe 320986
Voici le template HTML.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
| <div>
<h2>
<span jhiTranslate="appTransfetApp.transaction.home.title">Transactions</span>
<button class="btn btn-primary float-right create-transaction" [routerLink]="['/', { outlets: { popup: ['transaction-new'] } }]">
<span class="fa fa-plus"></span>
<span jhiTranslate="appTransfetApp.transaction.home.createLabel">
Create new Transaction
</span>
</button>
</h2>
<jhi-alert></jhi-alert>
<div class="row">
</div>
<br/>
<div class="" *ngIf="transactions">
<table class="table table-striped table-bordered table-responsive">
<thead>
<tr>
<th colspan="5"></th>
<th [colSpan]="unities?.length" class="text-center"><span>Entré</span></th>
<th [colSpan]="unities?.length" class="text-center"><span >Sortie</span></th>
<th [colSpan]="unities?.length" class="text-center"><span >Frais</span></th>
<th [colSpan]="unities?.length" class="text-center"><span >Payement Provenance</span></th>
<th [colSpan]="unities?.length" class="text-center"><span >Payement Destination</span></th>
<th [colSpan]="unities?.length" class="text-center"><span >Part du Bureau</span></th>
<!-- <th [colSpan]="unities?.length" class="text-center"><span >Payement</span></th> -->
<th colspan="2" class="text-center"><span >Agences</span></th>
</tr>
<tr>
<th><span jhiTranslate="appTransfetApp.transaction.dateCreated">Date Created</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.codeEntre">Code Entre</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.clientEnvoyeur">Client Envoyeur</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.clientReceveur">Client Receveur</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.codeSortie">Code Sortie</span></th>
<th *ngFor="let u of unities ;trackBy: trackId">
<span>{{u.uniteCode}}</span>
</th>
<th *ngFor="let u of unities ;trackBy: trackId">
<span>{{u.uniteCode}}</span>
</th>
<th *ngFor="let u of unities ;trackBy: trackId">
<span>{{u.uniteCode}}</span>
</th>
<th *ngFor="let u of unities ;trackBy: trackId">
<span>{{u.uniteCode}}</span>
</th>
<th *ngFor="let u of unities ;trackBy: trackId">
<span>{{u.uniteCode}}</span>
</th>
<th *ngFor="let u of unities ;trackBy: trackId">
<span>{{u.uniteCode}}</span>
</th>
<th><span jhiTranslate="appTransfetApp.transaction.agenceEnvoyeur">Provenance</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.agenceReceveur">Destination</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.state">State</span></th>
<!-- <th><span jhiTranslate="appTransfetApp.transaction.montantEnvoyer">Montant Envoyer</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.montantRemis">Montant Remis</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.tauxFrais">Taux Frais</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.montantFrais">Montant Frais</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.userCreated">User Created</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.userValidated">User Validated</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.userCanceled">User Canceled</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.userUpdated">User Updated</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.userPaid">User Paid</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.uniteEnvoi">Unite Envoi</span></th>
<th><span jhiTranslate="appTransfetApp.transaction.uniteRecu">Unite Recu</span></th>
<th></th> -->
</tr>
</thead>
<tbody>
<tr *ngFor="let transaction of transactions ;trackBy: trackId">
<td>{{transaction.dateCreated | date:'shortDate'}}</td>
<td>{{transaction.codeEntre}}</td>
<td >
<div class="text-nowrap" *ngIf="transaction.clientEnvoyeur">
{{transaction.clientEnvoyeur?.clientName}} {{transaction.clientEnvoyeur?.clientPhone}}
</div>
</td>
<td >
<div class="text-nowrap" *ngIf="transaction.clientReceveur">
{{transaction.clientReceveur?.clientName}} {{transaction.clientReceveur?.clientPhone}}
</div>
</td>
<td>{{transaction.codeSortie}}</td>
<td *ngFor="let u of unities ;trackBy: trackI">
<span *ngIf="transaction.uniteEnvoi?.id == u.id" [class]="'entre_'+transaction.uniteEnvoi.uniteCode">{{transaction.montantEnvoyer}}</span>
</td>
<td *ngFor="let u of unities ;trackBy: trackI">
<span *ngIf="transaction.uniteRecu?.id == u.id" [class]="'sortie_'+transaction.uniteEnvoi.uniteCode">{{transaction.montantRemis}}</span>
</td>
<td *ngFor="let u of unities ;trackBy: trackI">
<span *ngIf="transaction.uniteEnvoi?.id == u.id" [class]="'frais_'+transaction.uniteEnvoi.uniteCode">{{transaction.montantFrais}}</span>
</td>
<td *ngFor="let u of unities ;trackBy: trackI">
<span *ngIf="transaction.uniteEnvoi?.id == u.id" [class]="'pe_'+transaction.uniteEnvoi.uniteCode">
{{ transaction.agenceEnvoyeur.tauxEnvoi* transaction.montantFrais/100}}
</span>
</td>
<td *ngFor="let u of unities ;trackBy: trackI">
<span *ngIf="transaction.uniteEnvoi?.id == u.id" [class]="'ps_'+transaction.uniteEnvoi.uniteCode">
{{ transaction.agenceReceveur.tauxReception* transaction.montantFrais/100}}
</span>
</td>
<td *ngFor="let u of unities ;trackBy: trackI" >
<span *ngIf="transaction.uniteEnvoi?.id == u.id" [class]="'bureau_'+transaction.uniteEnvoi.uniteCode">
{{ transaction.montantFrais - ((transaction.agenceEnvoyeur.tauxEnvoi* transaction.montantFrais/100) + (transaction.agenceReceveur.tauxReception* transaction.montantFrais/100))}}
</span>
</td>
<td>
<div *ngIf="transaction.agenceEnvoyeur">
{{transaction.agenceEnvoyeur?.agenceName}}
</div>
</td>
<td>
<div *ngIf="transaction.agenceReceveur">
{{transaction.agenceReceveur?.agenceName}}
</div>
</td>
<td jhiTranslate="{{'appTransfetApp.TransactionState.' + transaction.state}}">{{transaction.state}}</td>
<!--<td class="text-right">
<div class="btn-group flex-btn-group-container">
<button type="submit"
[routerLink]="['../transaction', transaction.id ]"
class="btn btn-info btn-sm">
<span class="fa fa-eye"></span>
<span class="hidden-md-down" jhiTranslate="entity.action.view">View</span>
</button>
<button type="submit"
[routerLink]="['/', { outlets: { popup: 'transaction/'+ transaction.id + '/edit'} }]"
replaceUrl="true"
class="btn btn-primary btn-sm">
<span class="fa fa-pencil"></span>
<span class="hidden-md-down" jhiTranslate="entity.action.edit">Edit</span>
</button>
<button type="submit"
[routerLink]="['/', { outlets: { popup: 'transaction/'+ transaction.id + '/delete'} }]"
replaceUrl="true"
class="btn btn-danger btn-sm">
<span class="fa fa-remove"></span>
<span class="hidden-md-down" jhiTranslate="entity.action.delete">Delete</span>
</button>
</div>
</td> -->
</tr>
<tr>
<th colspan="5"><span class="pull-right">TOTAUX</span></th>
<td *ngFor="let u of unities ;trackBy: trackI">
</td>
<td *ngFor="let u of unities ;trackBy: trackI">
</td>
<td *ngFor="let u of unities ;trackBy: trackI">
</td>
<td *ngFor="let u of unities ;trackBy: trackI">
</td>
<td *ngFor="let u of unities ;trackBy: trackI">
</td>
<td *ngFor="let u of unities ;trackBy: trackI">
</td>
<td *ngFor="let u of unities ;trackBy: trackI">
</td>
</tr>
</tbody>
</table>
</div>
</div> |
Bien à vous.