add getall and delete function from quotation page
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<form nz-form nzLayout="horizontal" [formGroup]="QuotationForm" (ngSubmit)="submitForm()">
|
<form nz-form nzLayout="horizontal" [formGroup]="QuotationForm">
|
||||||
<nz-form-item nz-flex>
|
<nz-form-item nz-flex>
|
||||||
<nz-form-label nzSpan="9">
|
<nz-form-label nzSpan="9">
|
||||||
Message du devis
|
Message du devis
|
||||||
@@ -18,15 +18,5 @@
|
|||||||
<input nz-input placeholder="Conditions de vente" formControlName="quotationConditionsSale">
|
<input nz-input placeholder="Conditions de vente" formControlName="quotationConditionsSale">
|
||||||
</nz-form-control>
|
</nz-form-control>
|
||||||
</nz-form-item>
|
</nz-form-item>
|
||||||
|
|
||||||
<nz-form-item nz-flex>
|
|
||||||
<nz-form-label nzSpan="9" nzRequired>
|
|
||||||
Fournisseur
|
|
||||||
</nz-form-label>
|
|
||||||
|
|
||||||
<nz-form-control nzSpan="12">
|
|
||||||
<input nz-input placeholder="Fournisseur" formControlName="quotationProvider">
|
|
||||||
</nz-form-control>
|
|
||||||
</nz-form-item>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
@@ -26,15 +26,4 @@ export class QuotationForm {
|
|||||||
quotationMessage: new FormControl<string>(null),
|
quotationMessage: new FormControl<string>(null),
|
||||||
quotationConditionsSale: new FormControl<string>(null),
|
quotationConditionsSale: new FormControl<string>(null),
|
||||||
})
|
})
|
||||||
|
|
||||||
submitForm() {
|
|
||||||
// Pour annuler si le formulaire est invalide
|
|
||||||
if (this.QuotationForm.invalid) return;
|
|
||||||
|
|
||||||
// Pour obtenir la valeur du formulaire
|
|
||||||
console.log(this.QuotationForm.getRawValue())
|
|
||||||
|
|
||||||
// Pour vider le formulaire
|
|
||||||
this.QuotationForm.reset()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
<nz-table #basicTable [nzData]="quotations" class="mr-7">
|
<nz-table class="mr-7"
|
||||||
|
[nzData]="quotations()"
|
||||||
|
[nzLoading]="quotationsLoading()"
|
||||||
|
[nzFrontPagination]="false"
|
||||||
|
>
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="text-center">
|
<tr class="text-center">
|
||||||
<th>Numéro de Devis</th>
|
<th>Numéro de Devis</th>
|
||||||
<th>Message</th>
|
<th>Message</th>
|
||||||
<th>Conditions de vente</th>
|
<th>Conditions de vente</th>
|
||||||
<th>Fournisseur</th>
|
|
||||||
<th>Produit</th>
|
<th>Produit</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 (quotation of quotations(); track quotation.id) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{data.quotationId}}</td>
|
<td>{{quotation.id}}</td>
|
||||||
<td>{{data.quotationMessage}}</td>
|
<td>{{quotation.message}}</td>
|
||||||
<td>{{data.quotationConditionsSale}}</td>
|
<td>{{quotation.conditionsSale}}</td>
|
||||||
<td>{{data.Supplier}}</td>
|
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<app-modal-button type="link" name="Voir les produits">
|
<app-modal-button type="link" name="Voir les produits">
|
||||||
<div style="max-height: 400px; overflow-y: auto;">
|
<div style="max-height: 400px; overflow-y: auto;">
|
||||||
@@ -31,25 +32,19 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="text-center">
|
<tbody class="text-center">
|
||||||
|
@for (product of quotation.getQuotationProductDto; track product.productId) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{data.quotationProductReference}}</td>
|
<td>{{ product.productReferences }}</td>
|
||||||
<td>{{data.quotationProductName}}</td>
|
<td>{{ product.productName }}</td>
|
||||||
<td>XX.XX€</td>
|
<td>Price ???</td>
|
||||||
<td>{{data.quotationProductQuantity}}</td>
|
<td>Quantité ???</td>
|
||||||
<td>
|
<td>
|
||||||
<div style="justify-content: center; display: flex">
|
<div style="justify-content: center; display: flex">
|
||||||
<app-modal-nav nameIcon="edit" name="Modification du produit" class="cursor-pointer">
|
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700"/>
|
||||||
<app-product-form></app-product-form>
|
|
||||||
</app-modal-nav>
|
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
|
||||||
<div>
|
|
||||||
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</nz-table>
|
</nz-table>
|
||||||
</div>
|
</div>
|
||||||
@@ -57,12 +52,16 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div style="justify-content: center; display: flex">
|
<div style="justify-content: center; display: flex">
|
||||||
|
<div>
|
||||||
|
<nz-icon nzType="plus-circle" nzTheme="outline" class="cursor-pointer text-green-700" />
|
||||||
|
</div>
|
||||||
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
<app-modal-nav nameIcon="edit" name="Modification du devis" class="cursor-pointer">
|
<app-modal-nav nameIcon="edit" name="Modification du devis" class="cursor-pointer">
|
||||||
<app-quotation-form></app-quotation-form>
|
<app-quotation-form></app-quotation-form>
|
||||||
</app-modal-nav>
|
</app-modal-nav>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
<div>
|
<div>
|
||||||
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700"/>
|
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700" (click)="delete(quotation.id)"/>
|
||||||
</div>
|
</div>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -1,27 +1,13 @@
|
|||||||
import { Component } from '@angular/core';
|
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||||
import {NzTableComponent} from "ng-zorro-antd/table";
|
import {NzTableComponent} from "ng-zorro-antd/table";
|
||||||
import {ModalButton} from "../modal-button/modal-button";
|
import {ModalButton} from "../modal-button/modal-button";
|
||||||
import {ModalNav} from "../modal-nav/modal-nav";
|
import {ModalNav} from "../modal-nav/modal-nav";
|
||||||
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
||||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
import {NzIconDirective} from "ng-zorro-antd/icon";
|
||||||
import {QuotationForm} from "../quotation-form/quotation-form";
|
import {QuotationForm} from "../quotation-form/quotation-form";
|
||||||
import {ProductTable} from "../product-table/product-table";
|
import {GetQuotationDto, QuotationsService} from "../../services/api";
|
||||||
import {ProductForm} from "../product-form/product-form";
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
|
import {firstValueFrom} from "rxjs";
|
||||||
interface QuotationInfo {
|
|
||||||
quotationId: number;
|
|
||||||
quotationMessage?: string;
|
|
||||||
quotationConditionsSale?: string;
|
|
||||||
quotationProduct: [
|
|
||||||
{ quotationProductReference: string; },
|
|
||||||
{ quotationProductName: string; },
|
|
||||||
{ quotationProductQuantity?: number; },
|
|
||||||
],
|
|
||||||
quotationProductReference: string;
|
|
||||||
quotationProductName: string;
|
|
||||||
quotationProductQuantity?: number;
|
|
||||||
Supplier?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-quotation-table',
|
selector: 'app-quotation-table',
|
||||||
@@ -32,56 +18,50 @@ interface QuotationInfo {
|
|||||||
NzIconDirective,
|
NzIconDirective,
|
||||||
NzTableComponent,
|
NzTableComponent,
|
||||||
QuotationForm,
|
QuotationForm,
|
||||||
ProductForm
|
|
||||||
],
|
],
|
||||||
templateUrl: './quotation-table.html',
|
templateUrl: './quotation-table.html',
|
||||||
styleUrl: './quotation-table.css',
|
styleUrl: './quotation-table.css',
|
||||||
})
|
})
|
||||||
|
|
||||||
export class QuotationTable {
|
export class QuotationTable implements OnInit {
|
||||||
quotations: QuotationInfo[] = [
|
private quotationsService = inject(QuotationsService);
|
||||||
{
|
private notificationService = inject(NzNotificationService)
|
||||||
quotationId: 101,
|
quotations = signal<GetQuotationDto[]>([]);
|
||||||
quotationMessage: 'Livraison urgente demandée',
|
quotationsLoading = signal<boolean>(false);
|
||||||
quotationConditionsSale: 'Paiement à 30 jours',
|
|
||||||
quotationProduct: [
|
async ngOnInit() {
|
||||||
{ quotationProductReference: 'DLV-1000' },
|
await this.fetchQuotations();
|
||||||
{ quotationProductName: 'Produit1'},
|
}
|
||||||
{ quotationProductQuantity: 5 },
|
|
||||||
],
|
async fetchQuotations() {
|
||||||
quotationProductReference: 'DLV-1000',
|
this.quotationsLoading.set(true)
|
||||||
quotationProductName: 'Produit1',
|
|
||||||
quotationProductQuantity: 5,
|
try {
|
||||||
Supplier: 'Fireworkssupplier&Co'
|
const quotations = await firstValueFrom(this.quotationsService.getAllQuotationEndpoint())
|
||||||
},
|
this.quotations.set(quotations);
|
||||||
{
|
} catch (e) {
|
||||||
quotationId: 102,
|
this.notificationService.error(
|
||||||
quotationMessage: 'Livraison standard',
|
'Erreur',
|
||||||
quotationConditionsSale: 'Payé d\'avance',
|
'Erreur de communication avec l\'API'
|
||||||
quotationProduct: [
|
)
|
||||||
{ quotationProductReference: 'DLV-1001' },
|
|
||||||
{ quotationProductName: 'Produit2'},
|
|
||||||
{ quotationProductQuantity: 6 },
|
|
||||||
],
|
|
||||||
quotationProductReference: 'DLV-1001',
|
|
||||||
quotationProductName: 'Produit2',
|
|
||||||
quotationProductQuantity: 6,
|
|
||||||
Supplier: 'Fireworkssupplier&Co'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
quotationId: 103,
|
|
||||||
quotationMessage: 'Livraison rapide',
|
|
||||||
quotationConditionsSale: 'Paiement à 15 jours',
|
|
||||||
quotationProduct: [
|
|
||||||
{ quotationProductReference: 'DLV-1003' },
|
|
||||||
{ quotationProductName: 'Produit3'},
|
|
||||||
{ quotationProductQuantity: 7 },
|
|
||||||
],
|
|
||||||
quotationProductReference: 'DLV-1002',
|
|
||||||
quotationProductName: 'Produit3',
|
|
||||||
quotationProductQuantity: 7,
|
|
||||||
Supplier: 'Fireworkssupplier&Co'
|
|
||||||
}
|
}
|
||||||
];
|
this.quotationsLoading.set(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(quotation:number) {
|
||||||
|
try {
|
||||||
|
await firstValueFrom(this.quotationsService.deleteQuotationEndpoint(quotation))
|
||||||
|
this.notificationService.success(
|
||||||
|
'Success',
|
||||||
|
'Suppression effectuée'
|
||||||
|
)
|
||||||
|
} catch (e) {
|
||||||
|
this.notificationService.error(
|
||||||
|
'Erreur',
|
||||||
|
'Impossible de supprimer la ligne'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
await this.fetchQuotations();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
<div class="flex mt-2">
|
<div class="flex mt-2">
|
||||||
<app-modal-button type="primary" name="Créer un devis">
|
|
||||||
<app-quotation-form></app-quotation-form>
|
|
||||||
</app-modal-button>
|
|
||||||
|
|
||||||
<div class="ml-95 w-150">
|
<div class="ml-95 w-150">
|
||||||
<app-search></app-search>
|
<app-search></app-search>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user