|
@ -30,12 +30,13 @@ export class OrgFormComponent { |
|
|
|
|
|
|
|
|
uploadLoading = false; |
|
|
uploadLoading = false; |
|
|
|
|
|
|
|
|
|
|
|
iconPreview = ""; |
|
|
|
|
|
|
|
|
get icon() { |
|
|
get icon() { |
|
|
return this.formGroup.get("icon")?.value; |
|
|
return this.formGroup.get("icon")?.value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
ngOnInit(): void { |
|
|
console.log("this.state", this.state); |
|
|
|
|
|
this.formGroup = this.fb.group({ |
|
|
this.formGroup = this.fb.group({ |
|
|
id: this.fb.control(""), |
|
|
id: this.fb.control(""), |
|
|
name: this.fb.control("", [FormValidators.required("单位名称不能为空")]), |
|
|
name: this.fb.control("", [FormValidators.required("单位名称不能为空")]), |
|
@ -46,6 +47,9 @@ export class OrgFormComponent { |
|
|
email: this.fb.control("", []), |
|
|
email: this.fb.control("", []), |
|
|
}); |
|
|
}); |
|
|
this.formGroup.patchValue(this.state); |
|
|
this.formGroup.patchValue(this.state); |
|
|
|
|
|
if (this.state["icon"]) { |
|
|
|
|
|
this.iconPreview = "/icon/" + this.state["icon"]; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async onSubmit() { |
|
|
async onSubmit() { |
|
@ -79,10 +83,14 @@ export class OrgFormComponent { |
|
|
const fileReader = new FileReader(); |
|
|
const fileReader = new FileReader(); |
|
|
fileReader.onload = () => { |
|
|
fileReader.onload = () => { |
|
|
const base64 = fileReader.result as string; |
|
|
const base64 = fileReader.result as string; |
|
|
this.formGroup.patchValue({ |
|
|
this.iconPreview = base64; |
|
|
icon: base64, |
|
|
// this.formGroup.get("icon")?.setValue(base64);
|
|
|
}); |
|
|
|
|
|
}; |
|
|
}; |
|
|
fileReader.readAsDataURL(file); |
|
|
fileReader.readAsDataURL(file); |
|
|
|
|
|
const formdata = new FormData(); |
|
|
|
|
|
formdata.append("file", file); |
|
|
|
|
|
this.api.upload(formdata).subscribe((res) => { |
|
|
|
|
|
this.formGroup.get("icon")?.setValue(res.body); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|