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

180 lines
4.4 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 { NzSafeAny } from 'ng-zorro-antd/core/types'
import { NZ_MODAL_DATA, NzModalService } 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'
import {
defectStatusText,
HandleTaskAssetItemComponent,
} from '../handle-task-asset-item/handle-task-asset-item.component'
import { lastValueFrom } from 'rxjs'
import { PlanTaskType } from 'app/types'
@Component({
selector: 'app-stocktaking-detail-form',
standalone: true,
imports: [
SharedModule,
SelectUserByOrgComponent,
SupplierSelectComponent,
AssetSelectComponent,
OrgSelectComponent,
PositionSelectComponent,
UploadComponent,
],
templateUrl: './handle-task.component.html',
styleUrl: './handle-task.component.less',
})
export class HandleTaskComponent {
constructor(
private fb: FormBuilder,
private api: ApiService,
private msg: NzMessageService,
private route: ActivatedRoute,
) {}
readonly data: NzSafeAny = inject(NZ_MODAL_DATA)
formGroup!: FormGroup
flowForms: NzSafeAny[] = []
teamList: NzSafeAny[] = []
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({
teamId: this.fb.control(null, []),
name: this.fb.control({ value: null, disabled: true }, [FormValidators.required('请输入')]),
remark: this.fb.control(null, []),
feedback: this.fb.control(null, []),
// plannedDate: this.fb.control(null, [FormValidators.required('请选择')]),
actualStartTime: this.fb.control(null, []),
businessId: this.fb.control({ value: null, disabled: true }, []),
duration: this.fb.control(null, []),
expectedStartTime: this.fb.control({ value: null, disabled: true }, []),
expectedFinishTime: this.fb.control({ value: null, disabled: true }, []),
order: this.fb.control(false, []),
limit: this.fb.control(false, []),
img: this.fb.control(null, []),
assetIdList: this.fb.control([], []),
})
this.patchValues()
}
title?: string
defectStatusText = defectStatusText
defectStatusTextOnThis: string[] = []
defectStatus = {
0: 'processing',
1: 'success',
2: 'warning',
3: 'error',
} as any
handlePreview(asset: NzSafeAny) {}
modal = inject(NzModalService)
handleItem(asset: NzSafeAny) {
this.modal.create({
nzTitle: this.title + '执行详情',
nzContent: HandleTaskAssetItemComponent,
nzWidth: '80vw',
nzWrapClassName: 'modal-lg',
nzData: {
asset,
task: this.data.value,
title: this.title,
type: this.data.type,
},
nzOnOk: async (e) => {
const vals = e.getValues()
if (vals) {
const res = await lastValueFrom(
this.api.handleTaskAssetItem(
{
...this.data.value,
defects: this.data.value.defects.map((i: NzSafeAny) => {
if (i.assetId === asset.assetId) {
return {
...asset,
_formValue: vals._extInfo,
...vals,
}
}
return i
}),
},
this.data.value.id,
),
)
this.msg.success(res.desc)
// this.table.ref.reload()
return true
}
return false
},
})
}
patchValues() {
const { value: data, preview, type } = this.data
this.title = taskTypeTitle.get(type)
this.defectStatusTextOnThis = this.defectStatusText[type as PlanTaskType]
if (data) {
this.formGroup.patchValue({
...data,
})
}
if (preview) {
this.formGroup.disable()
}
}
public getValues() {
let values = null
console.log('this.formGroup', this.formGroup)
if (FormValidators.validateFormGroup(this.formGroup)) {
const v = this.formGroup.value
values = {
...v,
assetIdList: v.assetIdList.map((i: NzSafeAny) => {
return {
...i,
// assetId: i,
}
}),
// assetId
}
}
return values
}
}