42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import {Component, effect, input} from '@angular/core';
|
|
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
|
|
import {NzColDirective} from "ng-zorro-antd/grid";
|
|
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
|
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
|
import {NzInputDirective} from "ng-zorro-antd/input";
|
|
import {GetPurchaseProductDto} from "../../services/api";
|
|
|
|
@Component({
|
|
selector: 'app-quantity-form',
|
|
imports: [
|
|
FormsModule,
|
|
NzColDirective,
|
|
NzFlexDirective,
|
|
NzFormControlComponent,
|
|
NzFormDirective,
|
|
NzFormItemComponent,
|
|
NzFormLabelComponent,
|
|
NzInputDirective,
|
|
ReactiveFormsModule
|
|
],
|
|
templateUrl: './quantity-form.html',
|
|
styleUrl: './quantity-form.css',
|
|
})
|
|
export class QuantityForm {
|
|
quantityForm: FormGroup = new FormGroup({
|
|
quantity: new FormControl<number>(null, [Validators.required])
|
|
})
|
|
|
|
quantity = input<GetPurchaseProductDto>();
|
|
|
|
constructor() {
|
|
effect(() => {
|
|
if (this.quantity()) {
|
|
this.quantityForm.patchValue({
|
|
quantity: this.quantity().quantity
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|