Added supplier in purchase order form
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
name="Créer un bon de commande"
|
||||
size="35%"
|
||||
class="ml-4">
|
||||
<app-create-purchaseorder-form #purchaseOrderForm></app-create-purchaseorder-form>
|
||||
<app-create-purchaseorder-form #purchaseOrderForm [suppliers]="suppliers()"></app-create-purchaseorder-form>
|
||||
</app-modal-button>
|
||||
|
||||
<app-modal-button #modalButtonQuotation
|
||||
@@ -30,7 +30,7 @@
|
||||
(click)="openSupplierForm()"
|
||||
(ok)="onModalSupplierOk()"
|
||||
(cancel)="onModalSupplierCancel()">
|
||||
<app-add-product-supplier-form #supplierForm></app-add-product-supplier-form>
|
||||
<app-add-product-supplier-form #supplierForm [suppliers]="suppliers()"></app-add-product-supplier-form>
|
||||
</app-modal-button>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import {Component, inject, signal, viewChild} from '@angular/core';
|
||||
import {Component, inject, OnInit, signal, viewChild} from '@angular/core';
|
||||
import {StockTable} from "../../components/stock-table/stock-table";
|
||||
import {ModalButton} from "../../components/modal-button/modal-button";
|
||||
import {CreatePurchaseorderForm} from "../../components/create-purchaseorder-form/create-purchaseorder-form";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {CreatePriceDto, PurchaseordersService, QuotationsService, SuppliersService} from "../../services/api";
|
||||
import {
|
||||
GetSupplierDto,
|
||||
PurchaseordersService,
|
||||
QuotationsService,
|
||||
SuppliersService
|
||||
} from "../../services/api";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {CreateQuotationForm} from "../../components/create-quotation-form/create-quotation-form";
|
||||
import {AddProductSupplierForm} from "../../components/add-product-supplier-form/add-product-supplier-form";
|
||||
@@ -21,7 +26,7 @@ import {AddProductSupplierForm} from "../../components/add-product-supplier-form
|
||||
styleUrl: './stock.css',
|
||||
})
|
||||
|
||||
export class Stock {
|
||||
export class Stock implements OnInit {
|
||||
createPurchaseOrder = viewChild.required<CreatePurchaseorderForm>('purchaseOrderForm');
|
||||
createQuotation = viewChild.required<CreateQuotationForm>('quotationForm');
|
||||
addProduct = viewChild.required<AddProductSupplierForm>('supplierForm');
|
||||
@@ -35,9 +40,20 @@ export class Stock {
|
||||
private notificationService = inject(NzNotificationService);
|
||||
|
||||
products = signal([]);
|
||||
suppliers = signal<GetSupplierDto[]>([]);
|
||||
|
||||
productIds = [];
|
||||
|
||||
async ngOnInit() {
|
||||
try {
|
||||
const suppliers = await firstValueFrom(this.suppliersService.getAllSuppliersEndpoint());
|
||||
this.suppliers.set(suppliers);
|
||||
}
|
||||
catch {
|
||||
this.notificationService.error('Erreur', 'Erreur de communication avec l\'API');
|
||||
}
|
||||
}
|
||||
|
||||
getSelectedProducts() {
|
||||
return this.products().filter(x => this.productIds.includes(x.id));
|
||||
}
|
||||
@@ -77,8 +93,6 @@ export class Stock {
|
||||
products: orderLines
|
||||
};
|
||||
|
||||
console.log(purchaseOrder);
|
||||
|
||||
try {
|
||||
await firstValueFrom(this.purchaseOrdersService.createPurchaseOrder(purchaseOrder));
|
||||
this.notificationService.success('Succès', 'Bon de commande créé');
|
||||
|
||||
Reference in New Issue
Block a user