import { Injectable } from '@angular/core'; import { LabelRuleDto, OpResult, LabelRuleQueryDto, DataResultT, RhSelectItem, LabelTemplateFileDto, LabelPrintNotifyMessage, LabelTemplateFileCopyDto, PrintModeType, StorageLocationConfigQueryDto, StorageLocationConfigDto, LabelPrintInputBase, MaterialDocQueryDto, MaterialDocDto, MaterialInventoryQueryDto, MaterialInventoryDto, GroupingPrintDetailItem, ContainerPrintDetailItem, StorageLocationPrintDetailItem, StorageLocationPrintCreatedData, JustInTimeStockPrintDetailItem, JustInTimeStockPrintCreatedData, MaterialPrintDetailItem, MaterialPrintCreatedData, ProductMaterialPrintDetailItem, ProductMaterialPrintCreatedData, PurchaseMaterialPrintDetailItem, PurchaseMaterialPrintCreatedData, ContainerPrintCreatedData, GroupingPrintCreatedData, ProductMaterialInLabelDataCreateInput, ProductMaterialInLabelOutput, ProductMaterialOutLabelDataCreateInput, ProductMaterialOutLabelOutput, LabelPrintOption, InPlanOrderMasterQueryDto, InPlanOrderDto, InWarehousePlanOutDto, InPlanOrderDetailQueryDto, InPlanOrderDetailDto, JSDQkeyComponentPrintInputDto, JSDQkeyComponentPrintOutputDto, RhSelectableDto, RhBaseDto, RhInterfaceLocationDto, RhSafeAny } from 'rh-base/model'; import { Observable, of } from 'rxjs'; import { RhApiUrlsService, MsgHelper, FileHelper, RhAppConfigService, RhStorageService } from 'rh-base/core'; import { RhPortType, RhPortLocalFieldType } from 'rh-base/model'; import { ProductSnCreateRuleCopyDto, LabelTemplateDesignRuleCopyDto, ProductSnCreateDto, LabelRuleInput, LabelRuleOutput, LabelTemplateDesignRuleQueryDto, LabelTemplateDesignRuleDto, LabelRuleProductRelationsQueryDto, LabelRuleProductRelationsDto, InWarehouseLabelCreateDto, ParaSettingsQueryDto, ParaSettingsDto, SnLibraryInWarehouseDto, RebuildInWarehouseLabelDto, SnLibraryMaterialInventoryDto, ProductSnLibraryDto, ContainerInfoDto, LabelPrintDataLibraryDto, LabelPrintOutput, LabelRePrintInput, LabelListPrintInput } from './label-model'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { NzModalService, NzModalState } from 'ng-zorro-antd/modal'; // declare const ulModalService: NzModalService; @Injectable() export class RhLabelService { constructor( private apiUrls: RhApiUrlsService, private http: HttpClient, private appconfigSer: RhAppConfigService, private storage: RhStorageService, private modalSer: NzModalService ) {} tolabelDesign(dto: LabelTemplateDesignRuleDto, msg?: string) { MsgHelper.ShowGlobalLoadingMessage(`${msg || '正在调用打印机,请稍候...'}`); this.PrintToolsTemplateDesign(dto).subscribe((result) => { if (result.Success) { this.getPrintLabelClientUrlNew(result.Attach); } else { MsgHelper.ShowErrorModal(`打开打印插件失败:${result.Message}`); } }); } //#region api区域 /** * 下载打印插件 */ DownLoadLabelPrintTools() { const url = this.apiUrls.GetApiOperateUrl(RhPortType.rhwms, 'LabelConfigApi', 'DownLoadLabelPrintTools', RhPortLocalFieldType.rhwms); // FileHelper.downloadFileViaGet(url, '打印插件.exe'); return url; } /** * 下载打印插件 */ DownLoadPrintToolsNew() { // return this.apiUrls.GetRdp('PrintToolApi','DownLoadPrintTools'); const url = this.apiUrls.GetApiOperateUrl(RhPortType.rdp, 'PrintToolApi', 'DownLoadPrintTools', RhPortLocalFieldType.rhwms); // FileHelper.downloadFileViaGet(url, '打印插件.exe'); return url; } /** * 下载驱动程序 */ DownLoadNetFramework() { // return this.apiUrls.GetRhWms(RHWMSApiControllerNames.LabelConfigApi, 'DownLoadNetFramework'); const url = this.apiUrls.GetApiOperateUrl(RhPortType.rhwms, 'LabelConfigApi', 'DownLoadNetFramework', RhPortLocalFieldType.rhwms); FileHelper.downloadFileViaGet(url, '驱动程序.exe'); } /** * 下载打印驱动 */ DownLoadNetFrameworkNew() { // return this.apiUrls.GetRdp('PrintToolApi','DownLoadNetFramework'); const url = this.apiUrls.GetApiOperateUrl(RhPortType.rdp, 'PrintToolApi', 'DownLoadNetFramework', RhPortLocalFieldType.rhwms); return url; } /** * 获取标签规则业务类型 */ GetLabelRuleBusinessTypes(): Observable> { return this.apiUrls.GetRhWms('LabelConfigApi', 'GetLabelRuleBusinessTypes'); } /** * 获取标签规则数据 */ GetLabelRuleDatas(queryDto: LabelRuleQueryDto): Observable> { return this.apiUrls.PostRhWms('LabelConfigApi', 'GetLabelRuleDatas', queryDto); } /** * 获取标签规则 */ GetLabelRuleDatasNew(queryDto: LabelRuleQueryDto): Observable> { return this.apiUrls.PostMdp('LabelRuleApi', 'GetLabelRuleDatas', { isEnable: true, ...queryDto }); } /** * 获取客户端打印软件地址 * @param userIp 用户Ip * @param openMode 打开方式(1为不打开打印确认框) */ getPrintLabelClientUrl(userIp: string, openMode: PrintModeType): string { return `YgLabelPrint://${userIp}-${openMode}`; } /** 使用连接字符串唤醒打印插件 */ getPrintLabelClientUrlNew(url: string) { location.href = url; } /** * 根据标签规则ID获取对应的模板信息 */ GetLabelTemplateFiles(labelRuleId: string): Observable> { return this.apiUrls.GetRhWms('LabelConfigApi', 'GetLabelTemplateFiles', { params: { labelRuleId } }); } /** * 获取标签模板设计规则数据 */ GetLabelTemplateDesignRuleDatas(ruleId: string): Observable> { const queryDto = LabelTemplateDesignRuleQueryDto.create(); queryDto.RuleId = ruleId ? `$${ruleId}` : null; queryDto.Mode = 8; return this.apiUrls.PostMdp('LabelTemplateDesignRuleApi', 'GetLabelTemplateDesignRuleDatas', queryDto); } /** * 移除标签规则数据 */ RemoveLabelRuleData(dto: LabelRuleDto[]): Observable { return this.apiUrls.PostRhWms('LabelConfigApi', 'RemoveLabelRule', dto); } /** * 删除标签模板文件 */ RemoveLabelTemplateFile(dto: LabelTemplateFileDto): Observable { return this.apiUrls.PostRhWms('LabelConfigApi', 'RemoveLabelTemplateFile', dto); } /** * 移除标签模板设计规则 */ RemoveLabelTemplateDesignRuleDatas(LabelTemplateDesignRuleDto: LabelTemplateDesignRuleDto[]): Observable { return this.apiUrls.PostMdp('LabelTemplateDesignRuleApi', 'RemoveLabelTemplateDesignRuleDatas', LabelTemplateDesignRuleDto); } /** * 存储标签规则数据 */ StoreLabelRuleData(dto: LabelRuleDto): Observable { return this.apiUrls.PostRhWms('LabelConfigApi', 'StoreLabelRuleData', dto); } /** * 保存标签模板设计规则 */ StoreLabelTemplateDesignRuleData(dto: LabelTemplateDesignRuleDto): Observable { return this.apiUrls.PostMdp('LabelTemplateDesignRuleApi', 'StoreLabelTemplateDesignRuleData', dto); } /** * 存储标签模板信息,并返回标签打印通知消息 */ StoreLabelTemplateSpecify(dto: LabelTemplateFileDto): Observable> { return this.apiUrls.PostRhWms('LabelConfigApi', 'StoreLabelTemplateSpecify', dto); } /** * 存储拷贝的标签模板信息,并返回标签打印通知消息 */ StoreCopyLabelTemplateSpecify(dto: LabelTemplateFileCopyDto): Observable> { return this.apiUrls.PostRhWms('LabelConfigApi', 'StoreCopyLabelTemplateSpecify', dto); } //#endregion api区域结束 //#region 标签打印管理区域 /** * 获取库位标签数据 */ GetStorageLocationsDatas(queryDto: StorageLocationConfigQueryDto): Observable> { return this.apiUrls.PostRhWms('LabelPrintApi', 'GetStorageLocationsDatas', queryDto); } /** * 获取物料标签数据 */ GetMaterialDatas(queryDto: MaterialDocQueryDto): Observable> { return this.apiUrls.PostRhWms('LabelPrintApi', 'GetMaterialDatas', queryDto); } /** * 获取即时物料库存信息 */ GetJustInTimeStockDatas(queryDto: MaterialInventoryQueryDto): Observable> { return this.apiUrls.PostRhWms('LabelPrintApi', 'GetJustInTimeStockDatas', queryDto); } /** * 载入托标签 */ GetGroupingLabelItems(): Observable> { return this.apiUrls.GetRhWms('LabelPrintApi', 'GetGroupingLabelItems'); } /** * 载入容器标签 */ GetContainerLabelItems(): Observable> { return this.apiUrls.GetRhWms('LabelPrintApi', 'GetContainerLabelItems'); } /** * 创建库位标签打印数据 */ CreateStorageLocationLabelPrintDatas( item: StorageLocationPrintDetailItem ): Observable> | null { if (!this.validatePrintQty(item)) { return null; } return this.apiUrls.PostRhWms('LabelPrintApi', 'CreateStorageLocationLabelPrintDatas', item); } /** * 创建即时物料库存标签打印数据 */ CreateJustInTimeStockLabelPrintDatas(item: JustInTimeStockPrintDetailItem): Observable> { return this.apiUrls.PostRhWms('LabelPrintApi', 'CreateJustInTimeStockLabelPrintDatas', item); } /** * 创建物料标签打印数据 */ CreateMaterialLabelPrintDatas(item: MaterialPrintDetailItem): Observable> | null { if (!this.validatePrintQty(item)) { return null; } return this.apiUrls.PostRhWms('LabelPrintApi', 'CreateMaterialLabelPrintDatas', item); } /** * 创建生产物料标签打印数据 */ CreateProductMaterialLabelPrintDatas( item: ProductMaterialPrintDetailItem ): Observable> | null { if (!this.validatePrintQty(item)) { return null; } return this.apiUrls.PostRhWms('LabelPrintApi', 'CreateProductMaterialLabelPrintDatas', item); } /** * 创建采购物料标签打印数据 */ CreatePurchaseMaterialLabelPrintDatas( item: PurchaseMaterialPrintDetailItem ): Observable> | null { if (!this.validatePrintQty(item)) { return null; } return this.apiUrls.PostRhWms('LabelPrintApi', 'CreatePurchaseMaterialLabelPrintDatas', item); } /** * 创建容器标签打印数据 */ CreateContainerLabelPrintDatas(item: ContainerPrintDetailItem): Observable> { return this.apiUrls.PostRhWms('LabelPrintApi', 'CreateContainerLabelPrintDatas', item); } /** * 创建组托标签打印数据 */ CreateGroupingLabelPrintDatas(item: GroupingPrintDetailItem): Observable> { return this.apiUrls.PostRhWms('LabelPrintApi', 'CreateGroupingLabelPrintDatas', item); } /** * 创建成品入库标签打印数据LabelType=ProductMaterialInLabel */ CreateProductMaterialInLabelPrintDatas( input: ProductMaterialInLabelDataCreateInput ): Observable> { return this.apiUrls.PostRhWms('LabelPrintApi', 'CreateProductMaterialInLabelPrintDatas', input); } /** * 创建成品出库标签打印数据LabelType=ProductMaterialOutLabel */ CreateProductMaterialOutLabelPrintDatas( input: ProductMaterialOutLabelDataCreateInput ): Observable> { return this.apiUrls.PostRhWms('LabelPrintApi', 'CreateProductMaterialOutLabelPrintDatas', input); } /** * 准备打印标签数据,并返回标签打印通知消息 */ PreparePrintLabelDatas(option: LabelPrintOption): Observable> { return this.apiUrls.PostRhWms('LabelPrintApi', 'PreparePrintLabelDatas', option); } // /** // * 获取不同业务类型的入库计划数据 // */ // GetPerBusinessInWarehousePlans(queryDto: InPlanOrderMasterQueryDto): Observable> { // return this.apiUrls.PostRhWms(RHWMSApiControllerNames.InWarehousePlanApi, 'GetPerBusinessInWarehousePlans', queryDto); // } /** * 获取入库计划数据 */ GetPrintInWarehousePlans(queryDto: InPlanOrderMasterQueryDto): Observable> { return this.apiUrls.PostRhWms('InWarehousePlanApi', 'GetPrintInWarehousePlans', queryDto); } /** * 获取不同业务类型的可打印的入库计划数据 */ GetPerBusinessPrintInWarehousePlans(queryDto: InPlanOrderMasterQueryDto): Observable> { return this.apiUrls.PostRhWms('InWarehousePlanApi', 'GetPerBusinessPrintInWarehousePlans', queryDto); } /** * 创建标签打印预览PDF文件 */ CreateLabelPrintViewPdfFile(): string { const interfaceDto: RhInterfaceLocationDto = { interfaceType: 'post', port: 20085, controllerName: 'LabelPrintApi', interfaceName: 'CreateLabelPrintViewPdfFile' }; return this.apiUrls.getUrl(interfaceDto); //return this.apiUrls.GetRhWmsApiOperateUrl('LabelPrintApi', 'CreateLabelPrintViewPdfFile'); } /** * 获取入库计划明细数据 */ GetInPlanOrderDetailDatas(queryDto: InPlanOrderDetailQueryDto): Observable> { return this.apiUrls.PostRhWms('InWarehousePlanApi', 'GetInPlanOrderDetailDatas', queryDto); } //#endregion 标签打印管理区域结束 //#region common methods区域 private validatePrintQty(input: LabelPrintInputBase): boolean { if (!input.PackageQty || !input.PrintQty || !input.PrintSheets) { MsgHelper.ShowErrorModal('打印数量、包装数量或打印张数不能为0'); return false; } return true; } caculatePrintQty(item: LabelPrintInputBase, fieldName: string) { item.PackageQty = item.PackageQty || 0; item.PrintSheets = item.PrintSheets || 0; if (fieldName !== 'PrintSheets') { if (fieldName === 'PackageQty' && item.PrintSheets) { item.PrintQty = item.PackageQty * item.PrintSheets; } else if (item.PackageQty && item.PrintQty) { item.PrintSheets = Math.ceil(item.PrintQty / item.PackageQty); } // if (!item.PackageQty || !item.PrintQty) { // item.PrintSheets = 0; // } else { // item.PrintSheets = Math.ceil(item.PrintQty / item.PackageQty); // } } else { if (!item.PackageQty) { return; } item.PrintQty = item.PackageQty * item.PrintSheets; } } navigateToLabelDesignPrintUrl(labelType: string, businessType: string, systemSource: 'WMS' | 'MES') { // if (!labelType) { // return MsgHelper.ShowWarningModal('找不到对应的标签类型!'); // } let serverIp = this.appconfigSer.appConfig.ServerIp; let serverPort = 6021; const url = `http://${serverIp}:${serverPort}/label-manage/label-display?LabelType=${labelType}&BusinessType=${businessType}&SystemSource=${systemSource}`; const targetWin = window.open(url); // 跨域发送用户信息 const userSession = this.storage.getUserSession(); if (userSession) { userSession.Menus = []; (userSession as RhSafeAny)['type'] = 'userSession'; } // 停止发送 const handler = (e: RhSafeAny) => { // console.log(e) if (e.data === 'loaded') { targetWin?.postMessage(userSession, '*'); // window.removeEventListener('message', handler, false); } }; window.addEventListener('message', handler, { once: true }); } //#endregion common methods区域结束 //#region 新标签打印 /** * 获取关键件的打印数据 */ GetKeyComponentPrintDatas(dto: JSDQkeyComponentPrintInputDto): Observable> { return this.apiUrls.PostRhMes('JSDQQualityManagementApi', 'GetKeyComponentPrintDatas', dto); } /** * 模板打印 */ // eslint-disable-next-line @typescript-eslint/ban-types TemplatePrint(dynamicObj: Object): Observable> { return this.apiUrls.PostRhMes('PrintApi', 'TemplatePrint', dynamicObj); } //#endregion 新标签打印 //#region 新版api区域 /** * 保存标签规则 */ StoreLabelRuleDataNew(input: LabelRuleInput): Observable { return this.apiUrls.PostMdp('LabelRuleApi', 'StoreLabelRuleData', input); } /** * 产品条码配置数据复制 */ ProductSnCreateRuleCopy(dto: ProductSnCreateRuleCopyDto): Observable { return this.apiUrls.PostMdp('LabelSnWebApi', 'ProductSnCreateRuleCopy', dto); } /** * 获取当前服务器打印机 */ GetLocalPrinters(): Observable> { return this.apiUrls.GetRdp('CommonWebApi', 'GetLocalPrinters'); } /** * 标签模板设计规则复制 */ LabelTemplateDesignRuleCopy(input: LabelTemplateDesignRuleCopyDto): Observable { return this.apiUrls.PostMdp('LabelTemplateDesignRuleApi', 'LabelTemplateDesignRuleCopy', input); } /** * 产品标签创建 */ ProductLabelCreate(input: ProductSnCreateDto): Observable> { return this.apiUrls.PostEmp('SnLibraryApi', 'ProductLabelCreate', input); } /** * 入库条码创建 */ InWarehouseLabelCreate(input: InWarehouseLabelCreateDto): Observable> { return this.apiUrls.PostRhpWms('SnLibraryApi', 'InWarehouseLabelCreate', input); } /** * 获取产品标签默认数据库连接信息配置 */ GetProductLabelConnectionConfig(): Observable> { return this.apiUrls.GetMdp('ConfigurationWebApi', 'GetProductLabelConnectionConfig'); } /** * 获取参数值(数据库连接信息配置) */ GetParaSettingsDatas(queryDto: ParaSettingsQueryDto): Observable> { return this.apiUrls.PostRdp('ConfigurationWebApi', 'GetParaSettingsDatas', queryDto); } /** * 打印插件模板设计 */ PrintToolsTemplateDesign(dto: LabelTemplateDesignRuleDto): Observable> { return this.apiUrls.PostMdp('LabelTemplateDesignRuleApi', 'PrintToolsTemplateDesign', dto); } /** * 获取保存标签规则产品关联数据 */ GetLabelRuleProductRelationsDatas(queryDto: LabelRuleProductRelationsQueryDto): Observable> { return this.apiUrls.PostMdp('LabelRuleProductRelationsApi', 'GetLabelRuleProductRelationsDatas', queryDto); } /** * 保存标签规则产品关联数据 */ StoreLabelRuleProductRelationsDatas(LabelRuleProductRelationsDto: LabelRuleProductRelationsDto[]): Observable { return this.apiUrls.PostMdp('LabelRuleProductRelationsApi', 'StoreLabelRuleProductRelationsDatas', LabelRuleProductRelationsDto); } /** * 移除标签规则产品关联数据 */ RemoveLabelRuleProductRelationsDatas(LabelRuleProductRelationsDto: LabelRuleProductRelationsDto[]): Observable { return this.apiUrls.PostMdp('LabelRuleProductRelationsApi', 'RemoveLabelRuleProductRelationsDatas', LabelRuleProductRelationsDto); } /** * 补打采购物料条码 */ // RebuildPurchaseMaterialLabel(input: RebuildPurchaseMaterialLabelDto): Observable> { // return this.apiUrls.PostRhpWms('SnLibraryApi', 'RebuildPurchaseMaterialLabel', input); // } /** * 弃用采购物料标签 */ // AbortedPurchaseMaterialLabelDatas(PurchaseMaterialSnLibraryDto: PurchaseMaterialSnLibraryDto[]): Observable { // return this.apiUrls.PostRhpWms('SnLibraryApi', 'AbortedPurchaseMaterialLabelDatas', PurchaseMaterialSnLibraryDto); // } /** * 作废标签打印数据 */ AbortedLabelPrintDatas(dtos: LabelPrintDataLibraryDto[]): Observable { return this.apiUrls.PostRhpWms('LabelPrintApi', 'AbortedLabelPrintDatas', dtos); } /** * 标签打印 */ // LabelPrint(input: LabelPrintInput): Observable> { // return this.apiUrls.PostRhpWms('LabelPrintApi', 'LabelPrint', input); // } /** * 标签批量打印 */ LabelListPrint(input: LabelListPrintInput): Observable> { return this.apiUrls.PostRhpWms('LabelPrintApi', 'LabelListPrint', input); } /** * 标签补打 */ LabelRePrint(input: LabelRePrintInput): Observable> { return this.apiUrls.PostRhpWms('LabelPrintApi', 'LabelRePrint', input); } /** * 弃用入库条码 */ AbortedInWarehouseLabelDatas(SnLibraryInWarehouseDto: SnLibraryInWarehouseDto[]): Observable { return this.apiUrls.PostRhpWms('SnLibraryApi', 'AbortedInWarehouseLabelDatas', SnLibraryInWarehouseDto); } /** * 补打入库条码 */ RebuildInWarehouseLabel(dto: RebuildInWarehouseLabelDto): Observable> { return this.apiUrls.PostRhpWms('SnLibraryApi', 'RebuildInWarehouseLabel', dto); } /** * 弃用物料库存条码 */ AbortedSnLibraryMaterialInventoryDatas_Wms(SnLibraryMaterialInventoryDto: SnLibraryMaterialInventoryDto[]): Observable { return this.apiUrls.PostRhpWms('SnLibraryApi', 'AbortedSnLibraryMaterialInventoryDatas', SnLibraryMaterialInventoryDto); } /** * 弃用产品条码 */ AbortedSnLibraryMaterialInventoryDatas_Emp(ProductSnLibraryDto: ProductSnLibraryDto[]): Observable { return this.apiUrls.PostEmp('SnLibraryApi', 'AbortedSnLibraryMaterialInventoryDatas', ProductSnLibraryDto); } /** * 获取标签规则选择项目 */ GetLabelRuleSelectItems(queryDto: LabelRuleQueryDto): Observable> { return this.apiUrls.PostMdp('LabelRuleApi', 'GetLabelRuleSelectItems', queryDto); } /** * 弃用容器标签 */ AbortedSnLibraryContainerInfoDatas(ContainerInfoDto: ContainerInfoDto[]): Observable { return this.apiUrls.PostMdp('WarehouseWebApi', 'AbortedSnLibraryContainerInfoDatas', ContainerInfoDto); } //#endregion 新版api区域结束 /** * 获取标签业务状态初始码 */ GetLabelBusinessInitStatus(): Observable> { return this.apiUrls.GetRhpWms('ConfigurationWebApi', 'GetLabelBusinessInitStatus'); } /** 新版打印接口调用成功后同步数据 */ // TransferTempLabelDataToOfficialData(PrintSign: string): Observable { // return this.apiUrls.GetRhpWms('LabelPrintApi', `TransferTempLabelDataToOfficialData?sign=${PrintSign}`); // } /** * 标签打印日志记录 */ LabelPrintLogRecord(dto: RhBaseDto): Observable { return this.apiUrls.PostRhpWms('LabelPrintApi', 'LabelPrintLogRecord', dto); } //#region 标签设计平台区域开始 // 下载地址 appConfig = this.appconfigSer.appConfig; downloadUrl = `http://${this.appConfig['NodeDownloadIp']}:${this.appConfig['NodeDownloadApiPort']}/configuration/RhLabelPrintHelper.exe`; downloadName = 'RhLabelPrintHelper.exe'; globalWarningModal: NzModalState | null = null; localServerWarning() { if (this.globalWarningModal === NzModalState.OPEN) return; this.globalWarningModal = this.modalSer.warning({ nzTitle: '警示:', nzContent: `请先安装打印助手,打开并刷新页面!`, nzOkText: '确定', nzOnCancel: () => (this.globalWarningModal = NzModalState.CLOSED), nzOnOk: () => (this.globalWarningModal = NzModalState.CLOSED) }).state; // MsgHelper.ShowWarningModal(`请先安装打印助手,打开并刷新页面!`); } // 根据控制器名称和路由名称获取标签打印Api操作接口Url地址 public GetLabelPrintApiOperateUrl(ctrlName: string, actionName: string, isLocal: boolean): string { let url: string; if (isLocal) { url = `http://127.0.0.1:${this.appConfig['NodeLocalPrintApiPort']}/${ctrlName}/${actionName}`; } else { url = `http://${this.appConfig.NodeServerIp}:${this.appConfig['NodePrintApiPort']}/${ctrlName}/${actionName}`; } return url; } /// 标签打印 Get方法 public GetLabelPrint( ctrlName: string, actionName: string, isLocal = false, options?: { headers?: | HttpHeaders | { [header: string]: string | string[]; }; observe?: 'body'; params?: | HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; } ): Observable { const url = this.GetLabelPrintApiOperateUrl(ctrlName, actionName, isLocal); return this.http.get(url, options); } /// 标签打印 Post方法 public PostLabelPrint( ctrlName: string, actionName: string, dto: InputT, isLocal = false, options?: { headers?: | HttpHeaders | { [header: string]: string | string[]; }; observe?: 'body'; params?: | HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; } ): Observable { const url = this.GetLabelPrintApiOperateUrl(ctrlName, actionName, isLocal); return this.http.post(url, dto, options); } /** 获取打印机(本地) */ GetPrintersByLocal(): Observable> { return new Observable((observer) => { this.GetLabelPrint('LocalServer', 'getLocalPrinters', true, { headers: { ignoreBubble: '1' } }).subscribe( (result) => { observer.next(result as DataResultT); observer.complete(); }, (error) => { if (error?.status === 0) { this.localServerWarning(); observer.error(`打印助手未启动!`); } else { observer.error(error); } } ); }); } /** 标签打印(本地) */ LabelPrintByLocal(dto: RhBaseDto): Observable { return new Observable((observer) => { this.PostLabelPrint('LocalServer', 'localPrint', dto, true, { headers: { ignoreBubble: '1' } }).subscribe( (result) => { observer.next(result as OpResult); observer.complete(); }, (error) => { if (error?.status === 0) { this.localServerWarning(); observer.error(`打印助手未启动!`); } else { observer.error(error); } } ); }); } /** 标签预览(本地) */ LabelPreviewByLocal(dto: RhBaseDto): Observable> { return new Observable((observer) => { this.PostLabelPrint('LocalServer', 'localPreview', dto, true, { headers: { ignoreBubble: '1' } }).subscribe( (result) => { observer.next(result as DataResultT); observer.complete(); }, (error) => { if (error?.status === 0) { this.localServerWarning(); observer.error(`打印助手未启动!`); } else { observer.error(error); } } ); }); } /** 获取默认打印机(本地) */ GetDefaultPrinterByLocal(): Observable> { return new Observable((observer) => { this.GetLabelPrint('LocalServer', 'getDefaultPrinter', true, { headers: { ignoreBubble: '1' } }).subscribe( (result) => { observer.next(result as DataResultT); observer.complete(); }, (error) => { if (error?.status === 0) { this.localServerWarning(); observer.error(`打印助手未启动!`); } else { observer.error(error); } } ); }); } /** 获取标签模板 */ GetLabelTemplateDatas(dto: RhBaseDto): Observable> { return this.PostLabelPrint('LabelTemplateFile', 'getData', dto); } //#endregion 标签设计平台区域结束 }