17 changed files with 234 additions and 30 deletions
@ -0,0 +1,45 @@ |
|||
<div class="modal"> |
|||
<form nz-form [formGroup]="formGroup" nzLayout="vertical"> |
|||
<div class="overflow-hidden"> |
|||
<div nz-row [nzGutter]="24"> |
|||
<div nz-col [nzSpan]="6"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>流程标题</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input nz-input placeholder="请输入流程标题" formControlName="title" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="6"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>申请部门</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<app-org-select formControlName="applyDepartmentId" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="6"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>申请人</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input nz-input placeholder="请输入申请人" formControlName="applicant" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
|
|||
<div nz-col [nzSpan]="24"> |
|||
<nz-form-item> |
|||
<nz-form-label [nzRequired]="true">原因</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<textarea nz-input placeholder="请输入原因" formControlName="notes"></textarea> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
|
|||
<ng-template #errorTpl let-control> |
|||
<form-error-tips [control]="control"></form-error-tips> |
|||
</ng-template> |
|||
</div> |
@ -0,0 +1,100 @@ |
|||
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-apply-asset-flow', |
|||
standalone: true, |
|||
imports: [ |
|||
SharedModule, |
|||
SelectUserByOrgComponent, |
|||
SupplierSelectComponent, |
|||
AssetSelectComponent, |
|||
OrgSelectComponent, |
|||
PositionSelectComponent, |
|||
WarehouseSelectComponent, |
|||
], |
|||
templateUrl: './apply-asset-flow.component.html', |
|||
styleUrl: './apply-asset-flow.component.less', |
|||
}) |
|||
export class ApplyAssetFlowComponent { |
|||
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 { |
|||
this.formGroup = this.fb.group({ |
|||
id: this.fb.control(null, []), |
|||
title: this.fb.control('', [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('请输入')]), |
|||
}) |
|||
|
|||
this.patchValues() |
|||
} |
|||
|
|||
patchValues() { |
|||
const { value: data, preview } = this.data |
|||
if (data) { |
|||
this.formGroup.patchValue({ |
|||
...data, |
|||
}) |
|||
} |
|||
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) |
|||
}) |
|||
} |
|||
} |
Loading…
Reference in new issue