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

92 lines
2.7 KiB

import { Component, TemplateRef, ViewChild } from '@angular/core'
import { FormControl, FormGroup } from '@angular/forms'
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table'
import { ApiService } from 'app/services'
import { SharedModule } from 'app/shared/shared.module'
import { lastValueFrom, map, of } from 'rxjs'
import { NzSafeAny } from 'ng-zorro-antd/core/types'
import { NzModalService } from 'ng-zorro-antd/modal'
import { NzMessageService } from 'ng-zorro-antd/message'
import { FormValidators } from 'app/utils'
@Component({
selector: 'app-flow-my-finished',
standalone: true,
imports: [SharedModule],
templateUrl: './flow-my-finished.component.html',
styleUrl: './flow-my-finished.component.less',
})
export class FlowMyFinishedComponent {
constructor(
private api: ApiService,
private modal: NzModalService,
private msg: NzMessageService,
) {}
@ViewChild('createFormTpl') createFormTpl!: TemplateRef<{}>
createForm = new FormGroup({
formId: new FormControl(''),
userId: new FormControl<NzSafeAny[]>([], [FormValidators.required('请选择')]),
})
table = new TableOption(this.fetchData.bind(this))
ngOnInit(): void {
this.table
// .setConfig({
// selectable: true,
// rowKey: 'id',
// })
.setColumn([
{ key: 'taskName', title: '标识', visible: true },
{ key: 'name', title: '名称', visible: true },
{ key: 'status', title: '审批状态', visible: true },
{ key: 'category', title: '流程类型', visible: true },
{ key: 'assigneeName', title: '审批人', visible: true },
{ key: 'createTime', title: '提交时间', visible: true },
// { key: 'createTime', title: '作废时间', visible: true },
// { key: 'createTime', title: '完成时间', visible: true },
])
.setRowOperate([{ title: '详情' }, { title: '作废' }])
}
fetchData(p: {}, q: AnyObject) {
return this.api.getMyFinishedAssetFlow({ ...p, ...q })
}
onSetApprover(data?: NzSafeAny) {
if (data) {
console.log('data._assignee.userId', data._assignee.userId)
this.createForm.patchValue({
userId: data._assignee.userId ? [data._assignee.userId] : [],
})
}
this.modal.create({
nzTitle: '设置审批人',
nzContent: this.createFormTpl,
nzOnOk: async () => {
if (FormValidators.validateFormGroup(this.createForm)) {
const vals = this.createForm.value
const res = await lastValueFrom(
this.api.setFlowFormsAssignee({
...vals,
userId: vals.userId?.[0],
}),
)
this.msg.success(res.desc)
this.table.ref.reload()
this.createForm.reset()
return true
}
return false
},
nzOnCancel: () => {
this.createForm.reset()
},
})
}
}