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.
104 lines
3.1 KiB
104 lines
3.1 KiB
12 months 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'
|
||
12 months 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'
|
||
12 months ago
|
import { NzSafeAny } from 'ng-zorro-antd/core/types'
|
||
|
import { NZ_MODAL_DATA } from 'ng-zorro-antd/modal'
|
||
12 months 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'
|
||
12 months ago
|
|
||
|
@Component({
|
||
12 months ago
|
selector: 'app-asset-employee-apply',
|
||
12 months ago
|
standalone: true,
|
||
|
imports: [
|
||
|
SharedModule,
|
||
|
SelectUserByOrgComponent,
|
||
|
SupplierSelectComponent,
|
||
|
AssetSelectComponent,
|
||
|
OrgSelectComponent,
|
||
|
PositionSelectComponent,
|
||
|
WarehouseSelectComponent,
|
||
|
],
|
||
12 months ago
|
templateUrl: './asset-employee-apply.component.html',
|
||
|
styleUrl: './asset-employee-apply.component.less',
|
||
12 months ago
|
})
|
||
12 months ago
|
export class AssetEmployeeApplyComponent {
|
||
12 months ago
|
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 {
|
||
12 months ago
|
console.log('this.data', this.data)
|
||
12 months ago
|
this.formGroup = this.fb.group({
|
||
|
id: this.fb.control(null, []),
|
||
12 months ago
|
title: this.fb.control(this.data.value?.name, [FormValidators.required('请输入')]),
|
||
12 months ago
|
// 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('请输入')]),
|
||
12 months ago
|
urgency: this.fb.control(1, []),
|
||
12 months ago
|
})
|
||
|
|
||
|
this.patchValues()
|
||
|
}
|
||
|
|
||
|
patchValues() {
|
||
|
const { value: data, preview } = this.data
|
||
|
if (data) {
|
||
|
this.formGroup.patchValue({
|
||
12 months ago
|
...data.procVars,
|
||
|
applyDepartmentId: data.procVars?.applyDepartmentId + '',
|
||
12 months ago
|
})
|
||
|
}
|
||
|
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)
|
||
|
})
|
||
|
}
|
||
|
}
|