固定资产项目前端文件
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.
 
 
 
 

103 lines
3.1 KiB

import { Component, Input, OnInit, inject } from '@angular/core'
import { FormBuilder, FormGroup } from '@angular/forms'
import { ApiService } from 'app/services'
import { SharedModule } from 'app/shared/shared.module'
import { FormValidators, Utils } from 'app/utils'
import { NzMessageService } from 'ng-zorro-antd/message'
import { OrgSelectComponent } from '../../org-select/org-select.component'
import { SelectUserByOrgComponent } from '../../select-user-by-org/select-user-by-org.component'
import { PositionSelectComponent } from '../../position-select/position-select.component'
import { NzSafeAny } from 'ng-zorro-antd/core/types'
import { NZ_MODAL_DATA } from 'ng-zorro-antd/modal'
import { SupplierSelectComponent } from '../../supplier-select/supplier-select.component'
import { AssetSelectComponent } from '../../asset-select/asset-select.component'
import { WarehouseSelectComponent } from '../../warehouse-select/warehouse-select.component'
@Component({
selector: 'app-asset-employee-apply',
standalone: true,
imports: [
SharedModule,
SelectUserByOrgComponent,
SupplierSelectComponent,
AssetSelectComponent,
OrgSelectComponent,
PositionSelectComponent,
WarehouseSelectComponent,
],
templateUrl: './asset-employee-apply.component.html',
styleUrl: './asset-employee-apply.component.less',
})
export class AssetEmployeeApplyComponent {
constructor(
private fb: FormBuilder,
private api: ApiService,
private msg: NzMessageService,
) {}
readonly data: NzSafeAny = inject(NZ_MODAL_DATA)
formGroup!: FormGroup
groupIndex = 0
uploadLoading = false
ngOnInit(): void {
console.log('this.data', this.data)
this.formGroup = this.fb.group({
id: this.fb.control(null, []),
title: this.fb.control(this.data.value?.name, [FormValidators.required('请输入')]),
// useUserId: this.fb.control(null, [FormValidators.required('请选择')]),
applyDepartmentId: this.fb.control(null, [FormValidators.required('请选择')]),
applicant: this.fb.control({ value: this.api.authInfo?.userName, disabled: true }, [
FormValidators.required('请选择'),
]),
// businessGeneratedDate: this.fb.control(null, [FormValidators.required('请选择')]),
notes: this.fb.control(null, [FormValidators.required('请输入')]),
urgency: this.fb.control(1, []),
})
this.patchValues()
}
patchValues() {
const { value: data, preview } = this.data
if (data) {
this.formGroup.patchValue({
...data.procVars,
applyDepartmentId: data.procVars?.applyDepartmentId + '',
})
}
if (preview) {
this.formGroup.disable()
}
}
public getValues() {
let values = null
if (FormValidators.validateFormGroup(this.formGroup)) {
const v = this.formGroup.value
values = {
...v,
applyDepartmentId: Number(v.applyDepartmentId?.[0]),
}
}
return values
}
onFileChange(e: Event) {
const target = e.target as HTMLInputElement
const file = target.files![0]
target.value = ''
const formdata = new FormData()
formdata.append('file', file)
this.api.upload(formdata).subscribe((res) => {
this.formGroup.get('attach')?.setValue(res.body.fileName)
})
}
}