diff --git a/BBWY.Client/APIServices/BatchPurchaseService.cs b/BBWY.Client/APIServices/BatchPurchaseService.cs index b51eadb0..237f9eb5 100644 --- a/BBWY.Client/APIServices/BatchPurchaseService.cs +++ b/BBWY.Client/APIServices/BatchPurchaseService.cs @@ -171,12 +171,12 @@ namespace BBWY.Client.APIServices /// /// /// - public ApiResponse UpdatePackMoney(string orderId, decimal PackMoney) + public ApiResponse UpdatePackState(string orderId, PackState packState) { - return SendRequest(globalContext.BBYWApiHost, "api/BatchPurchase/UpdatePackMoney", new + return SendRequest(globalContext.BBYWApiHost, "api/BatchPurchase/UpdatePackState", new { orderId, - PackMoney + packState }, null, HttpMethod.Post); } diff --git a/BBWY.Client/APIServices/PackTaskService.cs b/BBWY.Client/APIServices/PackTaskService.cs index 66c9b75c..3ce41e77 100644 --- a/BBWY.Client/APIServices/PackTaskService.cs +++ b/BBWY.Client/APIServices/PackTaskService.cs @@ -25,19 +25,19 @@ namespace BBWY.Client.APIServices - public ApiResponse GetOrderList( string skuId = null, string taskId = null, + public ApiResponse GetOrderList(string skuId = null, string taskId = null, DateTime? startTime = null, DateTime? endTime = null, TaskState? availability = null, int? taskStatus = null, int pageIndex = 1, int pageSize = 10 - + ) { - return SendRequest(globalContext.QKApiHost, "api/PackTask/SearchNewPackTaskList", new + return SendRequest(globalContext.QKApiHost, "api/PackTask/SearchNew2PackTaskList", new { - + SkuId = skuId, TaskId = taskId, StartTime = startTime, @@ -49,7 +49,7 @@ namespace BBWY.Client.APIServices ShopId = globalContext.User.Shop.ShopId.ToString() }, null, HttpMethod.Post); } - public ApiResponse GetWareHouseList(int? isWorry=null,string departmentName = null, string skuId = null, string taskId = null, + public ApiResponse GetWareHouseList(int? isWorry = null, string departmentName = null, string skuId = null, string taskId = null, DateTime? startTime = null, DateTime? endTime = null, TaskState? availability = null, @@ -59,9 +59,9 @@ namespace BBWY.Client.APIServices ) { - return SendRequest(globalContext.QKApiHost, "api/PackTask/SearchNewPackTaskList", new + return SendRequest(globalContext.QKApiHost, "api/PackTask/SearchNew2PackTaskList", new { - IsWorry=isWorry, + IsWorry = isWorry, DepartmentName = departmentName, SkuId = skuId, TaskId = taskId, @@ -95,7 +95,7 @@ namespace BBWY.Client.APIServices { HttpClientHelper helper = new HttpClientHelper(globalContext.QKApiHost); - string url = $"{globalContext.QKApiHost}/api/PackTask/SearchProduct?skuId={skuId}&ShopId={globalContext.User.Shop.ShopId}"; + string url = $"{globalContext.QKApiHost}/api/PackTask/SearchProductNew?skuId={skuId}&ShopId={globalContext.User.Shop.ShopId}"; var data = helper.Get(url); return JsonConvert.DeserializeObject>(data); @@ -112,7 +112,7 @@ namespace BBWY.Client.APIServices public ApiResponse UpdateTask(CreateTaskRequest createTaskRequest) { - return SendRequest(globalContext.QKApiHost, "api/PackTask/UpdatePackTask", + return SendRequest(globalContext.QKApiHost, "api/PackTask/UpdatePackTaskNew", createTaskRequest , null, HttpMethod.Post); } @@ -121,9 +121,10 @@ namespace BBWY.Client.APIServices public ApiResponse DeletedTask(long taskId) { return SendRequest(globalContext.QKApiHost, "api/PackTask/DeletedPackTask", - new { - TaskId = taskId, - UserId = globalContext.User.Id.ToString() + new + { + TaskId = taskId, + UserId = globalContext.User.Id.ToString() } , null, HttpMethod.Post); } @@ -131,12 +132,12 @@ namespace BBWY.Client.APIServices public ApiResponse CreateTask(CreateTaskRequest createTaskRequest) { - return SendRequest(globalContext.QKApiHost, "api/PackTask/CreatePackTask", + return SendRequest(globalContext.QKApiHost, "api/PackTask/CreatePackTaskNew", createTaskRequest , null, HttpMethod.Post); } - public ApiResponse UpdateTaskStatus(long id, int taskStatus,string orderId) + public ApiResponse UpdateTaskStatus(long id, int taskStatus, string orderId) { return SendRequest(globalContext.QKApiHost, "api/PackTask/UpdatePackTaskStatus", new { @@ -155,7 +156,7 @@ namespace BBWY.Client.APIServices public ApiResponse SaveCer(CerRequest cerRequest) { - return SendRequest(globalContext.QKApiHost, "api/PackTask/CommitCer", cerRequest + return SendRequest(globalContext.QKApiHost, "api/PackTask/CommitCerNew", cerRequest , null, HttpMethod.Post); } public ApiResponse SaveSpuCer(CerRequest cerRequest) @@ -212,23 +213,40 @@ namespace BBWY.Client.APIServices ShopName, PageIndex = pageIndex, PageSize = pageSize - + }, null, HttpMethod.Post); } - public ApiResponse BatchSettle(params long[] taskIds) + /// + /// 批量结算 + /// + /// + /// + public ApiResponse BatchSettle(params long[] taskIds) { - return SendRequest(globalContext.QKApiHost, "api/PackTask/BatchSettle", new + return SendRequest(globalContext.QKApiHost, "api/PackTask/BatchSettle", new { - taskIds= taskIds, - userId= globalContext.User.Id.ToString(), + taskIds = taskIds, + userId = globalContext.User.Id.ToString(), }, null, HttpMethod.Post); } + /// + /// 取消拳探任务 + /// + /// + /// + public ApiResponse CancelQTTask(string orderId) + { + return SendRequest(globalContext.QKApiHost, "api/PackTask/CancelQTTask", new + { + orderId, + userId = globalContext.User.Id.ToString(), + }, null, HttpMethod.Post); + } } - public class AddConsumableRequest { - public long TaskId { get; set; } + public long TaskId { get; set; } public long[] ConsumableIds { get; set; } } @@ -347,7 +365,7 @@ namespace BBWY.Client.APIServices ///// 工序数量 ///// //public string WorkProcessNos { get; set; } - + /// /// /// diff --git a/BBWY.Client/BBWYAppSettings.json b/BBWY.Client/BBWYAppSettings.json index 726de360..4c310dc2 100644 --- a/BBWY.Client/BBWYAppSettings.json +++ b/BBWY.Client/BBWYAppSettings.json @@ -1,9 +1,9 @@ { - // "BBWYApiHost": "http://localhost:5000", - "BBWYApiHost": "http://bbwytest.qiyue666.com", + "BBWYApiHost": "http://localhost:5000", + //"BBWYApiHost": "http://bbwytest.qiyue666.com", "MDSApiHost": "http://mdsapi.qiyue666.com", "JOSApiHost": "", "1688ApiHost": "", - //"QKApiHost": "http://localhost:8080" - "QKApiHost": "http://qiku.qiyue666.com" + "QKApiHost": "http://localhost:8080" + //"QKApiHost": "http://qiku.qiyue666.com" } \ No newline at end of file diff --git a/BBWY.Client/Helpers/MyPrintHelper.cs b/BBWY.Client/Helpers/MyPrintHelper.cs index 1fc86a16..45e6e6ff 100644 --- a/BBWY.Client/Helpers/MyPrintHelper.cs +++ b/BBWY.Client/Helpers/MyPrintHelper.cs @@ -8,7 +8,9 @@ using System.Drawing.Imaging; using System.Drawing.Printing; using System.IO; using System.Linq; +using System.Reflection; using System.Text; +using WebSocketSharp; namespace BBWY.Client.Helpers { @@ -156,6 +158,8 @@ namespace BBWY.Client.Helpers public static void PrintCertificate(ref PrintPageEventArgs args, CertificateModel certificate, Font font) { + + args.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; args.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; var sige = args.Graphics.VisibleClipBounds;// 宽:236 高:157 打印可视化区域 @@ -189,9 +193,111 @@ namespace BBWY.Client.Helpers private static void SetCerStander(ref PrintPageEventArgs args, CertificateModel certificate, Font font) { +//#if DEBUG +// Bitmap bitmap = new Bitmap(236, 157); +// // Bitmap bitmap = new Bitmap(500, 500); +// Graphics graphics = Graphics.FromImage(bitmap); + +// var sige = graphics.VisibleClipBounds;// 宽:236 高:157 打印可视化区域 +// graphics.TranslateTransform((sige.Width - 236) / 2, 0);//设置起始位置 +// graphics.DrawRectangle(new System.Drawing.Pen(System.Drawing.Brushes.Black), 5, 5, sige.Width - 10, sige.Height - 10);//画出条码编辑区域 +// int bigJiange = 20;//合格证与品牌的高度差 +// var heightSpace = 4;//所有行间隔高度 +// if (!string.IsNullOrEmpty(certificate.ProduceDate)) +// { +// bigJiange = 10; heightSpace = 3; +// } + +// 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); +// graphics.DrawImage(image, 190, 7, 28, 21); +// graphics.DrawString(certificate.FactoryNumber, font, System.Drawing.Brushes.Black, 188, 28); +// } + +// var fontBig = new Font("宋体", 14, System.Drawing.FontStyle.Regular); +// string cerName = "合格证"; +// SizeF bigSize = graphics.MeasureString(cerName, fontBig); + +// float verHeight = bigJiange + bigSize.Height; +// graphics.DrawString(cerName, fontBig, System.Drawing.Brushes.Black, new PointF((236 - bigSize.Width) / 2, 10)); + +// graphics.DrawString($"品牌: {certificate.Brand}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); +// if (!string.IsNullOrEmpty(certificate.ProductNo)) +// graphics.DrawString($"型号: {certificate.ProductNo}", font, System.Drawing.Brushes.Black, new PointF(122, verHeight)); +// var smallSize = graphics.MeasureString(certificate.Brand, font);//小字体高度 + +// verHeight += (smallSize.Height + heightSpace); +// graphics.DrawString($"品名: {certificate.BrandName}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); + +// graphics.DrawString($"材质: {certificate.Shader}", font, System.Drawing.Brushes.Black, new PointF(122, verHeight)); + +// StringBuilder sb = new StringBuilder(); +// var excutes = certificate.ExcuteStander.Split(new string[] { ",", "," }, 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 = graphics.MeasureString(excuteStander, font); +// verHeight += (smallSize.Height + heightSpace); +// 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); +// graphics.DrawString($"{rows[i]}", font, System.Drawing.Brushes.Black, new PointF(12 + smallSize.Width, verHeight)); +// } + +// if (!string.IsNullOrEmpty(certificate.ProduceDate)) +// { +// verHeight += (smallSize.Height + heightSpace) - 3; +// graphics.DrawString($"生产日期: {certificate.ProduceDate}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); +// } + +// verHeight += (smallSize.Height + heightSpace); +// RectangleF rect = new RectangleF(10, verHeight, 220, smallSize.Height * 2 + heightSpace); +// var productStr = $"生产商: {certificate.ProductShop}"; +// if (graphics.MeasureString(productStr, font).Width <= 220) +// { +// graphics.DrawString(productStr, font, System.Drawing.Brushes.Black, 10, verHeight); +// verHeight += smallSize.Height + heightSpace; +// } +// else +// { +// graphics.DrawString(productStr, font, System.Drawing.Brushes.Black, rect); +// verHeight += 2 * smallSize.Height + heightSpace; +// } +// var productShop = graphics.MeasureString("生产商", font); +// var adress = graphics.MeasureString("地 址", font); + +// var rect1 = new RectangleF(10 + productShop.Width - adress.Width, verHeight - 2, 220, smallSize.Height * 3 + heightSpace); +// graphics.DrawString($"地 址: {certificate.ProductAdress}", font, System.Drawing.Brushes.Black, rect1); + +// var applicationPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); +// bitmap.Save($"{applicationPath}/{certificate.LabelModel}-{certificate.GoodsNumber}.jpg", ImageFormat.Png); + + int bigJiange = 20;//合格证与品牌的高度差 var heightSpace = 4;//所有行间隔高度 int standerSpace = 1;//执行标准之间的 + + if (!string.IsNullOrEmpty(certificate.ProduceDate)) + { + bigJiange = 10; heightSpace = 3; + } + if (certificate.IsLogo == 1)//含图标 { string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); @@ -211,6 +317,7 @@ namespace BBWY.Client.Helpers 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)); + if(!string.IsNullOrEmpty(certificate.ProductNo)) args.Graphics.DrawString($"型号: {certificate.ProductNo}", font, System.Drawing.Brushes.Black, new PointF(122, verHeight)); var smallSize = args.Graphics.MeasureString(certificate.Brand, font);//小字体高度 @@ -240,11 +347,17 @@ namespace BBWY.Client.Helpers for (int i = 1; i < rows.Count(); i++) { - verHeight += (smallSize.Height + standerSpace); + verHeight += (smallSize.Height + standerSpace) - 3; args.Graphics.DrawString($"{rows[i]}", font, System.Drawing.Brushes.Black, new PointF(10 + smallSize.Width, verHeight)); } - verHeight += (smallSize.Height + heightSpace); + if (!string.IsNullOrEmpty(certificate.ProduceDate)) + { + verHeight += (smallSize.Height + heightSpace); + args.Graphics.DrawString($"生产日期: {certificate.ProduceDate}", font, System.Drawing.Brushes.Black, new PointF(10, 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) @@ -260,19 +373,121 @@ namespace BBWY.Client.Helpers var productShop = args.Graphics.MeasureString("生产商", font); var adress = args.Graphics.MeasureString("地 址", font); - var rect1 = new RectangleF(10 + productShop.Width - adress.Width, verHeight, 220, smallSize.Height * 3 + heightSpace); + var rect1 = new RectangleF(10 + productShop.Width - adress.Width, verHeight- 2, 220, smallSize.Height * 3 + heightSpace); args.Graphics.DrawString($"地 址: {certificate.ProductAdress}", font, System.Drawing.Brushes.Black, rect1); + + + } private static void SetCerNoXingHao(ref PrintPageEventArgs args, CertificateModel certificate, Font font) { + //Bitmap bitmap = new Bitmap(236, 157); + //Graphics graphics = Graphics.FromImage(bitmap); + //graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; + //graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; + //var sige = graphics.VisibleClipBounds;// 宽:236 高:157 打印可视化区域 + //graphics.TranslateTransform((sige.Width - 236) / 2, 0);//设置起始位置 + //graphics.DrawRectangle(new System.Drawing.Pen(System.Drawing.Brushes.Black), 5, 5, sige.Width - 10, sige.Height - 10);//画出条码编辑区域 + //graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; + //graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; + //var twoWidth = graphics.MeasureString("适用", font); + //var oneWidth = graphics.MeasureString("适", font); + + //int bigJiange = 20;//合格证与品牌的高度差 + //if (!string.IsNullOrEmpty(certificate.ProduceDate)) bigJiange = 10; + //var heightSpace = 4;//所有行间隔高度 + //int standerSpace = 1;//执行标准之间的 + //var fontBig = new Font("宋体", 14, System.Drawing.FontStyle.Regular); + //string cerName = "合格证"; + //SizeF bigSize = graphics.MeasureString(cerName, fontBig); + + //float verHeight = bigJiange + bigSize.Height; + //graphics.DrawString(cerName, fontBig, System.Drawing.Brushes.Black, new PointF((236 - bigSize.Width) / 2, 10)); + + //graphics.DrawString($"品牌: {certificate.Brand}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); + //graphics.DrawString($"品名: {certificate.BrandName}", font, System.Drawing.Brushes.Black, new PointF(122, verHeight)); + //var smallSize = graphics.MeasureString(certificate.BrandName, font);//小字体高度 + + //verHeight += (smallSize.Height + heightSpace); + //graphics.DrawString($"材质: {certificate.Shader}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); + + //switch (certificate.LabelModel) + //{ + // case CertificateLabelModel.标准无3c: + // break; + // case CertificateLabelModel.标准有3c: + // break; + // case CertificateLabelModel.无型号: + // break; + // case CertificateLabelModel.适用年龄: + + + // graphics.DrawString($"适用年龄: {certificate.ApplyAge}", font, System.Drawing.Brushes.Black, new PointF(125 - twoWidth.Width, verHeight)); + // break; + // default: + // break; + //} + + ////graphics.DrawString($"材质: {certificate.Shader}", font, System.Drawing.Brushes.Black, new PointF(122, verHeight)); + + //StringBuilder sb = new StringBuilder(); + //var excutes = certificate.ExcuteStander.Split(new string[] { ",", "," }, 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 = graphics.MeasureString(excuteStander, font); + //verHeight += (smallSize.Height + heightSpace); + //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); + // graphics.DrawString($"{rows[i]}", font, System.Drawing.Brushes.Black, new PointF(12 + smallSize.Width, verHeight)); + //} + //if (!string.IsNullOrEmpty(certificate.ProduceDate)) + //{ + // verHeight += (smallSize.Height + heightSpace)-3; + // graphics.DrawString($"生产日期: {certificate.ProduceDate}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); + //} + //verHeight += (smallSize.Height + heightSpace); + + //RectangleF rect = new RectangleF(10, verHeight, 220, smallSize.Height * 2 + heightSpace); + //var productStr = $"生产商: {certificate.ProductShop}"; + //if (graphics.MeasureString(productStr, font).Width <= 220) + //{ + // graphics.DrawString(productStr, font, System.Drawing.Brushes.Black, 10, verHeight); + // verHeight += smallSize.Height + heightSpace; + //} + //else + //{ + // graphics.DrawString(productStr, font, System.Drawing.Brushes.Black, rect); + // verHeight += 2 * smallSize.Height + heightSpace; + //} + //var productShop = graphics.MeasureString("生产商", font); + //var adress = graphics.MeasureString("地 址", font); + + //var rect1 = new RectangleF(10 + productShop.Width - adress.Width, verHeight - 2, 220, smallSize.Height * 3 + heightSpace); + //graphics.DrawString($"地 址: {certificate.ProductAdress}", font, System.Drawing.Brushes.Black, rect1); + + //var applicationPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + //bitmap.Save($"{applicationPath}/{certificate.LabelModel}-{certificate.GoodsNumber}.jpg", ImageFormat.Png); int bigJiange = 20;//合格证与品牌的高度差 var heightSpace = 4;//所有行间隔高度 int standerSpace = 1;//执行标准之间的 - + if (!string.IsNullOrEmpty(certificate.ProduceDate)) bigJiange = 10; var fontBig = new Font("宋体", 14, System.Drawing.FontStyle.Regular); string cerName = "合格证"; SizeF bigSize = args.Graphics.MeasureString(cerName, fontBig); @@ -329,6 +544,11 @@ namespace BBWY.Client.Helpers verHeight += (smallSize.Height + standerSpace); args.Graphics.DrawString($"{rows[i]}", font, System.Drawing.Brushes.Black, new PointF(10 + smallSize.Width, verHeight)); } + if (!string.IsNullOrEmpty(certificate.ProduceDate)) + { + verHeight += (smallSize.Height + heightSpace)-3; + args.Graphics.DrawString($"生产日期: {certificate.ProduceDate}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); + } verHeight += (smallSize.Height + heightSpace); RectangleF rect = new RectangleF(10, verHeight, 220, smallSize.Height * 2 + heightSpace); @@ -346,17 +566,19 @@ namespace BBWY.Client.Helpers var productShop = args.Graphics.MeasureString("生产商", font); var adress = args.Graphics.MeasureString("地 址", font); - var rect1 = new RectangleF(10 + productShop.Width - adress.Width, verHeight, 220, smallSize.Height * 3 + heightSpace); + var rect1 = new RectangleF(10 + productShop.Width - adress.Width, verHeight-2, 220, smallSize.Height * 3 + heightSpace); args.Graphics.DrawString($"地 址: {certificate.ProductAdress}", font, System.Drawing.Brushes.Black, rect1); - + + + } public static void SaveImage(PrintPageEventArgs args) { args.Graphics.Save(); - // args.Graphics + // args.Graphics //Bitmap bitmap2 = new Bitmap(236, 157); //Graphics graphics2 = Graphics.FromImage(bitmap2); diff --git a/BBWY.Client/Models/APIModel/Request/CerRequest.cs b/BBWY.Client/Models/APIModel/Request/CerRequest.cs index 02838f37..7a10d65d 100644 --- a/BBWY.Client/Models/APIModel/Request/CerRequest.cs +++ b/BBWY.Client/Models/APIModel/Request/CerRequest.cs @@ -67,5 +67,9 @@ namespace BBWY.Client.Models.APIModel.Request /// 适用年龄 /// public string ApplyAge { get; set; } + + public int GoodsNumber { get; set; } + + public string ProduceDate { get; set; } } } diff --git a/BBWY.Client/Models/APIModel/Request/CreateTaskRequest.cs b/BBWY.Client/Models/APIModel/Request/CreateTaskRequest.cs index 04c0c50a..739c31ff 100644 --- a/BBWY.Client/Models/APIModel/Request/CreateTaskRequest.cs +++ b/BBWY.Client/Models/APIModel/Request/CreateTaskRequest.cs @@ -92,11 +92,16 @@ namespace BBWY.Client.Models.APIModel.Request /// public long? BarCodeId { get; set; } + /// /// 合格证Id /// public long? CertificateId { get; set; } /// + /// 合格证Id + /// + public string CerId { get; set; } + /// /// 合格证位置 /// public int? CertificatePosition { get; set; } diff --git a/BBWY.Client/Models/APIModel/Response/PackTask/PackTaskResultResponse.cs b/BBWY.Client/Models/APIModel/Response/PackTask/PackTaskResultResponse.cs index c0a9842d..620bb367 100644 --- a/BBWY.Client/Models/APIModel/Response/PackTask/PackTaskResultResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/PackTask/PackTaskResultResponse.cs @@ -6,7 +6,7 @@ using WebSocketSharp; namespace BBWY.Client.Models.APIModel.Response.PackTask { - public class PackTaskResultResponse + public class PackTaskResultResponse { /// /// 查询总数据(判断总页数) @@ -18,7 +18,7 @@ namespace BBWY.Client.Models.APIModel.Response.PackTask /// public GetPackTaskDTO[] Items { get; set; } } - public class GetPackTaskDTO + public class GetPackTaskDTO { /// /// SKU标题 @@ -158,7 +158,7 @@ namespace BBWY.Client.Models.APIModel.Response.PackTask public string MarkMessage { get; set; } public BarCodeModel BarCodeDTO { get; set; } - public CertificateModel certificate { get; set; } + public CertificateModel[] cers { get; set; } /// /// 是否加急 /// @@ -169,12 +169,12 @@ namespace BBWY.Client.Models.APIModel.Response.PackTask /// 品牌 /// public string Brand { get; set; } - public string OrderId { get; set; } + public string OrderId { get; set; } } //public class FeesItemTypeDTO :NotifyObject //{ - + // private bool isPaperBox; // public bool IsPaperBox { get => isPaperBox; set { Set(ref isPaperBox, value); } } diff --git a/BBWY.Client/Models/APIModel/Response/PackTask/ProductSkuResponse.cs b/BBWY.Client/Models/APIModel/Response/PackTask/ProductSkuResponse.cs index 1ee3f5bf..95416932 100644 --- a/BBWY.Client/Models/APIModel/Response/PackTask/ProductSkuResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/PackTask/ProductSkuResponse.cs @@ -51,7 +51,7 @@ namespace BBWY.Client.Models.APIModel.Response.PackTask /// /// 合格证信息 /// - public CertificateModel Certificate { get; set; } + public CertificateModel[] Cers { get; set; } /// /// 合格证信息 /// @@ -98,7 +98,7 @@ namespace BBWY.Client.Models.APIModel.Response.PackTask /// /// 合格证 /// - public long? CertificateId { get; set; } + public string CertificateId { get; set; } /// /// 合格证位置(外部包装=0,产品包装=1) diff --git a/BBWY.Client/Models/BatchPurchase/BatchPublishTask.cs b/BBWY.Client/Models/BatchPurchase/BatchPublishTask.cs index 8f0029a1..f01a0921 100644 --- a/BBWY.Client/Models/BatchPurchase/BatchPublishTask.cs +++ b/BBWY.Client/Models/BatchPurchase/BatchPublishTask.cs @@ -33,7 +33,7 @@ namespace BBWY.Client.Models public ObservableCollection WorryList { get => worryList; set { Set(ref worryList, value); } } private ObservableCollection positionTypeList = new ObservableCollection { - "本地仓","齐越仓", "京东仓"}; + "商家仓","齐越仓", "京东仓","聚水潭仓"}; public ObservableCollection PositionTypeList { get => positionTypeList; set { Set(ref positionTypeList, value); } } private ObservableCollection packTypeList = new ObservableCollection { @@ -236,11 +236,11 @@ namespace BBWY.Client.Models - private CertificateModel certificateModel; + private CertificateModel[] certificateModel; /// /// 合格证 /// - public CertificateModel CertificateModel { get => certificateModel; set { Set(ref certificateModel, value); } } + public CertificateModel[] CertificateModel { get => certificateModel; set { Set(ref certificateModel, value); } } /// /// 合格证位置(外部包装=0,产品包装=1) @@ -335,16 +335,21 @@ namespace BBWY.Client.Models if (CertificateModel == null) { - CertificateModel = new CertificateModel(); - CertificateModel.ProductNo = ProductNo; - CertificateModel.Brand = Brand; - CertificateModel.SkuId = SkuId; + CertificateModel = new CertificateModel[] { + new CertificateModel{ + ProductNo = ProductNo, + Brand = Brand, + SkuId = SkuId + } + }; + } if (!string.IsNullOrEmpty(BrandName)) - CertificateModel.BrandName = BrandName; + foreach (var item in CertificateModel) item.BrandName = BrandName; + SetCerWindow setCerWindow = new SetCerWindow(); - setCerWindow.LoadData(certificateModel, packTaskService, spuCertificateModel, IsSetSpuCertificate); + setCerWindow.LoadData(CertificateModel, packTaskService, spuCertificateModel, IsSetSpuCertificate); setCerWindow.SaveResult = s => { CertificateModel = s; @@ -452,19 +457,25 @@ namespace BBWY.Client.Models BrandName = productSku.Data.BrandName; - CertificateModel = productSku.Data.Certificate; + CertificateModel = productSku.Data.Cers; IsSetCertificate = false; if (CertificateModel == null) { - CertificateModel = new CertificateModel(); + CertificateModel = new CertificateModel[] { + new CertificateModel{ } + }; IsSetCertificate = true; } - CertificateModel.Brand = Brand; - if (!string.IsNullOrEmpty(BrandName)) - CertificateModel.BrandName = BrandName; - CertificateModel.ProductNo = ProductNo; - CertificateModel.SkuId = skuid; + foreach (var item in CertificateModel) + { + item.Brand = Brand; + if (!string.IsNullOrEmpty(BrandName)) + item.BrandName = BrandName; + item.ProductNo = ProductNo; + item.SkuId = skuid; + } + BarCodeModel = productSku.Data.BarCodeModel; IsSetBarCode = false; if (BarCodeModel == null) diff --git a/BBWY.Client/Models/Enums.cs b/BBWY.Client/Models/Enums.cs index 21bb87b7..e3f49d11 100644 --- a/BBWY.Client/Models/Enums.cs +++ b/BBWY.Client/Models/Enums.cs @@ -243,9 +243,10 @@ /// public enum PositionType { - 本地仓 = 0, + 商家仓 = 0, 齐越仓 = 1, - 京东仓 = 2 + 京东仓 = 2, + 聚水潭仓 = 3 } /// /// 合格证包装位置 diff --git a/BBWY.Client/Models/PackTask/CertificateModel.cs b/BBWY.Client/Models/PackTask/CertificateModel.cs index 794898cf..cde4a7ad 100644 --- a/BBWY.Client/Models/PackTask/CertificateModel.cs +++ b/BBWY.Client/Models/PackTask/CertificateModel.cs @@ -51,10 +51,14 @@ namespace BBWY.Client.Models /// /// 执行标准 /// - public string ExcuteStander { get => excuteStander; set { + public string ExcuteStander + { + get => excuteStander; set + { Set(ref excuteStander, value); GetExcuteStanderFormat(); - } } + } + } private string excuteStanderFormat; @@ -81,10 +85,10 @@ namespace BBWY.Client.Models /// public string ProductNo { get => productNo; set { Set(ref productNo, value); } } - /// - /// 生产日期 - /// - public DateTime ProductDate { get; set; } + ///// + ///// 生产日期 + ///// + //public DateTime ProductDate { get; set; } /// /// 经销商 @@ -115,23 +119,40 @@ namespace BBWY.Client.Models void GetExcuteStanderFormat() { StringBuilder sb = new StringBuilder(); - if (this.ExcuteStander.Contains(",")|| this.ExcuteStander.Contains(","))//有逗号就拆分 - { - var excutes = this.ExcuteStander.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < excutes.Length; i++) + if (!string.IsNullOrEmpty(ExcuteStander)) + if (this.ExcuteStander.Contains(",") || this.ExcuteStander.Contains(","))//有逗号就拆分 { - if (i % 2 == 0 && i > 0)//间隔两个换行 + var excutes = this.ExcuteStander.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < excutes.Length; i++) { - sb.Append("\r\n"); + if (i % 2 == 0 && i > 0)//间隔两个换行 + { + sb.Append("\r\n"); + } + sb.Append(excutes[i]).Append(" "); } - sb.Append(excutes[i]).Append(" "); + sb.Remove(sb.Length - 3, 3); + this.ExcuteStanderFormat = sb.ToString(); + return; } - sb.Remove(sb.Length - 3, 3); - this.ExcuteStanderFormat = sb.ToString(); - return; - } this.ExcuteStanderFormat = ExcuteStander; } + + + + + private int goodsNumber =1; + /// + /// 配件序号 + /// + public int GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } } + + private string produceDate; + /// + /// 生产日期 + /// + public string ProduceDate { get => produceDate; set { Set(ref produceDate, value); } } + } } diff --git a/BBWY.Client/Models/PackTask/PackTaskModel.cs b/BBWY.Client/Models/PackTask/PackTaskModel.cs index 21679a23..1f2f0dbd 100644 --- a/BBWY.Client/Models/PackTask/PackTaskModel.cs +++ b/BBWY.Client/Models/PackTask/PackTaskModel.cs @@ -51,16 +51,26 @@ namespace BBWY.Client.Models private void UpdateTask() { - CreatePackTask create = new CreatePackTask(); - ViewModelLocator viewModel = new ViewModelLocator(); - var createViewModel = viewModel.CreateTaskView; - if (createViewModel.ReflashWindow == null) - { - createViewModel.ReflashWindow = ReflashTask; - } - create.SendData(this);//初始化数据 - create.ShowDialog(); + var publicTaskViewModel = viewModel.PublishTask; + + if (publicTaskViewModel.ReflashWindow == null) + publicTaskViewModel.ReflashWindow = ReflashTask; + + publicTaskViewModel.InitData(this); + PublishTaskWindow publish = new PublishTaskWindow(); + publish.Show(); + + //CreatePackTask create = new CreatePackTask(); + + //ViewModelLocator viewModel = new ViewModelLocator(); + //var createViewModel = viewModel.CreateTaskView; + //if (createViewModel.ReflashWindow == null) + //{ + // createViewModel.ReflashWindow = ReflashTask; + //} + //create.SendData(this);//初始化数据 + //create.ShowDialog(); } @@ -410,11 +420,11 @@ namespace BBWY.Client.Models /// public BarCodeModel BarCodeModel { get => barCodeModel; set { Set(ref barCodeModel, value); } } - private CertificateModel certificateModel; + private CertificateModel[] certificateModel; /// /// 合格证 /// - public CertificateModel CertificateModel { get => certificateModel; set { Set(ref certificateModel, value); } } + public CertificateModel[] CertificateModel { get => certificateModel; set { Set(ref certificateModel, value); } } /// /// 合格证位置(外部包装=0,产品包装=1) diff --git a/BBWY.Client/ViewModels/BatchPurchase/BatchPublishTaskViewModel.cs b/BBWY.Client/ViewModels/BatchPurchase/BatchPublishTaskViewModel.cs index a197321b..e629206f 100644 --- a/BBWY.Client/ViewModels/BatchPurchase/BatchPublishTaskViewModel.cs +++ b/BBWY.Client/ViewModels/BatchPurchase/BatchPublishTaskViewModel.cs @@ -19,14 +19,17 @@ namespace BBWY.Client.ViewModels public class BatchPublishTaskViewModel : BaseVM, IDenpendency { + + + private ObservableCollection batchPublishTasks; + public ObservableCollection BatchPublishTasks { get => batchPublishTasks; set { Set(ref batchPublishTasks, value); } } + // public ObservableCollection BatchPublishTasks; + PackTaskService packTaskService; ProductService productService; + GlobalContext globalContext; private bool isLoading = false; public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } } - - private ObservableCollection batchPublishTasks; - public ObservableCollection BatchPublishTasks { get => batchPublishTasks; set { Set(ref batchPublishTasks, value); } } - // public ObservableCollection BatchPublishTasks; public ICommand OpenSkuDetailCommand { get; set; } public ICommand CreateTaskCommand { get; set; } public BatchPublishTaskViewModel(PackTaskService packTaskService, ProductService productService, GlobalContext globalContext) @@ -34,10 +37,10 @@ namespace BBWY.Client.ViewModels BatchPublishTasks = new ObservableCollection(); this.packTaskService = packTaskService; this.productService = productService; + + this.globalContext = globalContext; CreateTaskCommand = new RelayCommand(CreateTask); OpenSkuDetailCommand = new RelayCommand(OpenSkuDetail); - this.globalContext = globalContext; - @@ -63,7 +66,7 @@ namespace BBWY.Client.ViewModels } - GlobalContext globalContext; + private void CreateTask(object obj) { foreach (var task in BatchPublishTasks) @@ -94,7 +97,7 @@ namespace BBWY.Client.ViewModels SkuCount = task.SkuCount, UserId = globalContext.User.Id.ToString(), ShopId = PurchaserId, - IsWorry = task.IsWorry, + //IsWorry = task.IsWorry, OrderId = orderId, Platform =platform }; @@ -109,12 +112,12 @@ namespace BBWY.Client.ViewModels } if (task.IsNeedCertificateModel == Need.需要) { - if (task.CertificateModel == null || task.CertificateModel.Id <= 0) + if (task.CertificateModel == null || task.CertificateModel.Count() <= 0) { new TipsWindow("请设置合格证模板").Show(); return; } - createTaskModel.CertificateId = task.CertificateModel.Id;// + createTaskModel.CerId =string.Join(",", task.CertificateModel.Where(c=>c.Id>0).Select(c=>c.Id));// } ApiResponse res = null; res = packTaskService.CreateTask(createTaskModel); diff --git a/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseOrderListViewModel.cs b/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseOrderListViewModel.cs index d6fce42d..7e381de6 100644 --- a/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseOrderListViewModel.cs +++ b/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseOrderListViewModel.cs @@ -19,6 +19,7 @@ namespace BBWY.Client.ViewModels { public class BatchPurchaseOrderListViewModel : BaseVM, IDenpendency { + private PackTaskService packTaskService; private BatchPurchaseService batchPurchaseService; private GlobalContext globalContext; private DateTime startDate; @@ -47,6 +48,7 @@ namespace BBWY.Client.ViewModels public ICommand CancelPurchaseOrderCommand { get; set; } public ICommand CreateQTTaskCommand { get; set; } + public ICommand CancelQTTaskCommand { get; set; } public DateTime StartDate { get => startDate; set { Set(ref startDate, value); } } public DateTime EndDate { get => endDate; set { Set(ref endDate, value); } } @@ -65,7 +67,7 @@ namespace BBWY.Client.ViewModels public IList PurchaseOrderList { get; set; } - public BatchPurchaseOrderListViewModel(GlobalContext globalContext, BatchPurchaseService batchPurchaseService) + public BatchPurchaseOrderListViewModel(GlobalContext globalContext, BatchPurchaseService batchPurchaseService, PackTaskService packTaskService) { this.batchPurchaseService = batchPurchaseService; SetSearchDateCommand = new RelayCommand(SetSearchDate); @@ -78,12 +80,34 @@ namespace BBWY.Client.ViewModels CancelPurchaseOrderCommand = new RelayCommand(CancelPurchaseOrder); CreateQTTaskCommand = new RelayCommand(CreateQTTask); + CancelQTTaskCommand = new RelayCommand(CancelQTTask); PageSize = 10; this.globalContext = globalContext; EndDate = DateTime.Now.Date; StartDate = DateTime.Now.Date.AddDays(-15); PurchaseOrderList = new ObservableCollection(); InitQueryPurchaseOrder(); + this.packTaskService = packTaskService; + } + + private void CancelQTTask(object obj) + { + MessageBoxResult result = MessageBox.Show("确定取消订单任务?", "提示", + MessageBoxButton.YesNo, + MessageBoxImage.Warning); + if (result != MessageBoxResult.Yes) return; + var parameters = (object[])obj; + var id = parameters[0].ToString();//订单id + //取消打包任务 + + var res = packTaskService.CancelQTTask(id); + if (res.Success) + { + var resPackState = batchPurchaseService.UpdatePackState(id, Models.PackState.待发布); + if (resPackState.Success) + Task.Factory.StartNew(() => QueryPurchaseOrder(PageIndex)); + } + } private void CreateQTTask(object obj) @@ -101,25 +125,15 @@ namespace BBWY.Client.ViewModels batch.PublishTask = () => { - //修改状态 - var res = batchPurchaseService.UpdatePurchaseOrderState(id, Models.PurchaseOrderState.待打包); + //修改 打包状态 + var res = batchPurchaseService.UpdatePackState(id, Models.PackState.打包中); if (res.Success) - { Task.Factory.StartNew(() => QueryPurchaseOrder(PageIndex)); - } - + }; batch.AddSkus(PurchasePlatform, id, PurchaserId, itemList); - - BatchPublishTaskWindow window = new BatchPublishTaskWindow(); window.Show(); - - - - - - } private void CancelPurchaseOrder(object obj) diff --git a/BBWY.Client/ViewModels/PackTask/CreatePackTaskViewModel.cs b/BBWY.Client/ViewModels/PackTask/CreatePackTaskViewModel.cs index 16867f10..9905066c 100644 --- a/BBWY.Client/ViewModels/PackTask/CreatePackTaskViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/CreatePackTaskViewModel.cs @@ -28,6 +28,40 @@ namespace BBWY.Client.ViewModels.PackTask private bool isSelected; public bool IsSelected { get => isSelected; set { Set(ref isSelected, value); } } + private ObservableCollection worryList = new ObservableCollection { + "否","是" + }; + public ObservableCollection WorryList { get => worryList; set { Set(ref worryList, value); } } + + private ObservableCollection positionTypeList = new ObservableCollection { + "商家仓","齐越仓", "京东仓","聚水潭仓"}; + public ObservableCollection PositionTypeList { get => positionTypeList; set { Set(ref positionTypeList, value); } } + + private ObservableCollection packTypeList = new ObservableCollection { + "单件","多件" + }; + public ObservableCollection PackTypeList { get => packTypeList; set { Set(ref packTypeList, value); } } + + private ObservableCollection basicPackList = new ObservableCollection { + "快递袋","纸箱","麻袋" + }; + public ObservableCollection BasicPackList { get => basicPackList; set { Set(ref basicPackList, value); } } + + private ObservableCollection isNeedBarCodeList = new ObservableCollection { + "需要", "不需要" }; + public ObservableCollection IsNeedBarCodeList { get => isNeedBarCodeList; set { Set(ref isNeedBarCodeList, value); } } + + private ObservableCollection certificatePositionList = new ObservableCollection { + "无","外部包装","产品包装" + }; + public ObservableCollection CertificatePositionList { get => certificatePositionList; set { Set(ref certificatePositionList, value); } } + + private ObservableCollection availabilityList = new ObservableCollection { + "已到货","部分到货","未到货" + }; + public ObservableCollection AvailabilityList { get => availabilityList; set { Set(ref availabilityList, value); } } + + private bool isLoading = false; public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } } @@ -297,11 +331,11 @@ namespace BBWY.Client.ViewModels.PackTask - private CertificateModel certificateModel; + private CertificateModel[] certificateModel; /// /// 合格证 /// - public CertificateModel CertificateModel { get => certificateModel; set { Set(ref certificateModel, value); } } + public CertificateModel[] CertificateModel { get => certificateModel; set { Set(ref certificateModel, value); } } /// /// 合格证位置(外部包装=0,产品包装=1) @@ -634,7 +668,7 @@ namespace BBWY.Client.ViewModels.PackTask }); look.Show(); } - + /// /// /// @@ -660,42 +694,42 @@ namespace BBWY.Client.ViewModels.PackTask /// /// 保存合格证 /// - private void SaveCer() - { - 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)) - { - new TipsWindow("参数出错!请重新填写!").Show(); - return; - } - - var resData = packTaskService.SaveCer(new CerRequest - { - Brand = CertificateModel.Brand, - BrandName = CertificateModel.BrandName, - ProductNo = CertificateModel.ProductNo, - SkuId = CertificateModel.SkuId, - ExcuteStander = CertificateModel.ExcuteStander.Replace(",",","), - LabelModel = (int)CertificateModel.LabelModel, - FactoryNumber = CertificateModel.FactoryNumber, - IsLogo = CertificateModel.IsLogo, - ProductAdress = CertificateModel.ProductAdress, - ProductShop = CertificateModel.ProductShop, - Shader = CertificateModel.Shader, - ApplyAge = CertificateModel.ApplyAge, - }); - if (resData == null || !resData.Success) - { - IsSetCertificate = false; - return; - } - IsNeedCertificateModel = Need.需要; - CertificateModel.Id = resData.Data; - IsSetCertificate = false; - setCerWindow.Close(); - } + //private void SaveCer() + //{ + // 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)) + // { + // new TipsWindow("参数出错!请重新填写!").Show(); + // return; + // } + + // var resData = packTaskService.SaveCer(new CerRequest + // { + // Brand = CertificateModel.Brand, + // BrandName = CertificateModel.BrandName, + // ProductNo = CertificateModel.ProductNo, + // SkuId = CertificateModel.SkuId, + // ExcuteStander = CertificateModel.ExcuteStander.Replace(",", ","), + // LabelModel = (int)CertificateModel.LabelModel, + // FactoryNumber = CertificateModel.FactoryNumber, + // IsLogo = CertificateModel.IsLogo, + // ProductAdress = CertificateModel.ProductAdress, + // ProductShop = CertificateModel.ProductShop, + // Shader = CertificateModel.Shader, + // ApplyAge = CertificateModel.ApplyAge, + // }); + // if (resData == null || !resData.Success) + // { + // IsSetCertificate = false; + // return; + // } + // IsNeedCertificateModel = Need.需要; + // CertificateModel.Id = resData.Data; + // IsSetCertificate = false; + // setCerWindow.Close(); + //} SetBarCodeWindow setBarCodeWindow = null; SetCerWindow setCerWindow = null; SetSpuCerWindow setSpuCerWindow = null; @@ -742,16 +776,22 @@ namespace BBWY.Client.ViewModels.PackTask if (CertificateModel == null) { - CertificateModel = new CertificateModel(); - CertificateModel.ProductNo = ProductNo; - CertificateModel.Brand = Brand; - CertificateModel.SkuId = SkuId; + CertificateModel = new CertificateModel[] { + new CertificateModel() + { + ProductNo = ProductNo, + Brand = Brand, + SkuId = SkuId, + } + }; + } if (!string.IsNullOrEmpty(BrandName)) - CertificateModel.BrandName = BrandName; + foreach (var item in CertificateModel) item.BrandName = BrandName; + //CertificateModel.Foreach(c=>c.BrandName = BrandName) ; SetCerWindow setCerWindow = new SetCerWindow(); - setCerWindow.LoadData(certificateModel, packTaskService, spuCertificateModel, IsSetSpuCertificate); + setCerWindow.LoadData(CertificateModel, packTaskService, spuCertificateModel, IsSetSpuCertificate); setCerWindow.SaveResult = s => { CertificateModel = s; @@ -779,7 +819,7 @@ namespace BBWY.Client.ViewModels.PackTask //保存到服务器中 返回id var resData = packTaskService.SaveBarCode(new BarCodeRequest { - Brand = BarCodeModel. Brand, + Brand = BarCodeModel.Brand, BrandName = BarCodeModel.BrandName, ProductNo = BarCodeModel.ProductNo, SkuId = BarCodeModel.SkuId, @@ -847,7 +887,7 @@ namespace BBWY.Client.ViewModels.PackTask SkuCount = SkuCount, UserId = AccepUserId, ShopId = globalContext.User.Shop.ShopId.ToString(), - IsWorry = IsWorry + //IsWorry = IsWorry }; if (IsNeedBarCode == Need.需要) { @@ -860,12 +900,12 @@ namespace BBWY.Client.ViewModels.PackTask } if (IsNeedCertificateModel == Need.需要) { - if (CertificateModel == null || CertificateModel.Id <= 0) + if (CertificateModel == null || CertificateModel.Count() <= 0) { new TipsWindow("请设置合格证模板").Show(); return; } - createTaskModel.CertificateId = CertificateModel.Id;// + createTaskModel.CerId =string.Join(",", CertificateModel.Select(c=>c.Id));// } ApiResponse res = null; if (TaskId > 0)//修改界面 @@ -970,20 +1010,28 @@ namespace BBWY.Client.ViewModels.PackTask BrandName = productSku.Data.BrandName; - CertificateModel = productSku.Data.Certificate; + CertificateModel = productSku.Data.Cers; IsSetCertificate = false; if (CertificateModel == null) { - CertificateModel = new CertificateModel(); + CertificateModel = new CertificateModel[] { + new CertificateModel{ } + }; IsSetCertificate = true; } - CertificateModel.Brand = Brand; + foreach (var item in CertificateModel) + item.Brand = Brand; + if (!string.IsNullOrEmpty(BrandName)) - - CertificateModel.BrandName = BrandName; - CertificateModel.ProductNo = ProductNo; - CertificateModel.SkuId = SkuId; + foreach (var item in CertificateModel) + { + item.BrandName = BrandName; + item.ProductNo = ProductNo; + item.SkuId = SkuId; + } + + BarCodeModel = productSku.Data.BarCodeModel; IsSetBarCode = false; if (BarCodeModel == null) diff --git a/BBWY.Client/ViewModels/PackTask/PublishTaskViewModel.cs b/BBWY.Client/ViewModels/PackTask/PublishTaskViewModel.cs new file mode 100644 index 00000000..0bb26441 --- /dev/null +++ b/BBWY.Client/ViewModels/PackTask/PublishTaskViewModel.cs @@ -0,0 +1,759 @@ +using BBWY.Client.APIServices; +using BBWY.Client.Models; +using BBWY.Client.Models.PackTask; +using BBWY.Client.Views.PackTask; +using BBWY.Common.Models; +using GalaSoft.MvvmLight.Command; +using GalaSoft.MvvmLight.Messaging; +using Org.BouncyCastle.Ocsp; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; + +namespace BBWY.Client.ViewModels.PackTask +{ + public class PublishTaskViewModel : BaseVM, IDenpendency + { + + #region 属性 + + private string searchSkuId; + public string SearchSkuId { get => searchSkuId; set { Set(ref searchSkuId, value); } } + + public long TaskId { get; set; } + private bool isSelected; + public bool IsSelected { get => isSelected; set { Set(ref isSelected, value); } } + + private ObservableCollection worryList = new ObservableCollection { + "否","是" + }; + public ObservableCollection WorryList { get => worryList; set { Set(ref worryList, value); } } + + private ObservableCollection positionTypeList = new ObservableCollection { + "商家仓","齐越仓", "京东仓","聚水潭仓"}; + public ObservableCollection PositionTypeList { get => positionTypeList; set { Set(ref positionTypeList, value); } } + + private ObservableCollection packTypeList = new ObservableCollection { + "单件","多件" + }; + public ObservableCollection PackTypeList { get => packTypeList; set { Set(ref packTypeList, value); } } + + private ObservableCollection basicPackList = new ObservableCollection { + "快递袋","纸箱","麻袋" + }; + public ObservableCollection BasicPackList { get => basicPackList; set { Set(ref basicPackList, value); } } + + private ObservableCollection isNeedBarCodeList = new ObservableCollection { + "需要", "不需要" }; + public ObservableCollection IsNeedBarCodeList { get => isNeedBarCodeList; set { Set(ref isNeedBarCodeList, value); } } + + private ObservableCollection certificatePositionList = new ObservableCollection { + "无","外部包装","产品包装" + }; + public ObservableCollection CertificatePositionList { get => certificatePositionList; set { Set(ref certificatePositionList, value); } } + + private ObservableCollection availabilityList = new ObservableCollection { + "已到货","部分到货","未到货" + }; + public ObservableCollection AvailabilityList { get => availabilityList; set { Set(ref availabilityList, value); } } + + private int skuCount; + /// + /// Sku任务数 + /// + public int SkuCount { get => skuCount; set { Set(ref skuCount, value); } } + + private string skuId; + /// + /// Sku + /// + public string SkuId { get => skuId; set { Set(ref skuId, value); } } + + private string logo; + /// + /// 店铺Sku图链接 + /// + public string Logo { get => logo; set { Set(ref logo, value); } } + + private string skuName; + /// + /// 采购Sku名称 + /// + public string SkuName { get => skuName; set { Set(ref skuName, value); } } + + private string brand; + /// + /// 品牌 + /// + public string Brand { get => brand; set { Set(ref brand, value); } } + + + private string productNo; + /// + /// 货号 + /// + public string ProductNo { get => productNo; set { Set(ref productNo, value); } } + + private string brandName; + /// + /// 品名(手写上传) + /// + public string BrandName { get => brandName; set { Set(ref brandName, value); } } + + + private int goodsNumber; + /// + /// 配件数 + /// + public int GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } } + private Worry isWorry; + /// + /// 是否加急 + /// + public Worry IsWorry { get => isWorry; set { Set(ref isWorry, value); } } + + private TaskState availability; + /// + /// 到货情况(待收货=0,部分收货=1,已到货=2) + /// + public TaskState Availability { get => availability; set { Set(ref availability, value); } } + + private PackType packType; + /// + /// 打包类型(单件=0,多件=1) + /// + public PackType PackType { get => packType; set { Set(ref packType, value); } } + + private BasicPack basicPack; + /// + /// 基础包装(快递袋=0,纸箱=1,麻袋=2) + /// + public BasicPack BasicPack { get => basicPack; set { Set(ref basicPack, value); } } + + private PositionType positionType; + /// + /// 落仓(商家仓=0,齐越仓=1,京东仓=2,聚水潭仓=3) + /// + public PositionType PositionType { get => positionType; set { Set(ref positionType, value); } } + + private string skuTitle; + /// + /// sku配件商品名称 + /// + public string SkuTitle { get => skuTitle; set { Set(ref skuTitle, value); } } + + private Need isNeedBarCode; + /// + /// 是否需要合格证 + /// + public Need IsNeedBarCode { get => isNeedBarCode; set { Set(ref isNeedBarCode, value); } } + + + private Need isNeedCertificateModel; + /// + /// 是否需要条形码 + /// + public Need IsNeedCertificateModel { get => isNeedCertificateModel; set { Set(ref isNeedCertificateModel, value); } } + + + private BarCodeModel barCodeModel; + /// + /// 条形码 + /// + public BarCodeModel BarCodeModel { get => barCodeModel; set { Set(ref barCodeModel, value); } } + + + private bool isSetBarCode; + /// + /// 设置显示(条形码) + /// + public bool IsSetBarCode + { + get => isSetBarCode; + set + { + + Set(ref isSetBarCode, value); + IsNeedBarCode = IsSetBarCode ? Need.不需要 : Need.需要; + } + } + + private bool isSetCertificate; + /// + /// 设置显示(合格证) + /// + public bool IsSetCertificate + { + get => isSetCertificate; set + { + + Set(ref isSetCertificate, value); + IsNeedCertificateModel = IsSetCertificate ? Need.不需要 : Need.需要; + } + } + private string setSpuCerStatus; + + public string SetSpuCerStatus { get => setSpuCerStatus; set { Set(ref setSpuCerStatus, value); } } + private bool isSetSpuCertificate = true; + + + /// + /// 设置spu显示(合格证) + /// + public bool IsSetSpuCertificate + { + get => isSetSpuCertificate; set + { + + Set(ref isSetSpuCertificate, value); + SetSpuCerStatus = IsSetSpuCertificate ? "设置spu模板" : "修改spu模板"; + } + } + + + private string saveTask; + + /// + /// 设置显示(合格证) + /// + public string SaveTask { get => saveTask; set { Set(ref saveTask, value); } } + + + private string spuId; + /// + /// 合格证 + /// + public string SpuId { get => spuId; set { Set(ref spuId, value); } } + + private CertificateModel spuCertificateModel; + /// + /// spu合格证 + /// + public CertificateModel SpuCertificateModel { get => spuCertificateModel; set { Set(ref spuCertificateModel, value); } } + + + + private CertificateModel[] certificateModel; + /// + /// 合格证 + /// + public CertificateModel[] CertificateModel { get => certificateModel; set { Set(ref certificateModel, value); } } + + /// + /// 合格证位置(外部包装=0,产品包装=1) + /// + private CertificatePosition certificatePosition; + /// + /// 合格证位置(外部包装=0,产品包装=1) + /// + public CertificatePosition CertificatePosition { get => certificatePosition; set { Set(ref certificatePosition, value); } } + + /// + /// 注意事项(对接备注) + /// + private string markMessage; + /// + /// 注意事项(对接备注) + /// + public string MarkMessage { get => markMessage; set { Set(ref markMessage, value); } } + + + private ObservableCollection increateList; + /// + /// 增量耗材查询关键字 + /// + public ObservableCollection IncreateList { get => increateList; set { Set(ref increateList, value); } } + string[] increates = new string[] { "气泡纸", "气泡袋", "POP袋", "折纸箱", "气泡纸封边", "彩盒", "剪胶", "剪彩带", "快递袋", "收纳盒", "纸箱子", "装纸箱", "封边", "胶带", "折彩盒" }; + + PackTaskService packTaskService; + ProductService productService; + GlobalContext globalContext; + private bool isLoading = false; + public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } } + #endregion + + public PublishTaskViewModel(PackTaskService packTaskService, ProductService productService, GlobalContext globalContext) + { + this.packTaskService = packTaskService; + this.productService = productService; + this.globalContext = globalContext; + CreateTaskCommand = new RelayCommand(CreateTask); + OpenSkuDetailCommand = new RelayCommand(OpenSkuDetail); + SetBarCodeCommand = new RelayCommand(SetBarCode); + SetCertificateCommand = new RelayCommand(SetCertificate); + LookBarCommand = new RelayCommand(LookBar); + LookCerCommand = new RelayCommand(LookCer); + SearchSkuCommand = new RelayCommand(SearchSku); + IncreateList = new ObservableCollection(); + foreach (var item in increates) + { + IncreateList.Add(new IncreateModel + { + IncreateName = item, + IsSelected = false + }); + } + Messenger.Default.Register(this, "InitData", message => + { + + InitData(message); + }); + + } + + + #region 方法 + public ICommand SetBarCodeCommand { get; set; } + public ICommand SetCertificateCommand { get; set; } + public ICommand LookBarCommand { get; set; } + public ICommand LookCerCommand { get; set; } + + public ICommand OpenSkuDetailCommand { get; set; } + public ICommand CreateTaskCommand { get; set; } + + public ICommand SearchSkuCommand { get; set; } + + private void SetBarCode() + { + if (string.IsNullOrEmpty(SkuId)) + { + return; + } + if (BarCodeModel == null) + { + BarCodeModel = new BarCodeModel(); + BarCodeModel.ProductNo = ProductNo; + BarCodeModel.Brand = Brand; + BarCodeModel.SkuId = SkuId; + BarCodeModel.SkuName = SkuName; + } + if (!string.IsNullOrEmpty(BrandName)) + BarCodeModel.BrandName = BrandName; + + + SetBarCodeWindow setBarCodeWindow = new SetBarCodeWindow(); + setBarCodeWindow.LoadData(BarCodeModel, packTaskService); + setBarCodeWindow.SaveResult = b => + { + BarCodeModel = b; + IsSetBarCode = false; + IsNeedBarCode = Need.需要; + }; + setBarCodeWindow.Show(); + } + + /// + /// 设置合格证 + /// + private void SetCertificate() + { + if (string.IsNullOrEmpty(SkuId)) + return; + + SearSpuCer(); + + if (CertificateModel == null) + { + CertificateModel = new CertificateModel[] { + new CertificateModel{ + ProductNo = ProductNo, + Brand = Brand, + SkuId = SkuId, + + } + }; + + + } + if (!string.IsNullOrEmpty(BrandName)) + foreach (var item in CertificateModel) item.BrandName = BrandName; + + SetCerWindow setCerWindow = new SetCerWindow(); + setCerWindow.LoadData(CertificateModel, packTaskService, spuCertificateModel, IsSetSpuCertificate); + setCerWindow.SaveResult = s => + { + CertificateModel = s; + IsSetCertificate = false; + IsNeedCertificateModel = Need.需要; + }; + setCerWindow.Show(); + } + + + /// + /// 查看合格证 + /// + private void LookCer() + { + LookCerWindow lookCerWindow = new LookCerWindow(CertificateModel); + lookCerWindow.Show(); + } + /// + /// 查看条形码 + /// + private void LookBar() + { + LookBarCodeWindow look = new LookBarCodeWindow(); + look.SetData(BarCodeModel); + look.Show(); + } + + /// + /// 搜索 skuId + /// + public void SearchSku(object obj) + { + string skuid = (string)obj; + if (string.IsNullOrEmpty(skuid)) + return; + + SkuId = skuid; + ApiResponse productApiResponse = null; + var skuResponse = productService.GetProductSkuList(string.Empty, skuid); + if (skuResponse.Success) + { + if (skuResponse.Data.Count == 0) + { + return; + } + Logo = skuResponse.Data[0].Logo.Replace("80x80", "200x200"); + SkuName = skuResponse.Data[0].Title; + + + SpuId = skuResponse.Data[0].ProductId; + + productApiResponse = productService.GetProductList(skuResponse.Data[0].ProductId, string.Empty, string.Empty, 1); + + if (productApiResponse.Success) + { + if (productApiResponse.Data.Count == 0) + { + + return; + } + + ProductNo = productApiResponse.Data.Items[0].ProductItemNum; + Brand = productApiResponse.Data.Items[0].BrandName; + + } + var productSku = packTaskService.GetProductSku(skuid); + if (productSku == null || !productSku.Success) + { + + return; + } + + if (productSku.Data.PackConfig != null) + { + var config = productSku.Data.PackConfig; + SkuTitle = config.SkuGoodsTitle; + GoodsNumber = config.GoodsNumber; + PackType = (PackType)config.PackType; + BasicPack = (BasicPack)config.BasicPack; + Availability = (TaskState)config.Availability; + MarkMessage = config.MarkMessage; + CertificatePosition = config.CertificatePosition == null ? CertificatePosition.无 : (CertificatePosition)config.CertificatePosition.Value; + // Increment1 = config.Increment1; + string[] increateDatas = config.Increment1.Split(','); + + bool isSelected = false; + foreach (var item in increates) + { + isSelected = false; + if (increateDatas.Contains(item)) + { + isSelected = true; + } + App.Current.Dispatcher.Invoke(() => + { + IncreateList.Add(new IncreateModel + { + IncreateName = item, + IsSelected = isSelected + }); + }); + } + + } + + BrandName = productSku.Data.BrandName; + + + CertificateModel = productSku.Data.Cers; + IsSetCertificate = false; + if (CertificateModel == null) + { + CertificateModel = new CertificateModel[] { + new CertificateModel{ } + }; + IsSetCertificate = true; + + } + foreach (var item in CertificateModel) + { + item.Brand = Brand; + if (!string.IsNullOrEmpty(BrandName)) + item.BrandName = BrandName; + item.ProductNo = ProductNo; + item.SkuId = skuid; + } + + BarCodeModel = productSku.Data.BarCodeModel; + IsSetBarCode = false; + if (BarCodeModel == null) + { + BarCodeModel = new BarCodeModel(); + IsSetBarCode = true; + } + BarCodeModel.Brand = Brand; + if (!string.IsNullOrEmpty(BrandName)) + BarCodeModel.BrandName = BrandName; + BarCodeModel.ProductNo = ProductNo; + BarCodeModel.SkuId = skuid; + BarCodeModel.SkuName = SkuName; + } + else + { + + App.Current.Dispatcher.Invoke(() => MessageBox.Show(skuResponse.Msg, "加载sku")); + return; + } + + } + + public void SearSpuCer() + { + if (string.IsNullOrEmpty(SpuId)) + { + SearchSku(SkuId); + return; + } + SpuId = SpuId.Trim();//去掉空格 避免数据异常 + + + var productSku = packTaskService.GetSpuCer(SpuId); + if (productSku == null || !productSku.Success) + { + IsSetSpuCertificate = true; + + return; + } + SpuCertificateModel = productSku.Data; + IsSetSpuCertificate = false; + if (SpuCertificateModel == null) + { + SpuCertificateModel = new CertificateModel(); + IsSetSpuCertificate = true; + SpuCertificateModel.Brand = Brand; + SpuCertificateModel.BrandName = BrandName; + SpuCertificateModel.ProductNo = ProductNo; + SpuCertificateModel.SpuId = SpuId; + + } + + + } + + public Action ReflashWindow { get; set; } + public void InitData(PackTaskModel model = null) + { + + IncreateList = new ObservableCollection(); + SpuId = string.Empty; + if (model == null) + { + SaveTask = "发布"; + TaskId = 0; + Logo = string.Empty; + SearchSkuId = ""; + SkuId = ""; + SkuCount = 0; + SkuName = string.Empty; + ProductNo = string.Empty; + Brand = string.Empty; + BrandName = string.Empty; + this.MarkMessage = ""; + IsSetBarCode = true; + IsSetCertificate = true; + BarCodeModel = null; + + CertificateModel = null; + SkuTitle = string.Empty; + GoodsNumber = 0; + foreach (var item in increates) + { + IncreateList.Add(new IncreateModel + { + IncreateName = item, + IsSelected = false + }); + } + IsNeedBarCode = Need.需要; + return; + } + SaveTask = "保存"; + Logo = model.ItemList[0].Logo; + SearchSkuId = model.SkuId; + SkuId = model.SkuId; + SkuCount = model.SkuCount; + SkuName = model.ItemList[0].SkuName; + ProductNo = model.ItemList[0].GoodsNo; + Brand = model.Brand; + BrandName = model.ItemList[0].BrandName; + this.MarkMessage = model.MarkMessage; + IsSetBarCode = model.BarCodeModel != null ? false : true; + IsSetCertificate = model.CertificateModel != null ? false : true; + BarCodeModel = model.BarCodeModel; + CertificateModel = model.CertificateModel; + SkuTitle = model.SkuTitle; + GoodsNumber = model.GoodsNumber; + Availability = model.Availability; + IsWorry = model.IsWorry; + PositionType = model.PositionType; + PackType = model.PackType; + BasicPack = model.BasicPack; + IsNeedBarCode = model.BarCodeModel == null ? Need.不需要 : Need.需要; + IsNeedCertificateModel = model.CertificateModel == null ? Need.不需要 : Need.需要; + CertificatePosition = model.CertificatePosition; + TaskId = model.TaskId; + string[] increateDatas = model.Increment1.Split(','); + + bool isSelected = false; + foreach (var item in increates) + { + isSelected = false; + if (increateDatas.Contains(item)) + { + isSelected = true; + } + App.Current.Dispatcher.Invoke(() => + { + IncreateList.Add(new IncreateModel + { + IncreateName = item, + IsSelected = isSelected + }); + }); + } + SearchSku(SkuId); + + } + private void OpenSkuDetail(object param) + { + var paramList = (object[])param; + // var orderId = paramList[0].ToString(); + var skuId = paramList[0].ToString(); + + + var url = $"https://item.jd.com/{skuId}.html"; + try + { + System.Diagnostics.Process.Start("explorer.exe", url); + } + catch (Exception ex) + { + Clipboard.SetText(url); + MessageBox.Show($"{ex.Message}\r\n调用浏览器失败,网页链接已复制到剪切板,请手动打开浏览器访问", "提示"); + } + + } + + + + private void CreateTask(object obj) + { + if (string.IsNullOrEmpty(SkuId)) + { + new TipsWindow("请先搜索SkuId!").Show(); + return; + } + if (SkuCount <= 0) + { + new TipsWindow("请设置SKU任务数!").Show(); + return; + } + string increateStr = ""; + var increates = IncreateList.Where(i => i.IsSelected).Select(i => i.IncreateName); + if (increates != null && increates.Count() > 0) + { + increateStr = string.Join(",", increates); + } + var createTaskModel = new Models.APIModel.Request.CreateTaskRequest + { + ProductNo = ProductNo, + Logo = Logo, + SkuName = SkuName, + TaskId = TaskId, + BrandName = BrandName, + Availability = (int)Availability, + BasicPack = (int)BasicPack, + SkuId = SkuId, + CreateTime = DateTime.Now, + Increment1 = increateStr, + //Increment2 = (int)Increment2, + CertificatePosition = (int)CertificatePosition, + PackType = (int)PackType, + MarkMessage = MarkMessage, + PositionType = (int)PositionType, + GoodsNumber = GoodsNumber, + SkuGoodsTitle = SkuTitle, + SkuCount = SkuCount, + UserId = globalContext.User.Id.ToString(), + ShopId = globalContext.User.Shop.ShopId.ToString(), + + //IsWorry = IsWorry + }; + if (IsNeedBarCode == Need.需要) + { + if (BarCodeModel == null || BarCodeModel.Id <= 0) + { + new TipsWindow("请设置条形码模板").Show(); + return; + } + createTaskModel.BarCodeId = BarCodeModel.Id; + } + if (IsNeedCertificateModel == Need.需要) + { + if (CertificateModel == null || CertificateModel.Count() <= 0) + { + new TipsWindow("请设置合格证模板").Show(); + return; + } + try + { + createTaskModel.CertificateId = CertificateModel.Where(c => c.Id > 0).FirstOrDefault()?.Id; + } + catch + { + + + } + + createTaskModel.CerId = string.Join(",", CertificateModel.Where(c => c.Id > 0).Select(c => c.Id));// + } + ApiResponse res = null; + if (TaskId > 0)//修改界面 + { + res = packTaskService.UpdateTask(createTaskModel); + } + else + { + res = packTaskService.CreateTask(createTaskModel); + } + if (res.Success) + { + if (ReflashWindow != null) ReflashWindow();//刷新主界面 + + var win = obj as System.Windows.Window; + win.Close(); + } + } + #endregion + } +} diff --git a/BBWY.Client/ViewModels/PackTask/TaskListViewModel.cs b/BBWY.Client/ViewModels/PackTask/TaskListViewModel.cs index da3edc92..30903b91 100644 --- a/BBWY.Client/ViewModels/PackTask/TaskListViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/TaskListViewModel.cs @@ -156,13 +156,13 @@ namespace BBWY.Client.ViewModels.PackTask IsLoading = false; //加载数据 SetTaskState(Models.TaskState.全部); - + } - + private void DeletedTask(object obj) { - + MessageBoxResult result = MessageBox.Show("确定删除?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning); @@ -225,7 +225,7 @@ namespace BBWY.Client.ViewModels.PackTask /// public ICommand OpenSkuDetailCommand { get; set; } - + /// /// 删除任务 /// @@ -326,16 +326,16 @@ namespace BBWY.Client.ViewModels.PackTask { data.BarCodeModel = item.BarCodeDTO; } - if (item.certificate != null) + if (item.cers != null) { - data.CertificateModel = item.certificate; + data.CertificateModel = item.cers; } if (item.FeesItemResponse != null) { data.FeesItemResponse = item.FeesItemResponse; data.FeesMoney = item.FeesItemResponse.SingleFees; data.IsShowFees = data.FeesMoney > 0 ? true : false; - data.FeesItemResponse.DiscountSingleFees = item.FeesItemResponse.SingleFees *item.FeesItemResponse.disCount; + data.FeesItemResponse.DiscountSingleFees = item.FeesItemResponse.SingleFees * item.FeesItemResponse.disCount; data.FeesItemResponse.DiscountAllFees = item.FeesItemResponse.AllFees * item.FeesItemResponse.disCount; } @@ -394,19 +394,31 @@ namespace BBWY.Client.ViewModels.PackTask public void CreateTask() { ViewModelLocator viewModel = new ViewModelLocator(); - var createViewModel = viewModel.CreateTaskView; - if (createViewModel.ReflashWindow == null) - { - createViewModel.ReflashWindow = ReflashTask; - } + var publicTaskViewModel = viewModel.PublishTask; + + if (publicTaskViewModel.ReflashWindow == null) + + publicTaskViewModel.ReflashWindow = ReflashTask; + + publicTaskViewModel.InitData(); + PublishTaskWindow publish = new PublishTaskWindow(); + publish.Show(); + + //ViewModelLocator viewModel = new ViewModelLocator(); + + //var createViewModel = viewModel.CreateTaskView; + //if (createViewModel.ReflashWindow == null) + //{ + // createViewModel.ReflashWindow = ReflashTask; + //} - CreatePackTask create = new CreatePackTask(); - create.SendData(); + //CreatePackTask create = new CreatePackTask(); + //create.SendData(); - create.Show(); + //create.Show(); } diff --git a/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs b/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs index 05ef70d4..d6af7ec4 100644 --- a/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs @@ -327,9 +327,9 @@ namespace BBWY.Client.ViewModels.PackTask data.BarCodeModel = item.BarCodeDTO; } - if (item.certificate != null) + if (item.cers != null) { - data.CertificateModel = item.certificate; + data.CertificateModel = item.cers; } diff --git a/BBWY.Client/ViewModels/ViewModelLocator.cs b/BBWY.Client/ViewModels/ViewModelLocator.cs index d14db460..7ccd0dad 100644 --- a/BBWY.Client/ViewModels/ViewModelLocator.cs +++ b/BBWY.Client/ViewModels/ViewModelLocator.cs @@ -286,5 +286,13 @@ namespace BBWY.Client.ViewModels return s.ServiceProvider.GetRequiredService(); } } + public PublishTaskViewModel PublishTask + { + get + { + using var s = sp.CreateScope(); + return s.ServiceProvider.GetRequiredService(); + } + } } } diff --git a/BBWY.Client/Views/BatchPurchase/BatchPublishTaskWindow.xaml b/BBWY.Client/Views/BatchPurchase/BatchPublishTaskWindow.xaml index 5b87d01b..180ea937 100644 --- a/BBWY.Client/Views/BatchPurchase/BatchPublishTaskWindow.xaml +++ b/BBWY.Client/Views/BatchPurchase/BatchPublishTaskWindow.xaml @@ -21,6 +21,8 @@ + + @@ -114,35 +116,49 @@ + + + + + + + + - + - - - - + + + + + + + - + WaterRemark="打包备注" Margin="400 64 0 0 " AcceptsReturn="True" TextWrapping="Wrap"> + - - - - + + + + + + @@ -153,10 +169,10 @@ - + - - + + @@ -176,7 +192,7 @@ - + @@ -188,33 +204,25 @@ - - + + - - + + - - - - - - - - + Height="25" BorderThickness="0" Margin="1" + > @@ -231,18 +239,18 @@ - - + + - - + + - - + + diff --git a/BBWY.Client/Views/BatchPurchase/BatchPurchaseOrderList.xaml b/BBWY.Client/Views/BatchPurchase/BatchPurchaseOrderList.xaml index ffab05f3..108f6f48 100644 --- a/BBWY.Client/Views/BatchPurchase/BatchPurchaseOrderList.xaml +++ b/BBWY.Client/Views/BatchPurchase/BatchPurchaseOrderList.xaml @@ -128,15 +128,15 @@ Background="{Binding PurchaseOrderState,Converter={StaticResource objConverter},ConverterParameter=待收货:#8080FF:#F2F2F2}" Foreground="{Binding PurchaseOrderState,Converter={StaticResource objConverter},ConverterParameter=待收货:White:#4A4A4A}" Command="{Binding SetPurchaseOrderStateCommand}" CommandParameter="{x:Static cmodel:PurchaseOrderState.待收货}"/> - + Command="{Binding SetPurchaseOrderStateCommand}" CommandParameter="{x:Static cmodel:PurchaseOrderState.待质检}"/>--> - @@ -407,8 +407,8 @@ - - + @@ -425,27 +425,26 @@ - - - - + - - - + + + - + diff --git a/BBWY.Client/Views/MainWindow.xaml b/BBWY.Client/Views/MainWindow.xaml index 0afde378..04b116d7 100644 --- a/BBWY.Client/Views/MainWindow.xaml +++ b/BBWY.Client/Views/MainWindow.xaml @@ -26,7 +26,7 @@ - + diff --git a/BBWY.Client/Views/PackTask/BarcodeControl.xaml b/BBWY.Client/Views/PackTask/BarcodeControl.xaml index a67d1a34..eaf5ef5f 100644 --- a/BBWY.Client/Views/PackTask/BarcodeControl.xaml +++ b/BBWY.Client/Views/PackTask/BarcodeControl.xaml @@ -6,88 +6,69 @@ xmlns:local="clr-namespace:BBWY.Client.Views.PackTask" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> - - - - - - - - + - - + + - + - + - + - + - + - + - + - + - + - - - - - + - - + - + - + - + - - - - - - diff --git a/BBWY.Client/Views/PackTask/BarcodeControl.xaml.cs b/BBWY.Client/Views/PackTask/BarcodeControl.xaml.cs index e497a77d..97e446bc 100644 --- a/BBWY.Client/Views/PackTask/BarcodeControl.xaml.cs +++ b/BBWY.Client/Views/PackTask/BarcodeControl.xaml.cs @@ -22,7 +22,6 @@ namespace BBWY.Client.Views.PackTask public BarcodeControl() { InitializeComponent(); - this.DataContext = this.BarCodeData; } @@ -30,18 +29,18 @@ namespace BBWY.Client.Views.PackTask /// /// /// - public BarCodeModel BarCodeData + public BarCodeModel model { - get { return (BarCodeModel)GetValue(BarCodeDataProperty); } + get { return (BarCodeModel)GetValue(modelProperty); } set { - SetValue(BarCodeDataProperty, value); + SetValue(modelProperty, value); } } - public static readonly DependencyProperty BarCodeDataProperty = - DependencyProperty.Register("BarCodeData", typeof(BarCodeModel), typeof(BarcodeControl), new PropertyMetadata(ChangedProperty)); + public static readonly DependencyProperty modelProperty = + DependencyProperty.Register("model", typeof(BarCodeModel), typeof(BarcodeControl), new PropertyMetadata(ChangedProperty)); private static void ChangedProperty(DependencyObject d, DependencyPropertyChangedEventArgs e) { diff --git a/BBWY.Client/Views/PackTask/CerControl.xaml b/BBWY.Client/Views/PackTask/CerControl.xaml index 594d12da..aabf219b 100644 --- a/BBWY.Client/Views/PackTask/CerControl.xaml +++ b/BBWY.Client/Views/PackTask/CerControl.xaml @@ -2,103 +2,161 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:BBWY.Client.Views.PackTask" - mc:Ignorable="d" + mc:Ignorable="d" Background="White" d:DesignHeight="300" d:DesignWidth="382"> - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + diff --git a/BBWY.Client/Views/PackTask/CerControl.xaml.cs b/BBWY.Client/Views/PackTask/CerControl.xaml.cs index 94a1f23a..5b3c3efd 100644 --- a/BBWY.Client/Views/PackTask/CerControl.xaml.cs +++ b/BBWY.Client/Views/PackTask/CerControl.xaml.cs @@ -22,7 +22,7 @@ namespace BBWY.Client.Views.PackTask public CerControl() { InitializeComponent(); - this.DataContext = CerData; + //this.DataContext = CerData; } @@ -30,18 +30,16 @@ namespace BBWY.Client.Views.PackTask /// /// /// - public CertificateModel CerData + public CertificateModel model { - get { return (CertificateModel)GetValue(CerDataProperty); } + get { return (CertificateModel)GetValue(modelProperty); } set { - SetValue(CerDataProperty, value); + SetValue(modelProperty, value); } } - - - public static readonly DependencyProperty CerDataProperty = - DependencyProperty.Register("CerData", typeof(CertificateModel), typeof(CerControl), new PropertyMetadata(ChangedProperty)); + public static readonly DependencyProperty modelProperty = + DependencyProperty.Register("model", typeof(CertificateModel), typeof(CerControl), new PropertyMetadata(ChangedProperty)); private static void ChangedProperty(DependencyObject d, DependencyPropertyChangedEventArgs e) { diff --git a/BBWY.Client/Views/PackTask/CreatePackTask.xaml b/BBWY.Client/Views/PackTask/CreatePackTask.xaml index ce097fe4..9cf14a67 100644 --- a/BBWY.Client/Views/PackTask/CreatePackTask.xaml +++ b/BBWY.Client/Views/PackTask/CreatePackTask.xaml @@ -169,7 +169,7 @@ - + @@ -219,7 +219,7 @@ - + @@ -240,38 +240,31 @@ - - - - + + - - + - - - - + + - - - + + - - - - + + diff --git a/BBWY.Client/Views/PackTask/LookCerWindow.xaml b/BBWY.Client/Views/PackTask/LookCerWindow.xaml index 1f98d54c..d7893ee0 100644 --- a/BBWY.Client/Views/PackTask/LookCerWindow.xaml +++ b/BBWY.Client/Views/PackTask/LookCerWindow.xaml @@ -6,8 +6,9 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:BBWY.Client.Views.PackTask" mc:Ignorable="d" + xmlns:hc="https://handyorg.github.io/handycontrol" Style="{StaticResource bwstyle}" - Height="340" Width="382" + Height="373" Width="386" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" xmlns:ctr="clr-namespace:BBWY.Client.Converters" xmlns:cmodel="clr-namespace:BBWY.Client.Models" @@ -17,9 +18,9 @@ MinButtonVisibility="Collapsed" MaxButtonVisibility="Collapsed" RightButtonGroupMargin="0,5,5,0" - ResizeMode="NoResize" + > - + @@ -29,126 +30,29 @@ Background="{StaticResource Border.Background}"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs b/BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs index 6896f26e..f5ff0e73 100644 --- a/BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs +++ b/BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs @@ -1,8 +1,10 @@ using BBWY.Client.Models; using BBWY.Controls; +using NPOI.Util; using Org.BouncyCastle.Crypto.Tls; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Windows; @@ -21,31 +23,22 @@ namespace BBWY.Client.Views.PackTask /// public partial class LookCerWindow : BWindow { - public LookCerWindow(CertificateModel certificate) + public LookCerWindow(CertificateModel[] certificate) { - + InitializeComponent(); - //CertificateModel data = new CertificateModel - //{ - // Brand = certificate.Brand, - // BrandName = certificate.BrandName, - // ExcuteStander = certificate.ExcuteStander, - // FactoryNumber = certificate.FactoryNumber, - // IsLogo = certificate.IsLogo, - // LabelModel = certificate.LabelModel, - // ProductAdress = certificate.ProductAdress, - // Id = certificate.Id, - // ProductDate = certificate.ProductDate, - // ProductNo = certificate.ProductNo, - // ProductShop = certificate.ProductShop, - // Shader = certificate.Shader, - // SkuId = certificate.SkuId, - // Reseller = certificate.Reseller, - // ApplyAge = certificate.ApplyAge, - //}; - - this.DataContext = certificate; + GoodsNumberCerList = new ObservableCollection(); + foreach (CertificateModel certificateModel in certificate) + GoodsNumberCerList.Add(new GoodsNumberCer + { + CertificateModel = certificateModel.Copy(), + }); + this.DataContext = this; } + + + + public ObservableCollection GoodsNumberCerList { get; set; } } } diff --git a/BBWY.Client/Views/PackTask/PrintWindow.xaml b/BBWY.Client/Views/PackTask/PrintWindow.xaml index b7d3bd35..8bd367c2 100644 --- a/BBWY.Client/Views/PackTask/PrintWindow.xaml +++ b/BBWY.Client/Views/PackTask/PrintWindow.xaml @@ -7,7 +7,8 @@ xmlns:local="clr-namespace:BBWY.Client.Views.PackTask" mc:Ignorable="d" Style="{StaticResource bwstyle}" - Height="510" Width="448" + Height="532" Width="486" + xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" xmlns:ctr="clr-namespace:BBWY.Client.Converters" xmlns:cmodel="clr-namespace:BBWY.Client.Models" @@ -17,7 +18,7 @@ MinButtonVisibility="Collapsed" MaxButtonVisibility="Collapsed" RightButtonGroupMargin="0,5,5,0" - ResizeMode="NoResize" + ResizeMode="NoResize" > @@ -110,9 +111,32 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + --> diff --git a/BBWY.Client/Views/PackTask/PrintWindow.xaml.cs b/BBWY.Client/Views/PackTask/PrintWindow.xaml.cs index ae8f1c9e..86c4772e 100644 --- a/BBWY.Client/Views/PackTask/PrintWindow.xaml.cs +++ b/BBWY.Client/Views/PackTask/PrintWindow.xaml.cs @@ -23,6 +23,8 @@ using System.Windows.Media.Imaging; using System.Windows.Media.Media3D; using System.Windows.Shapes; using System.Drawing.Printing; +using System.Collections.ObjectModel; +using BBWY.Client.Extensions; namespace BBWY.Client.Views.PackTask { @@ -34,9 +36,16 @@ namespace BBWY.Client.Views.PackTask public PrintWindow() { InitializeComponent(); - LoadPrints(); + this.Loaded += PrintWindow_Loaded; + } + + private void PrintWindow_Loaded(object sender, RoutedEventArgs e) + { + LoadPrints(); + } + /// /// 获取打印机名称 /// @@ -65,8 +74,7 @@ namespace BBWY.Client.Views.PackTask } - - + public ObservableCollection GoodsNumberCerList { get; set; } /// /// 加载预览打印数据 /// @@ -75,7 +83,15 @@ namespace BBWY.Client.Views.PackTask // PrintData data = new PrintData(); if (CertificateModel != null) { - this.DataContext = CertificateModel; + + GoodsNumberCerList = new ObservableCollection(); + foreach (CertificateModel certificateModel in CertificateModel) + GoodsNumberCerList.Add(new GoodsNumberCer + { + CertificateModel = certificateModel.Copy(), + }); + this.DataContext = this; + bar.Visibility = Visibility.Collapsed; cer.Visibility = Visibility.Visible; } @@ -88,7 +104,7 @@ namespace BBWY.Client.Views.PackTask } } - public CertificateModel CertificateModel { get; set; } + public CertificateModel[] CertificateModel { get; set; } public BarCodeModel BarCodeModel { get; set; } @@ -109,30 +125,63 @@ namespace BBWY.Client.Views.PackTask Task.Factory.StartNew(() => { - try + if (BarCodeModel != null) { - - 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(); - + PrintData(printCount, printName,BarCodeModel); + //MyPrintHelper.PrintBarcode(ref args, BarCodeModel, font); } - catch (Exception ex) + if (CertificateModel != null&& CertificateModel.Count()>0) { - App.Current.Dispatcher.Invoke(() => + foreach (var cer in CertificateModel) { - new TipsWindow("打印失败").ShowDialog(); - }); + PrintData(printCount, printName,null,cer); + System.Threading.Thread.Sleep(100); + // MyPrintHelper.PrintCertificate(ref args, cer, font); + } } + + + }); } + private void PrintData(int printCount, string printName, BarCodeModel barCode = null, CertificateModel certificateModel = null) + { + try + { + + PrintDocument document = new PrintDocument(); + document.PrinterSettings.PrinterName = printName;//使用打印机名称,指定特定的打印机进行打印。 + //设置打印页面 + //document.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 236, 157); + document.PrintPage += (s, a) => + { + Font font = new Font("宋体", 6, System.Drawing.FontStyle.Regular); + if (barCode != null) + { + MyPrintHelper.PrintBarcode(ref a, barCode, font); + } + if (certificateModel != null) + { + MyPrintHelper.PrintCertificate(ref a, certificateModel, font); + } + + }; + document.PrinterSettings.Copies = (short)printCount;//打印份数 + document.Print(); + + } + catch (Exception ex) + { + App.Current.Dispatcher.Invoke(() => + { + new TipsWindow("打印失败").ShowDialog(); + }); + + } + } private void Document_PrintPage(object sender, PrintPageEventArgs args) { @@ -174,7 +223,11 @@ namespace BBWY.Client.Views.PackTask } if (CertificateModel != null) { - MyPrintHelper.PrintCertificate(ref args, CertificateModel, font); + foreach (var cer in CertificateModel) + { + MyPrintHelper.PrintCertificate(ref args, cer, font); + } + } } diff --git a/BBWY.Client/Views/PackTask/PublishTaskWindow.xaml b/BBWY.Client/Views/PackTask/PublishTaskWindow.xaml new file mode 100644 index 00000000..e7b2b2df --- /dev/null +++ b/BBWY.Client/Views/PackTask/PublishTaskWindow.xaml @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/PackTask/PublishTaskWindow.xaml.cs b/BBWY.Client/Views/PackTask/PublishTaskWindow.xaml.cs new file mode 100644 index 00000000..845ba5dc --- /dev/null +++ b/BBWY.Client/Views/PackTask/PublishTaskWindow.xaml.cs @@ -0,0 +1,26 @@ +using BBWY.Controls; +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.Shapes; + +namespace BBWY.Client.Views.PackTask +{ + /// + /// PublishTaskWindow.xaml 的交互逻辑 + /// + public partial class PublishTaskWindow : BWindow + { + public PublishTaskWindow() + { + InitializeComponent(); + } + } +} diff --git a/BBWY.Client/Views/PackTask/SetCerControl.xaml b/BBWY.Client/Views/PackTask/SetCerControl.xaml index d6627082..18a3ce0d 100644 --- a/BBWY.Client/Views/PackTask/SetCerControl.xaml +++ b/BBWY.Client/Views/PackTask/SetCerControl.xaml @@ -19,87 +19,164 @@ - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/PackTask/SetCerWindow.xaml b/BBWY.Client/Views/PackTask/SetCerWindow.xaml index 6f4415cc..188a1a20 100644 --- a/BBWY.Client/Views/PackTask/SetCerWindow.xaml +++ b/BBWY.Client/Views/PackTask/SetCerWindow.xaml @@ -7,7 +7,8 @@ xmlns:local="clr-namespace:BBWY.Client.Views.PackTask" mc:Ignorable="d" Style="{StaticResource bwstyle}" - Height="860" Width="820" + xmlns:hc="https://handyorg.github.io/handycontrol" + Height="900" Width="850" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" xmlns:ctr="clr-namespace:BBWY.Client.Converters" xmlns:cmodel="clr-namespace:BBWY.Client.Models" @@ -18,7 +19,11 @@ MaxButtonVisibility="Collapsed" RightButtonGroupMargin="0,5,5,0"> + + + + @@ -31,16 +36,98 @@ + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + (); + + + foreach (var item in CertificateModel) + { + GoodsNumberCerList.Add(new GoodsNumberCer + { + CertificateModel = item.Copy(), + }); + + } this.DataContext = this; + } public bool IsSetSpuCertificate { get; set; } public PackTaskService packTaskService { get; set; } - public CertificateModel CertificateModel { get; set; } + public CertificateModel[] CertificateModel { get; set; } public CertificateModel SpuCertificateModel { get; set; } - public Action SaveResult { get; set; } + public Action SaveResult { get; set; } + + public ObservableCollection GoodsNumberCerList { get; set; } private void save_btn_Click(object sender, RoutedEventArgs e) { - 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)) - { - new TipsWindow("参数出错!请重新填写!").Show(); - return; - } - var standers = CertificateModel.ExcuteStander.Split(',', StringSplitOptions.RemoveEmptyEntries); - var resData = packTaskService.SaveCer(new CerRequest - { - Brand = CertificateModel.Brand, - BrandName = CertificateModel.BrandName, - ProductNo = CertificateModel.ProductNo, - SkuId = CertificateModel.SkuId, - ExcuteStander = CertificateModel.ExcuteStander, - LabelModel = (int)CertificateModel.LabelModel, - FactoryNumber = CertificateModel.FactoryNumber, - IsLogo = CertificateModel.IsLogo, - ProductAdress = CertificateModel.ProductAdress, - ProductShop = CertificateModel.ProductShop, - Shader = CertificateModel.Shader, - ApplyAge = CertificateModel.ApplyAge, - }); - if (resData == null || !resData.Success) + foreach (var item in GoodsNumberCerList) { - // IsSetCertificate = false; - return; + if (string.IsNullOrEmpty(item.CertificateModel.ExcuteStander) + || string.IsNullOrEmpty(item.CertificateModel.Shader) || string.IsNullOrEmpty(item.CertificateModel.BrandName) + || string.IsNullOrEmpty(item.CertificateModel.Brand) || string.IsNullOrEmpty(item.CertificateModel.ProductShop) + || string.IsNullOrEmpty(item.CertificateModel.ProductAdress)) + { + new TipsWindow("参数出错!请重新填写!").Show(); + return; + } + var standers = item.CertificateModel.ExcuteStander.Split(',', StringSplitOptions.RemoveEmptyEntries); + + var resData = packTaskService.SaveCer(new CerRequest + { + Brand = item.CertificateModel.Brand, + BrandName = item.CertificateModel.BrandName, + ProductNo = item.CertificateModel.ProductNo, + SkuId = item.CertificateModel.SkuId, + ExcuteStander = item.CertificateModel.ExcuteStander, + LabelModel = (int)item.CertificateModel.LabelModel, + FactoryNumber = item.CertificateModel.FactoryNumber, + IsLogo = item.CertificateModel.IsLogo, + ProductAdress = item.CertificateModel.ProductAdress, + ProductShop = item.CertificateModel.ProductShop, + Shader = item.CertificateModel.Shader, + ApplyAge = item.CertificateModel.ApplyAge, + GoodsNumber = item.CertificateModel.GoodsNumber, + ProduceDate= item.CertificateModel.ProduceDate, + + }); + if (resData == null || !resData.Success) + { + // IsSetCertificate = false; + return; + } + // IsNeedCertificateModel = "需要"; + item.CertificateModel.Id = resData.Data; + if (SaveResult != null) SaveResult(GoodsNumberCerList.Select(c => c.CertificateModel).ToArray()); + + //IsSetCertificate = false; + //setCerWindow.Close(); } - // IsNeedCertificateModel = "需要"; - CertificateModel.Id = resData.Data; - if (SaveResult != null) SaveResult(CertificateModel); this.Close(); - //IsSetCertificate = false; - //setCerWindow.Close(); } private void SetSpuCer_Click(object sender, RoutedEventArgs e) @@ -90,9 +116,9 @@ namespace BBWY.Client.Views.PackTask if (SpuCertificateModel == null) { SpuCertificateModel = new CertificateModel(); - SpuCertificateModel.ProductNo = CertificateModel.ProductNo; - SpuCertificateModel.Brand = CertificateModel.Brand; - SpuCertificateModel.SkuId = CertificateModel.SkuId; + SpuCertificateModel.ProductNo = CertificateModel[0].ProductNo; + SpuCertificateModel.Brand = CertificateModel[0].Brand; + SpuCertificateModel.SkuId = CertificateModel[0].SkuId; } SetSpuCerWindow setSpuCerWindow = new SetSpuCerWindow(); setSpuCerWindow.LoadData(SpuCertificateModel, packTaskService); @@ -107,6 +133,7 @@ namespace BBWY.Client.Views.PackTask setSpuCerWindow.Show(); } + int selectCer = -1;//tabcontrol 选中事件 private void InseartCer_Click(object sender, RoutedEventArgs e) { if (IsSetSpuCertificate) @@ -114,19 +141,72 @@ namespace BBWY.Client.Views.PackTask new TipsWindow("无可用模板").Show(); return; } + if (selectCer < 0) + { + new TipsWindow("未选中合格证").Show(); + return; + } + var cer = GoodsNumberCerList.SingleOrDefault(g => g.CertificateModel.GoodsNumber == selectCer); + cer.CertificateModel.Brand = SpuCertificateModel.Brand; + cer.CertificateModel.BrandName = SpuCertificateModel.BrandName; + cer.CertificateModel.ExcuteStander = SpuCertificateModel.ExcuteStander; + cer.CertificateModel.FactoryNumber = SpuCertificateModel.FactoryNumber; + cer.CertificateModel.IsLogo = SpuCertificateModel.IsLogo; + cer.CertificateModel.LabelModel = SpuCertificateModel.LabelModel; + cer.CertificateModel.ProductAdress = SpuCertificateModel.ProductAdress; + cer.CertificateModel.ProductNo = SpuCertificateModel.ProductNo; + cer.CertificateModel.Shader = SpuCertificateModel.Shader; + cer.CertificateModel.ProductShop = SpuCertificateModel.ProductShop; + cer.CertificateModel.ApplyAge = SpuCertificateModel.ApplyAge; + + } + + + private void add_goodsnum_Click(object sender, RoutedEventArgs e) + { + int num = 0; + p: + num++; + int goodsNumber = num; + var gncer = GoodsNumberCerList.SingleOrDefault(g => g.CertificateModel.GoodsNumber == goodsNumber); + if (gncer != null) goto p; + GoodsNumberCerList.Add(new GoodsNumberCer + { + CertificateModel = new CertificateModel + { + GoodsNumber = goodsNumber, + BrandName = CertificateModel[0].BrandName, + Brand = CertificateModel[0].Brand, + SkuId = CertificateModel[0].SkuId, + ProductNo = CertificateModel[0].ProductNo, + SpuId = CertificateModel[0].SkuId, + + } + }); + tab.SelectedIndex = GoodsNumberCerList.Count - 1; + this.UpdateLayout(); + } + - CertificateModel.Brand = SpuCertificateModel.Brand; - CertificateModel.BrandName = SpuCertificateModel.BrandName; - CertificateModel.ExcuteStander = SpuCertificateModel.ExcuteStander; - CertificateModel.FactoryNumber = SpuCertificateModel.FactoryNumber; - CertificateModel.IsLogo = SpuCertificateModel.IsLogo; - CertificateModel.LabelModel = SpuCertificateModel.LabelModel; - CertificateModel.ProductAdress = SpuCertificateModel.ProductAdress; - CertificateModel.ProductNo = SpuCertificateModel.ProductNo; - CertificateModel.Shader = SpuCertificateModel.Shader; - CertificateModel.ProductShop = SpuCertificateModel.ProductShop; - CertificateModel.ApplyAge = SpuCertificateModel.ApplyAge; + private void tab_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + var test = sender as HandyControl.Controls.TabControl; + if (test != null) + { + var select = test.SelectedItem as GoodsNumberCer; + if (select != null) + selectCer = select.CertificateModel.GoodsNumber; + } } } + + public class GoodsNumberCer + { + /// + /// 配件序号 + /// + // public int GoodsNumber { get; set; } + public CertificateModel CertificateModel { get; set; } + } } diff --git a/BBWY.Client/Views/PackTask/WareHouseList.xaml b/BBWY.Client/Views/PackTask/WareHouseList.xaml index e4e4be88..71decbf0 100644 --- a/BBWY.Client/Views/PackTask/WareHouseList.xaml +++ b/BBWY.Client/Views/PackTask/WareHouseList.xaml @@ -263,8 +263,6 @@ - -