Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. <table class="table table-striped table-header-rotated" *ngIf="product.vin == old_VIN">
  2. <!-- Что-то такое? -->
  3. <thead>
  4. <tr>
  5. <!-- First column header is not rotated -->
  6. <th></th>
  7. <!-- Following headers are rotated -->
  8. <th class="rotate-45" *ngFor="let product of filter_product; let i=index;"><div><span>Договор {{i+1}}</span></div></th>
  9. </tr>
  10. </thead>
  11. <tbody>
  12. <tr>
  13. <td class="row-header">Договор №</td>
  14. <td *ngFor="let product of filter_product;">{{product.treaty_number}</td>
  15. </tr>
  16. <tr>
  17. <td class="row-header">Улучшение условий</td>
  18. <td *ngFor="let product of filter_product;">{{product.improving_conditions}</td>
  19. </tr>
  20. <tr>
  21. <td class="row-header">VIN</td>
  22. <td *ngFor="let product of filter_product;">{{product.vin}}</td>
  23. </tr>
  24. </tbody>
  25. </table>
  26.  
  27. <table class="table table-striped table-header-rotated">
  28. <!-- Что-то такое? -->
  29. <thead>
  30. <tr>
  31. <!-- First column header is not rotated -->
  32. <th></th>
  33. <!-- Following headers are rotated -->
  34. <th><div><span>Договор 1</span></div></th>
  35. <th><div><span>Договор 2</span></div></th>
  36. </tr>
  37. </thead>
  38. <tbody>
  39. <tr>
  40. <td class="row-header">Договор №</td>
  41. <td>2310-22</td>
  42. <td>1314-82</td>
  43. </tr>
  44. <tr>
  45. <td class="row-header">Улучшение условий</td>
  46. <td>Нет</td>
  47. <td>Нет</td>
  48. </tr>
  49. <tr>
  50. <td class="row-header">VIN</td>
  51. <td>X23254FSFS43</td>
  52. <td>X23254FSFS43</td>
  53. </tr>
  54. </tbody>
  55. </table>
  56.  
  57. @Pipe({name: 'groupBy'})
  58. export class GroupByPipe implements PipeTransform {
  59. transform(value: Array<any>, field: string): Array<any> {
  60. const groupedObj = value.reduce((prev, cur)=> {
  61. if(!prev[cur[field]]) {
  62. prev[cur[field]] = [cur];
  63. } else {
  64. prev[cur[field]].push(cur);
  65. }
  66. return prev;
  67. }, {});
  68. return Object.keys(groupedObj).map(key => ({ key, value: groupedObj[key] }));
  69. }
  70. }
  71.  
  72. table.table.table-striped.table-header-rotated(*ngFor="let products of filter_product | groupBy:'vin'")
  73. thead
  74. tr
  75. th
  76. th(*ngFor="let product of products.value; let i=index;") Договор {{ i + 1}}
  77. tbody
  78. tr
  79. td.row-header Договор №
  80. td(*ngFor="let product of products.value") {{ product.treaty_number }}
  81. tr
  82. td.row-header Улучшение условий
  83. td(*ngFor="let product of products.value") {{ product.improving_conditions }}
  84. tr
  85. td.row-header VIN
  86. td(*ngFor="let product of products.value") {{ product.vin }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement