import { CodeClassModel, DataResultT, RhDynamicComponentFieldType, RhDynamicInterfaceDto, RhDynamicTableFieldDto, RhSafeAny, RhSelectableDto, RhSelectItem, RhTableQueryOptionDto } from 'rh-base/model'; import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; import { RhApiUrlsService } from 'rh-base/core'; import { RhPortType } from 'rh-base/model'; import { DynamicFormComponent, MaterialDocumentDto, MaterialDocumentQueryDto } from 'rh-base/shared'; @Component({ selector: 'rh-ipqc-sync-schema-card', templateUrl: './ipqc-sync-schema-card.component.html', styleUrls: ['./ipqc-sync-schema-card.component.less'] }) export class RhIpqcSyncSchemaCardComponent implements OnInit { inspectTypeList: RhSelectItem[] = []; inspectTypes: { label: string; value: string; checked?: boolean; disabled?: boolean }[] = []; defaultFieldDataset: RhDynamicComponentFieldType[] = []; ProductInterfaceInfo!: RhDynamicInterfaceDto; ProductQueryDto!: MaterialDocumentQueryDto; SelectedInspectGroup: { label: string; value: string; checked?: boolean; disabled?: boolean }[] = []; @ViewChild('materialForm', { static: false }) materialFormCmt!: DynamicFormComponent; selectedIndex = 0; dataLoading = false; materialDataresult!: DataResultT; @Output() rhSelectedProductDatasChange = new EventEmitter(); @Output() rhSelectedInspectTypesChange = new EventEmitter(); @Input() isLine!: boolean; @Output() rhSelectedInspectGroup = new EventEmitter(); constructor(private apiUrls: RhApiUrlsService) {} ngOnInit(): void { this.getProductDatas(); this.getInspectTypes(); this.getInspectGroups(); } getProductDatas() { const queryDto = MaterialDocumentQueryDto.create(); queryDto.Mode = 8; this.ProductQueryDto = queryDto; this.ProductInterfaceInfo = this.getProductInterfaceInfoDatas(); } getProductInterfaceInfoDatas(): RhDynamicInterfaceDto { const dto = RhDynamicInterfaceDto.create(); // 端口类型获取对应的端口号 const portNum = this.apiUrls.getPortNum(RhPortType.mdp); dto.interfaceType = 'post'; dto.port = portNum; dto.controllerName = 'ProductMaterialWebApi'; dto.interfaceName = 'GetMaterialDocumentDatas'; return dto; } // 获取检验类型 getInspectTypes() { this.apiUrls .getSettingEntry({ moduleKey: 'QualityManagement', groupKey: 'ProcessInspectOrderConst', paraCode: 'InspectCategory' }) .subscribe((result) => { if (result.Success) { this.inspectTypeList = result.Attach; this.inspectTypeList.forEach((ele) => { this.inspectTypes.push({ label: ele.Text, value: ele.Value?.toString() as string, checked: false }); }); } }); } // 获取检验组 getInspectGroups() { this.apiUrls .getSettingEntry({ moduleKey: 'QualityManagement', groupKey: 'ProcessInspectOrderConst', paraCode: 'InspectGroup' }) .subscribe((result) => { if (result.Success) { result.Attach.forEach((ele) => { this.SelectedInspectGroup.push({ label: ele.Text, value: ele.Value?.toString() as string, checked: false }); }); } }); } getSelectedDatas(datas: MaterialDocumentDto) { this.rhSelectedProductDatasChange.emit(datas); } getInspectTypeChange(items: RhSafeAny[]) { this.rhSelectedInspectTypesChange.emit(items); } getSelectedInspectGroup(item: RhSafeAny) { this.rhSelectedInspectGroup.emit(item); } dataLoadingChange(status: boolean) { this.dataLoading = status; } setDatas(dataset: DataResultT) { this.materialDataresult = dataset; } setInitFieldDataset(item: CodeClassModel) { const tempDatas: RhDynamicComponentFieldType[] = []; item.CodeProperties.forEach((ele) => { const temp = RhDynamicTableFieldDto.create(); temp.name = ele.PropertyName; temp.displayName = ele.Descirption; tempDatas.push(temp); }); this.defaultFieldDataset = [...tempDatas]; } closeEditTab() { this.selectedIndex = 0; } refreshData(option: RhTableQueryOptionDto) { this.getDatas(option); } private getDatas(option?: RhTableQueryOptionDto) { if (this.materialFormCmt) { this.materialFormCmt.submitDefaultForm(null, option); } } }