From 6b067e058cfdcf980bfd6297b13eb6177c163135 Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Tue, 25 Nov 2025 09:17:44 +0100 Subject: [PATCH] updated stock table --- .../quotation-table/quotation-table.html | 2 + .../components/stock-table/stock-table.html | 71 +++++++---- src/app/components/stock-table/stock-table.ts | 111 ++++++++++++------ .../supplier-table/supplier-table.html | 2 + src/app/interfaces/stock.interface.ts | 1 + src/app/pages/quotation/quotation.html | 2 +- src/app/pages/stock/stock.html | 21 +++- src/app/pages/stock/stock.ts | 11 ++ src/app/pages/supplier/supplier.html | 2 +- 9 files changed, 154 insertions(+), 69 deletions(-) diff --git a/src/app/components/quotation-table/quotation-table.html b/src/app/components/quotation-table/quotation-table.html index 3ddfe1e..0d2ac21 100644 --- a/src/app/components/quotation-table/quotation-table.html +++ b/src/app/components/quotation-table/quotation-table.html @@ -25,6 +25,7 @@ Réference Nom + Prix Quantité Action @@ -34,6 +35,7 @@ {{data.quotationProductReference}} {{data.quotationProductName}} + XX.XX€ {{data.quotationProductQuantity}}
diff --git a/src/app/components/stock-table/stock-table.html b/src/app/components/stock-table/stock-table.html index 7c33279..2ea8bf2 100644 --- a/src/app/components/stock-table/stock-table.html +++ b/src/app/components/stock-table/stock-table.html @@ -1,37 +1,58 @@ - + - - Nom - Réference - Nec - Calibre - Poid - Durée - Quantité - Limite - Action - + + + + + Nom + Référence + Nec + Calibre + Poids + Durée + Quantité + Limite + Action + + - @for (data of basicTable.data; track data) { + @for (data of rowSelectionTable.data; track data.id) { - {{data.product.name}} - {{data.product.reference}} - {{data.product.nec}} - {{data.product.caliber}} - {{data.product.weight}} - {{data.product.duration}} - {{data.quantity}} - {{data.product.minimalQuantity}} + + + + + {{ data.product.name }} + {{ data.product.reference }} + {{ data.product.nec }} + {{ data.product.caliber }} + {{ data.product.weight }} + {{ data.product.duration }} + {{ data.quantity }} + {{ data.product.minimalQuantity }} +
- + -
- -
+
diff --git a/src/app/components/stock-table/stock-table.ts b/src/app/components/stock-table/stock-table.ts index 65bda28..1aff173 100644 --- a/src/app/components/stock-table/stock-table.ts +++ b/src/app/components/stock-table/stock-table.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import {Component, output} from '@angular/core'; import {StockInfo} from "../../interfaces/stock.interface"; import {NzTableComponent} from "ng-zorro-antd/table"; import {ModalNav} from "../modal-nav/modal-nav"; @@ -6,54 +6,89 @@ import {NzIconDirective} from "ng-zorro-antd/icon"; import {StockForm} from "../stock-form/stock-form"; import {NzDividerComponent} from "ng-zorro-antd/divider"; import {ProductTable} from "../product-table/product-table"; +import {FormsModule} from "@angular/forms"; +import {NzCheckboxComponent} from "ng-zorro-antd/checkbox"; +import {NzButtonComponent} from "ng-zorro-antd/button"; @Component({ - selector: 'app-stock-table', + selector: 'app-stock-table', imports: [ NzTableComponent, ModalNav, NzIconDirective, StockForm, - NzDividerComponent + NzDividerComponent, + FormsModule, + NzCheckboxComponent, + NzButtonComponent, ], - templateUrl: './stock-table.html', - styleUrl: './stock-table.css', + templateUrl: './stock-table.html', + styleUrl: './stock-table.css', }) + export class StockTable { listOfData: StockInfo[] = [ - { product: ProductTable.listOfProducts[0], quantity: 10 }, - { product: ProductTable.listOfProducts[1], quantity: 5 }, - { product: ProductTable.listOfProducts[2], quantity: 8 }, - { product: ProductTable.listOfProducts[3], quantity: 12 }, - { product: ProductTable.listOfProducts[4], quantity: 7 }, - { product: ProductTable.listOfProducts[5], quantity: 15 }, - { product: ProductTable.listOfProducts[6], quantity: 9 }, - { product: ProductTable.listOfProducts[7], quantity: 6 }, - { product: ProductTable.listOfProducts[8], quantity: 11 }, - { product: ProductTable.listOfProducts[9], quantity: 14 }, - { product: ProductTable.listOfProducts[10], quantity: 7 }, - { product: ProductTable.listOfProducts[11], quantity: 13 }, - { product: ProductTable.listOfProducts[12], quantity: 10 }, - { product: ProductTable.listOfProducts[13], quantity: 5 }, - { product: ProductTable.listOfProducts[14], quantity: 8 }, - { product: ProductTable.listOfProducts[15], quantity: 12 }, - { product: ProductTable.listOfProducts[16], quantity: 9 }, - { product: ProductTable.listOfProducts[17], quantity: 6 }, - { product: ProductTable.listOfProducts[18], quantity: 11 }, - { product: ProductTable.listOfProducts[19], quantity: 14 }, - { product: ProductTable.listOfProducts[20], quantity: 7 }, - { product: ProductTable.listOfProducts[21], quantity: 13 }, - { product: ProductTable.listOfProducts[22], quantity: 10 }, - { product: ProductTable.listOfProducts[23], quantity: 5 }, - { product: ProductTable.listOfProducts[24], quantity: 8 }, - { product: ProductTable.listOfProducts[25], quantity: 12 }, - { product: ProductTable.listOfProducts[26], quantity: 9 }, - { product: ProductTable.listOfProducts[27], quantity: 6 }, - { product: ProductTable.listOfProducts[28], quantity: 11 }, - { product: ProductTable.listOfProducts[29], quantity: 14 }, + { id: 1, product: ProductTable.listOfProducts[0], quantity: 10 }, + { id: 2, product: ProductTable.listOfProducts[1], quantity: 5 }, + { id: 3, product: ProductTable.listOfProducts[2], quantity: 8 }, + { id: 4, product: ProductTable.listOfProducts[3], quantity: 12 }, + { id: 5, product: ProductTable.listOfProducts[4], quantity: 7 }, + { id: 6, product: ProductTable.listOfProducts[5], quantity: 15 }, + { id: 7, product: ProductTable.listOfProducts[6], quantity: 9 }, + { id: 8, product: ProductTable.listOfProducts[7], quantity: 6 }, + { id: 9, product: ProductTable.listOfProducts[8], quantity: 11 }, + { id: 10, product: ProductTable.listOfProducts[9], quantity: 14 }, + { id: 11, product: ProductTable.listOfProducts[10], quantity: 7 }, + { id: 12, product: ProductTable.listOfProducts[11], quantity: 13 }, + { id: 13, product: ProductTable.listOfProducts[12], quantity: 10 }, + { id: 14, product: ProductTable.listOfProducts[13], quantity: 5 }, ]; - delete(){ - return + checked = false; + indeterminate = false; + setOfCheckedId = new Set(); + + get hasSelection(): boolean { + return this.setOfCheckedId.size > 0; } -} + + + updateCheckedSet(id: number, checked: boolean): void { + if (checked) this.setOfCheckedId.add(id); + else this.setOfCheckedId.delete(id); + } + + onItemChecked(id: number, checked: boolean): void { + this.updateCheckedSet(id, checked); + this.refreshCheckedStatus(); + } + + onAllChecked(checked: boolean): void { + this.listOfData.forEach(item => this.updateCheckedSet(item.id, checked)); + this.refreshCheckedStatus(); + } + + refreshCheckedStatus(): void { + const total = this.listOfData.length; + const checkedCount = this.setOfCheckedId.size; + + this.checked = checkedCount === total; + this.indeterminate = checkedCount > 0 && checkedCount < total; + + // 🔥 Émission asynchrone -> corrige le retard d’affichage + setTimeout(() => { + this.selectionChange.emit(this.hasSelection); + }); + } + + + onCurrentPageDataChange($event: StockInfo[]): void { + this.listOfData = $event; + this.refreshCheckedStatus(); + } + + delete() { + return; + } + selectionChange = output() +} \ No newline at end of file diff --git a/src/app/components/supplier-table/supplier-table.html b/src/app/components/supplier-table/supplier-table.html index 8724470..b26448e 100644 --- a/src/app/components/supplier-table/supplier-table.html +++ b/src/app/components/supplier-table/supplier-table.html @@ -28,6 +28,7 @@ Nom Référence + Prix @@ -35,6 +36,7 @@ {{product.name}} {{product.reference}} + xx.x€ } diff --git a/src/app/interfaces/stock.interface.ts b/src/app/interfaces/stock.interface.ts index f21c99f..5d9439d 100644 --- a/src/app/interfaces/stock.interface.ts +++ b/src/app/interfaces/stock.interface.ts @@ -1,6 +1,7 @@ import {ProductInfo} from "./product.interface"; export interface StockInfo { + id: number; product: ProductInfo; quantity: number; } \ No newline at end of file diff --git a/src/app/pages/quotation/quotation.html b/src/app/pages/quotation/quotation.html index 6fa1e5b..2edf3b6 100644 --- a/src/app/pages/quotation/quotation.html +++ b/src/app/pages/quotation/quotation.html @@ -7,7 +7,7 @@
-voir prix dans les produits +
diff --git a/src/app/pages/stock/stock.html b/src/app/pages/stock/stock.html index e1edf81..97fcb2b 100644 --- a/src/app/pages/stock/stock.html +++ b/src/app/pages/stock/stock.html @@ -1,8 +1,21 @@ -
- +
+ @if (hasSelection) { + + + + + + + + } + +
+ +
-faire ici la creation de bon de commande avec case a cocher
- +
\ No newline at end of file diff --git a/src/app/pages/stock/stock.ts b/src/app/pages/stock/stock.ts index 5b07d92..6d7e544 100644 --- a/src/app/pages/stock/stock.ts +++ b/src/app/pages/stock/stock.ts @@ -1,17 +1,28 @@ import { Component } from '@angular/core'; import {StockTable} from "../../components/stock-table/stock-table"; import {Search} from "../../components/search/search"; +import {ModalButton} from "../../components/modal-button/modal-button"; +import {PurchaseOrderForm} from "../../components/purchase-order-form/purchase-order-form"; +import {QuotationForm} from "../../components/quotation-form/quotation-form"; @Component({ selector: 'app-stock', imports: [ StockTable, Search, + ModalButton, + PurchaseOrderForm, + QuotationForm, ], templateUrl: './stock.html', styleUrl: './stock.css', }) export class Stock { + hasSelection = false; + + onSelectionChange(value: boolean) { + this.hasSelection = value; + } } diff --git a/src/app/pages/supplier/supplier.html b/src/app/pages/supplier/supplier.html index 53cd6a6..08f4baa 100644 --- a/src/app/pages/supplier/supplier.html +++ b/src/app/pages/supplier/supplier.html @@ -7,7 +7,7 @@
-voir pour le prix dans le sous tableau produit +