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

134 lines
3.2 KiB

1 year 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'
import { NzSafeAny } from 'ng-zorro-antd/core/types'
import { NZ_MODAL_DATA } from 'ng-zorro-antd/modal'
import { ActivatedRoute } from '@angular/router'
import { STOCKTAKING_JOB_STATUS_MAP, taskTypeTitle } from 'app/constants'
import {
AssetSelectComponent,
OrgSelectComponent,
PositionSelectComponent,
SelectUserByOrgComponent,
SupplierSelectComponent,
} from 'app/components'
import { UploadComponent } from '../../../shared/components/upload/upload.component'
@Component({
selector: 'app-stocktaking-detail-form',
standalone: true,
imports: [
SharedModule,
SelectUserByOrgComponent,
SupplierSelectComponent,
AssetSelectComponent,
OrgSelectComponent,
PositionSelectComponent,
UploadComponent,
],
templateUrl: './task-form.component.html',
styleUrl: './task-form.component.less',
})
export class TaskFormComponent {
constructor(
private fb: FormBuilder,
private api: ApiService,
private msg: NzMessageService,
private route: ActivatedRoute,
) {}
readonly data: NzSafeAny = inject(NZ_MODAL_DATA)
STOCKTAKING_JOB_STATUS_MAP = STOCKTAKING_JOB_STATUS_MAP
formGroup!: FormGroup
groupIndex = 0
uploadLoading = false
uploadImgLoading = false
iconPreview = ''
flowForms: NzSafeAny[] = []
teamList: NzSafeAny[] = []
1 year ago
handle = false
1 year ago
ngOnInit(): void {
this.api.getAssetTeamAll().subscribe((res) => {
this.teamList = res.body
})
this.api.getFlowFormList().subscribe((res) => {
this.flowForms = res.body
})
this.formGroup = this.fb.group({
1 year ago
teamId: this.fb.control(null, [FormValidators.required('请选择')]),
1 year ago
name: this.fb.control(null, [FormValidators.required('请输入')]),
remark: this.fb.control(null, []),
1 year ago
formTempId: this.fb.control(null, [FormValidators.required('请选择')]),
1 year ago
// plannedDate: this.fb.control(null, [FormValidators.required('请选择')]),
actualStartTime: this.fb.control(null, []),
1 year ago
businessId: this.fb.control(null, []),
attachment: this.fb.control(null, []),
1 year ago
duration: this.fb.control(null, []),
order: this.fb.control(false, []),
limit: this.fb.control(false, []),
1 year ago
img: this.fb.control(null, []),
assetIdList: this.fb.control([], []),
})
this.patchValues()
}
title?: string
patchValues() {
const { value: data, preview, type } = this.data
this.title = taskTypeTitle.get(type)
1 year ago
1 year ago
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
1 year ago
const form = this.flowForms.find((i) => i.formTempId === v.formTempId)
1 year ago
values = {
...v,
1 year ago
formName: form.formName,
formValue: form.formValue,
teamName: this.teamList.find((i) => i.teamId === v.teamId).teamName,
1 year ago
assetIdList: v.assetIdList.map((i: NzSafeAny) => {
return {
...i,
1 year ago
1 year ago
// assetId: i,
}
}),
// assetId
}
}
return values
}
}