import { MsgHelper, ObjectHelper, RhNavigatorService } from 'rh-base/core'; import { Component, OnInit, ViewChild } from '@angular/core'; import { UntypedFormGroup, Validators } from '@angular/forms'; import { CodeClassModel, DataResultT, OpMode, OpResult, RhBaseDto, RhBaseQueryDto, RhDynamicComponentFieldType, RhDynamicInterfaceDto, RhDynamicTableFieldDto, RhSafeAny, RhSelectableDto, RhTableButtonInfoDto, RhTableQueryOptionDto } from 'rh-base/model'; import { RhDynamicSingleTableComponent, DynamicFormComponent } from 'rh-base/shared'; import { DataImportInput, EmployeeInfoDto, EmployeeMessageNotifyGroupConfigDto, InspectionSpecificationStandardFileDto, InspectionSpecificationStandardFileQueryDto, IqcInspectSchemaEntryQueryDto, IqcMaterialInspectSchemaDto, View_MessageNotifyGroupDto, InspectUploadCode, IqcInspectSchemaGroupDto, IqcInspectSchemaGroupQueryDto, IqcInspectTransferRuleQueryDto, IqcMaterialInspectSchemaFullDto, IqcInspectSchemaEntryDto, IqcMaterialInspectSchemaQueryDto, QCInspectSchemaEntryDto } from './../../qmp-model'; import { firstValueFrom, Observable, Observer } from 'rxjs'; import { RhIqcManagementService } from './../iqc-management.service'; import { RhQmpService } from '../../qmp.service'; import { RhQualityManageSharedService } from '../../shared/quality-manage-shared.service'; import { NzModalService } from 'ng-zorro-antd/modal'; import { NzTreeNode } from 'ng-zorro-antd/tree'; import { NzUploadFile } from 'ng-zorro-antd/upload'; @Component({ selector: 'rh-material-inspect-management', templateUrl: './material-inspect-management.component.html', styleUrls: ['./material-inspect-management.component.less'] }) export class RhMaterialInspectManagementComponent implements OnInit { @ViewChild('queryForm', { static: false }) queryFormCmt!: DynamicFormComponent; @ViewChild(RhDynamicSingleTableComponent) entryTableComp!: RhDynamicSingleTableComponent; selectedIndex = 0; dataLoading = false; dataresult!: DataResultT; entryDataresult!: DataResultT; tabType: 'transferRule' | 'bind' | 'import' | 'newschema' | 'entry' | 'inspectDetail' | null = null; defaultFieldDataset: RhDynamicComponentFieldType[] = []; defaultQueryDto: RhSafeAny = {}; inspectDetail!: IqcMaterialInspectSchemaFullDto; beforeInspectSchemaCode!: string; currentInspectSchemaGroupDto: IqcInspectSchemaGroupDto | null = null; currentInspectSchemaEntryDatas!: IqcInspectSchemaEntryDto; inspectSchemaEntryInterface!: RhDynamicInterfaceDto; inspectSchemaEntryQueryDto!: RhBaseQueryDto; // 已绑定物料 bindMaterialInterfaceInfo!: RhDynamicInterfaceDto; bindMaterialQueryDto!: IqcMaterialInspectSchemaQueryDto; count = 1; selectedDatas: RhSelectableDto[] = []; selecedSchemaDatas: IqcMaterialInspectSchemaDto[] = []; selectedData: RhSafeAny[] = []; InspectSchemaEntryBeforeSubmit = (data: RhBaseDto) => { data['InspectItemGroupCode'] = this.currentInspectSchemaGroupDto?.InspectItemGroupCode; return true; }; titleButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto( 'enableButton', '启用', 'default', false, 'unlock', true, null, () => this.enableIqcMaterialInspectSchemaDatas(), false, true ), new RhTableButtonInfoDto( 'disableButton', '禁用', 'primary', true, 'lock', true, null, () => this.cancleEnableIqcMaterialInspectSchemaDatas(), false, true ) ]; editButtonDataset: RhTableButtonInfoDto[] = [ // new RhTableButtonInfoDto('details', '检验项目明细', 'default', 'unordered-list', false, null, (data) => // this.openEntryDatasTab(data as RhBaseDto, true) // ), new RhTableButtonInfoDto('navigateToSchemaPage', '转到检验方案维护', 'default', false, 'send', false, null, (data) => this.openInspectDetail(data as IqcMaterialInspectSchemaDto) ), new RhTableButtonInfoDto('upload', '附件上传', 'default', false, 'cloud-upload', false, null, (data) => this.openUploadModal(data as RhBaseDto) ), new RhTableButtonInfoDto( 'review', '附件预览', 'default', false, 'eye', false, null, (data) => this.openPreviewModal(data as RhBaseDto), true, false, 'green' ), new RhTableButtonInfoDto( 'disbind', '解绑', 'primary', true, 'disconnect', false, null, (data) => this.singleDisBind(data as RhBaseDto), true, false, 'red' ), new RhTableButtonInfoDto( 'transfer', '修改转移规则', 'default', false, 'swap', false, null, (data) => this.transferModify(data as RhBaseDto), true, false ) ]; extraButtonDataset: RhTableButtonInfoDto[] = [ // new RhTableButtonInfoDto('import', '导入Excel', 'default', 'import', false, null, () => this.openImportModal(), true) ]; titleInspectButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('new', '新建', 'primary', false, 'file', false, null, () => this.openAddModal(), true), new RhTableButtonInfoDto( 'delete', '删除', 'primary', true, 'delete', true, null, (datas, buttonInfo) => this.deleteEntryDatas(datas as IqcInspectSchemaEntryDto[], buttonInfo as RhTableButtonInfoDto), false, true ) ]; editInspectButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto( 'edit', '编辑', 'primary', false, 'edit', false, null, (data) => this.openAddModal(data as IqcInspectSchemaEntryDto), true ), new RhTableButtonInfoDto('upload', '附件上传', 'default', false, 'cloud-upload', false, null, (data) => this.openUploadModal(data as RhBaseDto) ), new RhTableButtonInfoDto( 'preview', '附件预览', 'default', false, 'eye', false, null, (data) => this.openPreviewModal(data as RhBaseDto), true, true, 'green' ) ]; extraInspectButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto( 'unlock', '启用', 'primary', false, 'unlock', true, null, (datas, buttonInfo) => this.enableEntryDatas(datas as IqcInspectSchemaEntryDto[], buttonInfo as RhTableButtonInfoDto), false, true ), new RhTableButtonInfoDto( 'lock', '禁用', 'primary', true, 'lock', true, null, (datas, buttonInfo) => this.disableEntryDatas(datas as IqcInspectSchemaEntryDto[], buttonInfo as RhTableButtonInfoDto), false, true ) ]; // 选中的物料检验方案 selectData: RhBaseDto | null = null; isShowAddModal = false; inspectSchemaEntryDto!: IqcInspectSchemaEntryDto | RhSafeAny; //树内选中的物料 selectedMaterial: RhSafeAny; //#region 检验项目(物料检验方案表体) entryDatasInterfaceInfo!: RhDynamicInterfaceDto; entryDatasQueryDto!: IqcInspectSchemaEntryQueryDto; entrySelectedIndex = 0; entryEditDto: RhBaseDto = {}; isShowEntryEditTab = false; transferData: RhSafeAny; InspectItemGroupName!: IqcInspectSchemaGroupDto[]; isShowForm = false; /** 是否显示新建、删除按钮 */ isShowEditButton = true; //#endregion // //#region 检验方案附件预览 isShowFilePreviewModal = false; fileQueryDto!: InspectionSpecificationStandardFileQueryDto; fileDatas: InspectionSpecificationStandardFileDto[] = []; uploadCode = InspectUploadCode.MaterialInspectSchema; uploadType = 'IqcAttachFileModule'; selectFileData: RhBaseDto | null = null; isShowUploadModal = false; isShowPreviewModal = false; isEditTransferRule = false; TransferDataLoading = false; //#endregion // //#region 新建方案 editDto: RhBaseDto = {}; startDate!: Date; endDate!: Date; // rangeDate: Date[] = []; /** 检验人员 && 检验组 */ qualityInspectGroup: EmployeeMessageNotifyGroupConfigDto[] = []; qualityInspector: View_MessageNotifyGroupDto[] = []; //选择员工Modal isShowInspectorModal = false; selectEmployeeData: EmployeeInfoDto | null = null; editForm!: UntypedFormGroup; saveLoading = false; //#endregion // // 数据导入 isShowUploadDrawer = false; /** 上传的文件数据模型列表 */ uploadDatas: RhSafeAny; uploadFileList: NzUploadFile[] = []; uploading = false; importDatas: RhSafeAny[] = []; // 导入数据返回的表头信息 dataHeadFields: { FieldName: string; FieldDescription: string }[] = []; tableWidth = '0px'; isAddAfterDeleteAll = false; validateForm!: UntypedFormGroup; constructor( private operator: RhIqcManagementService, private modal: NzModalService, private qmpSer: RhQmpService, public navigateSer: RhNavigatorService, public sharedSer: RhQualityManageSharedService ) { // } beforeTransferRuleFormSubmit = (data: RhBaseDto) => { if (this.transferData) { data['MaterialCode'] = this.transferData.MaterialCode; data['MaterialName'] = this.transferData.MaterialName; data['SupplierCode'] = this.transferData.SupplierCode; data['SupplierName'] = this.transferData.SupplierName; data['InspectSchemaCode'] = this.transferData.InspectSchemaCode; data['InspectItemGroupCode'] = this.transferData.InspectItemGroupCode; } return true; }; ngOnInit() { // 附件预览 this.fileQueryDto = this.initFileQueryDto(); // 获取检验组数据 // this.getQualityInspectGroup(); } //#region ********** 物料检验方案查询相关(主界面) ********** // selectedMaterialCode(item: RhSafeAny) { // if (item) { // this.selectedMaterial = item; // this.getDatas(); // } // } selectedMaterialCode(node: NzTreeNode) { if (node && node.origin['customData']) { const item = node.origin['customData']; if (node.level === 1 && node.isSelected) { this.selectedMaterial = item; this.getDatas(); } } else { this.selectedMaterial = null; } } setDatas(dataset: DataResultT) { this.dataresult = dataset; if (!this.dataresult?.Success) { MsgHelper.ShowWarningMessage(`搜索无数据!${this.dataresult?.Message}`); } } setEntryDatas(dataset: DataResultT) { this.entryDataresult = dataset; if (!this.entryDataresult?.Success) { MsgHelper.ShowWarningMessage(`搜索无数据!${this.entryDataresult?.Message}`); } } dataLoadingChange(status: boolean) { this.dataLoading = status; } setInitFieldDatset(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]; } refreshDatas(option: RhTableQueryOptionDto) { this.getDatas(option); } //调用子组件中的接口 getDatas(option?: RhTableQueryOptionDto) { if (this.queryFormCmt) { const queryDto: RhSafeAny = {}; if (this.selectedMaterial?.MaterialCode) { queryDto.MaterialCode = `$${this.selectedMaterial.MaterialCode}`; } this.defaultQueryDto = queryDto; setTimeout(() => { this.queryFormCmt.submitDefaultForm(null, option); }); } } // // 获取检验组 // getQualityInspectGroup() { // const queryDto = EmployeeMessageNotifyGroupConfigQueryDto.create(); // queryDto.IsEnable = true; // queryDto.Mode = 8; // queryDto.ModuleKey = 'QualityManagement'; // this.qmpSer.GetEmployeeMessageNotifyGroupConfigDatas(queryDto).subscribe((result) => { // if (result && result.Success) { // this.qualityInspectGroup = result.Attach; // } else { // this.qualityInspectGroup = []; // } // }); // } // 打开员工选择框 closeInspectorModal() { this.isShowInspectorModal = false; } openInspectorModal(formGroup: UntypedFormGroup) { this.editForm = formGroup; this.isShowInspectorModal = true; } // 从维护人员组件中获取到的人员 getAssignEmployee(data: View_MessageNotifyGroupDto) { const selectedEmp = EmployeeInfoDto.create(); selectedEmp.EmployeeCode = data?.EmployeeCode; selectedEmp.EmployeeName = data?.EmployeeName; this.selectEmployeeData = selectedEmp.EmployeeCode ? selectedEmp : null; } saveInspectorDates() { this.editForm.get('QualityInspector')?.setValue(this.selectEmployeeData?.EmployeeCode); this.closeInspectorModal(); } //#endregion // //#region ********** 检验项目(物料检验方案表体) ********** openEntryDatasTab(dto: RhBaseDto, isShow: boolean) { this.isShowEditButton = isShow; this.selectData = dto; this.tabType = 'entry'; this.selectedIndex = 1; } transferModify(dto: RhBaseDto) { this.selectData = dto; this.tabType = 'transferRule'; this.selectedIndex = 1; this.getIqcInspectSchemaGroupDatas(); } getIqcInspectTransferRuleDatas(item: string) { const dto = IqcInspectTransferRuleQueryDto.create(); dto.MaterialCode = this.selectData?.['MaterialCode']; dto.MaterialName = this.selectData?.['MaterialName']; dto.InspectSchemaCode = this.selectData?.['InspectSchemaCode']; dto.SupplierCode = this.selectData?.['SupplierCode']; dto.SupplierName = this.selectData?.['SupplierName']; dto.InspectItemGroupCode = item; this.operator.GetIqcInspectTransferRuleDataByCode(dto).subscribe((result) => { if (result.Success) { this.transferData = result.Attach; } else { MsgHelper.ShowWarningMessage(`未搜索到转移规则,请新建`); this.transferData = dto; this.transferData.NormalToTightened = null; this.transferData.TightenedToNormal = null; this.transferData.ReducedToNormal = null; this.transferData.NormalToReduced = null; } }); } getIqcInspectSchemaGroupDatas() { const dto = IqcInspectSchemaGroupQueryDto.create(); dto.InspectSchemaCode = this.selectData?.['InspectSchemaCode']; this.operator.GetIqcInspectSchemaGroupDatas(dto).subscribe((result) => { if (result.Success) { this.InspectItemGroupName = result.Attach; } else { MsgHelper.ShowWarningMessage(`获取数据失败,${result.Message}`); } }); } onStoreIqcInspectTransferRuleData(result: OpResult) { if (result?.Success) { MsgHelper.ShowSuccessMessage(`保存数据成功!`); // this.transferData = []; } else { MsgHelper.ShowWarningModal(`保存数据失败!${result.Message}`); } } getCheckedData(item: IqcInspectSchemaGroupDto) { this.isShowForm = true; this.getIqcInspectTransferRuleDatas(item.InspectItemGroupCode as string); } enableIqcMaterialInspectSchemaDatas() { if (this.selectedDatas.some((ele) => ele['IsUse'] !== false)) { MsgHelper.ShowWarningMessage(`只有状态为 "禁用" 时才能进行启用,请检查!`); return; } this.operator.EnableIqcMaterialInspectSchemaDatas(this.selecedSchemaDatas).subscribe((result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`启用数据成功`); this.getDatas(); } else { MsgHelper.ShowWarningMessage(`启用失败!${result.Message}`); } }); } cancleEnableIqcMaterialInspectSchemaDatas() { if (this.selectedDatas.some((ele) => ele['IsUse'] !== true)) { MsgHelper.ShowWarningMessage(`只有状态为 "启用" 时才能进行禁用,请检查!`); return; } this.operator.CancelEnableIqcMaterialInspectSchemaDatas(this.selecedSchemaDatas).subscribe((result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`禁止数据成功`); this.getDatas(); } else { MsgHelper.ShowWarningMessage(`禁止数据失败!${result.Message}`); } }); } selectedDatasChange(dtos: RhSelectableDto[]) { if (dtos) { this.selecedSchemaDatas = []; this.selectedDatas = dtos; this.selectedDatas.forEach((ele) => { this.selecedSchemaDatas.push(ele as IqcMaterialInspectSchemaDto); }); } } closeTransferTab() { this.tabType = null; this.selectedIndex = 0; this.isShowForm = false; } closeEntryDatasTab() { this.tabType = null; this.selectedIndex = 0; } //#endregion // //#region ********** 绑定方案 ********** openBindTab() { this.tabType = 'bind'; this.selectedIndex = 1; } closeBindTab() { this.tabType = null; this.selectedIndex = 0; this.getDatas(); } //#endregion //#region ********** 新建方案 ********** openNewSchemaTab() { this.tabType = 'newschema'; this.editDto = {}; this.editDto.OpSign = OpMode.OpAdd; if (this.selectedMaterial?.MaterialCode) { this.editDto['MaterialCode'] = this.selectedMaterial.MaterialCode; this.editDto['MaterialName'] = this.selectedMaterial.MaterialName; this.editDto['MaterialSpecification'] = this.selectedMaterial.MaterialSpecification; this.editDto['MaterialCategory'] = this.selectedMaterial.MaterialCategory; } this.selectedIndex = 1; } closeNewSchemaTab() { this.tabType = null; this.selectedIndex = 0; this.getDatas(); } openTransferRuleTab() { this.tabType = 'transferRule'; this.editDto = {}; this.editDto.OpSign = OpMode.OpAdd; if (this.selectedMaterial?.MaterialCode) { this.editDto['MaterialCode'] = this.selectedMaterial.MaterialCode; this.editDto['MaterialName'] = this.selectedMaterial.MaterialName; this.editDto['MaterialSpecification'] = this.selectedMaterial.MaterialSpecification; this.editDto['MaterialCategory'] = this.selectedMaterial.MaterialCategory; } this.selectedIndex = 1; } onStoreNewSchemaData(result: DataResultT) { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`新建数据成功!`); this.editDto = ObjectHelper.createRhBaseDto(); this.getDatas(); } else { MsgHelper.ShowWarningModal(`存储数据失败!${result.Message}`); } } setStartAndEndDate(dates: Date[]) { if (!dates || dates?.length < 2) { return; } this.startDate = new Date(dates[0]); this.endDate = new Date(dates[1]); // console.log(this.startDate, this.endDate); } dataHandler = (data: RhBaseDto) => { data['ValidStartDate'] = this.startDate; data['ValidEndDate'] = this.endDate; return true; }; //#endregion // //#region ********** 单条数据解绑 ********** singleDisBind(dto: RhBaseDto) { this.selectData = dto; const datas: IqcMaterialInspectSchemaDto[] = []; datas.push(dto as IqcMaterialInspectSchemaDto); MsgHelper.ShowConfirmModal( '是否解绑', '是否继续执行解绑操作?', () => { this.operator.RemoveIqcMaterialInspectSchemaDatas(datas).subscribe((result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage('解绑成功'); this.getDatas(); } else { MsgHelper.ShowWarningMessage(`解绑失败:${result.Message}`); } }); }, () => { return; } ); } //#endregion // //#region ********** 转移规则相关 ********** editTransferRule() { this.changeTransferRuleEditStatus(false); } cancelEditTransferRule() { this.getIqcInspectTransferRuleDatas(this.transferData.InspectItemGroupCode); this.changeTransferRuleEditStatus(true); } changeTransferRuleEditStatus(status: boolean) { this.isEditTransferRule = !status; } //#endregion //#region ********** 附件相关 ********** // 附件预览 filePreview(data: RhBaseDto) { this.selectData = data; // this.isShowFilePreviewModal = true; this.getInspectionSpecificationStandardFileDatas(data); } openFilePreviewModal() { this.isShowFilePreviewModal = true; } closeFilePreviewModal() { this.isShowFilePreviewModal = false; } initFileQueryDto(): InspectionSpecificationStandardFileQueryDto { const dto = InspectionSpecificationStandardFileQueryDto.create(); return dto; } // 获取附件列表 getInspectionSpecificationStandardFileDatas(dto: RhBaseDto) { this.fileQueryDto.InspectSchemaCode = dto['InspectSchemaCode']; // this.queryDto = { ...this.queryDto }; this.operator.GetInspectionSpecificationStandardFileDatas(this.fileQueryDto).subscribe((result) => { if (result && result.Success) { this.fileDatas = result.Attach; this.openFilePreviewModal(); } else { this.fileDatas = []; MsgHelper.ShowWarningModal(`查询无附件:${result.Message}`); } }); } //#endregion // //#region ********** 数据导入 ********** //打开文件上传modal openImportModal() { this.isShowUploadDrawer = true; } closeImportModal() { this.isShowUploadDrawer = false; this.uploadFileList = []; } // getCheckedData(item: ModelDto){ // } beforeUpload = (file: NzUploadFile) => { if (this.uploadFileList.length >= 1) { MsgHelper.ShowWarningMessage('每次只能上传一个文件!'); return false; } return new Observable((observer: Observer) => { const reader = new FileReader(); reader.readAsDataURL(file as RhSafeAny); reader.onload = () => { const importQueryDto = DataImportInput.create(); importQueryDto.FileStreamString = reader.result as RhSafeAny; this.uploadDatas = importQueryDto; // 只有一个文件 this.uploadFileList = this.uploadFileList.concat(file); // this.uploadFileList = [file]; observer.next(false); observer.complete(); }; reader.onerror = (e) => { MsgHelper.ShowWarningModal(`读取文件失败!${e}`); observer.next(false); observer.complete(); }; }); }; handleImport() { this.uploading = true; this.uploadDatas.BusinessCode = 'IqcMaterialInspectSchemaImporter'; this.operator.DataImport(this.uploadDatas).subscribe( (result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage('文件导入成功!'); this.importDatas = result.Attach; this.dataHeadFields = result.DataHeadFields as RhSafeAny; this.tableWidth = this.dataHeadFields.length * 120 + 100 + 'px'; this.closeImportModal(); this.getDatas(); this.openImportTab(); } else { MsgHelper.ShowWarningModal(`文件导入失败!${result.Message}`); } this.uploading = false; }, () => (this.uploading = false) ); } // 文件导入tab openImportTab() { this.tabType = 'import'; this.isAddAfterDeleteAll = false; this.selectedIndex = 1; } closeImportTab() { this.tabType === null; this.selectedIndex = 0; this.currentInspectSchemaGroupDto = null; this.getDatas(); } // 保存数据 async storeImportedDatas() { if (this.importDatas.some((f) => !f.Success)) { MsgHelper.ShowWarningMessage('请修改错误或重新导入后保存!'); return; } let result: OpResult | null = null; if (this.isAddAfterDeleteAll) { this.importDatas.forEach((f) => (f.OpSign = OpMode.OpAddAfterDeleteAll)); } else { this.importDatas.forEach((f) => (f.OpSign = OpMode.OpAdd)); } try { result = await firstValueFrom(this.operator.StoreIqcMaterialInspectSchemaDatas(this.importDatas)); } catch (error) { MsgHelper.ShowErrorMessage(`保存错误!${error}`); } if (result) { if (result.Success) { MsgHelper.ShowSuccessMessage('保存成功!'); this.importDatas = []; this.closeImportTab(); } else { MsgHelper.ShowWarningMessage(`保存失败!${result.Message}`); } } } // 清空数据 clearImportedPlanDatas() { MsgHelper.ShowConfirmModal('是否继续', '是否清空所有导入的模板数据?', () => { this.importDatas = []; MsgHelper.ShowSuccessMessage('数据清空成功!'); }); } changeIsAddAfterDeleteAll(value: boolean) { if (value) { this.modal.confirm({ nzTitle: '警告!', nzContent: '若勾选此项,将会进行不可逆的删除,是否确认?', nzOnCancel: () => { this.isAddAfterDeleteAll = false; }, nzOkType: 'primary', nzOkDanger: true, nzIconType: 'warning' }); } } removeImportTempData(index: number) { MsgHelper.ShowConfirmModal('是否继续', '是否移除选中的模板数据?', () => { this.importDatas.splice(index, 1); this.importDatas = [...this.importDatas]; }); } getDataType(data: string) { if (data) { const tmp = data.toString().trim().toLowerCase(); const dateReg = new RegExp(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?/, 'i'); if (['true', 'false'].includes(tmp)) { return 'boolean'; } else if (dateReg.test(data)) { return 'date'; } } return 'string'; } //#endregion // //#region ********** 附件相关 ********** openUploadModal(data: RhBaseDto) { this.selectFileData = data; this.isShowUploadModal = true; } closeUploadModal() { this.isShowUploadModal = false; } closePreviewModal() { this.isShowPreviewModal = false; } openPreviewModal(data: RhBaseDto) { this.selectFileData = data; this.isShowPreviewModal = true; } //#endregion *******附件相关结束******** openInspectDetail(data: IqcMaterialInspectSchemaDto) { this.beforeInspectSchemaCode = data.InspectSchemaCode as string; this.operator.GetIqcMaterialInspectSchemaFullData(data).subscribe((result) => { if (result.Success) { this.inspectDetail = result.Attach; this.tabType = 'inspectDetail'; this.selectedIndex = 1; this.inspectSchemaEntryInterface = this.initInspectSchemaEntryInterface(); this.inspectSchemaEntryDto = this.initInspectSchemaEntryDto(); this.inspectSchemaEntryQueryDto = this.initInpsectSchemaEntryQueryDto(); this.bindMaterialQueryDto = IqcMaterialInspectSchemaQueryDto.create(); this.bindMaterialQueryDto.InspectSchemaCode = this.inspectDetail?.InspectSchemaCode; this.bindMaterialInterfaceInfo = this.sharedSer.getIQCBindMaterialDatasInterfaceInfo(); } else { MsgHelper.ShowWarningMessage(`获取检验方案明细失败!${result.Message}`); } }); } onSelectItemGroupDataChange(data: IqcInspectSchemaGroupDto) { this.currentInspectSchemaGroupDto = data; if (!this.currentInspectSchemaGroupDto) { return; } this.inspectSchemaEntryQueryDto['InspectSchemaCode'] = this.inspectDetail.IsPrivateSchema ? '$' + data.InspectSchemaCode : '$' + this.beforeInspectSchemaCode; this.inspectSchemaEntryQueryDto['InspectItemGroupCode'] = data.InspectItemGroupCode; this.inspectSchemaEntryQueryDto = { ...this.inspectSchemaEntryQueryDto }; } closeAddModal() { this.isShowAddModal = false; this.inspectSchemaEntryDto = this.initInspectSchemaEntryDto(); this.getEntryDatas(); } private initInspectSchemaEntryDto() { const temp = IqcInspectSchemaEntryDto.create(); temp.InspectSchemaCode = this.inspectDetail?.InspectSchemaCode; temp.OpSign = OpMode.OpAdd; return temp; } private getEntryDatas() { if (this.entryTableComp) { this.entryTableComp.getDatasDebounceFn(); } } onStoreInspectSchemaEntryData(result: OpResult) { if (result?.Success) { MsgHelper.ShowSuccessMessage(`${this.inspectSchemaEntryDto?.OpSign === OpMode.OpAdd ? '新增' : '编辑'}数据成功!`); this.getEntryDatas(); } else { MsgHelper.ShowWarningModal(`${this.inspectSchemaEntryDto?.OpSign === OpMode.OpAdd ? '新增' : '编辑'}数据失败!${result.Message}`); } if (this.inspectSchemaEntryDto?.OpSign === OpMode.OpEdit) { this.closeAddModal(); } } changeInspectMode(mode: string, form: UntypedFormGroup) { if (mode === 'Quantitative') { form.get('UpperTolerance')?.setValidators(Validators.required); form.get('LowerTolerance')?.setValidators(Validators.required); } else { form.get('UpperTolerance')?.clearValidators(); form.get('UpperTolerance')?.patchValue(null); form.get('LowerTolerance')?.clearValidators(); form.get('LowerTolerance')?.patchValue(null); } } private initInspectSchemaEntryInterface() { const dto = RhDynamicInterfaceDto.create(); dto.interfaceType = 'post'; dto.port = 52882; dto.controllerName = 'IqcMaterialInspectApi'; dto.interfaceName = 'GetIqcInspectSchemaEntryDatas'; return dto; } private initInpsectSchemaEntryQueryDto(): RhBaseQueryDto { const queryDto = ObjectHelper.createRhBaseQueryDto(); queryDto['op']; return queryDto; } openAddModal(data?: IqcInspectSchemaEntryDto) { if (data) { data.OpSign = OpMode.OpEdit; this.inspectSchemaEntryDto = data; } else { this.inspectSchemaEntryDto = this.initInspectSchemaEntryDto(); } this.isShowAddModal = true; } confirmSelect() { const dto = QCInspectSchemaEntryDto.create(); dto.InspectItemDtos = this.selectedData; dto.InspectSchemaCode = this.inspectDetail.InspectSchemaCode; dto.InspectCategory = this.selectedData[0].InspectLink; this.operator.StoreIqcInspectSchemaEntryDatas(dto).subscribe((result) => { if (result.Success) { MsgHelper.ShowSuccessMessage('新建检验项目成功!'); this.isShowAddModal = false; this.getEntryDatas(); } else { MsgHelper.ShowErrorMessage(`新建失败!${result.Message}`); } }); } onSelectedDatasChange(datas: RhSelectableDto[]) { this.selectedData = datas; } deleteEntryDatas(datas: IqcInspectSchemaEntryDto[], buttonInfo: RhTableButtonInfoDto) { buttonInfo.loading = true; this.operator.RemoveIqcInspectSchemaEntryDatas(datas).subscribe( (result) => { if (result?.Success) { MsgHelper.ShowSuccessMessage('检验项目数据删除成功!'); this.getEntryDatas(); } else { MsgHelper.ShowWarningModal(`检验项目数据删除失败!${result.Message}`); } buttonInfo.loading = false; }, () => (buttonInfo.loading = false) ); } enableEntryDatas(datas: IqcInspectSchemaEntryDto[], buttonInfo: RhTableButtonInfoDto) { buttonInfo.loading = true; this.operator.EnableIqcInspectSchemaEntryDatas(datas).subscribe( (result) => { if (result?.Success) { MsgHelper.ShowSuccessMessage('检验项目数据启用成功!'); this.getEntryDatas(); } else { MsgHelper.ShowWarningModal(`检验项目数据启用失败!${result.Message}`); } buttonInfo.loading = false; }, () => (buttonInfo.loading = false) ); } disableEntryDatas(datas: IqcInspectSchemaEntryDto[], buttonInfo: RhTableButtonInfoDto) { buttonInfo.loading = true; this.operator.CancelEnableIqcInspectSchemaEntryDatas(datas).subscribe( (result) => { if (result?.Success) { MsgHelper.ShowSuccessMessage('检验项目数据禁用成功!'); this.getEntryDatas(); } else { MsgHelper.ShowWarningModal(`检验项目数据禁用失败!${result.Message}`); } buttonInfo.loading = false; }, () => (buttonInfo.loading = false) ); } startEdit() { this.operator.StoreIqcMaterialInspectSchemaFullData(this.inspectDetail).subscribe((result) => { if (result?.Success) { this.inspectDetail.IsPrivateSchema = true; MsgHelper.ShowSuccessMessage('保存成功!'); } else { MsgHelper.ShowWarningModal(`${result.Message}`); } }); } getCurrentInspectSchemaEntryDatas(data: DataResultT) { this.currentInspectSchemaEntryDatas = data.Attach; } }