diff --git a/web-admin-app/README.md b/web-admin-app/README.md index 0c7d82b..2758755 100644 --- a/web-admin-app/README.md +++ b/web-admin-app/README.md @@ -90,6 +90,38 @@ # v2 -## 10-10 +- 日历 月份 & 类型 +- 任务创建方式 +- 流程首页 资管流程分析 & 资管流程 数量 + + +- 任务处置数据 接口 +- 工作报表 接口 +- 流程管理 自动指派 +- 消息中心 流程消息? 告警? +- 资产管理 审批 & 编辑 + +- 检查项 & 查看 + + +# 修改 + +- 创建巡检任务 任务反馈 +- 创建任务 验证 +- procInsId +- 处置 & 提交审核 /api/flowable/task/complete +- 任务状态 status: + - 受理 TO_BE_ASSIGNED + - 指派 TO_BE_ASSIGNED + - 处置 DISPOSE + - 报表 COMPLETED + +- 计划 停用 & 启用 /api/v2/plan/changeStatus +- 自动指派 /api/flForm/update + +# 10.20 + +提交审核 /api/flowable/task/complete 之前必须全部执行 保存:整个任务数据 +执行接口 /api/v2/flowable/device/update/{id} + -- \ No newline at end of file diff --git a/web-admin-app/src/app/components/flow-form-v2/flow-form-v2.component.html b/web-admin-app/src/app/components/flow-form-v2/flow-form-v2.component.html new file mode 100644 index 0000000..883b798 --- /dev/null +++ b/web-admin-app/src/app/components/flow-form-v2/flow-form-v2.component.html @@ -0,0 +1,144 @@ + diff --git a/web-admin-app/src/app/components/flow-form-v2/flow-form-v2.component.less b/web-admin-app/src/app/components/flow-form-v2/flow-form-v2.component.less new file mode 100644 index 0000000..e69de29 diff --git a/web-admin-app/src/app/components/flow-form-v2/flow-form-v2.component.ts b/web-admin-app/src/app/components/flow-form-v2/flow-form-v2.component.ts new file mode 100644 index 0000000..6b62a66 --- /dev/null +++ b/web-admin-app/src/app/components/flow-form-v2/flow-form-v2.component.ts @@ -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 + } +} diff --git a/web-admin-app/src/app/components/plan-task/calendar-list/calendar-list.component.html b/web-admin-app/src/app/components/plan-task/calendar-list/calendar-list.component.html index 015e0dd..811df90 100644 --- a/web-admin-app/src/app/components/plan-task/calendar-list/calendar-list.component.html +++ b/web-admin-app/src/app/components/plan-task/calendar-list/calendar-list.component.html @@ -1,5 +1,5 @@ -
+
@@ -7,13 +7,17 @@ 任务状态 - + - - - - - + + + + + + + + + @@ -22,7 +26,7 @@ 计划名称 - +
@@ -30,10 +34,15 @@ 创建方式 - - - - + + + + @@ -42,44 +51,31 @@
- - + +
- +
    - @switch (date.getDate()) { - @case (8) { - @for (item of listDataMap.eight; track $index) { -
  • - -
  • - } - } - @case (10) { - @for (item of listDataMap.ten; track $index) { -
  • - -
  • - } - } - @case (11) { - @for (item of listDataMap.eleven; track $index) { -
  • - -
  • - } - } + @for (item of getDateData(date); track $index) { +
  • + +
  • }
@if (getMonthData(month); as monthData) {
{{ monthData }}
- Backlog number + 任务
}
diff --git a/web-admin-app/src/app/components/plan-task/calendar-list/calendar-list.component.ts b/web-admin-app/src/app/components/plan-task/calendar-list/calendar-list.component.ts index f154433..12c449a 100644 --- a/web-admin-app/src/app/components/plan-task/calendar-list/calendar-list.component.ts +++ b/web-admin-app/src/app/components/plan-task/calendar-list/calendar-list.component.ts @@ -1,7 +1,11 @@ -import { Component, Input } from '@angular/core' +import { Component, inject, Input, OnInit } from '@angular/core' +import { FormControl, FormGroup } from '@angular/forms' +import { ApiService } from 'app/services' import { SharedModule } from 'app/shared/shared.module' import { PlanTaskType } from 'app/types' import { NzCalendarMode } from 'ng-zorro-antd/calendar' +import { format } from 'date-fns' +import { NzSafeAny } from 'ng-zorro-antd/core/types' @Component({ selector: 'app-calendar-list', @@ -10,45 +14,101 @@ import { NzCalendarMode } from 'ng-zorro-antd/calendar' templateUrl: './calendar-list.component.html', styleUrl: './calendar-list.component.less', }) -export class CalendarListComponent { +export class CalendarListComponent implements OnInit { constructor() {} @Input() type: PlanTaskType = 'inspection' - date = new Date(2012, 11, 21) + date = new Date() mode: NzCalendarMode = 'month' - OnInit() {} + api = inject(ApiService) + + queryForm = new FormGroup({ + createType: new FormControl(), + status: new FormControl(), + name: new FormControl(), + }) + + ngOnInit() { + this.getData() + } + + getData() { + this.api + .getCalendarData({ + ...this.queryForm.value, + month: this.date, + jobtype: this.type, + }) + .subscribe((res) => { + this.listDataMap = res.body.map((i: NzSafeAny) => { + let color = '' + switch (i.status) { + // 1-起草 2-审批中 3-已结束 4-已驳回 5-已废弃 6-流程异常 7-待指派 8-已挂起 + case 1: + color = '#ffc53d' + break + case 2: + color = '#ffc53d' + break + case 3: + color = '#52c41a' + break + case 4: + color = '#ff4d4f' + break + case 5: + color = '#ff4d4f' + break + case 6: + color = '#ff4d4f' + break + case 7: + color = '#ffc53d' + break + case 8: + color = '#ffc53d' + break + } + return { + ...i, + date: format(new Date(i.createTime), 'yyyy-MM-dd'), + month: format(new Date(i.createTime), 'yyyy-MM'), + color, + } + }) + }) + } panelChange(change: { date: Date; mode: string }): void { console.log(change.date, change.mode) } + nzSelectChange(change: NzSafeAny): void { + console.log(change) + this.getData() + } + + listDataMap = [] + + onQuery() { + this.getData() + } - listDataMap = { - eight: [ - { type: 'warning', content: 'This is warning event.' }, - { type: 'success', content: 'This is usual event.' }, - ], - ten: [ - { type: 'warning', content: 'This is warning event.' }, - { type: 'success', content: 'This is usual event.' }, - { type: 'error', content: 'This is error event.' }, - ], - eleven: [ - { type: 'warning', content: 'This is warning event' }, - { type: 'success', content: 'This is very long usual event........' }, - { type: 'error', content: 'This is error event 1.' }, - { type: 'error', content: 'This is error event 2.' }, - { type: 'error', content: 'This is error event 3.' }, - { type: 'error', content: 'This is error event 4.' }, - ], + getDateData(date: Date): NzSafeAny[] { + return this.listDataMap.filter((f: NzSafeAny) => format(date, 'yyyy-MM-dd') === f.date) } getMonthData(date: Date): number | null { - if (date.getMonth() === 8) { - return 1394 - } - return null + return ( + this.listDataMap.reduce((a: number, f: NzSafeAny) => { + if (format(date, 'yyyy-MM') === f.month) { + return a + 1 + } else { + return a + } + }, 0) || null + ) } } diff --git a/web-admin-app/src/app/components/plan-task/handle-task-asset-item/handle-task-asset-item.component.html b/web-admin-app/src/app/components/plan-task/handle-task-asset-item/handle-task-asset-item.component.html new file mode 100644 index 0000000..487f443 --- /dev/null +++ b/web-admin-app/src/app/components/plan-task/handle-task-asset-item/handle-task-asset-item.component.html @@ -0,0 +1,135 @@ +
+
+
+
+ + 设备编号 + + {{ data.asset.assetCode }} + + +
+
+ + 设备名称 + + {{ data.asset.name }} + + +
+
+ + 设备分类 + + {{ data.asset.assetCode }} + + +
+
+ + 设备状态 + + + + + + + + + +
+ +
+ + 自动发起报修流程 + + + + +
+
+ + {{ data.title }}总结 + + + + +
+ +
+ + 图片信息 + + + + +
+
+ + 附件信息 + + + + +
+
+
+ @if (extraFields.length > 0) { +
{{ data.title }}项目
+
+ @for (item of extraFields; track item.key) { +
+ + {{ item.name }} + + @switch (item.type) { + @case ('DATE') { + + } + @case ('RADIO') { + + + + + + } + @case ('NUMBER') { + + } + @default { + + } + } + + +
+ } +
+ } +
+ + + + +
+
diff --git a/web-admin-app/src/app/components/plan-task/handle-task-asset-item/handle-task-asset-item.component.less b/web-admin-app/src/app/components/plan-task/handle-task-asset-item/handle-task-asset-item.component.less new file mode 100644 index 0000000..e69de29 diff --git a/web-admin-app/src/app/components/plan-task/handle-task-asset-item/handle-task-asset-item.component.ts b/web-admin-app/src/app/components/plan-task/handle-task-asset-item/handle-task-asset-item.component.ts new file mode 100644 index 0000000..d2b15b1 --- /dev/null +++ b/web-admin-app/src/app/components/plan-task/handle-task-asset-item/handle-task-asset-item.component.ts @@ -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 = { + 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 + } +} diff --git a/web-admin-app/src/app/components/plan-task/handle-task/handle-task.component.html b/web-admin-app/src/app/components/plan-task/handle-task/handle-task.component.html new file mode 100644 index 0000000..27f2388 --- /dev/null +++ b/web-admin-app/src/app/components/plan-task/handle-task/handle-task.component.html @@ -0,0 +1,208 @@ + diff --git a/web-admin-app/src/app/components/plan-task/handle-task/handle-task.component.less b/web-admin-app/src/app/components/plan-task/handle-task/handle-task.component.less new file mode 100644 index 0000000..e69de29 diff --git a/web-admin-app/src/app/components/plan-task/handle-task/handle-task.component.ts b/web-admin-app/src/app/components/plan-task/handle-task/handle-task.component.ts new file mode 100644 index 0000000..cbba90f --- /dev/null +++ b/web-admin-app/src/app/components/plan-task/handle-task/handle-task.component.ts @@ -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 + } +} diff --git a/web-admin-app/src/app/components/plan-task/plan-form/plan-form.component.ts b/web-admin-app/src/app/components/plan-task/plan-form/plan-form.component.ts index f6d2422..c893d8f 100644 --- a/web-admin-app/src/app/components/plan-task/plan-form/plan-form.component.ts +++ b/web-admin-app/src/app/components/plan-task/plan-form/plan-form.component.ts @@ -108,11 +108,12 @@ export class PlanFormComponent { public getValues() { let values = null - console.log('this.formGroup', this.formGroup) + if (FormValidators.validateFormGroup(this.formGroup)) { const v = this.formGroup.value values = { ...v, + teamName: this.teamList.find((i) => i.teamId === v.teamId).teamName, assetIdList: v.assetIdList.map((i: NzSafeAny) => { return { ...i, diff --git a/web-admin-app/src/app/components/plan-task/plan-list/plan-list.component.ts b/web-admin-app/src/app/components/plan-task/plan-list/plan-list.component.ts index e1eb31d..e90c581 100644 --- a/web-admin-app/src/app/components/plan-task/plan-list/plan-list.component.ts +++ b/web-admin-app/src/app/components/plan-task/plan-list/plan-list.component.ts @@ -68,8 +68,20 @@ export class PlanListComponent { }, { title: '修改', onClick: this.onCreate.bind(this) }, { title: '删除', onClick: this.deleteItem.bind(this) }, - { title: '停用', onClick: this.deleteItem.bind(this) }, - { title: '启用', onClick: this.deleteItem.bind(this) }, + { + title: '停用', + onClick: this.changeStatus.bind(this), + visible(v) { + return v.status === '0' + }, + }, + { + title: '启用', + onClick: this.changeStatus.bind(this), + visible(v) { + return v.status === '1' + }, + }, { title: '报表', onClick: this.deleteItem.bind(this) }, ]) } @@ -78,6 +90,24 @@ export class PlanListComponent { return this.api.getPlanPage({ ...p, ...q, planType: this.type }) } + changeStatus(d: NzSafeAny) { + const action = d.status === '0' ? '停用' : '启用' + this.modal.confirm({ + nzTitle: '警告', + nzContent: `是否要${action}该计划?`, + nzOnOk: async () => { + const res = await lastValueFrom( + this.api.changePlanStatus({ + ...d, + status: d.status === '0' ? '1' : '0', + }), + ) + this.msg.success(res.desc) + this.table.ref.reload() + }, + }) + } + onCreate(data?: NzSafeAny, preview?: boolean) { let nzTitle = data ? '编辑计划' : '添加计划' if (preview) { @@ -98,6 +128,7 @@ export class PlanListComponent { const res = await lastValueFrom( this.api.savePlan({ ...vals, + planType: this.type, }), ) @@ -112,12 +143,11 @@ export class PlanListComponent { } deleteItem(item?: NzSafeAny) { - const ids = item ? [item.teamId] : Array.from(this.table.ref.selected) this.modal.confirm({ nzTitle: '警告', - nzContent: `是否要删除${ids.length}个计划?`, + nzContent: `是否要删除该计划?`, nzOnOk: async () => { - const res = await lastValueFrom(this.api.deleteUserTeam(ids)) + const res = await lastValueFrom(this.api.deletePlan(item)) this.msg.success(res.desc) this.table.ref.reload() }, diff --git a/web-admin-app/src/app/components/plan-task/task-form/task-form.component.html b/web-admin-app/src/app/components/plan-task/task-form/task-form.component.html index b83c878..4702cfd 100644 --- a/web-admin-app/src/app/components/plan-task/task-form/task-form.component.html +++ b/web-admin-app/src/app/components/plan-task/task-form/task-form.component.html @@ -33,22 +33,24 @@
- 任务开始 + 任务开始
+
任务时长 - +
+
顺序巡检 @@ -66,16 +68,39 @@
+ +
任务备注 - + + + +
+
+ + 任务单据 + + + @for (item of flowForms; track $index) { + + } +
-
选择设备
+
{{ title }}设备
diff --git a/web-admin-app/src/app/components/plan-task/task-form/task-form.component.ts b/web-admin-app/src/app/components/plan-task/task-form/task-form.component.ts index b1fffcb..09a92b4 100644 --- a/web-admin-app/src/app/components/plan-task/task-form/task-form.component.ts +++ b/web-admin-app/src/app/components/plan-task/task-form/task-form.component.ts @@ -59,6 +59,8 @@ export class TaskFormComponent { flowForms: NzSafeAny[] = [] teamList: NzSafeAny[] = [] + + handle = false ngOnInit(): void { this.api.getAssetTeamAll().subscribe((res) => { this.teamList = res.body @@ -68,10 +70,12 @@ export class TaskFormComponent { }) this.formGroup = this.fb.group({ - teamId: this.fb.control(null, []), + teamId: this.fb.control(null, [FormValidators.required('请选择')]), name: this.fb.control(null, [FormValidators.required('请输入')]), remark: this.fb.control(null, []), + formTempId: this.fb.control(null, [FormValidators.required('请选择')]), + // plannedDate: this.fb.control(null, [FormValidators.required('请选择')]), actualStartTime: this.fb.control(null, []), @@ -93,6 +97,7 @@ export class TaskFormComponent { patchValues() { const { value: data, preview, type } = this.data this.title = taskTypeTitle.get(type) + if (data) { this.formGroup.patchValue({ ...data, @@ -105,14 +110,18 @@ export class TaskFormComponent { public getValues() { let values = null - console.log('this.formGroup', this.formGroup) if (FormValidators.validateFormGroup(this.formGroup)) { const v = this.formGroup.value + const form = this.flowForms.find((i) => i.formTempId === v.formTempId) values = { ...v, + formName: form.formName, + formValue: form.formValue, + teamName: this.teamList.find((i) => i.teamId === v.teamId).teamName, assetIdList: v.assetIdList.map((i: NzSafeAny) => { return { ...i, + // assetId: i, } }), @@ -121,37 +130,4 @@ export class TaskFormComponent { } return values } - - onFileChange(e: Event) { - const target = e.target as HTMLInputElement - const file = target.files![0] - target.value = '' - - const formdata = new FormData() - formdata.append('file', file) - this.api.upload(formdata).subscribe((res) => { - this.formGroup.get('attachment')?.setValue(res.body.fileName) - }) - } - - onImgChange(e: Event) { - const target = e.target as HTMLInputElement - const file = target.files![0] - target.value = '' - if (file.size / 1024 / 1024 >= 2) { - this.msg.error('图片大小不能超过2M') - return - } - const fileReader = new FileReader() - fileReader.onload = () => { - const base64 = fileReader.result as string - this.iconPreview = base64 - } - fileReader.readAsDataURL(file) - const formdata = new FormData() - formdata.append('file', file) - this.api.upload(formdata).subscribe((res) => { - this.formGroup.get('img')?.setValue(res.body.fileName) - }) - } } diff --git a/web-admin-app/src/app/components/plan-task/task-list/task-list.component.html b/web-admin-app/src/app/components/plan-task/task-list/task-list.component.html index 0cecd75..751380b 100644 --- a/web-admin-app/src/app/components/plan-task/task-list/task-list.component.html +++ b/web-admin-app/src/app/components/plan-task/task-list/task-list.component.html @@ -13,7 +13,7 @@ @switch (data) { @case ('APPROVAL') { - 待处理 + 审批中 } @case ('COMPLETED') { 已完成 @@ -30,6 +30,9 @@ @case ('REJECTED') { 已驳回 } + @case ('DISPOSE') { + 待处置 + } @case ('SUSPENDED') { 已挂起 } @@ -68,3 +71,28 @@
+ + +
+ + 任务处置人员 + + + + +
+
+ +
+ + {{ shenhe ? '审批意见' : '驳回意见' }} + + + + +
+
diff --git a/web-admin-app/src/app/components/plan-task/task-list/task-list.component.less b/web-admin-app/src/app/components/plan-task/task-list/task-list.component.less index e69de29..18cab4b 100644 --- a/web-admin-app/src/app/components/plan-task/task-list/task-list.component.less +++ b/web-admin-app/src/app/components/plan-task/task-list/task-list.component.less @@ -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; + } + +} \ No newline at end of file diff --git a/web-admin-app/src/app/components/plan-task/task-list/task-list.component.ts b/web-admin-app/src/app/components/plan-task/task-list/task-list.component.ts index 617048e..40572cb 100644 --- a/web-admin-app/src/app/components/plan-task/task-list/task-list.component.ts +++ b/web-admin-app/src/app/components/plan-task/task-list/task-list.component.ts @@ -15,6 +15,8 @@ import { ASSET_TYPE } from 'app/constants' import { AssetBasicTeamFormComponent } from 'app/components/asset-basic-team-form/asset-basic-team-form.component' import { StatusTagComponent } from 'app/components/status-tag/status-tag.component' import { PlanFormComponent } from '../plan-form/plan-form.component' +import { TaskFormComponent } from '../task-form/task-form.component' +import { HandleTaskComponent } from '../handle-task/handle-task.component' @Component({ selector: 'app-task-list', @@ -32,6 +34,9 @@ export class TaskListComponent { @Input() type: PlanTaskType = 'inspection' + @ViewChild('zhipaiTpl') zhipaiTpl!: TemplateRef + @ViewChild('shenheTpl') shenheTpl!: TemplateRef + queryForm = new FormGroup({ name: new FormControl(), @@ -44,6 +49,7 @@ export class TaskListComponent { ASSET_TYPE = ASSET_TYPE + teamList: NzSafeAny[] = [] ngOnInit(): void { this.table @@ -67,87 +73,268 @@ export class TaskListComponent { this.onCreate(v, true) }, }, - { title: '受理', onClick: this.shouli.bind(this) }, - { title: '指派', onClick: this.zhipai.bind(this) }, - { title: '处置', onClick: this.chuzhi.bind(this) }, - { title: '报表', onClick: this.deleteItem.bind(this) }, + { + title: '受理', + onClick: this.shouli.bind(this), + visible(v) { + return v.status === 'TO_BE_ASSIGNED' + }, + }, + { + title: '指派', + onClick: this.zhipai.bind(this), + premissions: ['ROOT'], + visible(v) { + return v.status === 'TO_BE_ASSIGNED' + }, + }, + { + title: '处置', + onClick: this.onHandle.bind(this, true), + visible(v) { + return v.status === 'DISPOSE' + }, + }, + { + title: '审批', + onClick: this.onHandle.bind(this, false), + visible(v) { + return true + return v.status === 'APPROVAL' + }, + }, + { + title: '报表', + onClick: this.deleteItem.bind(this), + visible(v) { + return v.status === 'COMPLETED' + }, + }, ]) + this.api.getAssetTeamAll().subscribe((res) => { + this.teamList = res.body.map((i: NzSafeAny) => { + let users = [] + + try { + users = JSON.parse(i.value) + } catch (error) {} + return { + ...i, + label: i.teamName, + value: i.teamId, + children: users.map((c: NzSafeAny) => { + return { + label: c.userName, + value: c.userId, + isLeaf: true, + } + }), + } + }) + }) } fetchData(p: {}, q: AnyObject) { return this.api.getTaskPage({ ...p, ...q, jobType: this.type }) } + onShenpi(item: NzSafeAny) { + const nzTitle = this.shenhe ? '请填写审批意见' : '请填写驳回意见' + this.modal.create({ + nzTitle, + nzContent: this.shenheTpl, + nzOnOk: async () => { + if (!this.comment) { + this.msg.error(nzTitle) + return false + } + if (this.shenhe) { + const res = await lastValueFrom( + this.api.completeProcessFlow({ + instanceId: item.procInsId, + taskId: item.taskId, + assignee: this.assignee, + comment: this.comment, + }), + ) + this.msg.success(res.desc) + } else { + const res = await lastValueFrom( + this.api.rejectProcessFlow({ + instanceId: item.procInsId, + taskId: item.taskId, + assignee: this.assignee, + comment: this.comment, + }), + ) + this.msg.success(res.desc) + } + + this.table.ref.reload() + return true + }, + }) + } shouli(item?: NzSafeAny) { - const ids = item ? [item.teamId] : Array.from(this.table.ref.selected) this.modal.confirm({ nzTitle: '是否确定受理当前设备流程?', nzContent: `受理后你将作为该任务的责任人,其他人员无法受理!`, nzOnOk: async () => { - const res = await lastValueFrom(this.api.deleteUserTeam(ids)) + const res = await lastValueFrom(this.api.takeTask({ instanceId: item.procInsId, taskId: item.taskId })) this.msg.success(res.desc) this.table.ref.reload() }, }) } + + assignee?: string + + comment?: string + + shenhe = false zhipai(item?: NzSafeAny) { - const ids = item ? [item.teamId] : Array.from(this.table.ref.selected) - this.modal.confirm({ - nzTitle: '请选择设备任务处置人员', - nzContent: ``, + this.modal.create({ + nzTitle: '任务指派', + nzContent: this.zhipaiTpl, nzOnOk: async () => { - const res = await lastValueFrom(this.api.deleteUserTeam(ids)) + if (!this.assignee) { + this.msg.error('请选择处理人') + return false + } + const res = await lastValueFrom( + this.api.assignTask({ instanceId: item.procInsId, taskId: item.taskId, assignee: this.assignee }), + ) this.msg.success(res.desc) this.table.ref.reload() + return true }, }) } - chuzhi(data: NzSafeAny) {} - onCreate(data?: NzSafeAny, preview?: boolean) { - let nzTitle = data ? '编辑任务' : '添加任务' - if (preview) { - nzTitle = '预览任务' - } + let nzTitle = '查看任务' + this.modal.create({ nzTitle, - nzContent: PlanFormComponent, + nzContent: TaskFormComponent, nzWidth: '80vw', nzWrapClassName: 'modal-lg', nzData: { - value: data, + value: { + ...data, + assetIdList: data.defects, + }, preview, + type: this.type, }, - nzOnOk: async (e) => { - const vals = e.getValues() - if (vals) { - const res = await lastValueFrom( - this.api.savePlan({ - ...vals, - planType: this.type, - }), - ) - this.msg.success(res.desc) - this.table.ref.reload() - return true - } + // nzOnOk: async (e) => { + // const vals = e.getValues() + // if (vals) { + // const res = await lastValueFrom( + // this.api.savePlan({ + // ...vals, + // planType: this.type, + // }), + // ) + // this.msg.success(res.desc) + // this.table.ref.reload() + // return true + // } - return false - }, + // return false + // }, }) } + onHandle(chuzhi: boolean, data: NzSafeAny) { + console.log('chuzhi', chuzhi, data) + let nzTitle = chuzhi ? '处置任务' : '任务审批' + const footer: NzSafeAny[] = chuzhi + ? [ + { + label: '提交审核', + type: 'reject', + onClick: async (e: HandleTaskComponent) => { + const vals = e.getValues() + if (vals) { + const res = await lastValueFrom( + this.api.completeProcessFlow({ + variables: { + ...data, + ...vals, + }, + taskId: data.taskId, + instanceId: data.procInsId, + }), + ) + this.msg.success(res.desc) + this.table.ref.reload() + ref.close() + } + }, + }, + { + label: '保存', + type: 'primary', + onClick: async (e: HandleTaskComponent) => { + const vals = e.getValues() + if (vals) { + const res = await lastValueFrom( + this.api.handleTaskAssetItem( + { + variables: { + ...data, + ...vals, + }, + taskId: data.taskId, + instanceId: data.procInsId, + }, + data.id, + ), + ) + this.msg.success(res.desc) + this.table.ref.reload() + ref.close() + } + }, + }, + ] + : [ + { + label: '驳回', + type: 'reject', - deleteItem(item?: NzSafeAny) { - const ids = item ? [item.teamId] : Array.from(this.table.ref.selected) - this.modal.confirm({ - nzTitle: '警告', - nzContent: `是否要删除${ids.length}个任务?`, - nzOnOk: async () => { - const res = await lastValueFrom(this.api.deleteUserTeam(ids)) - this.msg.success(res.desc) - this.table.ref.reload() + onClick: async (e: HandleTaskComponent) => { + this.shenhe = false + this.onShenpi(data) + }, + }, + { + label: '通过', + type: 'primary', + onClick: async (e: HandleTaskComponent) => { + this.shenhe = true + this.onShenpi(data) + }, + }, + ] + const ref = this.modal.create({ + nzTitle, + nzContent: HandleTaskComponent, + nzWidth: '80vw', + nzWrapClassName: 'modal-lg modal-for-btn', + nzData: { + value: data, + chuzhi, + type: this.type, }, + nzFooter: footer.concat({ + label: '取消', + onClick: () => { + ref.close() + }, + }), }) } + + deleteItem(item?: NzSafeAny) {} } diff --git a/web-admin-app/src/app/constants/index.ts b/web-admin-app/src/app/constants/index.ts index 33421fd..9635142 100644 --- a/web-admin-app/src/app/constants/index.ts +++ b/web-admin-app/src/app/constants/index.ts @@ -153,7 +153,7 @@ export const businessType = new Map([ // APPROVAL,COMPLETED,DISCARDED,DRAFTING,EXCEPTION,REJECTED,SUSPENDED,TO_BE_ASSIGNED export const flowStatus = new Map([ - ['APPROVAL', '审批中'], + ['APPROVAL', '审批中'], // ['COMPLETED', '已完成'], ['DISCARDED', '已废弃'], ['DRAFTING', '起草中'], @@ -161,4 +161,28 @@ export const flowStatus = new Map([ ['REJECTED', '已驳回'], ['SUSPENDED', '已挂起'], ['TO_BE_ASSIGNED', '待分配'], + ['DISPOSE', '待处置'], +]) + +// DRAFTING(1, "起草"), +// APPROVAL(2, "审批中"), +// COMPLETED(3, "已结束"), +// REJECTED(4, "已驳回"), +// DISCARDED(5, "已废弃"), +// EXCEPTION(6, "流程异常"), +// TO_BE_ASSIGNED(7,"待指派"), +// SUSPENDED(8,"已挂起"), +// // +// DISPOSE(9,"待处置"), +// ; +export const flowIntStatus = new Map([ + [1, '起草'], + [2, '审批中'], + [3, '已结束'], + [4, '已驳回'], + [5, '已废弃'], + [6, '流程异常'], + [7, '待指派'], + [8, '已挂起'], + [9, '待处置'], ]) diff --git a/web-admin-app/src/app/pages/fixed-asset/asset-management/asset-management.component.ts b/web-admin-app/src/app/pages/fixed-asset/asset-management/asset-management.component.ts index 01bd67c..41f02a1 100644 --- a/web-admin-app/src/app/pages/fixed-asset/asset-management/asset-management.component.ts +++ b/web-admin-app/src/app/pages/fixed-asset/asset-management/asset-management.component.ts @@ -79,10 +79,41 @@ export class AssetManagementComponent { { key: '_position', title: '当前节点', visible: true }, { key: '_position', title: '备注', visible: true }, ]) - // .setRowOperate([ - // { title: '二维码', onClick: this.qrcode.bind(this) }, - // { title: '删除', onClick: this.deleteItem.bind(this) }, - // ]) + .setRowOperate([ + { title: '查看', onClick: this.itemAction.bind(this, 'preview') }, + { title: '修改', onClick: this.itemAction.bind(this, 'edit') }, + { title: '删除', onClick: this.deleteItem.bind(this) }, + ]) + } + + itemAction(type: 'preview' | 'edit', data: NzSafeAny) { + switch (data.type) { + case 'ALLOCATE': + this.onAllot(data, type === 'preview') + break + case 'BORROW': + this.onBorrow(data, type === 'preview') + break + case 'COLLECTION': + this.onDistribution(data, type === 'preview') + break + + case 'RETURN_INVENTORY': + this.onReturn(data, type === 'preview') + break + case 'STORAGE': + this.onEntry(data, type === 'preview') + break + case 'RETURN': + this.onRevert(data, type === 'preview') + break + case 'TRANSFER': + this.onTransfer(data, type === 'preview') + break + case 'RETIREMENT': + this.onScrap(data, type === 'preview') + break + } } fetchData(p: {}, q: AnyObject) { diff --git a/web-admin-app/src/app/pages/flow/flow-main/flow-main.component.html b/web-admin-app/src/app/pages/flow/flow-main/flow-main.component.html index 412ec50..a5ed0a4 100644 --- a/web-admin-app/src/app/pages/flow/flow-main/flow-main.component.html +++ b/web-admin-app/src/app/pages/flow/flow-main/flow-main.component.html @@ -4,13 +4,13 @@
- +
- +
- +
@@ -19,13 +19,13 @@
- +
- +
- +
@@ -61,21 +61,24 @@
-
-
-
-
-
- + @for (item of deviceFlows; track $index) { +
+
+
+
+
+ +
+
+
+
{{ item.name }}
-
-
-
报修维修
-
-
+ } + +
diff --git a/web-admin-app/src/app/pages/flow/flow-main/flow-main.component.ts b/web-admin-app/src/app/pages/flow/flow-main/flow-main.component.ts index 359f3be..394501e 100644 --- a/web-admin-app/src/app/pages/flow/flow-main/flow-main.component.ts +++ b/web-admin-app/src/app/pages/flow/flow-main/flow-main.component.ts @@ -47,10 +47,23 @@ export class FlowMainComponent implements OnInit { assetFlows: NzSafeAny[] = [] + deviceFlows: NzSafeAny[] = [] + loading = false + assetcounter: any = { + count: 0, + increase: 0, + todo: 0, + } + devicecounter: any = { + count: 0, + increase: 0, + todo: 0, + } ngOnInit(): void { this.loading = true + this.getCounter() this.api .getFlowForms({}) .pipe( @@ -59,15 +72,32 @@ export class FlowMainComponent implements OnInit { }), ) .subscribe((res) => { - this.assetFlows = res.body.map((i: NzSafeAny) => { - return { - ...i, - enabled: Boolean(comsMap[i.formKey as keyof typeof comsMap]), + res.body.forEach((i: NzSafeAny) => { + const enabled = Boolean(comsMap[i.formKey as keyof typeof comsMap]) + const formType = (i.formKey as string).split('_').splice(-1)[0] + console.log('formType', formType) + const item = { ...i, enabled, formType } + if (i.type === '设备流程') { + this.deviceFlows.push(item) + } else { + this.assetFlows.push(item) } }) }) } + getCounter() { + this.api.getFlowHomeData().subscribe((res) => { + res.body?.forEach((i: NzSafeAny) => { + if (i.type === '设备流程') { + this.devicecounter = i + } else { + this.assetFlows = i + } + }) + }) + } + onStart(model: NzSafeAny) { this.modal.create({ nzTitle: '开始流程', @@ -83,6 +113,7 @@ export class FlowMainComponent implements OnInit { if (vals) { const res = await lastValueFrom(this.api.startFlow(vals, model.formKey)) this.msg.success(res.desc) + this.getCounter() return true } return false @@ -116,7 +147,7 @@ export class FlowMainComponent implements OnInit { const res = await lastValueFrom(this.api.createTask({ ...vals, jobType: type })) this.msg.success(res.desc) } - + this.getCounter() return true } return false diff --git a/web-admin-app/src/app/pages/flow/flow-management/flow-management.component.html b/web-admin-app/src/app/pages/flow/flow-management/flow-management.component.html index a98afbc..2ca4f6e 100644 --- a/web-admin-app/src/app/pages/flow/flow-management/flow-management.component.html +++ b/web-admin-app/src/app/pages/flow/flow-management/flow-management.component.html @@ -1 +1,47 @@ -

flow-management works!

+ +
+ + + @switch (key) { + @case ('checkRequire') { + {{ data ? '是' : '否' }} + } + @case ('status') { + @if (data === 0) { + + } @else { + + } + } + @case ('autoAssign') { + @if (row.type !== '资管流程') { + + + + } @else { + / + } + } + @default { + {{ data }} + } + } + + +
+
+ + +
+ + 审批人 + + + + +
+
+ + + + diff --git a/web-admin-app/src/app/pages/flow/flow-management/flow-management.component.ts b/web-admin-app/src/app/pages/flow/flow-management/flow-management.component.ts index 495f135..6d30b62 100644 --- a/web-admin-app/src/app/pages/flow/flow-management/flow-management.component.ts +++ b/web-admin-app/src/app/pages/flow/flow-management/flow-management.component.ts @@ -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', - standalone: true, - imports: [], - templateUrl: './flow-management.component.html', - styleUrl: './flow-management.component.less' + selector: 'app-flow-form', + standalone: true, + imports: [SharedModule, SelectUserByOrgComponent], + templateUrl: './flow-management.component.html', + 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([], [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() + }, + }) + } } diff --git a/web-admin-app/src/app/pages/flow/flow-my-apply/flow-my-apply.component.html b/web-admin-app/src/app/pages/flow/flow-my-apply/flow-my-apply.component.html index 2a60d57..c2380bf 100644 --- a/web-admin-app/src/app/pages/flow/flow-my-apply/flow-my-apply.component.html +++ b/web-admin-app/src/app/pages/flow/flow-my-apply/flow-my-apply.component.html @@ -12,7 +12,7 @@ {{ data.userName }} } @case ('procVars') { - {{ data?.title }} + {{ data?.title ?? data?.name ?? '-' }} } @case ('status') { diff --git a/web-admin-app/src/app/pages/flow/flow-my-apply/flow-my-apply.component.ts b/web-admin-app/src/app/pages/flow/flow-my-apply/flow-my-apply.component.ts index e569fe9..262d00c 100644 --- a/web-admin-app/src/app/pages/flow/flow-my-apply/flow-my-apply.component.ts +++ b/web-admin-app/src/app/pages/flow/flow-my-apply/flow-my-apply.component.ts @@ -12,7 +12,7 @@ import { NzMessageService } from 'ng-zorro-antd/message' import { FormValidators } from 'app/utils' import { AssetEmployeeApplyComponent } from 'app/components' import { comsMap } from '../flow-main/flow-main.component' -import { FLOW_STATUS } from 'app/constants' +import { FLOW_STATUS, flowIntStatus } from 'app/constants' @Component({ selector: 'app-flow-my-apply', @@ -41,7 +41,7 @@ export class FlowMyApplyComponent { name: new FormControl(''), }) - FLOW_STATUS = FLOW_STATUS + FLOW_STATUS = flowIntStatus ngOnInit(): void { this.table // .setConfig({ diff --git a/web-admin-app/src/app/pages/flow/flow-my-finished/flow-my-finished.component.html b/web-admin-app/src/app/pages/flow/flow-my-finished/flow-my-finished.component.html index baf0c28..c2380bf 100644 --- a/web-admin-app/src/app/pages/flow/flow-my-finished/flow-my-finished.component.html +++ b/web-admin-app/src/app/pages/flow/flow-my-finished/flow-my-finished.component.html @@ -12,7 +12,7 @@ {{ data.userName }} } @case ('procVars') { - {{ data.title }} + {{ data?.title ?? data?.name ?? '-' }} } @case ('status') { diff --git a/web-admin-app/src/app/pages/flow/flow-my-finished/flow-my-finished.component.ts b/web-admin-app/src/app/pages/flow/flow-my-finished/flow-my-finished.component.ts index f10a9eb..6be7ba3 100644 --- a/web-admin-app/src/app/pages/flow/flow-my-finished/flow-my-finished.component.ts +++ b/web-admin-app/src/app/pages/flow/flow-my-finished/flow-my-finished.component.ts @@ -11,7 +11,7 @@ import { NzModalService } from 'ng-zorro-antd/modal' import { NzMessageService } from 'ng-zorro-antd/message' import { FormValidators } from 'app/utils' import { comsMap } from '../flow-main/flow-main.component' -import { FLOW_STATUS } from 'app/constants' +import { FLOW_STATUS, flowIntStatus } from 'app/constants' @Component({ selector: 'app-flow-my-finished', @@ -40,7 +40,7 @@ export class FlowMyFinishedComponent { name: new FormControl(''), }) - FLOW_STATUS = FLOW_STATUS + FLOW_STATUS = flowIntStatus ngOnInit(): void { this.table diff --git a/web-admin-app/src/app/pages/flow/flow-my-todo/flow-my-todo.component.html b/web-admin-app/src/app/pages/flow/flow-my-todo/flow-my-todo.component.html index bb2bc26..69a4e8b 100644 --- a/web-admin-app/src/app/pages/flow/flow-my-todo/flow-my-todo.component.html +++ b/web-admin-app/src/app/pages/flow/flow-my-todo/flow-my-todo.component.html @@ -12,7 +12,7 @@ {{ data.userName }} } @case ('procVars') { - {{ data.title }} + {{ data?.title ?? data?.name ?? '-' }} } @case ('status') { diff --git a/web-admin-app/src/app/pages/flow/flow-my-todo/flow-my-todo.component.ts b/web-admin-app/src/app/pages/flow/flow-my-todo/flow-my-todo.component.ts index acf4ab0..a51af71 100644 --- a/web-admin-app/src/app/pages/flow/flow-my-todo/flow-my-todo.component.ts +++ b/web-admin-app/src/app/pages/flow/flow-my-todo/flow-my-todo.component.ts @@ -11,7 +11,7 @@ import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal' import { NzMessageService } from 'ng-zorro-antd/message' import { FormValidators } from 'app/utils' import { comsMap } from '../flow-main/flow-main.component' -import { FLOW_STATUS } from 'app/constants' +import { FLOW_STATUS, flowIntStatus } from 'app/constants' @Component({ selector: 'app-flow-my-todo', @@ -44,7 +44,7 @@ export class FlowMyTodoComponent { name: new FormControl(''), }) - FLOW_STATUS = FLOW_STATUS + FLOW_STATUS = flowIntStatus ngOnInit(): void { this.table // .setConfig({ diff --git a/web-admin-app/src/app/pages/msg/flow-msg/flow-msg.component.ts b/web-admin-app/src/app/pages/msg/flow-msg/flow-msg.component.ts index d944139..d2d9c12 100644 --- a/web-admin-app/src/app/pages/msg/flow-msg/flow-msg.component.ts +++ b/web-admin-app/src/app/pages/msg/flow-msg/flow-msg.component.ts @@ -29,9 +29,9 @@ export class FlowMsgComponent { @ViewChild('createFormTpl') createFormTpl!: TemplateRef<{}> queryForm = new FormGroup({ - logContent: new FormControl(''), - logType: new FormControl(''), - createTime: new FormControl(''), + logContent: new FormControl(null), + logType: new FormControl(null), + createTime: new FormControl(null), }) table = new TableOption(this.fetchData.bind(this)) @@ -52,6 +52,6 @@ export class FlowMsgComponent { } fetchData(p: {}, q: AnyObject) { - return this.api.getAlarmMsg({ ...p, ...q }) + return this.api.getFlowMsg({ ...p, ...q }) } } diff --git a/web-admin-app/src/app/services/api.service.ts b/web-admin-app/src/app/services/api.service.ts index b4c7095..05fee66 100644 --- a/web-admin-app/src/app/services/api.service.ts +++ b/web-admin-app/src/app/services/api.service.ts @@ -584,11 +584,16 @@ export class ApiService { return this.http.post(`/api/flowable/task/revokeProcess`, data) } rejectProcessFlow(data: {}) { + // 驳回 return this.http.post(`/api/flowable/task/reject`, data) } completeProcessFlow(data: {}) { + // 通过 return this.http.post(`/api/flowable/task/complete`, data) } + handleTaskAssetItem(data: {}, id: string) { + return this.http.post(`/api/v2/flowable/device/update/${id}`, { variables: data }) + } cancelFlow(data: {}) { return this.http.post(`/api/flowable/task/stopProcess`, data) } @@ -661,8 +666,17 @@ export class ApiService { getPlanPage(data: {}) { return this.http.post(`/api/v2/plan/list`, data) } - savePlan(data: {}) { - return this.http.post(`/api/v2/plan/add`, data) + savePlan(data: NzSafeAny) { + if (Utils.isEmpty(data.jobId)) { + return this.http.post(`/api/v2/plan/add`, data) + } + return this.http.post('/api/v2/plan/update', data) + } + deletePlan(data: {}) { + return this.http.post(`/api/v2/plan/delete`, data) + } + changePlanStatus(data: {}) { + return this.http.post(`/api/v2/plan/changeStatus`, data) } createRapairTask(data: {}) { return this.http.post(`/api/v2/flowable/device/start/repair`, data) @@ -670,6 +684,12 @@ export class ApiService { createTask(data: {}) { return this.http.post(`/api/v2/flowable/device/start`, data) } + takeTask(data: {}) { + return this.http.post(`/api/flowable/task/claim`, data) + } + assignTask(data: {}) { + return this.http.post(`/api/flowable/task/assignTask`, data) + } getSysLog(data: {}) { return this.http.post('/api/v2/sysLog/list', data) @@ -677,4 +697,16 @@ export class ApiService { getAlarmMsg(data: {}) { return this.http.post('/api/v2/alarm/list', data) } + getFlowMsg(data: {}) { + return this.http.post('/api/flowable/task/todoListMSG ', data) + } + getCalendarData(data: {}) { + return this.http.post('/api/flFormItem/calendar', data) + } + getFlowHomeData() { + return this.http.post('/api/flFormItem/home', null) + } + flowFormUpdate(d: {}) { + return this.http.post('/api/flForm/update', d) + } } diff --git a/web-admin-app/src/styles.less b/web-admin-app/src/styles.less index a7c3553..a2e02c6 100644 --- a/web-admin-app/src/styles.less +++ b/web-admin-app/src/styles.less @@ -45,6 +45,7 @@ body { } + ::-webkit-scrollbar { width: 8px; height: 8px; @@ -72,7 +73,8 @@ body { // } } - .modal-lg-container { + .modal-lg-container, + .ant-modal-body { height: 70vh; overflow: auto; }