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

109 lines
3.3 KiB

2 years ago
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'
2 years ago
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'
2 years ago
import { NzSafeAny } from 'ng-zorro-antd/core/types'
import { NZ_MODAL_DATA } from 'ng-zorro-antd/modal'
2 years ago
import { SupplierSelectComponent } from '../../supplier-select/supplier-select.component'
import { AssetSelectComponent } from '../../asset-select/asset-select.component'
import { WarehouseSelectComponent } from '../../warehouse-select/warehouse-select.component'
2 years ago
@Component({
2 years ago
selector: 'app-eam-asset-employee-scrap',
2 years ago
standalone: true,
imports: [
SharedModule,
SelectUserByOrgComponent,
SupplierSelectComponent,
AssetSelectComponent,
OrgSelectComponent,
PositionSelectComponent,
WarehouseSelectComponent,
],
2 years ago
templateUrl: './eam-asset-employee-scrap.component.html',
styleUrl: './eam-asset-employee-scrap.component.less',
2 years ago
})
2 years ago
export class EamAssetEmployeeScrapComponent {
2 years ago
constructor(
private fb: FormBuilder,
private api: ApiService,
private msg: NzMessageService,
) {}
readonly data: NzSafeAny = inject(NZ_MODAL_DATA)
formGroup!: FormGroup
groupIndex = 0
uploadLoading = false
2 years ago
iconPreview = ''
2 years ago
ngOnInit(): void {
this.formGroup = this.fb.group({
id: this.fb.control(null, []),
2 years ago
title: this.fb.control(this.data.value?.name, [FormValidators.required('请输入')]),
2 years ago
// useUserId: this.fb.control(null, [FormValidators.required('请选择')]),
2 years ago
scrapType: this.fb.control(null, [FormValidators.required('请选择')]),
scrapTime: this.fb.control(null, [FormValidators.required('请选择')]),
2 years ago
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('请输入')]),
2 years ago
urgency: this.fb.control(1, []),
assetIdList: this.fb.control([], []),
attach: this.fb.control(null, []),
2 years ago
})
this.patchValues()
}
patchValues() {
const { value: data, preview } = this.data
if (data) {
2 years ago
this.iconPreview = data.procVars?.img
2 years ago
this.formGroup.patchValue({
2 years ago
...data.procVars,
applyDepartmentId: data.procVars?.applyDepartmentId + '',
2 years ago
})
}
if (preview) {
this.formGroup.disable()
}
}
public getValues() {
let values = null
if (FormValidators.validateFormGroup(this.formGroup)) {
const v = this.formGroup.value
values = {
...v,
2 years ago
// applyDepartmentId: Number(v.applyDepartmentId?.[0]),
2 years ago
}
}
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)
})
}
}