updated stock table
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
<tr class="text-center">
|
<tr class="text-center">
|
||||||
<th>Réference</th>
|
<th>Réference</th>
|
||||||
<th>Nom</th>
|
<th>Nom</th>
|
||||||
|
<th>Prix</th>
|
||||||
<th>Quantité</th>
|
<th>Quantité</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{data.quotationProductReference}}</td>
|
<td>{{data.quotationProductReference}}</td>
|
||||||
<td>{{data.quotationProductName}}</td>
|
<td>{{data.quotationProductName}}</td>
|
||||||
|
<td>XX.XX€</td>
|
||||||
<td>{{data.quotationProductQuantity}}</td>
|
<td>{{data.quotationProductQuantity}}</td>
|
||||||
<td>
|
<td>
|
||||||
<div style="justify-content: center; display: flex">
|
<div style="justify-content: center; display: flex">
|
||||||
|
|||||||
@@ -1,20 +1,41 @@
|
|||||||
<nz-table #basicTable [nzData]="listOfData" class="mr-7">
|
<nz-table
|
||||||
|
#rowSelectionTable
|
||||||
|
[nzData]="listOfData"
|
||||||
|
(nzCurrentPageDataChange)="onCurrentPageDataChange($event)"
|
||||||
|
>
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="text-center">
|
<tr class="text-center">
|
||||||
|
<th nzWidth="40px">
|
||||||
|
<label
|
||||||
|
nz-checkbox
|
||||||
|
[(ngModel)]="checked"
|
||||||
|
[nzIndeterminate]="indeterminate"
|
||||||
|
(ngModelChange)="onAllChecked($event)"
|
||||||
|
></label>
|
||||||
|
</th>
|
||||||
<th>Nom</th>
|
<th>Nom</th>
|
||||||
<th>Réference</th>
|
<th>Référence</th>
|
||||||
<th>Nec</th>
|
<th>Nec</th>
|
||||||
<th>Calibre</th>
|
<th>Calibre</th>
|
||||||
<th>Poid</th>
|
<th>Poids</th>
|
||||||
<th>Durée</th>
|
<th>Durée</th>
|
||||||
<th>Quantité</th>
|
<th>Quantité</th>
|
||||||
<th>Limite</th>
|
<th>Limite</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody class="text-center">
|
<tbody class="text-center">
|
||||||
@for (data of basicTable.data; track data) {
|
@for (data of rowSelectionTable.data; track data.id) {
|
||||||
<tr>
|
<tr>
|
||||||
|
<td nzWidth="40px">
|
||||||
|
<label
|
||||||
|
nz-checkbox
|
||||||
|
[ngModel]="setOfCheckedId.has(data.id)"
|
||||||
|
(ngModelChange)="onItemChecked(data.id, $event)"
|
||||||
|
></label>
|
||||||
|
</td>
|
||||||
|
|
||||||
<td>{{ data.product.name }}</td>
|
<td>{{ data.product.name }}</td>
|
||||||
<td>{{ data.product.reference }}</td>
|
<td>{{ data.product.reference }}</td>
|
||||||
<td>{{ data.product.nec }}</td>
|
<td>{{ data.product.nec }}</td>
|
||||||
@@ -23,15 +44,15 @@
|
|||||||
<td>{{ data.product.duration }}</td>
|
<td>{{ data.product.duration }}</td>
|
||||||
<td>{{ data.quantity }}</td>
|
<td>{{ data.quantity }}</td>
|
||||||
<td>{{ data.product.minimalQuantity }}</td>
|
<td>{{ data.product.minimalQuantity }}</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<div style="justify-content: center; display: flex">
|
<div style="justify-content: center; display: flex">
|
||||||
<app-modal-nav nameIcon="edit" name="Modification de la quantité minimale" class="cursor-pointer">
|
<app-modal-nav nameIcon="edit" name="Modification de la quantité minimale">
|
||||||
<app-stock-form></app-stock-form>
|
<app-stock-form></app-stock-form>
|
||||||
</app-modal-nav>
|
</app-modal-nav>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
<div>
|
<nz-icon nzType="delete" (click)="delete()" nzTheme="outline"
|
||||||
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700"/>
|
class="cursor-pointer text-red-700"/>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component } from '@angular/core';
|
import {Component, output} from '@angular/core';
|
||||||
import {StockInfo} from "../../interfaces/stock.interface";
|
import {StockInfo} from "../../interfaces/stock.interface";
|
||||||
import {NzTableComponent} from "ng-zorro-antd/table";
|
import {NzTableComponent} from "ng-zorro-antd/table";
|
||||||
import {ModalNav} from "../modal-nav/modal-nav";
|
import {ModalNav} from "../modal-nav/modal-nav";
|
||||||
@@ -6,6 +6,9 @@ import {NzIconDirective} from "ng-zorro-antd/icon";
|
|||||||
import {StockForm} from "../stock-form/stock-form";
|
import {StockForm} from "../stock-form/stock-form";
|
||||||
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
||||||
import {ProductTable} from "../product-table/product-table";
|
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({
|
@Component({
|
||||||
selector: 'app-stock-table',
|
selector: 'app-stock-table',
|
||||||
@@ -14,46 +17,78 @@ import {ProductTable} from "../product-table/product-table";
|
|||||||
ModalNav,
|
ModalNav,
|
||||||
NzIconDirective,
|
NzIconDirective,
|
||||||
StockForm,
|
StockForm,
|
||||||
NzDividerComponent
|
NzDividerComponent,
|
||||||
|
FormsModule,
|
||||||
|
NzCheckboxComponent,
|
||||||
|
NzButtonComponent,
|
||||||
],
|
],
|
||||||
templateUrl: './stock-table.html',
|
templateUrl: './stock-table.html',
|
||||||
styleUrl: './stock-table.css',
|
styleUrl: './stock-table.css',
|
||||||
})
|
})
|
||||||
|
|
||||||
export class StockTable {
|
export class StockTable {
|
||||||
listOfData: StockInfo[] = [
|
listOfData: StockInfo[] = [
|
||||||
{ product: ProductTable.listOfProducts[0], quantity: 10 },
|
{ id: 1, product: ProductTable.listOfProducts[0], quantity: 10 },
|
||||||
{ product: ProductTable.listOfProducts[1], quantity: 5 },
|
{ id: 2, product: ProductTable.listOfProducts[1], quantity: 5 },
|
||||||
{ product: ProductTable.listOfProducts[2], quantity: 8 },
|
{ id: 3, product: ProductTable.listOfProducts[2], quantity: 8 },
|
||||||
{ product: ProductTable.listOfProducts[3], quantity: 12 },
|
{ id: 4, product: ProductTable.listOfProducts[3], quantity: 12 },
|
||||||
{ product: ProductTable.listOfProducts[4], quantity: 7 },
|
{ id: 5, product: ProductTable.listOfProducts[4], quantity: 7 },
|
||||||
{ product: ProductTable.listOfProducts[5], quantity: 15 },
|
{ id: 6, product: ProductTable.listOfProducts[5], quantity: 15 },
|
||||||
{ product: ProductTable.listOfProducts[6], quantity: 9 },
|
{ id: 7, product: ProductTable.listOfProducts[6], quantity: 9 },
|
||||||
{ product: ProductTable.listOfProducts[7], quantity: 6 },
|
{ id: 8, product: ProductTable.listOfProducts[7], quantity: 6 },
|
||||||
{ product: ProductTable.listOfProducts[8], quantity: 11 },
|
{ id: 9, product: ProductTable.listOfProducts[8], quantity: 11 },
|
||||||
{ product: ProductTable.listOfProducts[9], quantity: 14 },
|
{ id: 10, product: ProductTable.listOfProducts[9], quantity: 14 },
|
||||||
{ product: ProductTable.listOfProducts[10], quantity: 7 },
|
{ id: 11, product: ProductTable.listOfProducts[10], quantity: 7 },
|
||||||
{ product: ProductTable.listOfProducts[11], quantity: 13 },
|
{ id: 12, product: ProductTable.listOfProducts[11], quantity: 13 },
|
||||||
{ product: ProductTable.listOfProducts[12], quantity: 10 },
|
{ id: 13, product: ProductTable.listOfProducts[12], quantity: 10 },
|
||||||
{ product: ProductTable.listOfProducts[13], quantity: 5 },
|
{ id: 14, 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 },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
checked = false;
|
||||||
|
indeterminate = false;
|
||||||
|
setOfCheckedId = new Set<number>();
|
||||||
|
|
||||||
|
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() {
|
delete() {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
selectionChange = output<boolean>()
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
<tr class="text-center">
|
<tr class="text-center">
|
||||||
<th>Nom</th>
|
<th>Nom</th>
|
||||||
<th>Référence</th>
|
<th>Référence</th>
|
||||||
|
<th>Prix</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="text-center">
|
<tbody class="text-center">
|
||||||
@@ -35,6 +36,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{product.name}}</td>
|
<td>{{product.name}}</td>
|
||||||
<td>{{product.reference}}</td>
|
<td>{{product.reference}}</td>
|
||||||
|
<td>xx.x€</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {ProductInfo} from "./product.interface";
|
import {ProductInfo} from "./product.interface";
|
||||||
|
|
||||||
export interface StockInfo {
|
export interface StockInfo {
|
||||||
|
id: number;
|
||||||
product: ProductInfo;
|
product: ProductInfo;
|
||||||
quantity: number;
|
quantity: number;
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<app-search></app-search>
|
<app-search></app-search>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
voir prix dans les produits
|
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
<app-quotation-table></app-quotation-table>
|
<app-quotation-table></app-quotation-table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,21 @@
|
|||||||
<div class="ml-130 w-170 mt-2">
|
<div class="flex mt-2">
|
||||||
<app-search></app-search>
|
@if (hasSelection) {
|
||||||
|
<app-modal-button type="default" name="Créer un bon de commande" class="ml-4">
|
||||||
|
<app-purchase-order-form></app-purchase-order-form>
|
||||||
|
</app-modal-button>
|
||||||
|
|
||||||
|
<app-modal-button type="default" name="Créer un devis" class="ml-4">
|
||||||
|
<app-quotation-form></app-quotation-form>
|
||||||
|
</app-modal-button>
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="ml-95 w-150">
|
||||||
|
<app-search class="w-full"></app-search>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
faire ici la creation de bon de commande avec case a cocher
|
|
||||||
|
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
<app-stock-table></app-stock-table>
|
<app-stock-table
|
||||||
|
(selectionChange)="onSelectionChange($event)"
|
||||||
|
></app-stock-table>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,17 +1,28 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import {StockTable} from "../../components/stock-table/stock-table";
|
import {StockTable} from "../../components/stock-table/stock-table";
|
||||||
import {Search} from "../../components/search/search";
|
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({
|
@Component({
|
||||||
selector: 'app-stock',
|
selector: 'app-stock',
|
||||||
imports: [
|
imports: [
|
||||||
StockTable,
|
StockTable,
|
||||||
Search,
|
Search,
|
||||||
|
ModalButton,
|
||||||
|
PurchaseOrderForm,
|
||||||
|
QuotationForm,
|
||||||
],
|
],
|
||||||
templateUrl: './stock.html',
|
templateUrl: './stock.html',
|
||||||
styleUrl: './stock.css',
|
styleUrl: './stock.css',
|
||||||
})
|
})
|
||||||
|
|
||||||
export class Stock {
|
export class Stock {
|
||||||
|
hasSelection = false;
|
||||||
|
|
||||||
|
onSelectionChange(value: boolean) {
|
||||||
|
this.hasSelection = value;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<app-search class="w-full"></app-search>
|
<app-search class="w-full"></app-search>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
voir pour le prix dans le sous tableau produit
|
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
<app-supplier-table></app-supplier-table>
|
<app-supplier-table></app-supplier-table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user