Fixed error to function to create purchase order
This commit is contained in:
@@ -9,45 +9,46 @@ import {NzInputNumberComponent} from "ng-zorro-antd/input-number";
|
||||
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
|
||||
|
||||
@Component({
|
||||
selector: 'app-add-product-supplier-form',
|
||||
imports: [
|
||||
NzRowDirective,
|
||||
NzFormControlComponent,
|
||||
NzFormLabelComponent,
|
||||
ReactiveFormsModule,
|
||||
NzFlexDirective,
|
||||
NzColDirective,
|
||||
NzTableComponent,
|
||||
NzInputNumberComponent,
|
||||
NzOptionComponent,
|
||||
NzSelectComponent
|
||||
],
|
||||
templateUrl: './add-product-supplier-form.html',
|
||||
styleUrl: './add-product-supplier-form.css',
|
||||
selector: 'app-add-product-supplier-form',
|
||||
imports: [
|
||||
NzRowDirective,
|
||||
NzFormControlComponent,
|
||||
NzFormLabelComponent,
|
||||
ReactiveFormsModule,
|
||||
NzFlexDirective,
|
||||
NzColDirective,
|
||||
NzTableComponent,
|
||||
NzInputNumberComponent,
|
||||
NzOptionComponent,
|
||||
NzSelectComponent
|
||||
],
|
||||
templateUrl: './add-product-supplier-form.html',
|
||||
styleUrl: './add-product-supplier-form.css',
|
||||
})
|
||||
export class AddProductSupplierForm {
|
||||
addProductForm: FormGroup = new FormGroup({
|
||||
supplierId: new FormControl<number>(null, Validators.required),
|
||||
lines: new FormArray([], Validators.required),
|
||||
});
|
||||
|
||||
suppliers = input.required<GetSupplierDto[]>();
|
||||
|
||||
get lines(): FormArray {
|
||||
return this.addProductForm.get('lines') as FormArray;
|
||||
}
|
||||
|
||||
addProductToForm(selectedProducts: GetProductDto[]) {
|
||||
this.lines.clear();
|
||||
|
||||
selectedProducts.forEach(x => {
|
||||
this.lines.push(
|
||||
new FormGroup({
|
||||
productId: new FormControl(x.id),
|
||||
name: new FormControl(x.name),
|
||||
price: new FormControl(0, [Validators.required,Validators.min(0)])
|
||||
})
|
||||
);
|
||||
addProductForm: FormGroup = new FormGroup({
|
||||
supplierId: new FormControl<number>(null, Validators.required),
|
||||
lines: new FormArray([], Validators.required),
|
||||
});
|
||||
}
|
||||
|
||||
suppliers = input.required<GetSupplierDto[]>();
|
||||
products = input.required<GetProductDto[]>();
|
||||
|
||||
get lines(): FormArray {
|
||||
return this.addProductForm.get('lines') as FormArray;
|
||||
}
|
||||
|
||||
addProductToForm() {
|
||||
this.lines.clear();
|
||||
|
||||
this.products().forEach(x => {
|
||||
this.lines.push(
|
||||
new FormGroup({
|
||||
productId: new FormControl(x.id),
|
||||
name: new FormControl(x.name),
|
||||
price: new FormControl(0, [Validators.required, Validators.min(0)])
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user