import { Component } from "@angular/core"; import { FormBuilder, FormGroup } from "@angular/forms"; import { Router } from "@angular/router"; import { FormValidators } from "@cdk/validators"; @Component({ selector: "app-standard-setting", templateUrl: "./standard-setting.component.html", styleUrls: ["./standard-setting.component.less"], }) export class StandardSettingComponent { constructor(private fb: FormBuilder, private router: Router) {} formGroup!: FormGroup; uploadLoading = false; ngOnInit(): void { this.formGroup = this.fb.group({ id: this.fb.control("", [FormValidators.required()]), name: this.fb.control("", [FormValidators.required()]), unit: this.fb.control("", [FormValidators.required()]), day: this.fb.control("1", [FormValidators.required()]), logo: this.fb.control("", []), month: this.fb.control([], []), }); } onSubmit() { this.router.navigate(["/", "standard", "setting", "45"]); } onFileChange(e: Event) { const target = e.target as HTMLInputElement; const file = target.files![0]; target.value = ""; const formData = new FormData(); const fileReader = new FileReader(); fileReader.onload = () => { const base64 = fileReader.result as string; const v = base64.split("base64,")[1]; }; formData.append("file", file); this.uploadLoading = true; // this.api // .uploadLogo(formData) // .pipe( // finalize(() => { // this.uploadLoading = false; // }) // ) // .subscribe((r) => { // this.msg.success(r.desc); // fileReader.readAsDataURL(file); // }); } }