diff --git a/BBWY.Client/APIServices/BatchPurchaseService.cs b/BBWY.Client/APIServices/BatchPurchaseService.cs index b9c0b993..237f9eb5 100644 --- a/BBWY.Client/APIServices/BatchPurchaseService.cs +++ b/BBWY.Client/APIServices/BatchPurchaseService.cs @@ -144,30 +144,54 @@ namespace BBWY.Client.APIServices return SendRequest(globalContext.BBYWApiHost, "api/BatchPurchase/PayPurchaseOrder", new { orderId, - PurchasePlatform, - purchaseAccount, - globalContext.User.Shop.ShopId, - globalContext.User.Shop.ShopName, - globalContext.User.Shop.AppKey, - globalContext.User.Shop.AppSecret, - globalContext.User.Shop.AppToken + Platform = purchaseAccount.PurchasePlatformId, + purchaseAccount.AppKey, + purchaseAccount.AppSecret, + purchaseAccount.AppToken, }, null, HttpMethod.Post); } - public ApiResponse CancelOrder(string orderId,Platform PurchasePlatform, PurchaseAccount purchaseAccount, string remark="") + public ApiResponse CancelOrder(string orderId, PurchaseAccount purchaseAccount, string remark="") { return SendRequest(globalContext.BBYWApiHost, "api/BatchPurchase/CancelPurchaseOrder", new { orderId, - PurchasePlatform, - purchaseAccount, + Platform = purchaseAccount.PurchasePlatformId, + purchaseAccount.AppKey, + purchaseAccount.AppSecret, + purchaseAccount.AppToken, remark, - globalContext.User.Shop.ShopId, - globalContext.User.Shop.ShopName, - globalContext.User.Shop.AppKey, - globalContext.User.Shop.AppSecret, - globalContext.User.Shop.AppToken + }, null, HttpMethod.Post); + } + + /// + /// 修改打包状态 + /// + /// + /// + /// + public ApiResponse UpdatePackState(string orderId, PackState packState) + { + return SendRequest(globalContext.BBYWApiHost, "api/BatchPurchase/UpdatePackState", new + { + orderId, + packState + }, null, HttpMethod.Post); + } + + /// + /// 修改采购单状态 + /// + /// + /// + /// + public ApiResponse UpdatePurchaseOrderState(string orderId, PurchaseOrderState PurchaseOrderState) + { + return SendRequest(globalContext.BBYWApiHost, "api/BatchPurchase/UpdatePurchaseOrderState", new + { + orderId, + PurchaseOrderState }, null, HttpMethod.Post); } diff --git a/BBWY.Client/APIServices/PackTaskService.cs b/BBWY.Client/APIServices/PackTaskService.cs index 0706efb2..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,18 +132,18 @@ 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) + public ApiResponse UpdateTaskStatus(long id, int taskStatus, string orderId) { return SendRequest(globalContext.QKApiHost, "api/PackTask/UpdatePackTaskStatus", new { id, - taskStatus - + taskStatus, + orderId } , null, HttpMethod.Post); } @@ -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; } } @@ -305,6 +323,10 @@ namespace BBWY.Client.APIServices public decimal? ConsumableFees { get; set; } public decimal? DiscountPrice { get; set; } + + public string OrderId { get; set; } + + public string SkuId { get; set; } } public class PersonTaskModel @@ -343,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 9622efaf..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/Converters/EnumToColorConverter.cs b/BBWY.Client/Converters/EnumToColorConverter.cs index a5c50883..dc4d8eb4 100644 --- a/BBWY.Client/Converters/EnumToColorConverter.cs +++ b/BBWY.Client/Converters/EnumToColorConverter.cs @@ -20,16 +20,20 @@ namespace BBWY.Client.Converters if (value == null) return DependencyProperty.UnsetValue; Assembly assem = Assembly.GetExecutingAssembly(); Type type = assem.GetType(parameter.ToString()); + + var enumName = Enum.Parse(type, value.ToString()); - if (value.ToString() == TaskState.已到货.GetName()) + if (enumName == null) return DependencyProperty.UnsetValue; + int enumIndex = (int)enumName; + if ((enumIndex == 0)) { return "#C1FFC1"; } - if (value.ToString() == "部分到货") + if (enumIndex == 1) { return "#FFDEAD"; } - if (value.ToString() == "未到货") + if(enumIndex==2) { return "#FFDAB9"; 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 8a9b8902..739c31ff 100644 --- a/BBWY.Client/Models/APIModel/Request/CreateTaskRequest.cs +++ b/BBWY.Client/Models/APIModel/Request/CreateTaskRequest.cs @@ -92,15 +92,22 @@ 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; } public Worry IsWorry { get; set; } + public string OrderId { get; set; } + public Platform Platform { get; set; } } } diff --git a/BBWY.Client/Models/APIModel/Response/BatchPurchase/PurchaseOrderV2Response.cs b/BBWY.Client/Models/APIModel/Response/BatchPurchase/PurchaseOrderV2Response.cs index 62019c13..c2278421 100644 --- a/BBWY.Client/Models/APIModel/Response/BatchPurchase/PurchaseOrderV2Response.cs +++ b/BBWY.Client/Models/APIModel/Response/BatchPurchase/PurchaseOrderV2Response.cs @@ -173,7 +173,13 @@ namespace BBWY.Client.Models /// public PurchaseOrderMode PurchaseOrderMode { get; set; } + /// + /// 打包状态(待发布 = 0, 打包中 = 1, 已完成 = 2) + /// + public PackState PackState { get; set; } + public IList ItemList { get; set; } } + } diff --git a/BBWY.Client/Models/APIModel/Response/PackTask/PackTaskResultResponse.cs b/BBWY.Client/Models/APIModel/Response/PackTask/PackTaskResultResponse.cs index 9bd05317..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; } /// /// 是否加急 /// @@ -168,13 +168,13 @@ namespace BBWY.Client.Models.APIModel.Response.PackTask /// /// 品牌 /// - public string Brand { get; set; } - + public string Brand { 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 new file mode 100644 index 00000000..f01a0921 --- /dev/null +++ b/BBWY.Client/Models/BatchPurchase/BatchPublishTask.cs @@ -0,0 +1,573 @@ +using BBWY.Client.APIServices; +using BBWY.Client.Models.PackTask; +using BBWY.Client.ViewModels; +using BBWY.Client.Views.PackTask; +using BBWY.Common.Models; +using GalaSoft.MvvmLight.Command; +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.Models +{ + //public class ComboxItem + //{ + // public int { get; set; } + //} + public class BatchPublishTask : NotifyObject + { + + #region 属性 + 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) + /// + 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); } } + #endregion + string[] increates = new string[] { "气泡纸", "气泡袋", "POP袋", "折纸箱", "气泡纸封边", "彩盒", "剪胶", "剪彩带", "快递袋", "收纳盒", "纸箱子", "装纸箱", "封边", "胶带", "折彩盒" }; + public PackTaskService packTaskService; + public ProductService productService; + public BatchPublishTask() + { + IncreateList = new ObservableCollection(); + foreach (var item in increates) + { + IncreateList.Add(new IncreateModel + { + IncreateName = item, + IsSelected = false + }); + } + SetBarCodeCommand = new RelayCommand(SetBarCode); + SetCertificateCommand = new RelayCommand(SetCertificate); + LookBarCommand = new RelayCommand(LookBar); + LookCerCommand = new RelayCommand(LookCer); + + } + #region 方法 + public ICommand SetBarCodeCommand { get; set; } + public ICommand SetCertificateCommand { get; set; } + public ICommand LookBarCommand { get; set; } + public ICommand LookCerCommand { 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(string skuid) + { + if (string.IsNullOrEmpty(skuid)) + return; + + 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 void InitData() + { + + IncreateList = new ObservableCollection(); + SpuId = string.Empty; + SaveTask = "发布"; + + Logo = string.Empty; + + 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 + }); + } + //SearchSku(SkuId); + + } + + #endregion + + } +} diff --git a/BBWY.Client/Models/Enums.cs b/BBWY.Client/Models/Enums.cs index a0b9eee3..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 } /// /// 合格证包装位置 @@ -384,4 +385,14 @@ 未结算 = 0, 已结清 = 1 } + + public enum Need + { + 不需要=0, + 需要=1 + } + public enum PackState + { + 待发布 = 0, 打包中 = 1, 已完成 = 2 + } } 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/ConsumableModel.cs b/BBWY.Client/Models/PackTask/ConsumableModel.cs index 5437d1b1..3125d821 100644 --- a/BBWY.Client/Models/PackTask/ConsumableModel.cs +++ b/BBWY.Client/Models/PackTask/ConsumableModel.cs @@ -4,11 +4,13 @@ using BBWY.Client.ViewModels; using BBWY.Client.Views.PackTask; using BBWY.Common.Models; using GalaSoft.MvvmLight.Command; +using HandyControl.Controls; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Resources; using System.Text; +using System.Windows; using System.Windows.Input; using System.Windows.Media.TextFormatting; @@ -95,6 +97,11 @@ namespace BBWY.Client.Models.PackTask public void DeletedConsumable(ObservableCollection list) { + MessageBoxResult result =System.Windows. MessageBox.Show("是否删除?", "提示", + MessageBoxButton.YesNo, + MessageBoxImage.Warning); + if (result != MessageBoxResult.Yes) return; + var res = consumableService.Deleted(Id); if (res.Success) { diff --git a/BBWY.Client/Models/PackTask/PackTaskModel.cs b/BBWY.Client/Models/PackTask/PackTaskModel.cs index f5406aa9..1f2f0dbd 100644 --- a/BBWY.Client/Models/PackTask/PackTaskModel.cs +++ b/BBWY.Client/Models/PackTask/PackTaskModel.cs @@ -27,10 +27,8 @@ namespace BBWY.Client.Models private long id; public long Id { get => id; set { Set(ref id, value); } } - private readonly PackTaskService packTaskService; - readonly WorkProcessService workProcessService; - readonly IncreateServiceService increateServiceService; - public ICommand SetTaskStatusCommand { get; set; } + + public ICommand PrintBarcodeCommand { get; set; } public ICommand PrintCerCommand { get; set; } @@ -38,66 +36,55 @@ namespace BBWY.Client.Models public ICommand LookBarCommand { get; set; } public ICommand SetServiceCommand { get; set; } - public ConsumableService consumableService; - /// /// 修改任务 /// public ICommand UpdateTaskCommand { get; set; } - /// - /// 删除任务 - /// - public ICommand DeletedTaskCommand { get; set; } + public Action ReflashTask { get; set; } - private void DeletedTask() - { - MessageBoxResult result = MessageBox.Show("确定删除?", "提示", - MessageBoxButton.YesNo, - MessageBoxImage.Warning); - if (result != MessageBoxResult.Yes) return; - packTaskService.DeletedTask(TaskId); - if (ReflashTask != null) - ReflashTask();//刷新界面 - } + 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(); } - public PackTaskModel(PackTaskService packTaskService, ConsumableService consumableService, WorkProcessService workProcessService, IncreateServiceService increateServiceService) + public PackTaskModel() { - - SetTaskStatusCommand = new RelayCommand(SetTaskStatus); PrintBarcodeCommand = new RelayCommand(PrintBarcode); PrintCerCommand = new RelayCommand(PrintCer); LookBarCommand = new RelayCommand(LookBar); LookCerCommand = new RelayCommand(LookCer); SetServiceCommand = new RelayCommand(SetService); UpdateTaskCommand = new RelayCommand(UpdateTask); - DeletedTaskCommand = new RelayCommand(DeletedTask); - this.packTaskService = packTaskService; - this.consumableService = consumableService; - this.workProcessService = workProcessService; - this.increateServiceService = increateServiceService; } private void SetService() @@ -108,12 +95,14 @@ namespace BBWY.Client.Models var serviceViewModel = viewModelLocator.PackServiceList; serviceViewModel.TaskCount = SkuCount; serviceViewModel.TaskId = TaskId; + serviceViewModel.OrderId= OrderId; + serviceViewModel.SkuId =SkuId ; serviceViewModel.LoadPackDatas(); serviceViewModel.SetAllFees = new Action>((feesItem, packUsers) => { FeesItemResponse = feesItem; PackUser = string.Join("\r\n", packUsers); - + FeesItemResponse.DiscountAllFees = feesItem.disCount * feesItem.AllFees; IsShowFees = feesItem.AllFees > 0 ? true : false; }); service.Show(); @@ -198,23 +187,7 @@ namespace BBWY.Client.Models //printWindow.Datas = LoadBarLabelModels(); printWindow.Show(); } - - public void SetTaskStatus(long taskId) - { - - if (this.TaskStatus == TaskStateType.已完成) - { - return; - - } - ///修改完成 - var model = packTaskService.UpdateTaskStatus(taskId, 1); - if (model != null && model.Success) - { - this.TaskStatus = TaskStateType.已完成; - new TipsWindow("修改成功").Show(); - } - } + /* public Dictionary LoadBarLabelModels() { @@ -447,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) @@ -497,6 +470,8 @@ namespace BBWY.Client.Models public FeesItemResponse FeesItemResponse { get => feesItemResponse; set { Set(ref feesItemResponse, value); } } public IList ItemList { get; set; } + + public string OrderId { get; set; } } public class SkuMessage : NotifyObject diff --git a/BBWY.Client/ViewModels/BaseVM.cs b/BBWY.Client/ViewModels/BaseVM.cs index 28a6ae70..c4a8b336 100644 --- a/BBWY.Client/ViewModels/BaseVM.cs +++ b/BBWY.Client/ViewModels/BaseVM.cs @@ -22,11 +22,11 @@ namespace BBWY.Client.ViewModels LoadCommand = new RelayCommand(Load); UnloadCommand = new RelayCommand(Unload); - CopyTextCommand = new RelayCommand(s => + CopyTextCommand = new RelayCommand(s => { try { - Clipboard.SetText(s); + Clipboard.SetText(s.ToString()); } catch (Exception ex) { diff --git a/BBWY.Client/ViewModels/BatchPurchase/BatchPublishTaskViewModel.cs b/BBWY.Client/ViewModels/BatchPurchase/BatchPublishTaskViewModel.cs new file mode 100644 index 00000000..e629206f --- /dev/null +++ b/BBWY.Client/ViewModels/BatchPurchase/BatchPublishTaskViewModel.cs @@ -0,0 +1,175 @@ +using BBWY.Client.APIServices; +using BBWY.Client.Models; +using BBWY.Client.Views.PackTask; +using BBWY.Common.Models; +using GalaSoft.MvvmLight.Command; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Net.Mail; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using System.Linq; +using System.Windows; +using GalaSoft.MvvmLight.Messaging; + +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); } } + public ICommand OpenSkuDetailCommand { get; set; } + public ICommand CreateTaskCommand { get; set; } + public BatchPublishTaskViewModel(PackTaskService packTaskService, ProductService productService, GlobalContext globalContext) + { + BatchPublishTasks = new ObservableCollection(); + this.packTaskService = packTaskService; + this.productService = productService; + + this.globalContext = globalContext; + CreateTaskCommand = new RelayCommand(CreateTask); + OpenSkuDetailCommand = new RelayCommand(OpenSkuDetail); + + + + } + 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) + { + foreach (var task in BatchPublishTasks) + { + string increateStr = ""; + var increates = task.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 = task.ProductNo, + Logo = task.Logo, + SkuName = task.SkuName, + BrandName = task.BrandName, + Availability = (int)task.Availability, + BasicPack = (int)task.BasicPack, + SkuId = task.SkuId, + CreateTime = DateTime.Now, + Increment1 = increateStr, + CertificatePosition = (int)task.CertificatePosition, + PackType = (int)task.PackType, + MarkMessage = task.MarkMessage, + PositionType = (int)task.PositionType, + GoodsNumber = task.GoodsNumber, + SkuGoodsTitle = task.SkuTitle, + SkuCount = task.SkuCount, + UserId = globalContext.User.Id.ToString(), + ShopId = PurchaserId, + //IsWorry = task.IsWorry, + OrderId = orderId, + Platform =platform + }; + if (task.IsNeedBarCode == Need.需要) + { + if (task.BarCodeModel == null || task.BarCodeModel.Id <= 0) + { + new TipsWindow("请设置条形码模板").Show(); + return; + } + createTaskModel.BarCodeId = task.BarCodeModel.Id; + } + if (task.IsNeedCertificateModel == Need.需要) + { + if (task.CertificateModel == null || task.CertificateModel.Count() <= 0) + { + new TipsWindow("请设置合格证模板").Show(); + return; + } + createTaskModel.CerId =string.Join(",", task.CertificateModel.Where(c=>c.Id>0).Select(c=>c.Id));// + } + ApiResponse res = null; + res = packTaskService.CreateTask(createTaskModel); + + if (!res.Success) + { + new TipsWindow(res.Msg); + return; + } + } + //var win = obj as System.Windows.Window; + + Messenger.Default.Send(true, "CloseBatchPublishTaskWindow"); + //win.Close(); + if (PublishTask != null) PublishTask(); + + } + + + + public Action PublishTask { get; set; } + + + Platform platform; string orderId; string PurchaserId; + public void AddSkus(Platform platform, string orderId, string PurchaserId, List purchaseOrderSkus) + { + BatchPublishTasks = new ObservableCollection(); + this.platform = platform; this.orderId = orderId; + this.PurchaserId = PurchaserId; + BatchPublishTask model = null; + IsLoading = true; + foreach (var item in purchaseOrderSkus) + { + model = new BatchPublishTask(); + model.productService = productService; + model.packTaskService = packTaskService; + model.SkuId = item.SkuId; + model.SkuCount = item.Quantity.Value; + model.Logo = item.Logo.Replace("80x80", "200x200"); + model.SpuId = item.ProductId; + model.SkuName = item.SkuTitle; + model.SearchSku(item.SkuId); + App.Current.Dispatcher.Invoke(() => + { + BatchPublishTasks.Add(model); + }); + + } + + IsLoading = false; + } + + + } +} diff --git a/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseOrderListViewModel.cs b/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseOrderListViewModel.cs index 463d9ea4..7e381de6 100644 --- a/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseOrderListViewModel.cs +++ b/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseOrderListViewModel.cs @@ -1,5 +1,6 @@ using BBWY.Client.APIServices; using BBWY.Client.Models; +using BBWY.Client.ViewModels; using BBWY.Client.Views.BatchPurchase; using BBWY.Common.Extensions; using BBWY.Common.Models; @@ -11,12 +12,14 @@ using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; using System.Windows; +using System.Windows.Data; using System.Windows.Input; namespace BBWY.Client.ViewModels { public class BatchPurchaseOrderListViewModel : BaseVM, IDenpendency { + private PackTaskService packTaskService; private BatchPurchaseService batchPurchaseService; private GlobalContext globalContext; private DateTime startDate; @@ -44,6 +47,9 @@ 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); } } public string SearchPurchaseOrderId { get => searchPurchaseOrderId; set { Set(ref searchPurchaseOrderId, value); } } @@ -61,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); @@ -72,15 +78,63 @@ namespace BBWY.Client.ViewModels PayPurchaseOrderCommand = new RelayCommand(PayPurchaseOrder); 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) + { + var parameters = (object[])obj; + var PurchasePlatform = (Platform)parameters[0];//采购平台 + var id = parameters[1].ToString();//订单id + var itemList = (List)parameters[2];//skuid 数量 + var PurchaserId = (string)parameters[3];//采购商id + + + ViewModelLocator viewModelLocator = new ViewModelLocator(); + BatchPublishTaskViewModel batch = viewModelLocator.BatchPublishTask; + + + batch.PublishTask = () => { + //修改 打包状态 + 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) { @@ -96,14 +150,22 @@ namespace BBWY.Client.ViewModels var purchaseAccount = globalContext.User.Shop.PurchaseAccountList.FirstOrDefault(p => p.PurchasePlatformId == PurchasePlatform); - var res = batchPurchaseService.CancelOrder(parameters[1].ToString(), PurchasePlatform, purchaseAccount, ""); + var res = batchPurchaseService.CancelOrder(parameters[1].ToString(), purchaseAccount, ""); if (res.Success) { - Task.Factory.StartNew(() => QueryPurchaseOrder(PageIndex)); + if (res.Data.Success) + { + Task.Factory.StartNew(() => QueryPurchaseOrder(PageIndex)); + return; + } + + MessageBox.Show(res.Data.Msg); return; } if (res.Data != null) MessageBox.Show(res.Data.Msg); + else + MessageBox.Show(res.Msg); } private void PayPurchaseOrder(object obj) @@ -120,11 +182,19 @@ namespace BBWY.Client.ViewModels var res = batchPurchaseService.PayOrder(parameters[1].ToString(), PurchasePlatform, purchaseAccount); if (res.Success) { - Task.Factory.StartNew(() => QueryPurchaseOrder(PageIndex)); + if (res.Data.Success) + { + Task.Factory.StartNew(() => QueryPurchaseOrder(PageIndex)); + return; + } + MessageBox.Show(res.Data.Msg); return; } if (res.Data != null) MessageBox.Show(res.Data.Msg); + else + MessageBox.Show(res.Msg); + } diff --git a/BBWY.Client/ViewModels/PackTask/CreatePackTaskViewModel.cs b/BBWY.Client/ViewModels/PackTask/CreatePackTaskViewModel.cs index 70f9d939..9905066c 100644 --- a/BBWY.Client/ViewModels/PackTask/CreatePackTaskViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/CreatePackTaskViewModel.cs @@ -24,6 +24,43 @@ namespace BBWY.Client.ViewModels.PackTask public class CreatePackTaskViewModel : BaseVM, IDenpendency { + #region 属性 + 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); } } @@ -82,12 +119,6 @@ namespace BBWY.Client.ViewModels.PackTask public string SkuName { get => skuName; set { Set(ref skuName, value); } } - //private long barCodeId; - ///// - ///// 条形码id - ///// - //public long BarCodeId { get => barCodeId; set { Set(ref barCodeId, value); } } - private string brand; /// /// 品牌 @@ -131,12 +162,6 @@ namespace BBWY.Client.ViewModels.PackTask /// public int GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } } - private DateTime endTime; - /// - /// 提交时间 - /// - public DateTime EndTime { get => endTime; set { Set(ref endTime, value); } } - private long taskId; /// @@ -173,14 +198,6 @@ namespace BBWY.Client.ViewModels.PackTask public TaskState Availability { get => availability; set { Set(ref availability, value); } } - - private int taskStatus; - /// - /// 任务状态(已完成=0,未完成=1) - /// - public int TaskStatus { get => taskStatus; set { Set(ref taskStatus, value); } } - - private PackType packType; /// /// 打包类型(单件=0,多件=1) @@ -222,18 +239,18 @@ namespace BBWY.Client.ViewModels.PackTask /// public PositionType PositionType { get => positionType; set { Set(ref positionType, value); } } - private string isNeedBarCode; + private Need isNeedBarCode; /// /// 是否需要合格证 /// - public string IsNeedBarCode { get => isNeedBarCode; set { Set(ref isNeedBarCode, value); } } + public Need IsNeedBarCode { get => isNeedBarCode; set { Set(ref isNeedBarCode, value); } } - private string isNeedCertificateModel; + private Need isNeedCertificateModel; /// /// 是否需要条形码 /// - public string IsNeedCertificateModel { get => isNeedCertificateModel; set { Set(ref isNeedCertificateModel, value); } } + public Need IsNeedCertificateModel { get => isNeedCertificateModel; set { Set(ref isNeedCertificateModel, value); } } @@ -255,7 +272,7 @@ namespace BBWY.Client.ViewModels.PackTask { Set(ref isSetBarCode, value); - IsNeedBarCode = IsSetBarCode ? "不需要" : "需要"; + IsNeedBarCode = IsSetBarCode ? Need.不需要 : Need.需要; } } @@ -269,7 +286,7 @@ namespace BBWY.Client.ViewModels.PackTask { Set(ref isSetCertificate, value); - IsNeedCertificateModel = IsSetCertificate ? "不需要" : "需要"; + IsNeedCertificateModel = IsSetCertificate ? Need.不需要 : Need.需要; } } private string setSpuCerStatus; @@ -295,14 +312,14 @@ namespace BBWY.Client.ViewModels.PackTask private string saveTask; /// - /// 设置显示(合格证) + /// 发布按钮(发布/保存) /// public string SaveTask { get => saveTask; set { Set(ref saveTask, value); } } private string spuId; /// - /// 合格证 + /// spu /// public string SpuId { get => spuId; set { Set(ref spuId, value); } } @@ -314,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) @@ -337,42 +354,13 @@ namespace BBWY.Client.ViewModels.PackTask /// 注意事项(对接备注) /// public string MarkMessage { get => markMessage; set { Set(ref markMessage, value); } } + #endregion + - /// - /// 服务收费 (单个任务id 消耗的总费用) - /// - private decimal feesMoney; - /// - /// 服务收费 (单个任务id 消耗的总费用) - /// - public decimal FeesMoney { get => feesMoney; set { Set(ref feesMoney, value); } } - /// - /// 打包员 - /// - private string packUser; - /// - /// 打包员 - /// - public string PackUser { get => packUser; set { Set(ref packUser, value); } } - private string printName; - /// - /// 选中的打印机名称 - /// - public string PrintName { get => printName; set { Set(ref printName, value); } } - private List printNames; - /// - /// 选中的打印机名称 - /// - public List PrintNames { get => printNames; set { Set(ref printNames, value); } } - private int printNums; - /// - /// 打印数 - /// - public int PrintNums { get => printNums; set { Set(ref printNums, value); } } private readonly PackTaskService packTaskService; @@ -402,13 +390,13 @@ namespace BBWY.Client.ViewModels.PackTask string[] increates = new string[] { "气泡纸", "气泡袋", "POP袋", "折纸箱", "气泡纸封边", "彩盒", "剪胶", "剪彩带", "快递袋", "收纳盒", "纸箱子", "装纸箱", "封边", "胶带", "折彩盒" }; public void InitData(PackTaskModel model = null) { - + IncreateList = new ObservableCollection(); SpuId = string.Empty; if (model == null) { - + SaveTask = "发布"; TaskId = 0; Logo = string.Empty; @@ -458,8 +446,8 @@ namespace BBWY.Client.ViewModels.PackTask PositionType = model.PositionType; PackType = model.PackType; BasicPack = model.BasicPack; - IsNeedBarCode = model.BarCodeModel != null ? "需要" : "不需要"; - IsNeedCertificateModel = model.CertificateModel != null ? "需要" : "不需要"; + IsNeedBarCode = model.BarCodeModel == null ? Need.不需要 : Need.需要; + IsNeedCertificateModel = model.CertificateModel == null ? Need.不需要 : Need.需要; CertificatePosition = model.CertificatePosition; TaskId = model.TaskId; string[] increateDatas = model.Increment1.Split(','); @@ -472,7 +460,8 @@ namespace BBWY.Client.ViewModels.PackTask { isSelected = true; } - App.Current.Dispatcher.Invoke(() => { + App.Current.Dispatcher.Invoke(() => + { IncreateList.Add(new IncreateModel { IncreateName = item, @@ -501,7 +490,7 @@ namespace BBWY.Client.ViewModels.PackTask IsSetCertificate = true; //数据库获取增量耗材数据 - + IncreateList = new ObservableCollection(); foreach (var item in increates) { @@ -521,103 +510,104 @@ namespace BBWY.Client.ViewModels.PackTask this.globalContext = globalContext; SetBarCodeCommand = new RelayCommand(SetBarCode); SetCertificateCommand = new RelayCommand(SetCertificate); - SaveBarCodeCommand = new RelayCommand(SaveBarCode); + //SaveBarCodeCommand = new RelayCommand(SaveBarCode); - SetSpuCerCommand = new RelayCommand(SetSpuCer); - SaveSpuCerCommand = new RelayCommand(SaveSpuCer); - InseartCerCommand = new RelayCommand(InseartCer); + //SetSpuCerCommand = new RelayCommand(SetSpuCer); + //SaveSpuCerCommand = new RelayCommand(SaveSpuCer); + //InseartCerCommand = new RelayCommand(InseartCer); - SaveCerCommand = new RelayCommand(SaveCer); + //SaveCerCommand = new RelayCommand(SaveCer); BarLabelCheckCommand = new RelayCommand(BarLabelCheck); - CerLabelCheckCommand = new RelayCommand(CerLabelCheck); - SpuCerLabelCheckCommand = new RelayCommand(SpuCerLabelCheck); + //CerLabelCheckCommand = new RelayCommand(CerLabelCheck); + //SpuCerLabelCheckCommand = new RelayCommand(SpuCerLabelCheck); LookBarCommand = new RelayCommand(LookBar); LookCerCommand = new RelayCommand(LookCer); - PrintNames = new List(); + delayTrigger = new DelayTrigger(500); delayTrigger.OnExecute = OnSearchIncreateKeyWordChanged; BarLabelCheck(BarcodeLabelModel.精简模板);//默认精简模式 } - private void InseartCer() - { - if (IsSetSpuCertificate) - { - new TipsWindow("无可用模板").Show(); - return; - } - CertificateModel = new CertificateModel() - { - //SpuId = SpuCertificateModel.SpuId, - SkuId = SkuId, - Brand = SpuCertificateModel.Brand, - BrandName = SpuCertificateModel.BrandName, - ExcuteStander = SpuCertificateModel.ExcuteStander, - FactoryNumber = SpuCertificateModel.FactoryNumber, - IsLogo = SpuCertificateModel.IsLogo, - LabelModel = SpuCertificateModel.LabelModel, - ProductAdress = SpuCertificateModel.ProductAdress, - ProductNo = SpuCertificateModel.ProductNo, - Shader = SpuCertificateModel.Shader, - ProductShop = SpuCertificateModel.ProductShop, - ApplyAge = SpuCertificateModel.ApplyAge, - }; - } - - private void SetSpuCer() - { - - if (SpuCertificateModel == null) - { - SpuCertificateModel = new CertificateModel(); - SpuCertificateModel.ProductNo = ProductNo; - SpuCertificateModel.Brand = Brand; - SpuCertificateModel.SkuId = SkuId; - } - SpuCertificateModel.BrandName = BrandName; - setSpuCerWindow = new SetSpuCerWindow(); - setSpuCerWindow.Show(); - } - - private void SaveSpuCer() - { - if (string.IsNullOrEmpty(SpuCertificateModel.ExcuteStander) - || string.IsNullOrEmpty(SpuCertificateModel.BrandName) - || string.IsNullOrEmpty(SpuCertificateModel.Brand) || string.IsNullOrEmpty(SpuCertificateModel.ProductShop) - || string.IsNullOrEmpty(SpuCertificateModel.ProductAdress)) - { - new TipsWindow("参数出错!请重新填写!").Show(); - return; - } - var resData = packTaskService.SaveSpuCer(new CerRequest - { - Brand = SpuCertificateModel.Brand, - BrandName = SpuCertificateModel.BrandName, - ProductNo = SpuCertificateModel.ProductNo, - SpuId = SpuCertificateModel.SpuId, - ExcuteStander = SpuCertificateModel.ExcuteStander, - LabelModel = (int)SpuCertificateModel.LabelModel, - FactoryNumber = SpuCertificateModel.FactoryNumber, - IsLogo = SpuCertificateModel.IsLogo, - ProductAdress = SpuCertificateModel.ProductAdress, - ProductShop = SpuCertificateModel.ProductShop, - Shader = SpuCertificateModel.Shader, - SkuId = SpuCertificateModel.SkuId, - ApplyAge = SpuCertificateModel.ApplyAge, - - - - }); - if (resData == null || !resData.Success) - { - IsSetSpuCertificate = false; - return; - } - IsSetSpuCertificate = false; - setSpuCerWindow.Close(); - } + //private void InseartCer() + //{ + // if (IsSetSpuCertificate) + // { + // new TipsWindow("无可用模板").Show(); + // return; + // } + // CertificateModel = new CertificateModel() + // { + // //SpuId = SpuCertificateModel.SpuId, + // SkuId = SkuId, + // Brand = SpuCertificateModel.Brand, + // BrandName = SpuCertificateModel.BrandName, + // ExcuteStander = SpuCertificateModel.ExcuteStander, + // FactoryNumber = SpuCertificateModel.FactoryNumber, + // IsLogo = SpuCertificateModel.IsLogo, + // LabelModel = SpuCertificateModel.LabelModel, + // ProductAdress = SpuCertificateModel.ProductAdress, + // ProductNo = SpuCertificateModel.ProductNo, + // Shader = SpuCertificateModel.Shader, + // ProductShop = SpuCertificateModel.ProductShop, + // ApplyAge = SpuCertificateModel.ApplyAge, + // }; + //} + + //private void SetSpuCer() + //{ + + // if (SpuCertificateModel == null) + // { + // SpuCertificateModel = new CertificateModel(); + // SpuCertificateModel.ProductNo = ProductNo; + // SpuCertificateModel.Brand = Brand; + // SpuCertificateModel.SkuId = SkuId; + // } + // if (!string.IsNullOrEmpty(BrandName)) + // SpuCertificateModel.BrandName = BrandName; + // setSpuCerWindow = new SetSpuCerWindow(); + // setSpuCerWindow.Show(); + //} + + //private void SaveSpuCer() + //{ + // if (string.IsNullOrEmpty(SpuCertificateModel.ExcuteStander) + // || string.IsNullOrEmpty(SpuCertificateModel.BrandName) + // || string.IsNullOrEmpty(SpuCertificateModel.Brand) || string.IsNullOrEmpty(SpuCertificateModel.ProductShop) + // || string.IsNullOrEmpty(SpuCertificateModel.ProductAdress)) + // { + // new TipsWindow("参数出错!请重新填写!").Show(); + // return; + // } + // var resData = packTaskService.SaveSpuCer(new CerRequest + // { + // Brand = SpuCertificateModel.Brand, + // BrandName = SpuCertificateModel.BrandName, + // ProductNo = SpuCertificateModel.ProductNo, + // SpuId = SpuCertificateModel.SpuId, + // ExcuteStander = SpuCertificateModel.ExcuteStander, + // LabelModel = (int)SpuCertificateModel.LabelModel, + // FactoryNumber = SpuCertificateModel.FactoryNumber, + // IsLogo = SpuCertificateModel.IsLogo, + // ProductAdress = SpuCertificateModel.ProductAdress, + // ProductShop = SpuCertificateModel.ProductShop, + // Shader = SpuCertificateModel.Shader, + // SkuId = SpuCertificateModel.SkuId, + // ApplyAge = SpuCertificateModel.ApplyAge, + + + + // }); + // if (resData == null || !resData.Success) + // { + // IsSetSpuCertificate = false; + // return; + // } + // IsSetSpuCertificate = false; + // setSpuCerWindow.Close(); + //} private void OnSearchIncreateKeyWordChanged(string key) { @@ -678,16 +668,7 @@ namespace BBWY.Client.ViewModels.PackTask }); look.Show(); } - private void SpuCerLabelCheck(CertificateLabelModel cer) - { - SpuCertificateModel.LabelModel = cer; - SpuCertificateModel.IsLogo = cer == CertificateLabelModel.标准有3c ? 1 : 0; - } - private void CerLabelCheck(CertificateLabelModel cer) - { - CertificateModel.LabelModel = cer; - CertificateModel.IsLogo = cer == CertificateLabelModel.标准有3c ? 1 : 0; - } + /// /// /// @@ -709,77 +690,55 @@ namespace BBWY.Client.ViewModels.PackTask //throw new NotImplementedException(); } - /// - /// 设置合格证 - /// - private void SetCertificate() - { - if (string.IsNullOrEmpty(SearchSkuId)) - { - new TipsWindow("请先查询skuId").Show(); - return; - } - SearSpuCer(); - - if (CertificateModel == null) - { - CertificateModel = new CertificateModel(); - CertificateModel.ProductNo = ProductNo; - CertificateModel.Brand = Brand; - CertificateModel.SkuId = SkuId; - } - CertificateModel.BrandName = BrandName; - setCerWindow = new SetCerWindow(); - setCerWindow.Show(); - //throw new NotImplementedException(); - } /// /// 保存合格证 /// - 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 = "需要"; - 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; + + public BarcodeLabelModel LabelModel = BarcodeLabelModel.精简模板; + private void SetBarCode() { - if (string.IsNullOrEmpty(SearchSkuId)) + if (string.IsNullOrEmpty(SkuId)) { - new TipsWindow("请先查询skuId").Show(); return; } if (BarCodeModel == null) @@ -789,15 +748,60 @@ namespace BBWY.Client.ViewModels.PackTask BarCodeModel.Brand = Brand; BarCodeModel.SkuId = SkuId; BarCodeModel.SkuName = SkuName; - } - BarCodeModel.BrandName = BrandName; - setBarCodeWindow = new SetBarCodeWindow(); + 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(); } - public BarcodeLabelModel LabelModel = BarcodeLabelModel.精简模板; + /// + /// 设置合格证 + /// + 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; + //CertificateModel.Foreach(c=>c.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 SaveBarCode() { @@ -815,12 +819,12 @@ namespace BBWY.Client.ViewModels.PackTask //保存到服务器中 返回id var resData = packTaskService.SaveBarCode(new BarCodeRequest { - Brand = Brand, - BrandName = BrandName, - ProductNo = ProductNo, - SkuId = SkuId, - SkuName = SkuName, - LabelModel = LabelModel + Brand = BarCodeModel.Brand, + BrandName = BarCodeModel.BrandName, + ProductNo = BarCodeModel.ProductNo, + SkuId = BarCodeModel.SkuId, + SkuName = BarCodeModel.SkuName, + LabelModel = BarCodeModel.LabelModel }); if (resData == null || !resData.Success) @@ -830,7 +834,7 @@ namespace BBWY.Client.ViewModels.PackTask } BarCodeModel.Id = resData.Data; - IsNeedBarCode = "需要"; + IsNeedBarCode = Need.需要; IsSetBarCode = false; setBarCodeWindow.Close(); } @@ -876,16 +880,16 @@ namespace BBWY.Client.ViewModels.PackTask Increment2 = (int)Increment2, CertificatePosition = (int)CertificatePosition, PackType = (int)PackType, - MarkMessage = markMessage, + MarkMessage = MarkMessage, PositionType = (int)PositionType, GoodsNumber = GoodsNumber, SkuGoodsTitle = SkuTitle, SkuCount = SkuCount, UserId = AccepUserId, ShopId = globalContext.User.Shop.ShopId.ToString(), - IsWorry = IsWorry + //IsWorry = IsWorry }; - if (IsNeedBarCode == "需要") + if (IsNeedBarCode == Need.需要) { if (BarCodeModel == null || BarCodeModel.Id <= 0) { @@ -894,14 +898,14 @@ namespace BBWY.Client.ViewModels.PackTask } createTaskModel.BarCodeId = BarCodeModel.Id; } - if (IsNeedCertificateModel == "需要") + 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,16 +974,16 @@ namespace BBWY.Client.ViewModels.PackTask return; } - if (productSku.Data.PackConfig!=null) + 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; + BasicPack = (BasicPack)config.BasicPack; + Availability = (TaskState)config.Availability; MarkMessage = config.MarkMessage; - CertificatePosition = config.CertificatePosition==null? CertificatePosition .无: (CertificatePosition)config.CertificatePosition.Value; + CertificatePosition = config.CertificatePosition == null ? CertificatePosition.无 : (CertificatePosition)config.CertificatePosition.Value; // Increment1 = config.Increment1; string[] increateDatas = config.Increment1.Split(','); @@ -991,12 +995,13 @@ namespace BBWY.Client.ViewModels.PackTask { isSelected = true; } - App.Current.Dispatcher.Invoke(() => { - IncreateList.Add(new IncreateModel + App.Current.Dispatcher.Invoke(() => { - IncreateName = item, - IsSelected = isSelected - }); + IncreateList.Add(new IncreateModel + { + IncreateName = item, + IsSelected = isSelected + }); }); } @@ -1005,18 +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; - CertificateModel.BrandName = BrandName; - CertificateModel.ProductNo = ProductNo; - CertificateModel.SkuId = SkuId; + foreach (var item in CertificateModel) + item.Brand = Brand; + + if (!string.IsNullOrEmpty(BrandName)) + foreach (var item in CertificateModel) + { + item.BrandName = BrandName; + item.ProductNo = ProductNo; + item.SkuId = SkuId; + } + + BarCodeModel = productSku.Data.BarCodeModel; IsSetBarCode = false; if (BarCodeModel == null) @@ -1025,8 +1040,10 @@ namespace BBWY.Client.ViewModels.PackTask IsSetBarCode = true; } BarCodeModel.Brand = Brand; - BarCodeModel.BrandName = BrandName; + if (!string.IsNullOrEmpty(BrandName)) + BarCodeModel.BrandName = BrandName; BarCodeModel.ProductNo = ProductNo; + BarCodeModel.SkuId = SkuId; BarCodeModel.SkuName = SkuName; } @@ -1065,7 +1082,8 @@ namespace BBWY.Client.ViewModels.PackTask SpuCertificateModel = new CertificateModel(); IsSetSpuCertificate = true; SpuCertificateModel.Brand = Brand; - SpuCertificateModel.BrandName = BrandName; + if (!string.IsNullOrEmpty(BrandName)) + SpuCertificateModel.BrandName = BrandName; SpuCertificateModel.ProductNo = ProductNo; SpuCertificateModel.SpuId = SpuId; diff --git a/BBWY.Client/ViewModels/PackTask/PackServiceViewModel.cs b/BBWY.Client/ViewModels/PackTask/PackServiceViewModel.cs index 0a614643..44df899e 100644 --- a/BBWY.Client/ViewModels/PackTask/PackServiceViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/PackServiceViewModel.cs @@ -44,7 +44,7 @@ namespace BBWY.Client.ViewModels.PackTask readonly PackTaskService packTaskService; readonly ConsumableService consumableService; readonly PackDetailService packDetailService; - + readonly BatchPurchaseService batchPurchaseService; private ObservableCollection increateList = new ObservableCollection(); public ObservableCollection IncreateList { get => increateList; set { Set(ref increateList, value); } } // @@ -75,7 +75,7 @@ namespace BBWY.Client.ViewModels.PackTask /// public List LoadList = new List(); - public PackServiceViewModel(PackTaskService packTaskService, ConsumableService consumableService, PackServiceService packServiceService, PackDetailService packDetailService)//, long taskId + public PackServiceViewModel(PackTaskService packTaskService, ConsumableService consumableService, PackServiceService packServiceService, PackDetailService packDetailService, BatchPurchaseService batchPurchaseService)//, long taskId { //TaskId = taskId; this.consumableService = consumableService; @@ -159,6 +159,7 @@ namespace BBWY.Client.ViewModels.PackTask AddConsumableCommand = new RelayCommand(AddConsumable); UpLoadPackCommand = new RelayCommand(UpLoadPack); SetAllCountCommand = new RelayCommand(SetAllCount); + this.batchPurchaseService = batchPurchaseService; @@ -284,7 +285,8 @@ namespace BBWY.Client.ViewModels.PackTask private int taskCount; public int TaskCount { get => taskCount; set { Set(ref taskCount, value); } } // - + public string OrderId { get; set; } + public string SkuId { get; set; } /// /// 上传数据 (判断是否超量) 统一上传 /// @@ -328,7 +330,7 @@ namespace BBWY.Client.ViewModels.PackTask decimal AllFees = 0; decimal price = 0; - decimal IncreateFees = 0,PackFees=0,ConsumableFees=0,DiscountPrice=0; + decimal IncreateFees = 0, PackFees = 0, ConsumableFees = 0, DiscountPrice = 0; foreach (var item in IncreateList)//增值服务上传 { if (item.SelectId <= 0 || string.IsNullOrEmpty(item.SelectUserId) || item.ItemCount <= 0) @@ -528,13 +530,14 @@ namespace BBWY.Client.ViewModels.PackTask } uploadService.AddPackServices = addDatas; uploadService.DeletedPackServices = del; - - uploadService.AllFees = Convert.ToDecimal((AllFees).ToString("0.00")); ; + uploadService.SkuId = SkuId; + uploadService.OrderId= OrderId; + uploadService.AllFees = Convert.ToDecimal(AllFees.ToString("0.00")); uploadService.SingleFees = singleFees; uploadService.IncreaseFees = Convert.ToDecimal((IncreateFees).ToString("0.00")); uploadService.PackFees = Convert.ToDecimal((PackFees).ToString("0.00")); uploadService.ConsumableFees = Convert.ToDecimal((ConsumableFees).ToString("0.00")); - uploadService. DiscountPrice = Convert.ToDecimal( (AllFees * upDisCount).ToString("0.00")); + uploadService.DiscountPrice = Convert.ToDecimal((AllFees * upDisCount).ToString("0.00")); var res = packDetailService.UploadService(uploadService); if (res != null && res.Success) { @@ -550,7 +553,6 @@ namespace BBWY.Client.ViewModels.PackTask SetAllFees(feesItem, packUsers); win.Close(); } - } /// /// 更新 打包员 和费用数据 diff --git a/BBWY.Client/ViewModels/PackTask/PackTaskTotalViewModel.cs b/BBWY.Client/ViewModels/PackTask/PackTaskTotalViewModel.cs index bd8d3054..5cd3bc6b 100644 --- a/BBWY.Client/ViewModels/PackTask/PackTaskTotalViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/PackTaskTotalViewModel.cs @@ -5,6 +5,7 @@ using BBWY.Client.Models; using BBWY.Client.Models.PackTask; using BBWY.Client.Views.Order; using BBWY.Client.Views.PackTask; +using BBWY.Common.Extensions; using BBWY.Common.Models; using BBWY.Controls; using GalaSoft.MvvmLight.Command; @@ -72,16 +73,19 @@ namespace BBWY.Client.ViewModels.PackTask public ICommand BatchCheckedCommand { get; set; } - public ICommand CopyTextCommand { get; set; } - + //public IList departmentList; + //ShopService shopService; public PackTaskTotalViewModel(PackTaskService packTaskService) { this.packTaskService = packTaskService; - EndDate = DateTime.Now; - StartDate = DateTime.Now.Date; - - SearchTaskTotalCommand = new RelayCommand(SearchTaskTotal); + //this.shopService = shopService; + SearchTaskTotalCommand = new RelayCommand(() => + { + SearchTask(1); + }); + StartDate = DateTime.Now; + EndDate = DateTime.Now; SetSearchDateCommand = new RelayCommand(d => { @@ -97,24 +101,29 @@ namespace BBWY.Client.ViewModels.PackTask }); BatchCheckedCommand = new RelayCommand(BatchCheck); - CopyTextCommand = new RelayCommand((obj) => - { - try - { - Clipboard.SetText(obj.ToString()); - } - catch (Exception ex) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(ex); - Console.ResetColor(); - } - }); BatchSettleCommand = new RelayCommand(BatchSettle); SettleCommand = new RelayCommand(SettleTask); ExportCommand = new RelayCommand(Export); SearchTaskTotal(); + + //LoadShopList(); + } + + private void LoadShopList() + { + + //departmentList=new List(); + //var response = shopService.GetDepartmentList(); + //if (!response.Success) + // throw new Exception(response.Msg); + //departmentList = response.Data.Map>(); + + + //var shopList = new List(); + //foreach (var d in departmentList) + // shopList.AddRange(d.ShopList); + } private void Export() 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 95e90778..30903b91 100644 --- a/BBWY.Client/ViewModels/PackTask/TaskListViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/TaskListViewModel.cs @@ -127,6 +127,11 @@ namespace BBWY.Client.ViewModels.PackTask public TaskListViewModel(PackTaskService packTaskService, GlobalContext globalContext, ProductService productService, ConsumableService consumableService, WorkProcessService workProcessService, IncreateServiceService increateServiceService) { + this.globalContext = globalContext; + this.productService = productService; + this.consumableService = consumableService; + this.workProcessService = workProcessService; + this.increateServiceService = increateServiceService; this.packTaskService = packTaskService; //TaskState = BBWY.Client.Models. TaskState.全部; PackTaskList = new ObservableCollection();//初始化数据 @@ -144,35 +149,28 @@ namespace BBWY.Client.ViewModels.PackTask }); OpenSkuDetailCommand = new RelayCommand(OpenSkuDetail); - CopyTextCommand = new RelayCommand(s => - { - try - { - Clipboard.SetText(s.ToString()); - } - catch (Exception ex) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(ex); - Console.ResetColor(); - } - }); + DeletedTaskCommand = new RelayCommand(DeletedTask); StartTime = DateTime.Now.Date; EndTime = DateTime.Now.Date; IsLoading = false; - - //加载数据 SetTaskState(Models.TaskState.全部); - this.globalContext = globalContext; - this.productService = productService; - this.consumableService = consumableService; - this.workProcessService = workProcessService; - this.increateServiceService = increateServiceService; + } + private void DeletedTask(object obj) + { + + MessageBoxResult result = MessageBox.Show("确定删除?", "提示", + MessageBoxButton.YesNo, + MessageBoxImage.Warning); + long taskId = (long)obj; + if (result != MessageBoxResult.Yes) return; + packTaskService.DeletedTask(taskId); + Task.Factory.StartNew(() => SearchTaskList()); + } private void IsLoadCount() @@ -227,11 +225,11 @@ namespace BBWY.Client.ViewModels.PackTask /// public ICommand OpenSkuDetailCommand { get; set; } + /// - /// 复制 + /// 删除任务 /// - public ICommand CopyTextCommand { get; set; } - + public ICommand DeletedTaskCommand { get; set; } public void SetTaskState(TaskState? taskState) { @@ -293,7 +291,7 @@ namespace BBWY.Client.ViewModels.PackTask foreach (var item in dataModel.Items) { - var data = new PackTaskModel(packTaskService, consumableService, workProcessService, increateServiceService) + var data = new PackTaskModel() { Brand = item.Brand, SkuId = item.SkuId, @@ -322,25 +320,22 @@ namespace BBWY.Client.ViewModels.PackTask TaskId = item.TaskId, TaskStatus = (TaskStateType)item.TaskStatus, EndTime = item.CreateTime, - IsWorry = (Worry)item.IsWorry - - - + IsWorry = (Worry)item.IsWorry, }; if (item.BarCodeDTO != null && item.BarCodeDTO.Id > 0) { 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; } @@ -399,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 3b87a1b8..d6af7ec4 100644 --- a/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs @@ -146,7 +146,7 @@ namespace BBWY.Client.ViewModels.PackTask private readonly WorkProcessService workProcessService; private readonly PackTaskService packTaskService; private readonly IncreateServiceService increateServiceService; - public WareHouseListViewModel(PackTaskService packTaskService, ConsumableService consumableService, WorkProcessService workProcessService, IncreateServiceService increateServiceService, ProductService productService) + public WareHouseListViewModel(PackTaskService packTaskService, ConsumableService consumableService, WorkProcessService workProcessService, IncreateServiceService increateServiceService, ProductService productService, BatchPurchaseService batchPurchaseService) { this.packTaskService = packTaskService; this.consumableService = consumableService; @@ -181,24 +181,18 @@ namespace BBWY.Client.ViewModels.PackTask StartTime = DateTime.Now.Date; EndTime = DateTime.Now.Date; IsLoading = false; - + SetTaskStatusCommand = new RelayCommand(SetTaskStatus); //加载数据 SetTaskState(Models.TaskState.全部); this.workProcessService = workProcessService; this.increateServiceService = increateServiceService; this.productService = productService; + this.batchPurchaseService = batchPurchaseService; } - - - - - - - - #region 事件绑定 + public ICommand SetTaskStatusCommand { get; set; } /// /// 打开图片链接 /// @@ -229,6 +223,21 @@ namespace BBWY.Client.ViewModels.PackTask public ICommand TaskPageIndexChangedCommand { get; set; } + BatchPurchaseService batchPurchaseService; + public void SetTaskStatus(object obj ) + { + var objList = (object[])obj; + + long taskId = (long)objList[0]; + + string orderId=(string)objList[1]; + ///修改完成 + var model = packTaskService.UpdateTaskStatus(taskId, 1,orderId); + if (model != null && model.Success) + SearchTaskList(); + + } + public void SetTaskState(TaskState? taskState) { IsWorry = null; @@ -280,7 +289,7 @@ namespace BBWY.Client.ViewModels.PackTask OrderCount = dataModel.TotalCount; foreach (var item in dataModel.Items) { - var data = new PackTaskModel(packTaskService, consumableService, workProcessService, increateServiceService) + var data = new PackTaskModel() { AcceptName = item.UserName, Availability = (TaskState)item.Availability, @@ -306,9 +315,11 @@ namespace BBWY.Client.ViewModels.PackTask SkuTitle = item.SkuGoodsTitle, TaskId = item.TaskId, TaskStatus = (TaskStateType)item.TaskStatus, - EndTime = item.CreateTime - - + EndTime = item.CreateTime, + OrderId= item.OrderId, + SkuId = item.SkuId, + SkuName = item.SkuName, + }; if (item.BarCodeDTO != null && item.BarCodeDTO.Id > 0) { @@ -316,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; } @@ -400,14 +411,5 @@ namespace BBWY.Client.ViewModels.PackTask #endregion - - - - - - - - - } } diff --git a/BBWY.Client/ViewModels/ViewModelLocator.cs b/BBWY.Client/ViewModels/ViewModelLocator.cs index 5aad40e1..7ccd0dad 100644 --- a/BBWY.Client/ViewModels/ViewModelLocator.cs +++ b/BBWY.Client/ViewModels/ViewModelLocator.cs @@ -277,5 +277,22 @@ namespace BBWY.Client.ViewModels return s.ServiceProvider.GetRequiredService(); } } + + public BatchPublishTaskViewModel BatchPublishTask + { + get + { + using var s = sp.CreateScope(); + 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 new file mode 100644 index 00000000..180ea937 --- /dev/null +++ b/BBWY.Client/Views/BatchPurchase/BatchPublishTaskWindow.xaml @@ -0,0 +1,277 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +