|
|
|
import { Component, OnInit } from '@angular/core'
|
|
|
|
import { ApplyAssetFlowComponent } from 'app/components'
|
|
|
|
import { ApiService } from 'app/services'
|
|
|
|
import { SharedModule } from 'app/shared/shared.module'
|
|
|
|
import { NzSafeAny } from 'ng-zorro-antd/core/types'
|
|
|
|
import { NzMessageService } from 'ng-zorro-antd/message'
|
|
|
|
import { NzModalService } from 'ng-zorro-antd/modal'
|
|
|
|
import { finalize, lastValueFrom } from 'rxjs'
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-flow-main',
|
|
|
|
standalone: true,
|
|
|
|
imports: [SharedModule],
|
|
|
|
templateUrl: './flow-main.component.html',
|
|
|
|
styleUrl: './flow-main.component.less',
|
|
|
|
})
|
|
|
|
export class FlowMainComponent implements OnInit {
|
|
|
|
constructor(
|
|
|
|
private api: ApiService,
|
|
|
|
private msg: NzMessageService,
|
|
|
|
private modal: NzModalService,
|
|
|
|
) {}
|
|
|
|
|
|
|
|
assetFlows: NzSafeAny[] = []
|
|
|
|
|
|
|
|
loading = false
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.loading = true
|
|
|
|
this.api
|
|
|
|
.getFlowForms({})
|
|
|
|
.pipe(
|
|
|
|
finalize(() => {
|
|
|
|
this.loading = false
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
.subscribe((res) => {
|
|
|
|
this.assetFlows = res.body
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
comsMap = {
|
|
|
|
eam_asset_employee_apply: ApplyAssetFlowComponent,
|
|
|
|
}
|
|
|
|
|
|
|
|
onStart(model: NzSafeAny) {
|
|
|
|
this.modal.create({
|
|
|
|
nzTitle: '开始流程',
|
|
|
|
nzContent: this.comsMap[model.formKey as keyof typeof this.comsMap],
|
|
|
|
nzWrapClassName: 'modal-lg',
|
|
|
|
nzWidth: '80vw',
|
|
|
|
nzData: {
|
|
|
|
value: model,
|
|
|
|
preview: false,
|
|
|
|
},
|
|
|
|
nzOnOk: async (e) => {
|
|
|
|
const vals = e.getValues()
|
|
|
|
if (vals) {
|
|
|
|
const res = await lastValueFrom(this.api.startFlow(vals, model.formKey))
|
|
|
|
this.msg.success(res.desc)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
},
|
|
|
|
nzOnCancel: () => {
|
|
|
|
console.log('Cancel')
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|