36 changed files with 1570 additions and 163 deletions
@ -0,0 +1,7 @@ |
|||||
|
<nz-tree-select |
||||
|
[nzNodes]="assetCategoryTree" |
||||
|
[nzPlaceHolder]="placeholder" |
||||
|
[(ngModel)]="value" |
||||
|
(ngModelChange)="onChange($event)" |
||||
|
> |
||||
|
</nz-tree-select> |
@ -0,0 +1,77 @@ |
|||||
|
import { ChangeDetectorRef, Component, Input, OnInit, TemplateRef, ViewChild, forwardRef } from '@angular/core' |
||||
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
||||
|
|
||||
|
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
||||
|
|
||||
|
import { NzModalService } from 'ng-zorro-antd/modal' |
||||
|
|
||||
|
import { ApiService } from 'app/services' |
||||
|
import { NzMessageService } from 'ng-zorro-antd/message' |
||||
|
|
||||
|
import { SharedModule } from 'app/shared/shared.module' |
||||
|
import { Utils } from 'app/utils' |
||||
|
import { NzFormatEmitEvent, NzTreeNode } from 'ng-zorro-antd/tree' |
||||
|
import { NzTreeSelectComponent } from 'ng-zorro-antd/tree-select' |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'app-asset-category-select', |
||||
|
standalone: true, |
||||
|
imports: [SharedModule], |
||||
|
templateUrl: './asset-category-select.component.html', |
||||
|
styleUrl: './asset-category-select.component.less', |
||||
|
providers: [ |
||||
|
{ |
||||
|
provide: NG_VALUE_ACCESSOR, |
||||
|
multi: true, |
||||
|
useExisting: forwardRef(() => AssetCategorySelectComponent), |
||||
|
}, |
||||
|
], |
||||
|
}) |
||||
|
export class AssetCategorySelectComponent implements ControlValueAccessor, OnInit { |
||||
|
constructor( |
||||
|
private modal: NzModalService, |
||||
|
private api: ApiService, |
||||
|
private msg: NzMessageService, |
||||
|
private cdr: ChangeDetectorRef, |
||||
|
) {} |
||||
|
|
||||
|
@Input() placeholder: string = '请选择' |
||||
|
|
||||
|
@Input() modalTitle: string = '选择' |
||||
|
|
||||
|
@Input() radio: boolean = false |
||||
|
|
||||
|
@ViewChild('el') el!: NzTreeSelectComponent |
||||
|
|
||||
|
assetCategoryTree: NzSafeAny[] = [] |
||||
|
|
||||
|
originTreeData: NzSafeAny[] = [] |
||||
|
|
||||
|
value?: string |
||||
|
|
||||
|
ngOnInit(): void { |
||||
|
this.api.getBasicCategoryTree().subscribe((res) => { |
||||
|
this.originTreeData = res.body |
||||
|
this.assetCategoryTree = Utils.buildTree(this.originTreeData, 'categoryId', 'categoryName') |
||||
|
console.log('this.assetCategoryTree', this.originTreeData, this.assetCategoryTree) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
onTouched = () => {} |
||||
|
|
||||
|
onChange(v: NzSafeAny[]) {} |
||||
|
|
||||
|
writeValue(v: NzSafeAny): void { |
||||
|
this.value = v |
||||
|
} |
||||
|
|
||||
|
registerOnChange(fn: any): void { |
||||
|
this.onChange = fn |
||||
|
} |
||||
|
|
||||
|
registerOnTouched(fn: any): void { |
||||
|
this.onTouched = fn |
||||
|
} |
||||
|
|
||||
|
setDisabledState?(isDisabled: boolean): void {} |
||||
|
} |
@ -0,0 +1,263 @@ |
|||||
|
<form nz-form [formGroup]="formGroup" nzLayout="vertical"> |
||||
|
<div class="asset-form"> |
||||
|
<nz-card [nzBordered]="false"> |
||||
|
<nz-card-tab> |
||||
|
<nz-tabset [(nzSelectedIndex)]="groupIndex"> |
||||
|
<nz-tab nzTitle="基本信息"></nz-tab> |
||||
|
<nz-tab nzTitle="维保信息"></nz-tab> |
||||
|
<nz-tab nzTitle="财务信息"></nz-tab> |
||||
|
</nz-tabset> |
||||
|
</nz-card-tab> |
||||
|
|
||||
|
@switch (groupIndex) { |
||||
|
@case (0) { |
||||
|
<ng-container [ngTemplateOutlet]="basicTpl"> </ng-container> |
||||
|
} |
||||
|
@case (1) { |
||||
|
<ng-container [ngTemplateOutlet]="maintainTpl"> </ng-container> |
||||
|
} |
||||
|
@case (2) { |
||||
|
<ng-container [ngTemplateOutlet]="financeTpl"> </ng-container> |
||||
|
} |
||||
|
} |
||||
|
</nz-card> |
||||
|
</div> |
||||
|
|
||||
|
<ng-template #basicTpl> |
||||
|
<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"> |
||||
|
<app-asset-category-select formControlName="categoryId"></app-asset-category-select> |
||||
|
</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 placeholder="请输入名称" formControlName="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"> |
||||
|
<nz-select nzPlaceHolder="请选择" formControlName="status"> |
||||
|
@for (item of ASSET_STATUS; track $index) { |
||||
|
<nz-option [nzLabel]="item.label" [nzValue]="item.value"></nz-option> |
||||
|
} |
||||
|
</nz-select> |
||||
|
</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"> |
||||
|
<app-org-select formControlName="ownCompanyId" [company]="true" /> |
||||
|
</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-org-select formControlName="useOrganizationId" /> |
||||
|
</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"> |
||||
|
<!-- manager --> |
||||
|
<app-select-user-by-org formControlName="manager" /> |
||||
|
</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-select-user-by-org formControlName="useUserId" /> |
||||
|
</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="sourceId"> |
||||
|
@for (item of ASSET_SOURCE_MAP | keyvalue; track $index) { |
||||
|
<nz-option [nzLabel]="item.value" [nzValue]="item.key"></nz-option> |
||||
|
} |
||||
|
</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"> |
||||
|
<!-- manufacturersVendorId --> |
||||
|
<app-manufacturer-select formControlName="manufacturersVendorId" /> |
||||
|
</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 placeholder="请输入序列号" formControlName="serialNumber" /> |
||||
|
</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 placeholder="请输入规格型号" formControlName="model" /> |
||||
|
</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 placeholder="请输入用途" formControlName="purpose" /> |
||||
|
</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"> |
||||
|
<!-- positionId --> |
||||
|
<app-position-select formControlName="positionId" /> |
||||
|
</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 placeholder="请输入详细位置" formControlName="positionDetail" /> |
||||
|
</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 placeholder="请输入计量单位" formControlName="unit" /> |
||||
|
</nz-form-control> |
||||
|
</nz-form-item> |
||||
|
</div> |
||||
|
</div> |
||||
|
</ng-template> |
||||
|
<ng-template #maintainTpl> |
||||
|
<div nz-row [nzGutter]="24"> |
||||
|
<div nz-col [nzSpan]="8"> |
||||
|
<nz-form-item> |
||||
|
<nz-form-label>维保厂商</nz-form-label> |
||||
|
<nz-form-control [nzErrorTip]="errorTpl"> |
||||
|
<app-maintenance-select formControlName="maintenanceVendor" /> |
||||
|
</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 placeholder="请输入联系人" formControlName="contactor" /> |
||||
|
</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 placeholder="请输入联系方式" formControlName="contact" /> |
||||
|
</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-select-user-by-org formControlName="responsiblePerson" /> |
||||
|
</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" formControlName="maintenanceStartDate" /> |
||||
|
</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" formControlName="maintenanceEndDate" /> |
||||
|
</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="maintenanceStatus"> |
||||
|
@for (item of MAINTENANCE_STATUS | keyvalue; track $index) { |
||||
|
<nz-option [nzLabel]="item.value" [nzValue]="item.key"></nz-option> |
||||
|
} |
||||
|
</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-select nzPlaceHolder="请选择" formControlName="maintenanceType"> |
||||
|
@for (item of MAINTENANCE_TYPE | keyvalue; track $index) { |
||||
|
<nz-option [nzLabel]="item.value" [nzValue]="item.key"></nz-option> |
||||
|
} |
||||
|
</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-select nzPlaceHolder="请选择" formControlName="suggestMaintenanceType"> |
||||
|
@for (item of MAINTENANCE_TYPE | keyvalue; track $index) { |
||||
|
<nz-option [nzLabel]="item.value" [nzValue]="item.key"></nz-option> |
||||
|
} |
||||
|
</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"> |
||||
|
<textarea nz-input placeholder="请输入" formControlName="maintenanceNotes"></textarea> |
||||
|
</nz-form-control> |
||||
|
</nz-form-item> |
||||
|
</div> |
||||
|
</div> |
||||
|
</ng-template> |
||||
|
<ng-template #financeTpl>3</ng-template> |
||||
|
</form> |
||||
|
|
||||
|
<ng-template #errorTpl let-control> |
||||
|
<form-error-tips [control]="control"></form-error-tips> |
||||
|
</ng-template> |
@ -0,0 +1,4 @@ |
|||||
|
.asset-form { |
||||
|
height: 80vh; |
||||
|
overflow: auto; |
||||
|
} |
@ -0,0 +1,122 @@ |
|||||
|
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 { 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 } 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' |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'app-asset-form', |
||||
|
standalone: true, |
||||
|
imports: [ |
||||
|
SharedModule, |
||||
|
AssetCategorySelectComponent, |
||||
|
OrgSelectComponent, |
||||
|
SelectUserByOrgComponent, |
||||
|
ManufacturerSelectComponent, |
||||
|
PositionSelectComponent, |
||||
|
MaintenanceSelectComponent, |
||||
|
], |
||||
|
templateUrl: './asset-form.component.html', |
||||
|
styleUrl: './asset-form.component.less', |
||||
|
}) |
||||
|
export class AssetFormComponent implements OnInit { |
||||
|
constructor( |
||||
|
private fb: FormBuilder, |
||||
|
private api: ApiService, |
||||
|
private msg: NzMessageService, |
||||
|
) {} |
||||
|
|
||||
|
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 |
||||
|
|
||||
|
ngOnInit(): void { |
||||
|
this.formGroup = this.fb.group({ |
||||
|
assetId: this.fb.control(null, []), |
||||
|
name: this.fb.control('', [FormValidators.required('请输入')]), |
||||
|
categoryId: this.fb.control(null, [FormValidators.required('请选择')]), |
||||
|
ownCompanyId: this.fb.control(null, [FormValidators.required('请选择')]), |
||||
|
status: this.fb.control(null, [FormValidators.required('请选择')]), |
||||
|
sourceId: this.fb.control(null, []), |
||||
|
unit: this.fb.control(null, []), |
||||
|
positionId: this.fb.control(null, []), |
||||
|
positionDetail: this.fb.control(null, []), |
||||
|
serialNumber: this.fb.control(null, []), |
||||
|
manufacturersVendorId: this.fb.control(null, []), |
||||
|
useUserId: this.fb.control(null, []), |
||||
|
useOrganizationId: this.fb.control(null, []), |
||||
|
manager: this.fb.control(null, []), |
||||
|
purpose: this.fb.control(null, []), |
||||
|
model: this.fb.control(null, []), |
||||
|
|
||||
|
maintenanceVendor: this.fb.control(null, []), |
||||
|
contactor: this.fb.control(null, []), |
||||
|
contact: this.fb.control(null, []), |
||||
|
responsiblePerson: this.fb.control(null, []), |
||||
|
maintenanceStartDate: this.fb.control(null, []), |
||||
|
maintenanceEndDate: this.fb.control(null, []), |
||||
|
maintenanceStatus: this.fb.control(null, []), |
||||
|
maintenanceType: this.fb.control(null, []), |
||||
|
suggestMaintenanceType: this.fb.control(null, []), |
||||
|
maintenanceNotes: this.fb.control(null, []), |
||||
|
}) |
||||
|
this.patchValues() |
||||
|
} |
||||
|
|
||||
|
patchValues() { |
||||
|
if (this.data) { |
||||
|
const data = this.data |
||||
|
this.formGroup.patchValue({ |
||||
|
...data, |
||||
|
|
||||
|
useUserId: data._useUser?.userId ? [data._useUser?.userId] : [], |
||||
|
manager: data._manager?.userId ? [data._manager?.userId] : [], |
||||
|
responsiblePerson: data._responsiblePerson?.userId ? [data._responsiblePerson?.userId] : [], |
||||
|
categoryId: data._category?.categoryId + '', |
||||
|
positionId: data._position?.positionId + '', |
||||
|
ownCompanyId: data._ownCompany?.organizationId + '', |
||||
|
useOrganizationId: data._useOrganization?.organizationId + '', |
||||
|
maintenanceVendor: data._maintenanceVendor?.maintenanceVendorId, |
||||
|
manufacturersVendorId: data._manufacturersVendor?.manufacturersVendorId, |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public getValues() { |
||||
|
let values = null |
||||
|
if (FormValidators.validateFormGroup(this.formGroup)) { |
||||
|
const v = this.formGroup.getRawValue() |
||||
|
values = { |
||||
|
...v, |
||||
|
useUserId: v.useUserId?.[0], |
||||
|
manager: v.manager?.[0], |
||||
|
categoryId: v.categoryId?.[0], |
||||
|
ownCompanyId: v.ownCompanyId?.[0], |
||||
|
positionId: v.positionId?.[0], |
||||
|
useOrganizationId: v.useOrganizationId?.[0], |
||||
|
responsiblePerson: v.responsiblePerson?.[0], |
||||
|
} |
||||
|
} |
||||
|
return values |
||||
|
} |
||||
|
} |
@ -1,3 +1,9 @@ |
|||||
export * from './component-org-tree/component-org-tree.component' |
export * from './component-org-tree/component-org-tree.component' |
||||
export * from './component-basic-category-tree/component-basic-category-tree.component' |
export * from './component-basic-category-tree/component-basic-category-tree.component' |
||||
export * from './select-user-by-org/select-user-by-org.component' |
export * from './select-user-by-org/select-user-by-org.component' |
||||
|
export * from './asset-form/asset-form.component' |
||||
|
export * from './asset-category-select/asset-category-select.component' |
||||
|
export * from './org-select/org-select.component' |
||||
|
export * from './manufacturer-select/manufacturer-select.component' |
||||
|
export * from './position-select/position-select.component' |
||||
|
export * from './maintenance-select/maintenance-select.component' |
||||
|
@ -0,0 +1,5 @@ |
|||||
|
<nz-select [nzPlaceHolder]="placeholder" [(ngModel)]="value" (ngModelChange)="onModelChange($event)"> |
||||
|
@for (item of originData; track $index) { |
||||
|
<nz-option [nzLabel]="item.name" [nzValue]="item.maintenanceVendorId"></nz-option> |
||||
|
} |
||||
|
</nz-select> |
@ -0,0 +1,87 @@ |
|||||
|
import { |
||||
|
ChangeDetectorRef, |
||||
|
Component, |
||||
|
EventEmitter, |
||||
|
Input, |
||||
|
OnInit, |
||||
|
Output, |
||||
|
TemplateRef, |
||||
|
ViewChild, |
||||
|
forwardRef, |
||||
|
} from '@angular/core' |
||||
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
||||
|
|
||||
|
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
||||
|
|
||||
|
import { NzModalService } from 'ng-zorro-antd/modal' |
||||
|
|
||||
|
import { ApiService } from 'app/services' |
||||
|
import { NzMessageService } from 'ng-zorro-antd/message' |
||||
|
|
||||
|
import { SharedModule } from 'app/shared/shared.module' |
||||
|
import { Utils } from 'app/utils' |
||||
|
import { NzFormatEmitEvent, NzTreeNode } from 'ng-zorro-antd/tree' |
||||
|
import { NzTreeSelectComponent } from 'ng-zorro-antd/tree-select' |
||||
|
import { MAX_PAGE_SIZE } from 'app/constants' |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'app-maintenance-select', |
||||
|
standalone: true, |
||||
|
imports: [SharedModule], |
||||
|
templateUrl: './maintenance-select.component.html', |
||||
|
styleUrl: './maintenance-select.component.less', |
||||
|
providers: [ |
||||
|
{ |
||||
|
provide: NG_VALUE_ACCESSOR, |
||||
|
multi: true, |
||||
|
useExisting: forwardRef(() => MaintenanceSelectComponent), |
||||
|
}, |
||||
|
], |
||||
|
}) |
||||
|
export class MaintenanceSelectComponent { |
||||
|
constructor(private api: ApiService) {} |
||||
|
|
||||
|
@Input() placeholder: string = '请选择' |
||||
|
|
||||
|
@Input() modalTitle: string = '选择' |
||||
|
|
||||
|
@Input() radio: boolean = false |
||||
|
|
||||
|
@Output() onSelected = new EventEmitter<NzSafeAny>() |
||||
|
|
||||
|
@ViewChild('el') el!: NzTreeSelectComponent |
||||
|
|
||||
|
originData: NzSafeAny[] = [] |
||||
|
|
||||
|
value?: string |
||||
|
|
||||
|
ngOnInit(): void { |
||||
|
this.api.getBasicMaintenanceVendorPage({ pageSize: MAX_PAGE_SIZE, pageNum: 1 }).subscribe((res) => { |
||||
|
this.originData = res.body.rows |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
onModelChange(v: NzSafeAny) { |
||||
|
const item = this.originData.find((f) => f.maintenanceVendorId === v) |
||||
|
this.onSelected.emit(item) |
||||
|
this.onChange(v) |
||||
|
} |
||||
|
|
||||
|
onTouched = () => {} |
||||
|
|
||||
|
onChange(v: NzSafeAny[]) {} |
||||
|
|
||||
|
writeValue(v: NzSafeAny): void { |
||||
|
this.value = v |
||||
|
} |
||||
|
|
||||
|
registerOnChange(fn: any): void { |
||||
|
this.onChange = fn |
||||
|
} |
||||
|
|
||||
|
registerOnTouched(fn: any): void { |
||||
|
this.onTouched = fn |
||||
|
} |
||||
|
|
||||
|
setDisabledState?(isDisabled: boolean): void {} |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
<nz-select |
||||
|
[nzPlaceHolder]="placeholder" |
||||
|
[(ngModel)]="value" |
||||
|
(ngModelChange)="onModelChange($event)" |
||||
|
[nzDropdownMatchSelectWidth]="false" |
||||
|
> |
||||
|
@for (item of originData; track $index) { |
||||
|
<nz-option [nzLabel]="item.name" [nzValue]="item.manufacturersVendorId"></nz-option> |
||||
|
} |
||||
|
</nz-select> |
@ -0,0 +1,78 @@ |
|||||
|
import { ChangeDetectorRef, Component, Input, OnInit, TemplateRef, ViewChild, forwardRef } from '@angular/core' |
||||
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
||||
|
|
||||
|
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
||||
|
|
||||
|
import { NzModalService } from 'ng-zorro-antd/modal' |
||||
|
|
||||
|
import { ApiService } from 'app/services' |
||||
|
import { NzMessageService } from 'ng-zorro-antd/message' |
||||
|
|
||||
|
import { SharedModule } from 'app/shared/shared.module' |
||||
|
import { Utils } from 'app/utils' |
||||
|
import { NzFormatEmitEvent, NzTreeNode } from 'ng-zorro-antd/tree' |
||||
|
import { NzTreeSelectComponent } from 'ng-zorro-antd/tree-select' |
||||
|
import { MAX_PAGE_SIZE } from 'app/constants' |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'app-manufacturer-select', |
||||
|
standalone: true, |
||||
|
imports: [SharedModule], |
||||
|
templateUrl: './manufacturer-select.component.html', |
||||
|
styleUrl: './manufacturer-select.component.less', |
||||
|
providers: [ |
||||
|
{ |
||||
|
provide: NG_VALUE_ACCESSOR, |
||||
|
multi: true, |
||||
|
useExisting: forwardRef(() => ManufacturerSelectComponent), |
||||
|
}, |
||||
|
], |
||||
|
}) |
||||
|
export class ManufacturerSelectComponent { |
||||
|
constructor( |
||||
|
private modal: NzModalService, |
||||
|
private api: ApiService, |
||||
|
private msg: NzMessageService, |
||||
|
private cdr: ChangeDetectorRef, |
||||
|
) {} |
||||
|
|
||||
|
@Input() placeholder: string = '请选择' |
||||
|
|
||||
|
@Input() modalTitle: string = '选择' |
||||
|
|
||||
|
@Input() radio: boolean = false |
||||
|
|
||||
|
@ViewChild('el') el!: NzTreeSelectComponent |
||||
|
|
||||
|
originData: NzSafeAny[] = [] |
||||
|
|
||||
|
value?: string |
||||
|
|
||||
|
ngOnInit(): void { |
||||
|
this.api.getBasicManufacturersVendorPage({ pageSize: MAX_PAGE_SIZE, pageNum: 1 }).subscribe((res) => { |
||||
|
this.originData = res.body.rows |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
onModelChange(v: NzSafeAny) { |
||||
|
this.onChange(v) |
||||
|
} |
||||
|
|
||||
|
onTouched = () => {} |
||||
|
|
||||
|
onChange(v: NzSafeAny[]) {} |
||||
|
|
||||
|
writeValue(v: NzSafeAny): void { |
||||
|
this.value = v |
||||
|
} |
||||
|
|
||||
|
registerOnChange(fn: any): void { |
||||
|
this.onChange = fn |
||||
|
} |
||||
|
|
||||
|
registerOnTouched(fn: any): void { |
||||
|
this.onTouched = fn |
||||
|
} |
||||
|
|
||||
|
setDisabledState?(isDisabled: boolean): void {} |
||||
|
} |
@ -0,0 +1,7 @@ |
|||||
|
<nz-tree-select |
||||
|
[nzNodes]="orgTree" |
||||
|
[nzPlaceHolder]="placeholder" |
||||
|
[(ngModel)]="value" |
||||
|
(ngModelChange)="onChange($event)" |
||||
|
> |
||||
|
</nz-tree-select> |
@ -0,0 +1,89 @@ |
|||||
|
import { ChangeDetectorRef, Component, Input, OnInit, TemplateRef, ViewChild, forwardRef } from '@angular/core' |
||||
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
||||
|
|
||||
|
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
||||
|
|
||||
|
import { NzModalService } from 'ng-zorro-antd/modal' |
||||
|
|
||||
|
import { ApiService } from 'app/services' |
||||
|
import { NzMessageService } from 'ng-zorro-antd/message' |
||||
|
|
||||
|
import { SharedModule } from 'app/shared/shared.module' |
||||
|
import { Utils } from 'app/utils' |
||||
|
import { NzFormatEmitEvent, NzTreeNode } from 'ng-zorro-antd/tree' |
||||
|
import { NzTreeSelectComponent } from 'ng-zorro-antd/tree-select' |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'app-org-select', |
||||
|
standalone: true, |
||||
|
imports: [SharedModule], |
||||
|
templateUrl: './org-select.component.html', |
||||
|
styleUrl: './org-select.component.less', |
||||
|
providers: [ |
||||
|
{ |
||||
|
provide: NG_VALUE_ACCESSOR, |
||||
|
multi: true, |
||||
|
useExisting: forwardRef(() => OrgSelectComponent), |
||||
|
}, |
||||
|
], |
||||
|
}) |
||||
|
export class OrgSelectComponent implements ControlValueAccessor, OnInit { |
||||
|
constructor( |
||||
|
private modal: NzModalService, |
||||
|
private api: ApiService, |
||||
|
private msg: NzMessageService, |
||||
|
private cdr: ChangeDetectorRef, |
||||
|
) {} |
||||
|
|
||||
|
@Input() placeholder: string = '请选择' |
||||
|
|
||||
|
@Input() company: boolean = false |
||||
|
|
||||
|
originTreeData: NzSafeAny[] = [] |
||||
|
|
||||
|
orgTree: NzSafeAny[] = [] |
||||
|
|
||||
|
value?: string |
||||
|
|
||||
|
ngOnInit(): void { |
||||
|
this.api.getOrgTree().subscribe((res) => { |
||||
|
this.originTreeData = res.body |
||||
|
|
||||
|
const c: NzSafeAny[] = [] |
||||
|
res.body.forEach((i: NzSafeAny) => { |
||||
|
if (this.company) { |
||||
|
if (i.organizationType === '0') { |
||||
|
c.push(i) |
||||
|
} |
||||
|
} else { |
||||
|
if (['1', '0'].includes(i.organizationType)) { |
||||
|
c.push(i) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
this.orgTree = Utils.buildTree(c, 'organizationId', 'organizationName') |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
onSelect(e: NzFormatEmitEvent) { |
||||
|
// this.onChange(e.keys ?? [])
|
||||
|
} |
||||
|
|
||||
|
onTouched = () => {} |
||||
|
|
||||
|
onChange(v: NzSafeAny[]) {} |
||||
|
|
||||
|
writeValue(v: NzSafeAny): void { |
||||
|
this.value = v |
||||
|
} |
||||
|
|
||||
|
registerOnChange(fn: any): void { |
||||
|
this.onChange = fn |
||||
|
} |
||||
|
|
||||
|
registerOnTouched(fn: any): void { |
||||
|
this.onTouched = fn |
||||
|
} |
||||
|
|
||||
|
setDisabledState?(isDisabled: boolean): void {} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
<nz-tree-select |
||||
|
[nzNodes]="positionTree" |
||||
|
[nzPlaceHolder]="placeholder" |
||||
|
[(ngModel)]="value" |
||||
|
(ngModelChange)="onChange($event)" |
||||
|
[nzDropdownMatchSelectWidth]="false" |
||||
|
> |
||||
|
</nz-tree-select> |
@ -0,0 +1,77 @@ |
|||||
|
import { ChangeDetectorRef, Component, Input, OnInit, TemplateRef, ViewChild, forwardRef } from '@angular/core' |
||||
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
||||
|
|
||||
|
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
||||
|
|
||||
|
import { NzModalService } from 'ng-zorro-antd/modal' |
||||
|
|
||||
|
import { ApiService } from 'app/services' |
||||
|
import { NzMessageService } from 'ng-zorro-antd/message' |
||||
|
|
||||
|
import { SharedModule } from 'app/shared/shared.module' |
||||
|
import { Utils } from 'app/utils' |
||||
|
import { NzFormatEmitEvent, NzTreeNode } from 'ng-zorro-antd/tree' |
||||
|
import { NzTreeSelectComponent } from 'ng-zorro-antd/tree-select' |
||||
|
import { MAX_PAGE_SIZE } from 'app/constants' |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'app-position-select', |
||||
|
standalone: true, |
||||
|
imports: [SharedModule], |
||||
|
templateUrl: './position-select.component.html', |
||||
|
styleUrl: './position-select.component.less', |
||||
|
providers: [ |
||||
|
{ |
||||
|
provide: NG_VALUE_ACCESSOR, |
||||
|
multi: true, |
||||
|
useExisting: forwardRef(() => PositionSelectComponent), |
||||
|
}, |
||||
|
], |
||||
|
}) |
||||
|
export class PositionSelectComponent { |
||||
|
constructor( |
||||
|
private modal: NzModalService, |
||||
|
private api: ApiService, |
||||
|
private msg: NzMessageService, |
||||
|
private cdr: ChangeDetectorRef, |
||||
|
) {} |
||||
|
|
||||
|
@Input() placeholder: string = '请选择' |
||||
|
|
||||
|
@Input() modalTitle: string = '选择' |
||||
|
|
||||
|
@Input() radio: boolean = false |
||||
|
|
||||
|
@ViewChild('el') el!: NzTreeSelectComponent |
||||
|
|
||||
|
originData: NzSafeAny[] = [] |
||||
|
|
||||
|
positionTree: NzSafeAny[] = [] |
||||
|
|
||||
|
value?: string |
||||
|
|
||||
|
ngOnInit(): void { |
||||
|
this.api.getBasicPositionTree().subscribe((res) => { |
||||
|
this.originData = res.body |
||||
|
this.positionTree = Utils.buildTree(res.body, 'positionId', 'name') |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
onTouched = () => {} |
||||
|
|
||||
|
onChange(v: NzSafeAny[]) {} |
||||
|
|
||||
|
writeValue(v: NzSafeAny): void { |
||||
|
this.value = v |
||||
|
} |
||||
|
|
||||
|
registerOnChange(fn: any): void { |
||||
|
this.onChange = fn |
||||
|
} |
||||
|
|
||||
|
registerOnTouched(fn: any): void { |
||||
|
this.onTouched = fn |
||||
|
} |
||||
|
|
||||
|
setDisabledState?(isDisabled: boolean): void {} |
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
export const MAX_PAGE_SIZE = 10000000 |
||||
|
|
||||
|
export const ASSET_STATUS = [ |
||||
|
{ label: '闲置', value: 0 }, |
||||
|
{ label: '在用', value: 1 }, |
||||
|
{ label: '借用中', value: 2 }, |
||||
|
{ label: '维修中', value: 3 }, |
||||
|
{ label: '调拨中', value: 4 }, |
||||
|
{ label: '待报废', value: 5 }, |
||||
|
{ label: '已处置', value: 6 }, |
||||
|
{ label: '库存', value: 7 }, |
||||
|
{ label: '已报废', value: 8 }, |
||||
|
] |
||||
|
|
||||
|
export const ASSET_STATUS_MAP = () => { |
||||
|
return ASSET_STATUS.reduce( |
||||
|
(map, item) => { |
||||
|
map[item.value] = item.label |
||||
|
return map |
||||
|
}, |
||||
|
{} as Record<number, string>, |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
export const ASSET_SOURCE_MAP = new Map([ |
||||
|
[0, '捐赠'], |
||||
|
[1, '赠送'], |
||||
|
[2, '其他'], |
||||
|
[3, '采购'], |
||||
|
[4, '自建'], |
||||
|
[4, '自购'], |
||||
|
]) |
||||
|
|
||||
|
export const MAINTENANCE_STATUS = new Map([ |
||||
|
[0, '不需要'], |
||||
|
[1, '脱保'], |
||||
|
[2, '在保'], |
||||
|
[3, '未知'], |
||||
|
]) |
||||
|
|
||||
|
export const MAINTENANCE_TYPE = new Map([ |
||||
|
[0, '原厂'], |
||||
|
[1, '第三方'], |
||||
|
]) |
@ -1,85 +1,197 @@ |
|||||
import { Component } from '@angular/core' |
import { Component, TemplateRef, ViewChild } from '@angular/core' |
||||
import { FormControl, FormGroup } from '@angular/forms' |
import { FormControl, FormGroup } from '@angular/forms' |
||||
|
|
||||
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table' |
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table' |
||||
import { ApiService } from 'app/services' |
import { ApiService } from 'app/services' |
||||
import { SharedModule } from 'app/shared/shared.module' |
import { SharedModule } from 'app/shared/shared.module' |
||||
import { format } from 'date-fns' |
import { format } from 'date-fns' |
||||
import { of } from 'rxjs' |
import { lastValueFrom, of } from 'rxjs' |
||||
|
import { AssetFormComponent, ManufacturerSelectComponent, PositionSelectComponent } from 'app/components' |
||||
|
import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal' |
||||
|
import { NzMessageService } from 'ng-zorro-antd/message' |
||||
|
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
||||
|
import { ASSET_SOURCE_MAP, ASSET_STATUS, ASSET_STATUS_MAP } from 'app/constants' |
||||
|
import { Utils } from 'app/utils' |
||||
|
|
||||
@Component({ |
@Component({ |
||||
selector: 'app-fixed-asset-manage', |
selector: 'app-fixed-asset-manage', |
||||
standalone: true, |
standalone: true, |
||||
imports: [SharedModule], |
imports: [SharedModule, AssetFormComponent, PositionSelectComponent, ManufacturerSelectComponent], |
||||
templateUrl: './fixed-asset-manage.component.html', |
templateUrl: './fixed-asset-manage.component.html', |
||||
styleUrl: './fixed-asset-manage.component.less', |
styleUrl: './fixed-asset-manage.component.less', |
||||
}) |
}) |
||||
export class FixedAssetManageComponent { |
export class FixedAssetManageComponent { |
||||
constructor(private api: ApiService) {} |
constructor( |
||||
|
private api: ApiService, |
||||
|
private modal: NzModalService, |
||||
|
private msg: NzMessageService, |
||||
|
) {} |
||||
|
|
||||
queryForm = new FormGroup({ |
queryForm = new FormGroup({ |
||||
name: new FormControl(''), |
name: new FormControl(), |
||||
type: new FormControl(''), |
model: new FormControl(), |
||||
status: new FormControl(''), |
status: new FormControl(), |
||||
date: new FormControl(''), |
assetCode: new FormControl(), |
||||
|
serialNumber: new FormControl(), |
||||
|
sourceId: new FormControl(), |
||||
|
positionId: new FormControl(), |
||||
|
manufacturersVendorId: new FormControl(), |
||||
}) |
}) |
||||
|
|
||||
|
@ViewChild('copyTpl') copyTpl!: TemplateRef<NzSafeAny> |
||||
|
|
||||
|
ASSET_STATUS_MAP = ASSET_STATUS_MAP() |
||||
|
|
||||
|
ASSET_SOURCE_MAP = ASSET_SOURCE_MAP |
||||
|
|
||||
table = new TableOption(this.fetchData.bind(this)) |
table = new TableOption(this.fetchData.bind(this)) |
||||
|
|
||||
|
copyNum = 1 |
||||
|
|
||||
ngOnInit(): void { |
ngOnInit(): void { |
||||
this.table |
this.table |
||||
.setConfig({ |
.setConfig({ |
||||
selectable: true, |
selectable: true, |
||||
|
rowKey: 'assetId', |
||||
}) |
}) |
||||
.setColumn([ |
.setColumn([ |
||||
{ key: '办理状态', title: '办理状态', visible: true }, |
{ key: 'assetCode', title: '资产编号', visible: true }, |
||||
{ key: '资产编号', title: '资产编号', visible: true }, |
{ key: 'name', title: '资产名称', visible: true }, |
||||
{ key: '资产状态', title: '资产状态', visible: true }, |
{ key: '_category', title: '资产分类', visible: true }, |
||||
{ key: '资产分类', title: '资产分类', visible: true }, |
{ key: 'status', title: '资产状态', visible: true }, |
||||
{ key: '资产名称', title: '资产名称', visible: true }, |
{ key: '_ownCompany', title: '所属公司', visible: true }, |
||||
{ key: '规格型号', title: '规格型号', visible: true }, |
{ key: '_useOrganization', title: '使用组织', visible: true }, |
||||
{ key: '所属公司', title: '所属公司', visible: true }, |
{ key: '_position', title: '存放位置', visible: true }, |
||||
{ key: '使用组织', title: '使用组织', visible: true }, |
|
||||
{ key: '存放位置', title: '存放位置', visible: true }, |
|
||||
]) |
]) |
||||
.setRowOperate([ |
.setRowOperate([ |
||||
{ title: '查看', premissions: [] }, |
{ title: '查看' }, |
||||
{ title: '修改' }, |
{ title: '修改', onClick: this.onCreate.bind(this) }, |
||||
{ title: '复制' }, |
{ title: '复制', onClick: this.onCopy.bind(this) }, |
||||
{ title: '密文箱' }, |
|
||||
{ title: '折旧记录' }, |
{ title: '折旧记录' }, |
||||
{ title: '二维码' }, |
{ title: '二维码', onClick: this.qrcode.bind(this) }, |
||||
{ title: '操作明细' }, |
{ title: '操作明细' }, |
||||
{ title: '删除' }, |
{ title: '删除', onClick: this.deleteItem.bind(this) }, |
||||
]) |
]) |
||||
} |
} |
||||
|
|
||||
fetchData(p: {}, q: AnyObject) { |
fetchData(p: {}, q: AnyObject) { |
||||
if (Array.isArray(q['createTime'])) { |
return this.api.getAssetPage({ ...p, ...q }) |
||||
const createTimeStart = q['createTime']?.[0] |
} |
||||
const createTimeEnd = q['createTime']?.[1] |
|
||||
|
|
||||
q['createTimeStart'] = createTimeStart ? format(new Date(createTimeStart), 'yyyy-MM-dd HH:mm:ss') : '' |
onCopy(data: NzSafeAny) { |
||||
q['createTimeEnd'] = createTimeEnd ? format(new Date(createTimeEnd), 'yyyy-MM-dd HH:mm:ss') : '' |
this.modal.create({ |
||||
} |
nzTitle: '复制资产', |
||||
return of({ |
nzWidth: 600, |
||||
data: { |
nzContent: this.copyTpl, |
||||
total: 5, |
nzOnOk: async () => { |
||||
records: [ |
if (!this.copyNum) { |
||||
{ |
this.msg.error('请输入复制数量') |
||||
id: 1, |
return false |
||||
name: '沙滩', |
} |
||||
price: 590, |
const res = await lastValueFrom(this.api.copyAsset(this.copyNum, data.assetId)) |
||||
type: 0, |
this.msg.success(res.desc) |
||||
lifespan: 6, |
this.table.ref.reload() |
||||
number: 20, |
return true |
||||
max: 20, |
}, |
||||
status: 1, |
}) |
||||
createTime: '2024-05-01', |
} |
||||
}, |
|
||||
], |
onCreate(data?: NzSafeAny) { |
||||
|
this.modal.create({ |
||||
|
nzTitle: data ? '编辑资产' : '添加资产', |
||||
|
nzContent: AssetFormComponent, |
||||
|
nzWidth: '80vw', |
||||
|
nzWrapClassName: 'modal-lg', |
||||
|
nzData: data, |
||||
|
nzOnOk: async (e) => { |
||||
|
const vals = e.getValues() |
||||
|
if (vals) { |
||||
|
const res = await lastValueFrom(this.api.saveAsset(vals)) |
||||
|
this.msg.success(res.desc) |
||||
|
this.table.ref.reload() |
||||
|
return true |
||||
|
} |
||||
|
|
||||
|
return false |
||||
|
}, |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
deleteItem(item?: NzSafeAny) { |
||||
|
const ids = item ? [item.assetId] : Array.from(this.table.ref.selected) |
||||
|
this.modal.confirm({ |
||||
|
nzTitle: '警告', |
||||
|
nzContent: `是否要删除${ids.length}个资产?`, |
||||
|
nzOnOk: async () => { |
||||
|
const res = await lastValueFrom(this.api.deleteAsset(ids)) |
||||
|
this.msg.success(res.desc) |
||||
|
this.table.ref.reload() |
||||
|
}, |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
confirmAsset() { |
||||
|
const ids = Array.from(this.table.ref.selected).map((i) => Number(i)) |
||||
|
this.modal.confirm({ |
||||
|
nzTitle: '警告', |
||||
|
nzContent: `是否对选择的${ids.length}个资产进行确认?`, |
||||
|
nzOnOk: async () => { |
||||
|
const res = await lastValueFrom(this.api.confirmAsset(ids)) |
||||
|
this.msg.success(res.desc) |
||||
|
this.table.ref.reload() |
||||
}, |
}, |
||||
}) |
}) |
||||
return this.api.getEntityPage(p, q) |
} |
||||
|
|
||||
|
qrcode(d: NzSafeAny) { |
||||
|
this.msg.loading('二维码生成中...') |
||||
|
this.api.assetQrcode(d.assetId).subscribe((res) => { |
||||
|
Utils.downLoadFile(res, 'application/pdf') |
||||
|
this.msg.remove() |
||||
|
this.msg.success('二维码生成成功') |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
downloadTemplate() { |
||||
|
this.msg.loading('模板下载中...') |
||||
|
this.api.downloadAssetTemplate().subscribe((res) => { |
||||
|
Utils.downLoadFile(res, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8') |
||||
|
this.msg.remove() |
||||
|
this.msg.success('模板下载成功') |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
importModalRef?: NzModalRef |
||||
|
importExcel(nzContent: TemplateRef<{}>) { |
||||
|
this.importModalRef = this.modal.create({ |
||||
|
nzTitle: '资产数据导入', |
||||
|
nzContent, |
||||
|
nzFooter: null, |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
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.uploadAsset(formdata).subscribe((res) => { |
||||
|
this.importModalRef?.close() |
||||
|
this.msg.success(res.desc) |
||||
|
this.table.ref.reload() |
||||
|
}) |
||||
|
} |
||||
|
exportExcel() { |
||||
|
const ids = Array.from(this.table.ref.selected).map((i) => Number(i)) |
||||
|
if (ids.length === 0) { |
||||
|
return |
||||
|
} |
||||
|
this.msg.loading('Excel生成中...') |
||||
|
this.api.exportAsset(ids).subscribe((res) => { |
||||
|
Utils.downLoadFile(res, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8') |
||||
|
this.msg.remove() |
||||
|
this.msg.success('Excel生成成功') |
||||
|
}) |
||||
} |
} |
||||
} |
} |
||||
|
Loading…
Reference in new issue