add getall and delete function from purchase order page
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<form nz-form nzLayout="horizontal" [formGroup]="productForm" (ngSubmit)="submitForm()">
|
||||
<form nz-form nzLayout="horizontal" [formGroup]="productForm">
|
||||
<nz-form-item nz-flex>
|
||||
<nz-form-label nzSpan="9" nzRequired>
|
||||
Prix
|
||||
|
||||
@@ -26,15 +26,4 @@ export class ProductForm {
|
||||
price: new FormControl<string>(null, [Validators.required]),
|
||||
quantity: new FormControl<string>(null, [Validators.required])
|
||||
})
|
||||
|
||||
submitForm() {
|
||||
// Pour annuler si le formulaire est invalide
|
||||
if (this.productForm.invalid) return;
|
||||
|
||||
// Pour obtenir la valeur du formulaire
|
||||
console.log(this.productForm.getRawValue())
|
||||
|
||||
// Pour vider le formulaire
|
||||
this.productForm.reset()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<p>product-table works!</p>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<form nz-form nzLayout="horizontal" [formGroup]="purchaseOrderForm" (ngSubmit)="submitForm()">
|
||||
<form nz-form nzLayout="horizontal" [formGroup]="purchaseOrderForm">
|
||||
<nz-form-item nz-flex>
|
||||
<nz-form-label nzSpan="12" nzRequired>
|
||||
Conditions générales de vente
|
||||
|
||||
@@ -25,15 +25,4 @@ export class PurchaseOrderForm {
|
||||
purchaseOrderForm: FormGroup = new FormGroup({
|
||||
purchaseCondition: new FormControl<string>(null,[Validators.required])
|
||||
})
|
||||
|
||||
submitForm() {
|
||||
// Pour annuler si le formulaire est invalide
|
||||
if (this.purchaseOrderForm.invalid) return;
|
||||
|
||||
// Pour obtenir la valeur du formulaire
|
||||
console.log(this.purchaseOrderForm.getRawValue())
|
||||
|
||||
// Pour vider le formulaire
|
||||
this.purchaseOrderForm.reset()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<nz-table #basicTable [nzData]="purchaseOrders" class="mr-7">
|
||||
<nz-table [nzData]="purchaseOrders()"
|
||||
[nzLoading]="purchaseOrdersLoading()"
|
||||
[nzFrontPagination]="false"
|
||||
class="mr-7">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th>Numéro</th>
|
||||
@@ -9,37 +12,36 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-center">
|
||||
@for (data of basicTable.data; track data) {
|
||||
@for (purchaseOrder of purchaseOrders(); track purchaseOrder.id) {
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>{{ purchaseOrder.id }}</td>
|
||||
<td>{{purchaseOrder.purchaseConditions}}</td>
|
||||
<td>Fournisseur ???</td>
|
||||
<td>
|
||||
<app-modal-button type="link" name="Voir les produits">
|
||||
<div style="max-height: 400px; overflow-y: auto;">
|
||||
<nz-table [nzData]="data.productOrder">
|
||||
<nz-table [nzData]="purchaseOrders()"
|
||||
[nzFrontPagination]="false">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th>Nom</th>
|
||||
<th>Reférence</th>
|
||||
<th>Prix</th>
|
||||
<th>Quantité</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-center">
|
||||
@for (product of data.productOrder; track product) {
|
||||
@for (product of purchaseOrder.getPurchaseProductDto; track product.productId) {
|
||||
<tr>
|
||||
<td>{{product.product.name}}</td>
|
||||
<td>{{product.price}}€</td>
|
||||
<td>{{product.productName}}</td>
|
||||
<td>{{product.productReferences}}</td>
|
||||
<td>Prix €€€€</td>
|
||||
<td>{{product.quantity}}</td>
|
||||
<td>
|
||||
<div style="justify-content: center; display: flex">
|
||||
<app-modal-nav nameIcon="edit" name="Modification des conditions de vente" class="cursor-pointer">
|
||||
<app-product-form></app-product-form>
|
||||
</app-modal-nav>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<div>
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete()" class="cursor-pointer text-red-700"/>
|
||||
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700"/>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@@ -52,12 +54,16 @@
|
||||
</td>
|
||||
<td>
|
||||
<div style="justify-content: center; display: flex">
|
||||
<div>
|
||||
<nz-icon nzType="plus-circle" nzTheme="outline" (click)="delete(purchaseOrder.id)" class="cursor-pointer text-green-700"/>
|
||||
</div>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<app-modal-nav nameIcon="edit" name="Modification des conditions de vente" class="cursor-pointer">
|
||||
<app-purchase-order-form></app-purchase-order-form>
|
||||
</app-modal-nav>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<div>
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete()" class="cursor-pointer text-red-700"/>
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(purchaseOrder.id)" class="cursor-pointer text-red-700"/>
|
||||
</div>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<div>
|
||||
@@ -65,7 +71,7 @@
|
||||
</div>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<div>
|
||||
<nz-icon nzType="interaction" nzTheme="outline" (click)="transfert()" class="cursor-pointer text-blue-700"/>
|
||||
<nz-icon nzType="interaction" nzTheme="outline" (click)="transfer()" class="cursor-pointer text-blue-700"/>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||
import {ModalNav} from "../modal-nav/modal-nav";
|
||||
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
||||
import {NzTableComponent} from "ng-zorro-antd/table";
|
||||
import {PurchaseOrderInfo} from "../../interfaces/purchase-order.interface";
|
||||
import {PurchaseOrderForm} from "../purchase-order-form/purchase-order-form";
|
||||
import {ModalButton} from "../modal-button/modal-button";
|
||||
import {ProductForm} from "../product-form/product-form";
|
||||
import {GetPurchaseOrderDto, PurchaseordersService} from "../../services/api";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'app-purchase-order-table',
|
||||
@@ -22,172 +24,52 @@ import {ProductForm} from "../product-form/product-form";
|
||||
templateUrl: './purchase-order-table.html',
|
||||
styleUrl: './purchase-order-table.css',
|
||||
})
|
||||
export class PurchaseOrderTable {
|
||||
purchaseOrders: PurchaseOrderInfo[] = [
|
||||
{
|
||||
purchaseCondition: "Condition d'achat standard 1",
|
||||
supplier: {
|
||||
name: "Fournisseur 1",
|
||||
email: "contact1@example.com",
|
||||
phone: "0100000001",
|
||||
address: "1 Rue de Paris",
|
||||
zipCode: "75001",
|
||||
city: "Paris",
|
||||
deliveryDelay: 3,
|
||||
products: [
|
||||
{
|
||||
reference: "F1-P1",
|
||||
name: "Produit 1A",
|
||||
supplier: [],
|
||||
duration: 0,
|
||||
caliber: "",
|
||||
approvalNumber: "",
|
||||
weight: 1,
|
||||
nec: 0,
|
||||
image: "",
|
||||
link: "",
|
||||
minimalQuantity: 1
|
||||
},
|
||||
{
|
||||
reference: "F1-P2",
|
||||
name: "Produit 1B",
|
||||
supplier: [],
|
||||
duration: 0,
|
||||
caliber: "",
|
||||
approvalNumber: "",
|
||||
weight: 2,
|
||||
nec: 0,
|
||||
image: "",
|
||||
link: "",
|
||||
minimalQuantity: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
productOrder: [
|
||||
{
|
||||
product: {
|
||||
reference: "F1-P1",
|
||||
name: "Produit 1A",
|
||||
supplier: [],
|
||||
duration: 0,
|
||||
caliber: "",
|
||||
approvalNumber: "",
|
||||
weight: 1,
|
||||
nec: 0,
|
||||
image: "",
|
||||
link: "",
|
||||
minimalQuantity: 1
|
||||
},
|
||||
quantity: 5,
|
||||
price: 10
|
||||
},
|
||||
{
|
||||
product: {
|
||||
reference: "F1-P2",
|
||||
name: "Produit 1B",
|
||||
supplier: [],
|
||||
duration: 0,
|
||||
caliber: "",
|
||||
approvalNumber: "",
|
||||
weight: 2,
|
||||
nec: 0,
|
||||
image: "",
|
||||
link: "",
|
||||
minimalQuantity: 1
|
||||
},
|
||||
quantity: 3,
|
||||
price: 15
|
||||
}
|
||||
]
|
||||
},
|
||||
export class PurchaseOrderTable implements OnInit {
|
||||
private purchaseOrdersService = inject(PurchaseordersService);
|
||||
private notificationService = inject(NzNotificationService)
|
||||
purchaseOrders = signal<GetPurchaseOrderDto[]>([]);
|
||||
purchaseOrdersLoading = signal<boolean>(false);
|
||||
|
||||
{
|
||||
purchaseCondition: "Condition d'achat standard 2",
|
||||
supplier: {
|
||||
name: "Fournisseur 2",
|
||||
email: "contact2@example.com",
|
||||
phone: "0100000002",
|
||||
address: "2 Rue de Lyon",
|
||||
zipCode: "75002",
|
||||
city: "Paris",
|
||||
deliveryDelay: 4,
|
||||
products: [
|
||||
{
|
||||
reference: "F2-P1",
|
||||
name: "Produit 2A",
|
||||
supplier: [],
|
||||
duration: 0,
|
||||
caliber: "",
|
||||
approvalNumber: "",
|
||||
weight: 1.5,
|
||||
nec: 0,
|
||||
image: "",
|
||||
link: "",
|
||||
minimalQuantity: 1
|
||||
},
|
||||
{
|
||||
reference: "F2-P2",
|
||||
name: "Produit 2B",
|
||||
supplier: [],
|
||||
duration: 0,
|
||||
caliber: "",
|
||||
approvalNumber: "",
|
||||
weight: 2.5,
|
||||
nec: 0,
|
||||
image: "",
|
||||
link: "",
|
||||
minimalQuantity: 1
|
||||
async ngOnInit() {
|
||||
await this.fetchPurchaseOrder();
|
||||
}
|
||||
]
|
||||
},
|
||||
productOrder: [
|
||||
{
|
||||
product: {
|
||||
reference: "F2-P1",
|
||||
name: "Produit 2A",
|
||||
supplier: [],
|
||||
duration: 0,
|
||||
caliber: "",
|
||||
approvalNumber: "",
|
||||
weight: 1.5,
|
||||
nec: 0,
|
||||
image: "",
|
||||
link: "",
|
||||
minimalQuantity: 1
|
||||
},
|
||||
quantity: 6,
|
||||
price: 11
|
||||
},
|
||||
{
|
||||
product: {
|
||||
reference: "F2-P2",
|
||||
name: "Produit 2B",
|
||||
supplier: [],
|
||||
duration: 0,
|
||||
caliber: "",
|
||||
approvalNumber: "",
|
||||
weight: 2.5,
|
||||
nec: 0,
|
||||
image: "",
|
||||
link: "",
|
||||
minimalQuantity: 1
|
||||
},
|
||||
quantity: 4,
|
||||
price: 16
|
||||
}
|
||||
]
|
||||
},
|
||||
];
|
||||
|
||||
delete() {
|
||||
return
|
||||
async fetchPurchaseOrder() {
|
||||
this.purchaseOrdersLoading.set(true)
|
||||
|
||||
try {
|
||||
const purchaseOrders = await firstValueFrom(this.purchaseOrdersService.getAllPurchaseOrderEndpoint())
|
||||
this.purchaseOrders.set(purchaseOrders);
|
||||
} catch (e) {
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Erreur de communication avec l\'API'
|
||||
)
|
||||
}
|
||||
this.purchaseOrdersLoading.set(false)
|
||||
}
|
||||
|
||||
async delete(purchaseOrderId:number) {
|
||||
try {
|
||||
await firstValueFrom(this.purchaseOrdersService.deletePurchaseOrderEndpoint(purchaseOrderId))
|
||||
this.notificationService.success(
|
||||
'Success',
|
||||
'Suppression effectuée'
|
||||
)
|
||||
} catch (e) {
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Impossible de supprimer la ligne'
|
||||
)
|
||||
}
|
||||
await this.fetchPurchaseOrder();
|
||||
}
|
||||
|
||||
export(){
|
||||
return
|
||||
}
|
||||
|
||||
transfert() {
|
||||
transfer() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user