added create quotation function and edit end delete product in quotation table

This commit is contained in:
2025-12-13 15:50:59 +01:00
parent 9ebe8ab37e
commit 8b7d48779e
16 changed files with 392 additions and 81 deletions

View File

@@ -0,0 +1,62 @@
import { Component } from '@angular/core';
import {
FormArray,
FormBuilder,
FormControl,
FormGroup,
FormsModule,
ReactiveFormsModule,
Validators
} from "@angular/forms";
import {NzColDirective} from "ng-zorro-antd/grid";
import {NzFlexDirective} from "ng-zorro-antd/flex";
import {NzFormControlComponent, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzInputDirective} from "ng-zorro-antd/input";
import {NzInputNumberComponent} from "ng-zorro-antd/input-number";
import {NzTableComponent} from "ng-zorro-antd/table";
import {GetProductDto} from "../../services/api";
@Component({
selector: 'app-create-quotation-form',
imports: [
FormsModule,
NzColDirective,
NzFlexDirective,
NzFormControlComponent,
NzFormItemComponent,
NzFormLabelComponent,
NzInputDirective,
NzInputNumberComponent,
NzTableComponent,
ReactiveFormsModule
],
templateUrl: './create-quotation-form.html',
styleUrl: './create-quotation-form.css',
})
export class CreateQuotationForm {
createQuotationForm: FormGroup
constructor(private fb: FormBuilder) {
this.createQuotationForm = this.fb.group({
message: new FormControl<string>(null, Validators.required),
purchaseConditions: new FormControl<string>(null, Validators.required),
lines: this.fb.array([])
});
}
get lines(): FormArray {
return this.createQuotationForm.get('lines') as FormArray;
}
// Ajouter des produits sélectionnés dans le formulaire
syncSelectedProducts(selectedProducts: GetProductDto[]) {
this.lines.clear();
selectedProducts.forEach(p => {
this.lines.push(this.fb.group({
productId: [p.id],
name: [p.name],
quantity: [1, [Validators.required, Validators.min(1)]]
}));
});
}
}