固定资产项目前端文件
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB

2 years ago
import { Component, OnDestroy, OnInit } from '@angular/core'
import { SharedModule } from '../../shared/shared.module'
import { ApiService } from 'app/services'
import { UserFormComponent } from 'app/components/user-form/user-form.component'
import { FormBuilder, FormControl, FormGroup } from '@angular/forms'
import { FormValidators } from 'app/utils'
import { NzMessageService } from 'ng-zorro-antd/message'
import { Subscription } from 'rxjs'
@Component({
standalone: true,
imports: [SharedModule, UserFormComponent],
selector: 'app-profile-basic',
templateUrl: './profile-basic.component.html',
styleUrls: ['./profile-basic.component.less'],
})
export class ProfileBasicComponent implements OnInit, OnDestroy {
constructor(
public api: ApiService,
private fb: FormBuilder,
private msg: NzMessageService,
) {}
formGroup!: FormGroup
ngOnInit(): void {
this.formGroup = this.fb.group({
name: new FormControl(this.api.authInfo.name, [FormValidators.required('请输入姓名')]),
remark: new FormControl(this.api.authInfo.remark),
})
}
ngOnDestroy(): void {}
public getValues() {
let values = null
if (FormValidators.validateFormGroup(this.formGroup)) {
values = this.formGroup.value
}
return values
}
onSubmit() {
const vals = this.getValues()
if (vals) {
this.api.saveUser({ ...this.api.authInfo, ...vals }).subscribe(() => {
this.msg.success('保存成功')
this.api.getAuthInfo(true).subscribe(() => {})
})
}
}
}