From 7ba2bcb0f1ca3945fee95684bbda3ba240038e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=9E=E5=9D=A4=20=E6=9E=97?= <506583276@qq.com> Date: Tue, 4 Apr 2023 19:49:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=93=E5=8D=B0=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BBWY.Client/APIServices/PackTaskService.cs | 6 +- BBWY.Client/Helpers/MyPrintHelper.cs | 214 ++++++++++++++++-- BBWY.Client/Models/Enums.cs | 24 +- BBWY.Client/Models/PackTask/BarCodeModel.cs | 2 +- BBWY.Client/Models/PackTask/PackTaskModel.cs | 12 +- .../PackTask/CreatePackTaskViewModel.cs | 56 ++--- .../PackTask/WareHouseListViewModel.cs | 62 ++--- .../Views/PackTask/BarcodeControl.xaml | 93 ++++++++ .../Views/PackTask/BarcodeControl.xaml.cs | 53 +++++ BBWY.Client/Views/PackTask/CerControl.xaml | 113 +++++++++ BBWY.Client/Views/PackTask/CerControl.xaml.cs | 56 +++++ .../Views/PackTask/LookBarCodeWindow.xaml | 37 ++- .../Views/PackTask/LookBarCodeWindow.xaml.cs | 18 +- BBWY.Client/Views/PackTask/LookCerWindow.xaml | 36 ++- .../Views/PackTask/LookCerWindow.xaml.cs | 13 -- BBWY.Client/Views/PackTask/PrintWindow.xaml | 132 ++++++++++- .../Views/PackTask/PrintWindow.xaml.cs | 209 ++++++++--------- BBWY.Client/Views/PackTask/SetBarCode.xaml | 62 +++-- BBWY.Client/Views/PackTask/SetCerWindow.xaml | 38 +++- .../Views/PackTask/TaskListControl.xaml | 4 +- .../Views/PackTask/WareHouseListControl.xaml | 4 +- 21 files changed, 954 insertions(+), 290 deletions(-) create mode 100644 BBWY.Client/Views/PackTask/BarcodeControl.xaml create mode 100644 BBWY.Client/Views/PackTask/BarcodeControl.xaml.cs create mode 100644 BBWY.Client/Views/PackTask/CerControl.xaml create mode 100644 BBWY.Client/Views/PackTask/CerControl.xaml.cs diff --git a/BBWY.Client/APIServices/PackTaskService.cs b/BBWY.Client/APIServices/PackTaskService.cs index 79c2c913..982151d2 100644 --- a/BBWY.Client/APIServices/PackTaskService.cs +++ b/BBWY.Client/APIServices/PackTaskService.cs @@ -109,10 +109,12 @@ namespace BBWY.Client.APIServices } - public ApiResponse DeletedTask(CreateTaskRequest createTaskRequest) + public ApiResponse DeletedTask(long taskId) { return SendRequest(globalContext.QKApiHost, "api/PackTask/DeletedPackTask", - createTaskRequest + new { + TaskId = taskId + } , null, HttpMethod.Post); } diff --git a/BBWY.Client/Helpers/MyPrintHelper.cs b/BBWY.Client/Helpers/MyPrintHelper.cs index c78b1129..4de83b45 100644 --- a/BBWY.Client/Helpers/MyPrintHelper.cs +++ b/BBWY.Client/Helpers/MyPrintHelper.cs @@ -21,18 +21,85 @@ namespace BBWY.Client.Helpers //args.Graphics.DrawRectangle(new System.Drawing.Pen(System.Drawing.Brushes.Black), 0, 0, sige.Width, sige.Height);//画出条码编辑区域 args.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; args.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; - if (barCode.LabelModel == BarcodeLabelModel.barsimplify) + + switch (barCode.LabelModel) { - font = new Font("宋体", 10, System.Drawing.FontStyle.Regular); - SetBarSimplify(barCode, ref args, font); + case BarcodeLabelModel.标准模板: + font = new Font("宋体", 8, System.Drawing.FontStyle.Regular); + SetBar(barCode, ref args, font, 5); + //SetBarStander(barCode, ref args, font); + break; + case BarcodeLabelModel.精简模板: + font = new Font("宋体", 10, System.Drawing.FontStyle.Regular); + //SetBar(barCode, ref args, font, 15); + + SetBarSimplify(barCode, ref args, font); + break; + case BarcodeLabelModel.无型号模板: + font = new Font("宋体", 10, System.Drawing.FontStyle.Regular); + SetBar(barCode, ref args, font,7); + break; + default: + break; } - else + + } + + + private static void SetBar(BarCodeModel barCode, ref PrintPageEventArgs args, Font font, int heightSpace) + { + + + float topHeigth = 0;//与顶部的距离 + string barcodeSku = $"POP{barCode.SkuId}"; + Barcode barcode = new Barcode(); + System.Drawing.Image img = barcode.Encode(TYPE.CODE128, barcodeSku, 500, 40); + SizeF size = args.Graphics.MeasureString(barCode.BrandName, font); + var sizeHeight = size.Height;//字体高度 + topHeigth += 10; + + switch (barCode.LabelModel) { - font = new Font("宋体", 8, System.Drawing.FontStyle.Regular); - SetBarStander(barCode, ref args, font); + case BarcodeLabelModel.无型号模板: + case BarcodeLabelModel.标准模板: + args.Graphics.DrawString($"品牌: {barCode.Brand}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); + topHeigth += (heightSpace + sizeHeight); + break; + case BarcodeLabelModel.精简模板: + break; } + + + + + args.Graphics.DrawString($"品名: {barCode.BrandName}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); + topHeigth += (heightSpace + sizeHeight); + + + switch (barCode.LabelModel) + { + case BarcodeLabelModel.标准模板: + args.Graphics.DrawString($"型号: {barCode.ProductNo}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); + topHeigth += (heightSpace + sizeHeight); + break; + case BarcodeLabelModel.无型号模板: + case BarcodeLabelModel.精简模板: + break; + default: + break; + } + args.Graphics.DrawString($"规格: {barCode.SkuName}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); + // g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; + size = args.Graphics.MeasureString(barcodeSku, font); + topHeigth += (heightSpace + sizeHeight); + args.Graphics.DrawImage(img, 1, topHeigth, 234, 50); + topHeigth += (50 + 5); + args.Graphics.DrawString(barcodeSku, font, System.Drawing.Brushes.Black, new PointF((236 - size.Width) / 2, topHeigth)); } + + + /// /// 标准 /// @@ -41,23 +108,28 @@ namespace BBWY.Client.Helpers /// private static void SetBarStander(BarCodeModel barCode, ref PrintPageEventArgs args, Font font) { - - + float topHeigth = 0;//与顶部的距离 string barcodeSku = $"POP{barCode.SkuId}"; Barcode barcode = new Barcode(); System.Drawing.Image img = barcode.Encode(TYPE.CODE128, barcodeSku, 500, 40); SizeF size = args.Graphics.MeasureString(barCode.BrandName, font); var sizeHeight = size.Height;//字体高度 var heightSpace = 5;//间隔高度 - - args.Graphics.DrawString($"品牌: {barCode.Brand}", font, System.Drawing.Brushes.Black, new PointF(10, 10)); - args.Graphics.DrawString($"品名: {barCode.BrandName}", font, System.Drawing.Brushes.Black, new PointF(10, 10 + heightSpace + sizeHeight)); - args.Graphics.DrawString($"型号: {barCode.ProductNo}", font, System.Drawing.Brushes.Black, new PointF(10, 10 + 2 * (heightSpace + sizeHeight))); - args.Graphics.DrawString($"规格: {barCode.SkuName}", font, System.Drawing.Brushes.Black, new PointF(10, 10 + 3 * (heightSpace + sizeHeight))); + topHeigth += 10; + args.Graphics.DrawString($"品牌: {barCode.Brand}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); + topHeigth += (heightSpace + sizeHeight); + args.Graphics.DrawString($"品名: {barCode.BrandName}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); + topHeigth += (heightSpace + sizeHeight); + args.Graphics.DrawString($"型号: {barCode.ProductNo}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); + topHeigth += (heightSpace + sizeHeight); + args.Graphics.DrawString($"规格: {barCode.SkuName}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); // g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; size = args.Graphics.MeasureString(barcodeSku, font); - args.Graphics.DrawString(barcodeSku, font, System.Drawing.Brushes.Black, new PointF((236 - size.Width) / 2, 10 + 4 * (heightSpace + sizeHeight) + 50 + 5)); - args.Graphics.DrawImage(img, 1, 10 + 4 * (heightSpace + sizeHeight), 234, 50); + topHeigth += (heightSpace + sizeHeight); + args.Graphics.DrawImage(img, 1, topHeigth, 234, 50); + topHeigth += (50 + 5); + args.Graphics.DrawString(barcodeSku, font, System.Drawing.Brushes.Black, new PointF((236 - size.Width) / 2, topHeigth)); + } /// /// 精简 @@ -89,7 +161,20 @@ namespace BBWY.Client.Helpers args.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; font = new Font("宋体", 6, System.Drawing.FontStyle.Regular); - SetCerStander(ref args, certificate, font); + switch (certificate.LabelModel) + { + case CertificateLabelModel.标准无3c: + case CertificateLabelModel.标准有3c: + SetCerStander(ref args, certificate, font); + break; + case CertificateLabelModel.无型号: + SetCerNoXingHao(ref args, certificate, font); + break; + default: + break; + } + + } private static void SetCerStander(ref PrintPageEventArgs args, CertificateModel certificate, Font font) @@ -112,14 +197,14 @@ namespace BBWY.Client.Helpers var fontBig = new Font("宋体", 14, System.Drawing.FontStyle.Regular); string cerName = "合格证"; SizeF bigSize = args.Graphics.MeasureString(cerName, fontBig); - + float verHeight = bigJiange + bigSize.Height; args.Graphics.DrawString(cerName, fontBig, System.Drawing.Brushes.Black, new PointF((236 - bigSize.Width) / 2, 10)); args.Graphics.DrawString($"品牌: {certificate.Brand}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); args.Graphics.DrawString($"型号: {certificate.ProductNo}", font, System.Drawing.Brushes.Black, new PointF(122, verHeight)); var smallSize = args.Graphics.MeasureString(certificate.Brand, font);//小字体高度 - + verHeight += (smallSize.Height + heightSpace); args.Graphics.DrawString($"品名: {certificate.BrandName}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); @@ -157,8 +242,95 @@ namespace BBWY.Client.Helpers var productStr = $"生产商: {certificate.ProductShop}"; if (args.Graphics.MeasureString(productStr, font).Width <= 220) { - args.Graphics.DrawString(productStr, font, System.Drawing.Brushes.Black,10,verHeight); - verHeight += smallSize.Height + heightSpace; + args.Graphics.DrawString(productStr, font, System.Drawing.Brushes.Black, 10, verHeight); + verHeight += smallSize.Height + heightSpace; + } + else + { + args.Graphics.DrawString(productStr, font, System.Drawing.Brushes.Black, rect); + verHeight += 2 * smallSize.Height + heightSpace; + } + + //var format = new StringFormat + //{ + // LineAlignment = StringAlignment.Far, + // // Alignment = StringAlignment.Center + //}; + + var rect1 = new RectangleF(10, verHeight, 220, smallSize.Height * 3 + heightSpace); + args.Graphics.DrawString($"地址: {certificate.ProductAdress}", font, System.Drawing.Brushes.Black, rect1); + //certificate.ExcuteStander =; + + + //args.Graphics.DrawImage(img, 1, 68, 234, 60); + } + private static void SetCerNoXingHao(ref PrintPageEventArgs args, CertificateModel certificate, Font font) + { + + int bigJiange = 20;//合格证与品牌的高度差 + var heightSpace = 4;//所有行间隔高度 + int standerSpace = 1;//执行标准之间的 + //if (certificate.IsLogo == 1)//含图标 + //{ + // string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + + // string path = appPath + $"/Resources/Images/3c.png"; + // Image image = Image.FromFile(path); + // args.Graphics.DrawImage(image, 190, 7, 28, 21); + // args.Graphics.DrawString(certificate.FactoryNumber, font, System.Drawing.Brushes.Black, 188, 28); + + //} + + var fontBig = new Font("宋体", 14, System.Drawing.FontStyle.Regular); + string cerName = "合格证"; + SizeF bigSize = args.Graphics.MeasureString(cerName, fontBig); + + float verHeight = bigJiange + bigSize.Height; + args.Graphics.DrawString(cerName, fontBig, System.Drawing.Brushes.Black, new PointF((236 - bigSize.Width) / 2, 10)); + + args.Graphics.DrawString($"品牌: {certificate.Brand}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); + args.Graphics.DrawString($"品名: {certificate.BrandName}", font, System.Drawing.Brushes.Black, new PointF(122, verHeight)); + var smallSize = args.Graphics.MeasureString(certificate.BrandName, font);//小字体高度 + + verHeight += (smallSize.Height + heightSpace); + args.Graphics.DrawString($"材质: {certificate.Shader}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); + + //args.Graphics.DrawString($"材质: {certificate.Shader}", font, System.Drawing.Brushes.Black, new PointF(122, verHeight)); + + StringBuilder sb = new StringBuilder(); + var excutes = certificate.ExcuteStander.Split(',', StringSplitOptions.RemoveEmptyEntries); + + + int hangCount = excutes.Count() / 2 + excutes.Count() % 2;//获取行数 + + for (int i = 0; i < excutes.Count(); i++) + { + if (i % 2 == 0 && i > 0)//间隔两个换行 + { + sb.Append("\n"); + } + sb.Append(excutes[i]).Append(" "); + } + sb.Remove(sb.Length - 3, 3); + var rows = sb.ToString().Split('\n'); + string excuteStander = "执行标准: "; + smallSize = args.Graphics.MeasureString(excuteStander, font); + verHeight += (smallSize.Height + heightSpace); + args.Graphics.DrawString($"执行标准: {rows[0]}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); + + for (int i = 1; i < rows.Count(); i++) + { + verHeight += (smallSize.Height + standerSpace); + args.Graphics.DrawString($"{rows[i]}", font, System.Drawing.Brushes.Black, new PointF(10 + smallSize.Width, verHeight)); + } + verHeight += (smallSize.Height + heightSpace); + + RectangleF rect = new RectangleF(10, verHeight, 220, smallSize.Height * 2 + heightSpace); + var productStr = $"生产商: {certificate.ProductShop}"; + if (args.Graphics.MeasureString(productStr, font).Width <= 220) + { + args.Graphics.DrawString(productStr, font, System.Drawing.Brushes.Black, 10, verHeight); + verHeight += smallSize.Height + heightSpace; } else { @@ -173,7 +345,7 @@ namespace BBWY.Client.Helpers //}; var rect1 = new RectangleF(10, verHeight, 220, smallSize.Height * 3 + heightSpace); - args.Graphics.DrawString($"地址: {certificate.ProductAdress}", font, System.Drawing.Brushes.Black, rect1 ); + args.Graphics.DrawString($"地址: {certificate.ProductAdress}", font, System.Drawing.Brushes.Black, rect1); //certificate.ExcuteStander =; diff --git a/BBWY.Client/Models/Enums.cs b/BBWY.Client/Models/Enums.cs index 2114a6bc..50640ff2 100644 --- a/BBWY.Client/Models/Enums.cs +++ b/BBWY.Client/Models/Enums.cs @@ -274,11 +274,15 @@ /// /// 标准模板 /// - barstander = 0, + 标准模板= 0, /// /// 精简模板 /// - barsimplify = 1, + 精简模板 = 1, + /// + /// 无型号模板 + /// + 无型号模板 = 2 } @@ -288,17 +292,11 @@ /// public enum CertificateLabelModel { - No3C = 0, - Is3C = 1 - } - ///// - ///// 合格证是否3c - ///// - //public enum CerHave3C - //{ - // No3C = 0, - // Is3C = 1 - //} + 标准无3c = 0, + 标准有3c = 1, + 无型号=2 + } + /// /// 加急 /// diff --git a/BBWY.Client/Models/PackTask/BarCodeModel.cs b/BBWY.Client/Models/PackTask/BarCodeModel.cs index e3be4454..0c09a043 100644 --- a/BBWY.Client/Models/PackTask/BarCodeModel.cs +++ b/BBWY.Client/Models/PackTask/BarCodeModel.cs @@ -56,7 +56,7 @@ namespace BBWY.Client.Models - private BarcodeLabelModel labelModel= BarcodeLabelModel.barsimplify; + private BarcodeLabelModel labelModel= BarcodeLabelModel.精简模板; /// /// 模板标签 /// diff --git a/BBWY.Client/Models/PackTask/PackTaskModel.cs b/BBWY.Client/Models/PackTask/PackTaskModel.cs index 3d5188ab..06121e08 100644 --- a/BBWY.Client/Models/PackTask/PackTaskModel.cs +++ b/BBWY.Client/Models/PackTask/PackTaskModel.cs @@ -54,10 +54,7 @@ namespace BBWY.Client.Models private void DeletedTask() { - packTaskService.DeletedTask(new APIModel.Request.CreateTaskRequest - { - TaskId = TaskId - }); + packTaskService.DeletedTask(TaskId); if (ReflashTask != null) ReflashTask();//刷新界面 } @@ -142,7 +139,8 @@ namespace BBWY.Client.Models new TipsWindow("该任务无设置条形码信息,无法查看!").ShowDialog(); return; } - LookBarCodeWindow look = new LookBarCodeWindow(new BarCodeModel + LookBarCodeWindow look = new LookBarCodeWindow(); + look.SetData(new BarCodeModel { Brand = BarCodeModel.Brand, BrandName = BarCodeModel.BrandName, @@ -181,7 +179,7 @@ namespace BBWY.Client.Models } PrintWindow printWindow = new PrintWindow(); - printWindow.barCodeModel = new BarCodeModel + printWindow.BarCodeModel = new BarCodeModel { Brand = BarCodeModel.Brand, BrandName = BarCodeModel.BrandName, @@ -321,7 +319,7 @@ namespace BBWY.Client.Models private Worry isWorry; /// - /// 到货情况(待收货=0,部分收货=1,已到货=2) + /// 是否加急 /// public Worry IsWorry { get => isWorry; set { Set(ref isWorry, value); } } diff --git a/BBWY.Client/ViewModels/PackTask/CreatePackTaskViewModel.cs b/BBWY.Client/ViewModels/PackTask/CreatePackTaskViewModel.cs index 1e66c947..811001ac 100644 --- a/BBWY.Client/ViewModels/PackTask/CreatePackTaskViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/CreatePackTaskViewModel.cs @@ -494,7 +494,7 @@ namespace BBWY.Client.ViewModels.PackTask PrintNames = new List(); delayTrigger = new DelayTrigger(500); delayTrigger.OnExecute = OnSearchIncreateKeyWordChanged; - BarLabelCheck(BarcodeLabelModel.barsimplify);//默认精简模式 + BarLabelCheck(BarcodeLabelModel.精简模板);//默认精简模式 } @@ -546,9 +546,10 @@ namespace BBWY.Client.ViewModels.PackTask /// private void LookBar() { - LookBarCodeWindow look = new LookBarCodeWindow(new BarCodeModel + LookBarCodeWindow look = new LookBarCodeWindow(); + look.SetData(new BarCodeModel { - Brand = BarCodeModel. Brand, + Brand = BarCodeModel.Brand, BrandName = BarCodeModel.BrandName, LabelModel = BarCodeModel.LabelModel, ProductNo = BarCodeModel.ProductNo, @@ -560,7 +561,8 @@ namespace BBWY.Client.ViewModels.PackTask private void CerLabelCheck(CertificateLabelModel cer) { - CertificateModel.IsLogo = (int)cer; + CertificateModel.LabelModel = cer; + CertificateModel.IsLogo = cer== CertificateLabelModel.标准有3c?1:0; } /// /// @@ -571,7 +573,7 @@ namespace BBWY.Client.ViewModels.PackTask { LabelModel = barcodeLabelModel; - if (LabelModel == BarcodeLabelModel.barstander)//标准版 判断数据是否异常 + if (LabelModel == BarcodeLabelModel.标准模板)//标准版 判断数据是否异常 { if (string.IsNullOrEmpty(ProductNo) || ProductNo == "待填写") { @@ -588,11 +590,21 @@ namespace BBWY.Client.ViewModels.PackTask /// private void SetCertificate() { - if (CertificateModel == null) + if (string.IsNullOrEmpty(SearchSkuId)) { - new TipsWindow("请先查询Sku数据").ShowDialog(); + new TipsWindow("请先查询skuId").Show(); return; } + + + if (CertificateModel == null) + { + CertificateModel = new CertificateModel(); + CertificateModel.ProductNo = ProductNo; + CertificateModel.Brand = Brand; + CertificateModel.SkuId = SkuId; + + } CertificateModel.BrandName = BrandName; setCerWindow = new SetCerWindow(); setCerWindow.ShowDialog(); @@ -603,7 +615,7 @@ namespace BBWY.Client.ViewModels.PackTask /// private void SaveCer() { - if (string.IsNullOrEmpty(CertificateModel.ExcuteStander) || string.IsNullOrEmpty(CertificateModel.ProductNo) + if (string.IsNullOrEmpty(CertificateModel.ExcuteStander) || string.IsNullOrEmpty(CertificateModel.Shader) || string.IsNullOrEmpty(CertificateModel.BrandName) || string.IsNullOrEmpty(CertificateModel.Brand) || string.IsNullOrEmpty(CertificateModel.ProductShop) || string.IsNullOrEmpty(CertificateModel.ProductAdress)) @@ -612,24 +624,7 @@ namespace BBWY.Client.ViewModels.PackTask return; } var standers = CertificateModel.ExcuteStander.Split(',', StringSplitOptions.RemoveEmptyEntries); - CertificateLabelModel labelModel = CertificateLabelModel.No3C; - - - switch (CertificateModel.IsLogo) - { - case 0://没图 - labelModel = CertificateLabelModel.No3C; break; - - - case 1://含3c图 - - labelModel = CertificateLabelModel.Is3C; - break; - default: - break; - } - CertificateModel.LabelModel = labelModel; var resData = packTaskService.SaveCer(new CerRequest { Brand = CertificateModel.Brand, @@ -680,12 +675,12 @@ namespace BBWY.Client.ViewModels.PackTask setBarCodeWindow.ShowDialog(); } - public BarcodeLabelModel LabelModel = BarcodeLabelModel.barsimplify; + public BarcodeLabelModel LabelModel = BarcodeLabelModel.精简模板; private void SaveBarCode() { - if (LabelModel == BarcodeLabelModel.barstander)//标准版 判断数据是否异常 + if (LabelModel == BarcodeLabelModel.标准模板)//标准版 判断数据是否异常 { if (string.IsNullOrEmpty(ProductNo) || ProductNo == "待填写") { @@ -807,8 +802,13 @@ namespace BBWY.Client.ViewModels.PackTask /// public void SearchSku() { + if (string.IsNullOrEmpty(SearchSkuId)) + { + return; + } + SearchSkuId = SearchSkuId.Trim();//去掉空格 避免数据异常 IsLoading = true; - SkuId = searchSkuId; + SkuId = SearchSkuId; ApiResponse productApiResponse = null; var skuResponse = productService.GetProductSkuList(string.Empty, SkuId); if (skuResponse.Success) diff --git a/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs b/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs index 252d9e16..412ca75a 100644 --- a/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs @@ -112,9 +112,7 @@ namespace BBWY.Client.ViewModels.PackTask private bool isLoading; public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } } - WorkProcessService workProcessService; - private readonly PackTaskService packTaskService; - + private int? IsWorry { get; set; } public int? taskStatus { get; set; } private ObservableCollection packTaskList; @@ -140,11 +138,13 @@ namespace BBWY.Client.ViewModels.PackTask } } - ConsumableService consumableService; - #endregion - + #endregion + private readonly ConsumableService consumableService; + private readonly WorkProcessService workProcessService; + private readonly PackTaskService packTaskService; + private readonly IncreateServiceService increateServiceService; public WareHouseListViewModel(PackTaskService packTaskService, ConsumableService consumableService, WorkProcessService workProcessService, IncreateServiceService increateServiceService) { this.packTaskService = packTaskService; @@ -192,25 +192,7 @@ namespace BBWY.Client.ViewModels.PackTask - private void IsLoadCount() - { - var packTaskResult = packTaskService.GetWareAllCount(); - if (packTaskResult != null && packTaskResult.Success) - { - App.Current.Dispatcher.Invoke(() => - { - ArrivedCount = packTaskResult.Data.ArrivedCount; - NoArrivedCount = packTaskResult.Data.NoArrivedCount; - SomeArrivedCount = packTaskResult.Data.SomeArrivedCount; - WorryCount = packTaskResult.Data.WorryCount; - }); - } - } - private void LoadIndex(int pageIndex) - { - PageIndex = pageIndex;// - SearchTaskList(); - } + #region 事件绑定 @@ -278,7 +260,7 @@ namespace BBWY.Client.ViewModels.PackTask } - private IncreateServiceService increateServiceService; + /// /// 搜索任务列表 /// @@ -366,17 +348,35 @@ namespace BBWY.Client.ViewModels.PackTask } else { - App.Current.Dispatcher.BeginInvoke(new Action(() => - { - new TipsWindow("查不到数据").Show(); - })); + //App.Current.Dispatcher.BeginInvoke(new Action(() => + //{ + // new TipsWindow("查不到数据").Show(); + //})); } IsLoadCount(); IsLoading = false; }); } - + private void IsLoadCount() + { + var packTaskResult = packTaskService.GetWareAllCount(); + if (packTaskResult != null && packTaskResult.Success) + { + App.Current.Dispatcher.Invoke(() => + { + ArrivedCount = packTaskResult.Data.ArrivedCount; + NoArrivedCount = packTaskResult.Data.NoArrivedCount; + SomeArrivedCount = packTaskResult.Data.SomeArrivedCount; + WorryCount = packTaskResult.Data.WorryCount; + }); + } + } + private void LoadIndex(int pageIndex) + { + PageIndex = pageIndex;// + SearchTaskList(); + } private void OpenSkuDetail(object param) { diff --git a/BBWY.Client/Views/PackTask/BarcodeControl.xaml b/BBWY.Client/Views/PackTask/BarcodeControl.xaml new file mode 100644 index 00000000..a67d1a34 --- /dev/null +++ b/BBWY.Client/Views/PackTask/BarcodeControl.xaml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/PackTask/BarcodeControl.xaml.cs b/BBWY.Client/Views/PackTask/BarcodeControl.xaml.cs new file mode 100644 index 00000000..e497a77d --- /dev/null +++ b/BBWY.Client/Views/PackTask/BarcodeControl.xaml.cs @@ -0,0 +1,53 @@ +using BBWY.Client.Models; +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BBWY.Client.Views.PackTask +{ + /// + /// BarcodeControl.xaml 的交互逻辑 + /// + public partial class BarcodeControl : UserControl + { + public BarcodeControl() + { + InitializeComponent(); + this.DataContext = this.BarCodeData; + } + + + + /// + /// + /// + public BarCodeModel BarCodeData + { + get { return (BarCodeModel)GetValue(BarCodeDataProperty); } + set + { + SetValue(BarCodeDataProperty, value); + } + } + + + public static readonly DependencyProperty BarCodeDataProperty = + DependencyProperty.Register("BarCodeData", typeof(BarCodeModel), typeof(BarcodeControl), new PropertyMetadata(ChangedProperty)); + + private static void ChangedProperty(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var control = d as BarcodeControl; + var data = e.NewValue as BarCodeModel; + + } + } +} diff --git a/BBWY.Client/Views/PackTask/CerControl.xaml b/BBWY.Client/Views/PackTask/CerControl.xaml new file mode 100644 index 00000000..9523b5b0 --- /dev/null +++ b/BBWY.Client/Views/PackTask/CerControl.xaml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/PackTask/CerControl.xaml.cs b/BBWY.Client/Views/PackTask/CerControl.xaml.cs new file mode 100644 index 00000000..94a1f23a --- /dev/null +++ b/BBWY.Client/Views/PackTask/CerControl.xaml.cs @@ -0,0 +1,56 @@ +using BBWY.Client.Models; +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BBWY.Client.Views.PackTask +{ + /// + /// CerControl.xaml 的交互逻辑 + /// + public partial class CerControl : UserControl + { + public CerControl() + { + InitializeComponent(); + this.DataContext = CerData; + } + + + + /// + /// + /// + public CertificateModel CerData + { + get { return (CertificateModel)GetValue(CerDataProperty); } + set + { + SetValue(CerDataProperty, value); + } + } + + + public static readonly DependencyProperty CerDataProperty = + DependencyProperty.Register("CerData", typeof(CertificateModel), typeof(CerControl), new PropertyMetadata(ChangedProperty)); + + private static void ChangedProperty(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + //var control = d as CerControl; + //var data = e.NewValue as CertificateModel; + //if (data != null) + //{ + // control.SetData(data); + //} + } + } +} diff --git a/BBWY.Client/Views/PackTask/LookBarCodeWindow.xaml b/BBWY.Client/Views/PackTask/LookBarCodeWindow.xaml index 5d7497f5..489db23f 100644 --- a/BBWY.Client/Views/PackTask/LookBarCodeWindow.xaml +++ b/BBWY.Client/Views/PackTask/LookBarCodeWindow.xaml @@ -16,13 +16,12 @@ CloseButtonColor="{StaticResource WindowButtonColor}" MinButtonVisibility="Collapsed" MaxButtonVisibility="Collapsed" - RightButtonGroupMargin="0,5,5,0" - ResizeMode="NoResize" + RightButtonGroupMargin="0,5,5,0" + Title="LookBarCodeWindow" > - @@ -30,8 +29,8 @@ Background="{StaticResource Border.Background}"> - - + + @@ -47,8 +46,7 @@ - - + @@ -77,9 +75,32 @@ + + + + + + + + + + + + + + + + + + - + + + + + + diff --git a/BBWY.Client/Views/PackTask/LookBarCodeWindow.xaml.cs b/BBWY.Client/Views/PackTask/LookBarCodeWindow.xaml.cs index 3b482270..f8a08d1a 100644 --- a/BBWY.Client/Views/PackTask/LookBarCodeWindow.xaml.cs +++ b/BBWY.Client/Views/PackTask/LookBarCodeWindow.xaml.cs @@ -19,22 +19,14 @@ namespace BBWY.Client.Views.PackTask /// public partial class LookBarCodeWindow : BWindow { - public LookBarCodeWindow(BarCodeModel BarCodeModel) + public LookBarCodeWindow() { InitializeComponent(); + + } + public void SetData(BarCodeModel BarCodeModel) + { this.DataContext = BarCodeModel; - if (BarCodeModel.LabelModel==BarcodeLabelModel.barsimplify) - {//精简版 - jingjian.Visibility = Visibility.Visible; - biaozhun.Visibility = Visibility.Collapsed; - } - else - { - jingjian.Visibility = Visibility.Collapsed; - biaozhun.Visibility = Visibility.Visible; - } } - - } } diff --git a/BBWY.Client/Views/PackTask/LookCerWindow.xaml b/BBWY.Client/Views/PackTask/LookCerWindow.xaml index dc4a2bd8..7e92d212 100644 --- a/BBWY.Client/Views/PackTask/LookCerWindow.xaml +++ b/BBWY.Client/Views/PackTask/LookCerWindow.xaml @@ -30,9 +30,8 @@ - - - + + @@ -62,7 +61,7 @@ - + @@ -94,7 +93,34 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs b/BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs index c463c326..9a7dcd2a 100644 --- a/BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs +++ b/BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs @@ -58,20 +58,7 @@ namespace BBWY.Client.Views.PackTask sb.Remove(sb.Length - 3, 3); data.ExcuteStander = sb.ToString(); } - - - this.DataContext = data; - if (data.IsLogo == 0) - { - is3c.Visibility = Visibility.Collapsed; - no3c.Visibility = Visibility.Visible; - } - else - { - is3c.Visibility = Visibility.Visible; - no3c.Visibility = Visibility.Collapsed; - } } } } diff --git a/BBWY.Client/Views/PackTask/PrintWindow.xaml b/BBWY.Client/Views/PackTask/PrintWindow.xaml index 0d1d86a3..b34a2802 100644 --- a/BBWY.Client/Views/PackTask/PrintWindow.xaml +++ b/BBWY.Client/Views/PackTask/PrintWindow.xaml @@ -36,9 +36,14 @@ - + + + - + @@ -54,7 +59,7 @@ - + @@ -78,10 +83,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -143,6 +236,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/PackTask/PrintWindow.xaml.cs b/BBWY.Client/Views/PackTask/PrintWindow.xaml.cs index 48b2aa51..54766eae 100644 --- a/BBWY.Client/Views/PackTask/PrintWindow.xaml.cs +++ b/BBWY.Client/Views/PackTask/PrintWindow.xaml.cs @@ -1,12 +1,15 @@ using BBWY.Client.Helpers; using BBWY.Client.Models; using BBWY.Controls; +using NPOI.SS.UserModel; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Printing; using System.IO; using System.Linq; +using System.Printing; +using System.Runtime.ConstrainedExecution; using System.Text; using System.Threading.Tasks; using System.Windows; @@ -17,7 +20,9 @@ using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Windows.Media.Media3D; using System.Windows.Shapes; +using System.Drawing.Printing; namespace BBWY.Client.Views.PackTask { @@ -29,13 +34,20 @@ namespace BBWY.Client.Views.PackTask public PrintWindow() { InitializeComponent(); + LoadPrints(); + } + /// + /// 获取打印机名称 + /// + private void LoadPrints() + { var printingNames = PrinterSettings.InstalledPrinters;//获取本机的打印机数据 int index = -1; int selectIndex = 0; foreach (string name in printingNames) { - if (name== "Microsoft XPS Document Writer"||name== "Microsoft Print to PDF"||name== "Fax") + if (name == "Microsoft XPS Document Writer" || name == "Microsoft Print to PDF" || name == "Fax") { continue; } @@ -46,125 +58,77 @@ namespace BBWY.Client.Views.PackTask } cbPrints.Items.Add(name); } - if (cbPrints.Items.Count>selectIndex) + if (cbPrints.Items.Count > selectIndex) { cbPrints.SelectedIndex = selectIndex; } - } + + + /// /// 加载预览打印数据 /// public void LoadData() { - if (CertificateModel==null) - { - cer.Visibility = Visibility.Collapsed; - } - else - { - cer.Visibility = Visibility.Visible; - bar.Visibility = Visibility.Collapsed; - - CertificateModel data = new CertificateModel - { - Brand = CertificateModel.Brand, - BrandName = CertificateModel.BrandName, - ExcuteStander = CertificateModel.ExcuteStander, - FactoryNumber = CertificateModel.FactoryNumber, - IsLogo =CertificateModel.IsLogo, - LabelModel = CertificateModel.LabelModel, - ProductAdress = CertificateModel.ProductAdress, - Id = CertificateModel.Id, - ProductDate = CertificateModel.ProductDate, - ProductNo = CertificateModel.ProductNo, - ProductShop = CertificateModel.ProductShop, - Shader = CertificateModel.Shader, - SkuId = CertificateModel.SkuId, - Reseller = CertificateModel.Reseller - - }; - StringBuilder sb = new StringBuilder(); - if (data.ExcuteStander.Contains(","))//有逗号就拆分 - { - var excutes = data.ExcuteStander.Split(',', StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < excutes.Count(); i++) - { - if (i % 2 == 0 && i > 0)//间隔两个换行 - { - sb.Append("\r\n"); - } - sb.Append(excutes[i]).Append(" "); - } - sb.Remove(sb.Length - 3, 3); - data.ExcuteStander = sb.ToString(); - } - - - - this.DataContext = data; - if (data.IsLogo == 0) - { - is3c.Visibility = Visibility.Collapsed; - no3c.Visibility = Visibility.Visible; - } - else - { - is3c.Visibility = Visibility.Visible; - no3c.Visibility = Visibility.Collapsed; - } - - } - if (BarCodeModel == null) + // PrintData data = new PrintData(); + if (CertificateModel != null) { + this.DataContext = CertificateModel; bar.Visibility = Visibility.Collapsed; + cer.Visibility = Visibility.Visible; } - else + + if (BarCodeModel != null) { - bar.Visibility = Visibility.Visible; - cer.Visibility = Visibility.Collapsed; this.DataContext = BarCodeModel; - if (BarCodeModel.LabelModel == BarcodeLabelModel.barsimplify) - {//精简版 - jingjian.Visibility = Visibility.Visible; - biaozhun.Visibility = Visibility.Collapsed; - } - else - { - jingjian.Visibility = Visibility.Collapsed; - biaozhun.Visibility = Visibility.Visible; - } + cer.Visibility = Visibility.Collapsed; + bar.Visibility = Visibility.Visible; } } - + public CertificateModel CertificateModel { get; set; } - public BarCodeModel BarCodeModel { get; set; } + public BarCodeModel BarCodeModel { get; set; } private void BButton_Click(object sender, RoutedEventArgs e) { - - int printCount = Convert.ToInt32(tbCount.Text); - string printName = cbPrints.Text;//选择的要打印的打印机名称 - Task.Factory.StartNew(() => { + int printCount = 0; try - { - PrintDocument pd = new PrintDocument(); - PrintDocument document = new PrintDocument(); - document.PrinterSettings.PrinterName = printName; - document.PrintPage += Document_PrintPage; - document.PrinterSettings.Copies = (short)printCount;//打印份数 - document.Print(); - + { + printCount = Convert.ToInt32(tbCount.Text); } - catch (Exception ex) + catch + { + new TipsWindow("请输入打印份数", 1).ShowDialog(); + return; + } + + string printName = cbPrints.Text;//选择的要打印的打印机名称 + + Task.Factory.StartNew(() => { - App.Current.Dispatcher.Invoke(() => { + try + { + + PrintDocument document = new PrintDocument(); + document.PrinterSettings.PrinterName = printName;//使用打印机名称,指定特定的打印机进行打印。 + //设置打印页面 + //document.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 236, 157); + document.PrintPage += Document_PrintPage; + document.PrinterSettings.Copies = (short)printCount;//打印份数 + document.Print(); + + } + catch (Exception ex) + { + App.Current.Dispatcher.Invoke(() => + { new TipsWindow("打印失败").ShowDialog(); }); - - } + + } }); } @@ -175,41 +139,52 @@ namespace BBWY.Client.Views.PackTask //RectangleF bounds = new RectangleF(0, 0, 236, 157); //args.Graphics.SetClip(bounds);//设置打印区域 + + + + //设置 打印纸张类型 + //var paperSizes = args.PageSettings.PrinterSettings.PaperSizes; + + + //foreach (System.Drawing.Printing.PaperSize item in paperSizes) + //{ + // if (item.Height==157) + // { + // args.PageSettings.PaperSize=item; + // break; + // } + //} + //var sss = args.PageSettings.PaperSize; + //默认设置 打印类型 + + + + #if DEBUG + //打印 纵向打印 会模糊 + args.PageSettings.PrinterSettings.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 236, 157); + args.PageSettings.PrinterSettings.DefaultPageSettings.Landscape = true; + #endif + Font font = new Font("宋体", 6, System.Drawing.FontStyle.Regular); if (BarCodeModel != null) { MyPrintHelper.PrintBarcode(ref args, BarCodeModel, font); } - if (CertificateModel !=null) + if (CertificateModel != null) { MyPrintHelper.PrintCertificate(ref args, CertificateModel, font); } - } + } + } + public class PrintData + { + public CertificateModel CertificateModel { get; set; } + public BarCodeModel BarCodeModel { get; set; } - /// - /// 打印条形码 - /// - //private void PrintBarCode(string labelPath,int printNums,string PrintName) - //{ - // BartenderHelper helper = new BartenderHelper(); - // string msg = ""; - // // File.AppendAllText("c:/1.txt", $"{PrintName}开始打印{printNums}份,{labelPath}"); - // helper.BTPrint(labelPath, Datas, out msg, printNums, PrintName); - // // File.AppendAllText("c:/1.txt", "结束打印"); - // //File.AppendAllText("c:/1.txt", msg); - // if (msg == "OK") - // { - - // return; - // } - // App.Current.Dispatcher.Invoke(new Action(() => { - // new TipsWindow(msg).ShowDialog();//打印失败提示 - // })); - - - //} } + + } diff --git a/BBWY.Client/Views/PackTask/SetBarCode.xaml b/BBWY.Client/Views/PackTask/SetBarCode.xaml index 0ea7376a..df2dc52f 100644 --- a/BBWY.Client/Views/PackTask/SetBarCode.xaml +++ b/BBWY.Client/Views/PackTask/SetBarCode.xaml @@ -7,7 +7,7 @@ xmlns:local="clr-namespace:BBWY.Client.Views.PackTask" mc:Ignorable="d" Style="{StaticResource bwstyle}" - Height="400" Width="600" + Height="651" Width="577" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" xmlns:ctr="clr-namespace:BBWY.Client.Converters" xmlns:cmodel="clr-namespace:BBWY.Client.Models" @@ -19,7 +19,7 @@ MaxButtonVisibility="Collapsed" RightButtonGroupMargin="0,5,5,0"> - + @@ -31,22 +31,24 @@ + + + + - - + + - - - + @@ -58,14 +60,13 @@ - + - - + @@ -93,17 +94,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + diff --git a/BBWY.Client/Views/PackTask/SetCerWindow.xaml b/BBWY.Client/Views/PackTask/SetCerWindow.xaml index 529aecc7..aacaa047 100644 --- a/BBWY.Client/Views/PackTask/SetCerWindow.xaml +++ b/BBWY.Client/Views/PackTask/SetCerWindow.xaml @@ -7,7 +7,7 @@ xmlns:local="clr-namespace:BBWY.Client.Views.PackTask" mc:Ignorable="d" Style="{StaticResource bwstyle}" - Height="500" Width="960" + Height="799" Width="820" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" xmlns:ctr="clr-namespace:BBWY.Client.Converters" xmlns:cmodel="clr-namespace:BBWY.Client.Models" @@ -31,15 +31,18 @@ + + + + - - - + + @@ -60,12 +63,11 @@ - - - + + @@ -92,8 +94,30 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/PackTask/TaskListControl.xaml b/BBWY.Client/Views/PackTask/TaskListControl.xaml index da6f5447..cf9feecc 100644 --- a/BBWY.Client/Views/PackTask/TaskListControl.xaml +++ b/BBWY.Client/Views/PackTask/TaskListControl.xaml @@ -109,9 +109,9 @@ + Margin=" 5,0,7,0"/> -