34 changed files with 1878 additions and 206 deletions
@ -0,0 +1,144 @@ |
|||
<div class="modal-container"> |
|||
<form nz-form [formGroup]="formGroup" nzLayout="vertical"> |
|||
<div class="overflow-hidden"> |
|||
<div class="text-lg mb-2">基本信息</div> |
|||
<div nz-row [nzGutter]="24"> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>流程标识</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input nz-input formControlName="formKey" placeholder="请输入" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>流程名称</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input nz-input formControlName="name" placeholder="请输入" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label>流程ID</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input nz-input formControlName="deployId" placeholder="请输入" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label>流程分类</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input nz-input formControlName="type" placeholder="请输入" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
|
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>流程状态</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-radio-group formControlName="status"> |
|||
<label nz-radio [nzValue]="0">启用 </label> |
|||
<label nz-radio [nzValue]="1">禁用 </label> |
|||
</nz-radio-group> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
|
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>自动指派</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-switch formControlName="autoAssign" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
|
|||
<div nz-col [nzSpan]="24"> |
|||
<nz-form-item> |
|||
<nz-form-label>流程备注</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input nz-input formControlName="remark" placeholder="请输入" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
|
|||
<div nz-col [nzSpan]="24"> |
|||
<nz-form-item> |
|||
<nz-form-label>审批节点</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-table nzTemplateMode nzSize="small" [nzBordered]="true"> |
|||
<thead> |
|||
<tr> |
|||
<th nzWidth="100px">序号</th> |
|||
<th>流程节点</th> |
|||
<th nzWidth="250px">权限角色</th> |
|||
<th nzWidth="250px">权限人员</th> |
|||
<th>备注</th> |
|||
<th>操作</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody formArrayName="nodes"> |
|||
<tr *ngFor="let item of nodes.controls; let i = index" [formGroupName]="i"> |
|||
<td> |
|||
<input nz-input formControlName="id" placeholder="请输入" /> |
|||
</td> |
|||
<td> |
|||
<input nz-input formControlName="name" placeholder="请输入" /> |
|||
</td> |
|||
<td> |
|||
<nz-select |
|||
class="!w-full" |
|||
nzMode="multiple" |
|||
formControlName="roleIds" |
|||
nzPlaceHolder="请选择" |
|||
> |
|||
<nz-option |
|||
*ngFor="let r of roles" |
|||
[nzValue]="r.roleId" |
|||
[nzLabel]="r.roleName" |
|||
></nz-option> |
|||
</nz-select> |
|||
</td> |
|||
<td> |
|||
<app-select-user-by-org formControlName="userIds" /> |
|||
</td> |
|||
<td> |
|||
<input nz-input formControlName="remark" placeholder="请输入" /> |
|||
</td> |
|||
<td> |
|||
<button |
|||
[disabled]="!!item.get('isDefault')?.value" |
|||
nz-button |
|||
nzDanger |
|||
nzType="text" |
|||
(click)="removeNode(i)" |
|||
> |
|||
<span nz-icon nzType="delete" nzTheme="outline"></span> |
|||
</button> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="6"> |
|||
<button nz-button nzBlock nzType="dashed" (click)="addNode()"> |
|||
<i nz-icon nzType="plus"></i> |
|||
新增节点 |
|||
</button> |
|||
</td> |
|||
</tr> |
|||
</tbody> |
|||
</nz-table> |
|||
</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,137 @@ |
|||
import { Component, Input, OnInit, inject } from '@angular/core' |
|||
import { FormArray, 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 { MAX_PAGE_SIZE, STOCKTAKING_JOB_STATUS_MAP } from 'app/constants' |
|||
import { |
|||
AssetSelectComponent, |
|||
OrgSelectComponent, |
|||
PositionSelectComponent, |
|||
SelectUserByOrgComponent, |
|||
SupplierSelectComponent, |
|||
} from 'app/components' |
|||
|
|||
@Component({ |
|||
selector: 'app-stocktaking-detail-form', |
|||
standalone: true, |
|||
imports: [ |
|||
SharedModule, |
|||
SelectUserByOrgComponent, |
|||
SupplierSelectComponent, |
|||
AssetSelectComponent, |
|||
OrgSelectComponent, |
|||
PositionSelectComponent, |
|||
], |
|||
templateUrl: './flow-form-v2.component.html', |
|||
styleUrl: './flow-form-v2.component.less', |
|||
}) |
|||
export class FlowFormV2Component { |
|||
constructor( |
|||
private fb: FormBuilder, |
|||
private api: ApiService, |
|||
private msg: NzMessageService, |
|||
private route: ActivatedRoute, |
|||
) {} |
|||
|
|||
readonly data: NzSafeAny = inject(NZ_MODAL_DATA) |
|||
|
|||
formGroup!: FormGroup |
|||
|
|||
roles: NzSafeAny[] = [] |
|||
ngOnInit(): void { |
|||
this.api.getRolePage({ pageSize: MAX_PAGE_SIZE, pageNum: 1 }).subscribe((res) => { |
|||
this.roles = res.body.rows |
|||
}) |
|||
|
|||
this.formGroup = this.fb.group({ |
|||
status: this.fb.control(null, [FormValidators.required('请选择')]), |
|||
autoAssign: this.fb.control(null, [FormValidators.required('请输入')]), |
|||
remark: this.fb.control(null, []), |
|||
name: this.fb.control({ value: null, disabled: true }, [FormValidators.required('请输入')]), |
|||
formKey: this.fb.control({ value: null, disabled: true }, [FormValidators.required('请输入')]), |
|||
deployId: this.fb.control({ value: null, disabled: true }, [FormValidators.required('请输入')]), |
|||
type: this.fb.control({ value: null, disabled: true }, [FormValidators.required('请输入')]), |
|||
nodes: this.fb.array([]), |
|||
}) |
|||
|
|||
this.patchValues() |
|||
} |
|||
|
|||
get nodes(): FormArray { |
|||
return this.formGroup.get('nodes') as FormArray |
|||
} |
|||
|
|||
removeNode(idx: number) { |
|||
this.nodes.removeAt(idx) |
|||
} |
|||
addNode() { |
|||
this.nodes.push( |
|||
this.fb.group({ |
|||
id: this.fb.control(null, [FormValidators.required('请输入')]), |
|||
isDefault: this.fb.control(false), |
|||
name: this.fb.control(null, [FormValidators.required('请输入')]), |
|||
remark: this.fb.control(null), |
|||
roleIds: this.fb.control([], [FormValidators.required('请输入')]), |
|||
userIds: this.fb.control([], [FormValidators.required('请输入')]), |
|||
}), |
|||
) |
|||
} |
|||
patchValues() { |
|||
const { value: data, preview } = this.data |
|||
if (data) { |
|||
const nodes = data?.nodes ?? [] |
|||
this.nodes.clear() |
|||
nodes.forEach((node: NzSafeAny) => { |
|||
const fg = this.fb.group({ |
|||
id: this.fb.control(node.id), |
|||
isDefault: this.fb.control(node.isDefault), |
|||
name: this.fb.control(node.name), |
|||
remark: this.fb.control(node.remark), |
|||
roleIds: this.fb.control(node.roleIds), |
|||
userIds: this.fb.control(node.userIds), |
|||
}) |
|||
if (node.isDefault === 1) { |
|||
// fg.disable()
|
|||
} |
|||
this.nodes.push(fg) |
|||
}) |
|||
|
|||
this.formGroup.patchValue({ |
|||
...data, |
|||
}) |
|||
} |
|||
if (preview) { |
|||
this.formGroup.disable() |
|||
} |
|||
} |
|||
|
|||
public getValues() { |
|||
let values = null |
|||
if (FormValidators.validateFormGroup(this.formGroup)) { |
|||
// const nodes = this.nodes.value ?? []
|
|||
// if (nodes.some((i: NzSafeAny) => !i.roleIds?.length || !i.userIds?.length || !i.name || !i.id)) {
|
|||
// this.msg.error('请完善节点信息')
|
|||
// return
|
|||
// }
|
|||
const v = this.formGroup.value |
|||
values = { |
|||
...v, |
|||
nodes: v.nodes.map((i: NzSafeAny) => { |
|||
return { |
|||
...i, |
|||
isDefault: i.isDefault ? 1 : 0, |
|||
} |
|||
}), |
|||
// assetId
|
|||
} |
|||
} |
|||
return values |
|||
} |
|||
} |
|||
@ -0,0 +1,135 @@ |
|||
<div class="asset-form"> |
|||
<form nz-form [formGroup]="formGroup" nzLayout="vertical"> |
|||
<div nz-row [nzGutter]="24"> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>设备编号</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
{{ data.asset.assetCode }} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>设备名称</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
{{ data.asset.name }} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>设备分类</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
{{ data.asset.assetCode }} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>设备状态</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-radio-group formControlName="defectStatus"> |
|||
<label nz-radio [nzValue]="0">{{ statusText[type][0] }}</label> |
|||
<label nz-radio [nzValue]="1">{{ statusText[type][1] }}</label> |
|||
<label nz-radio [nzValue]="2">{{ statusText[type][2] }}</label> |
|||
<label nz-radio [nzValue]="3">{{ statusText[type][3] }}</label> |
|||
</nz-radio-group> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
|
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>自动发起报修流程</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-switch /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="24"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>{{ data.title }}总结</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input nz-input formControlName="notes" placeholder="请输入总结内容" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
|
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label>图片信息</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<app-upload [drag]="true" formControlName="img" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label>附件信息</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<app-upload [drag]="true" formControlName="attachment" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
</div> |
|||
<div formArrayName="_extInfo"> |
|||
@if (extraFields.length > 0) { |
|||
<div class="text-lg mb-6">{{ data.title }}项目</div> |
|||
<div nz-row [nzGutter]="24"> |
|||
@for (item of extraFields; track item.key) { |
|||
<div nz-col nzSpan="8" [formGroupName]="$index"> |
|||
<nz-form-item> |
|||
<nz-form-label>{{ item.name }}</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
@switch (item.type) { |
|||
@case ('DATE') { |
|||
<nz-date-picker |
|||
class="!w-full" |
|||
placeholder="请输入" |
|||
[formControlName]="'value'" |
|||
/> |
|||
} |
|||
@case ('RADIO') { |
|||
<ng-container *ngIf="item?.value?.fields as fields"> |
|||
<nz-radio-group [formControlName]="'value'" class="radio"> |
|||
<label |
|||
*ngFor="let f of fields; let i = index" |
|||
nz-radio |
|||
[nzValue]="f" |
|||
> |
|||
{{ f }} |
|||
</label> |
|||
</nz-radio-group> |
|||
</ng-container> |
|||
} |
|||
@case ('NUMBER') { |
|||
<nz-input-number |
|||
class="!w-full" |
|||
nz-input |
|||
placeholder="请输入" |
|||
[formControlName]="'value'" |
|||
/> |
|||
} |
|||
@default { |
|||
<input |
|||
class="w-full" |
|||
nz-input |
|||
placeholder="请输入" |
|||
[formControlName]="'value'" |
|||
/> |
|||
} |
|||
} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
} |
|||
</div> |
|||
} |
|||
</div> |
|||
|
|||
<ng-template #errorTpl let-control> |
|||
<form-error-tips [control]="control"></form-error-tips> |
|||
</ng-template> |
|||
</form> |
|||
</div> |
|||
@ -0,0 +1,181 @@ |
|||
import { Component, Input, OnInit, ViewChild, inject } from '@angular/core' |
|||
import { FormArray, 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 { AssetCategorySelectComponent } from '../asset-category-select/asset-category-select.component'
|
|||
// import { OrgSelectComponent } from '../org-select/org-select.component'
|
|||
import { ASSET_SOURCE_MAP, ASSET_STATUS, MAINTENANCE_STATUS, MAINTENANCE_TYPE, MAX_PAGE_SIZE } from 'app/constants' |
|||
// import { SelectUserByOrgComponent } from '../select-user-by-org/select-user-by-org.component'
|
|||
// import { ManufacturerSelectComponent } from '../manufacturer-select/manufacturer-select.component'
|
|||
// import { PositionSelectComponent } from '../position-select/position-select.component'
|
|||
// import { MaintenanceSelectComponent } from '../maintenance-select/maintenance-select.component'
|
|||
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
|||
import { NZ_MODAL_DATA } from 'ng-zorro-antd/modal' |
|||
import { UploadComponent } from 'app/shared/components/upload/upload.component' |
|||
import { AssetCategorySelectComponent } from 'app/components/asset-category-select/asset-category-select.component' |
|||
import { PlanTaskType } from 'app/types' |
|||
// import { AssetOperationRecordsComponent } from '../asset-operation-records/asset-operation-records.component'
|
|||
// import { AssetRepairRecordsComponent } from '../asset-repair-records/asset-repair-records.component'
|
|||
// import { UploadComponent } from '../../shared/components/upload/upload.component'
|
|||
|
|||
export const defectStatusText: Record<PlanTaskType, string[]> = { |
|||
inspection: ['待检', '正常', '异常', '取消'], |
|||
stocktaking: ['待盘点', '正常', '盘赢', '盘亏'], |
|||
maintenance: ['待保养', '正常', '异常', '取消'], |
|||
repair: [], |
|||
} |
|||
@Component({ |
|||
selector: 'app-asset-form', |
|||
standalone: true, |
|||
imports: [ |
|||
SharedModule, |
|||
// AssetCategorySelectComponent,
|
|||
// OrgSelectComponent,
|
|||
// SelectUserByOrgComponent,
|
|||
// ManufacturerSelectComponent,
|
|||
// PositionSelectComponent,
|
|||
// MaintenanceSelectComponent,
|
|||
// AssetOperationRecordsComponent,
|
|||
// AssetRepairRecordsComponent,
|
|||
UploadComponent, |
|||
], |
|||
templateUrl: './handle-task-asset-item.component.html', |
|||
styleUrl: './handle-task-asset-item.component.less', |
|||
}) |
|||
export class HandleTaskAssetItemComponent { |
|||
constructor( |
|||
private fb: FormBuilder, |
|||
private api: ApiService, |
|||
private msg: NzMessageService, |
|||
) {} |
|||
|
|||
@ViewChild('assetCategorySelect') assetCategorySelect!: AssetCategorySelectComponent |
|||
|
|||
readonly data: NzSafeAny = inject(NZ_MODAL_DATA) |
|||
|
|||
formGroup!: FormGroup |
|||
|
|||
groupIndex = 0 |
|||
|
|||
ASSET_STATUS = ASSET_STATUS |
|||
|
|||
ASSET_SOURCE_MAP = ASSET_SOURCE_MAP |
|||
|
|||
MAINTENANCE_STATUS = MAINTENANCE_STATUS |
|||
|
|||
MAINTENANCE_TYPE = MAINTENANCE_TYPE |
|||
|
|||
financialCategory: NzSafeAny[] = [] |
|||
|
|||
flowForms: NzSafeAny[] = [] |
|||
|
|||
extraFields: NzSafeAny[] = [] |
|||
|
|||
statusText = defectStatusText |
|||
|
|||
type: PlanTaskType = 'inspection' |
|||
ngOnInit(): void { |
|||
// this.api.getFlowFormList().subscribe((res) => {
|
|||
// this.flowForms = res.body
|
|||
// })
|
|||
this.formGroup = this.fb.group({ |
|||
defectStatus: this.fb.control(null, [FormValidators.required('请选择')]), |
|||
|
|||
img: this.fb.control(null, []), |
|||
attachment: this.fb.control(null, []), |
|||
notes: this.fb.control(null, []), |
|||
|
|||
_extInfo: this.fb.array([]), |
|||
}) |
|||
|
|||
this.patchValues() |
|||
|
|||
this.api.getBasicFinancialCategory({}).subscribe((res) => { |
|||
this.financialCategory = res.body |
|||
}) |
|||
} |
|||
|
|||
get extInfo(): FormArray { |
|||
return this.formGroup.get('_extInfo') as FormArray |
|||
} |
|||
|
|||
onExtraChange(v: any) { |
|||
let extraFields: NzSafeAny[] = [] |
|||
try { |
|||
const formValue = this.assetCategorySelect.originTreeData.find((f) => f.categoryId === Number(v)) |
|||
?._assetExtTemp |
|||
extraFields = formValue ?? [] |
|||
} catch (error) {} |
|||
|
|||
this.setExtraFields(extraFields) |
|||
} |
|||
|
|||
ext = null |
|||
setExtraFields(fields: NzSafeAny[]) { |
|||
this.extInfo.clear() |
|||
this.extraFields = fields |
|||
.sort((a, b) => a.sort - b.sort) |
|||
.map((i) => { |
|||
let val = i.value |
|||
if (i.type === 'RADIO') { |
|||
val = i.value?.value |
|||
} else if (i.type === 'DATE') { |
|||
val = i.value ? new Date(i.value) : null |
|||
} |
|||
|
|||
this.extInfo.push( |
|||
this.fb.group({ |
|||
key: this.fb.control(i.key), |
|||
name: this.fb.control(i.name), |
|||
remark: this.fb.control(i.remark), |
|||
sort: this.fb.control(i.sort), |
|||
type: this.fb.control(i.type), |
|||
value: this.fb.control(val), |
|||
fields: this.fb.control(i.type === 'RADIO' ? i.value?.fields : []), |
|||
}), |
|||
) |
|||
return i |
|||
}) |
|||
} |
|||
|
|||
patchValues() { |
|||
const { asset: data, preview, type } = this.data |
|||
if (data) { |
|||
this.type = type |
|||
this.formGroup.patchValue({ |
|||
...data, |
|||
}) |
|||
this.setExtraFields(data._formValue) |
|||
} |
|||
if (preview) { |
|||
this.formGroup.disable() |
|||
} |
|||
} |
|||
|
|||
public getValues() { |
|||
let values = null |
|||
if (FormValidators.validateFormGroup(this.formGroup)) { |
|||
const v = this.formGroup.getRawValue() |
|||
|
|||
values = { |
|||
...v, |
|||
|
|||
_extInfo: this.extInfo.value.map((v: any) => { |
|||
if (v.type === 'RADIO') { |
|||
return { |
|||
...v, |
|||
value: { |
|||
value: v.value, |
|||
fields: v.fields.map((i: string) => i), |
|||
}, |
|||
} |
|||
} |
|||
return v |
|||
}), |
|||
} |
|||
} |
|||
return values |
|||
} |
|||
} |
|||
@ -0,0 +1,208 @@ |
|||
<div class="modal-lg-container"> |
|||
<form nz-form [formGroup]="formGroup" nzLayout="vertical"> |
|||
<div class="overflow-hidden"> |
|||
<div class="text-lg mb-2">基本信息</div> |
|||
<div nz-row [nzGutter]="24"> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label>任务名称</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input nz-input formControlName="name" placeholder="请输入" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label>任务编号</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input nz-input formControlName="businessId" placeholder="请输入" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label>执行班组</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-select nzPlaceHolder="请选择" formControlName="teamId" nzAllowClear nzShowSearch> |
|||
@for (item of teamList; track $index) { |
|||
<nz-option [nzLabel]="item.teamName" [nzValue]="item.teamId" /> |
|||
} |
|||
</nz-select> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label>预计开始</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-date-picker class="!w-full" nzShowTime formControlName="expectedStartTime" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label>预计完成</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-date-picker class="!w-full" nzShowTime formControlName="expectedFinishTime" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>计划用时</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-input-group nzAddOnAfter="天"> |
|||
<nz-input-number class="!w-full" [nzMin]="0" formControlName="duration" /> |
|||
</nz-input-group> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>实际开始</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-date-picker class="!w-full" nzShowTime formControlName="actualStartTime" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>实际完成</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-date-picker class="!w-full" nzShowTime formControlName="actualStartTime" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col [nzSpan]="8"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired>任务状态</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
@switch (data.value.status) { |
|||
<!-- APPROVAL,COMPLETED,DISCARDED,DRAFTING,EXCEPTION,REJECTED,SUSPENDED,TO_BE_ASSIGNED --> |
|||
@case ('APPROVAL') { |
|||
<span class="text-blue-500">待处理</span> |
|||
} |
|||
@case ('COMPLETED') { |
|||
<span class="text-green-500">已完成</span> |
|||
} |
|||
@case ('DISCARDED') { |
|||
<span class="text-gray-500">已废弃</span> |
|||
} |
|||
@case ('DRAFTING') { |
|||
<span class="text-yellow-500">草稿中</span> |
|||
} |
|||
@case ('EXCEPTION') { |
|||
<span class="text-red-500">异常</span> |
|||
} |
|||
@case ('REJECTED') { |
|||
<span class="text-red-500">已驳回</span> |
|||
} |
|||
@case ('DISPOSE') { |
|||
<span class="text-blue-500">待处置</span> |
|||
} |
|||
@case ('SUSPENDED') { |
|||
<span class="text-yellow-500">已挂起</span> |
|||
} |
|||
@case ('TO_BE_ASSIGNED') { |
|||
<span class="text-yellow-500">待分配</span> |
|||
} |
|||
@default { |
|||
{{ data }} |
|||
} |
|||
} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
|
|||
<div nz-col [nzSpan]="24"> |
|||
<nz-form-item> |
|||
<nz-form-label>任务反馈</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input nz-input placeholder="请输入" formControlName="feedback" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
|
|||
<div nz-col [nzSpan]="24"> |
|||
<nz-form-item> |
|||
<nz-form-label>备注</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input nz-input placeholder="请输入" formControlName="remark" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
<div nz-col nzSpan="24"> |
|||
<div class="text-lg mb-2">{{ title }}设备</div> |
|||
</div> |
|||
<div nz-col [nzSpan]="24"> |
|||
<nz-form-item> |
|||
<!-- <nz-form-label>资产列表</nz-form-label> --> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-table nzTemplateMode [nzBordered]="true" nzSize="small"> |
|||
<thead> |
|||
<tr> |
|||
<th>序号</th> |
|||
<th>设备编号</th> |
|||
<th>设备名称</th> |
|||
<th>设备分类</th> |
|||
<th nzWidth="100px">{{ title }}状态</th> |
|||
<th nzWidth="100px">操作</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
@for (item of data.value.defects; track $index) { |
|||
<tr> |
|||
<td> |
|||
{{ item.assetId }} |
|||
</td> |
|||
<td> |
|||
{{ item.assetCode }} |
|||
</td> |
|||
<td> |
|||
{{ item.name }} |
|||
</td> |
|||
<td> |
|||
{{ item.categoryName }} |
|||
</td> |
|||
<td> |
|||
<nz-badge |
|||
[nzText]="defectStatusTextOnThis[item.defectStatus]" |
|||
[nzStatus]="defectStatus[item.defectStatus]" |
|||
/> |
|||
</td> |
|||
<td> |
|||
<nz-space> |
|||
@if (item.defectStatus == 0) { |
|||
<a |
|||
*nzSpaceItem |
|||
nz-button |
|||
nzType="link" |
|||
(click)="handleItem(item)" |
|||
>执行</a |
|||
> |
|||
} @else { |
|||
<a |
|||
*nzSpaceItem |
|||
nz-button |
|||
nzType="link" |
|||
(click)="handlePreview(item)" |
|||
>查看</a |
|||
> |
|||
} |
|||
</nz-space> |
|||
</td> |
|||
</tr> |
|||
} |
|||
</tbody> |
|||
</nz-table> |
|||
</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,180 @@ |
|||
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 |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
::ng-deep .modal-for-btn { |
|||
.ant-modal-footer .ant-btn[ng-reflect-nz-type="reject"] { |
|||
background-color: #f59a23 !important; |
|||
border-color: #f59a23 !important; |
|||
color: #fff !important; |
|||
} |
|||
|
|||
} |
|||
@ -1 +1,47 @@ |
|||
<p>flow-management works!</p> |
|||
<app-page> |
|||
<div class="flex-1 overflow-hidden"> |
|||
<app-server-paginated-table [options]="table" [renderColumn]="renderColumnTpl"> |
|||
<ng-template #renderColumnTpl let-data let-key="key" let-row="row"> |
|||
@switch (key) { |
|||
@case ('checkRequire') { |
|||
{{ data ? '是' : '否' }} |
|||
} |
|||
@case ('status') { |
|||
@if (data === 0) { |
|||
<nz-badge nzText="启用" nzColor="green" /> |
|||
} @else { |
|||
<nz-badge nzText="停用" nzColor="red" /> |
|||
} |
|||
} |
|||
@case ('autoAssign') { |
|||
@if (row.type !== '资管流程') { |
|||
<span class="cursor-pointer" (click)="updateAutoAssign(row)"> |
|||
<nz-switch [ngModel]="data" class="pointer-events-none" /> |
|||
</span> |
|||
} @else { |
|||
/ |
|||
} |
|||
} |
|||
@default { |
|||
{{ data }} |
|||
} |
|||
} |
|||
</ng-template> |
|||
</app-server-paginated-table> |
|||
</div> |
|||
</app-page> |
|||
|
|||
<ng-template #createFormTpl> |
|||
<form nz-form [formGroup]="createForm"> |
|||
<nz-form-item> |
|||
<nz-form-label [nzSpan]="6" [nzRequired]="true">审批人</nz-form-label> |
|||
<nz-form-control [nzSpan]="12" [nzErrorTip]="errorTpl"> |
|||
<app-select-user-by-org formControlName="userId" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</form> |
|||
</ng-template> |
|||
|
|||
<ng-template #errorTpl let-control> |
|||
<form-error-tips [control]="control"></form-error-tips> |
|||
</ng-template> |
|||
|
|||
@ -1,12 +1,187 @@ |
|||
import { Component } from '@angular/core'; |
|||
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' |
|||
import { SelectUserByOrgComponent } from 'app/components' |
|||
import { MAX_PAGE_SIZE, taskTypeTitle } from 'app/constants' |
|||
import { FlowFormV2Component } from 'app/components/flow-form-v2/flow-form-v2.component' |
|||
|
|||
@Component({ |
|||
selector: 'app-flow-management', |
|||
selector: 'app-flow-form', |
|||
standalone: true, |
|||
imports: [], |
|||
imports: [SharedModule, SelectUserByOrgComponent], |
|||
templateUrl: './flow-management.component.html', |
|||
styleUrl: './flow-management.component.less' |
|||
styleUrl: './flow-management.component.less', |
|||
}) |
|||
export class FlowManagementComponent { |
|||
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: 'formId', title: '主键', width: '100px', visible: true }, |
|||
{ key: 'formKey', title: '标识', width: '250px', visible: true }, |
|||
{ key: 'name', title: '名称', visible: true }, |
|||
{ key: 'deployId', title: '流程ID', width: '100px', visible: true }, |
|||
{ key: 'type', title: '流程分类', visible: true }, |
|||
{ key: 'status', title: '流程状态', visible: true }, |
|||
{ key: 'checkRequire', title: '验收要求', visible: true }, |
|||
{ key: 'autoAssign', title: '自动指派', visible: true }, |
|||
// { key: '_assignee', title: '审批人', visible: true },
|
|||
// { key: 'createTime', title: '创建时间', visible: true },
|
|||
]) |
|||
.setRowOperate([ |
|||
{ title: '编辑', onClick: this.onEdit.bind(this) }, |
|||
{ |
|||
title: '禁用', |
|||
onClick: this.onStop.bind(this), |
|||
visible(v) { |
|||
return v.status === 0 |
|||
}, |
|||
}, |
|||
{ |
|||
title: '启用', |
|||
onClick: this.onStop.bind(this), |
|||
visible(v) { |
|||
return v.status === 1 |
|||
}, |
|||
}, |
|||
]) |
|||
} |
|||
|
|||
updateAutoAssign(d: any) { |
|||
this.modal.confirm({ |
|||
nzTitle: '警告', |
|||
nzContent: `是否要${d.autoAssign ? '关闭' : '开启'}自动指派?`, |
|||
nzOkText: '确定', |
|||
nzCancelText: '取消', |
|||
nzOnOk: async () => { |
|||
const res = await lastValueFrom( |
|||
this.api.flowFormUpdate({ |
|||
...d, |
|||
autoAssign: !d.autoAssign, |
|||
}), |
|||
) |
|||
this.msg.success(res.desc) |
|||
this.table.ref.reload() |
|||
}, |
|||
}) |
|||
} |
|||
fetchData(p: {}, q: AnyObject) { |
|||
return this.api.getFlowForms({ ...p, ...q }).pipe( |
|||
map((r) => { |
|||
return { |
|||
body: { |
|||
rows: r.body, |
|||
total: r.body.length, |
|||
}, |
|||
} |
|||
}), |
|||
) |
|||
} |
|||
|
|||
onEdit(d: NzSafeAny) { |
|||
const nzTitle = '编辑' + d.type |
|||
this.modal.create({ |
|||
nzTitle, |
|||
nzContent: FlowFormV2Component, |
|||
nzWrapClassName: 'modal-lg', |
|||
nzWidth: '80vw', |
|||
|
|||
nzData: { |
|||
value: d, |
|||
preview: false, |
|||
type: d.type, |
|||
}, |
|||
nzOnOk: async (e: NzSafeAny) => { |
|||
const vals = e.getValues() |
|||
console.log('vals', vals) |
|||
if (vals) { |
|||
const res = await lastValueFrom(this.api.flowFormUpdate({ ...d, ...vals })) |
|||
this.msg.success(res.desc) |
|||
this.table.ref.reload() |
|||
return true |
|||
} |
|||
return false |
|||
}, |
|||
nzOnCancel: () => { |
|||
console.log('Cancel') |
|||
}, |
|||
}) |
|||
} |
|||
|
|||
onStop(d: NzSafeAny) { |
|||
this.modal.confirm({ |
|||
nzTitle: '警告', |
|||
nzContent: `是否要${d.status ? '启用' : '禁用'}流程?`, |
|||
|
|||
nzOnOk: async () => { |
|||
const res = await lastValueFrom( |
|||
this.api.flowFormUpdate({ |
|||
...d, |
|||
status: d.status === 1 ? 0 : 1, |
|||
}), |
|||
) |
|||
this.msg.success(res.desc) |
|||
this.table.ref.reload() |
|||
}, |
|||
}) |
|||
} |
|||
|
|||
onSetApprover(data?: NzSafeAny) { |
|||
if (data) { |
|||
this.createForm.patchValue({ |
|||
formId: data.formId, |
|||
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() |
|||
}, |
|||
}) |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue