Просмотр исходного кода

菜单状态发货前锁定库存更新

klzhangweiya 1 год назад
Родитель
Сommit
851a8b8c9c

+ 4 - 2
src_0nline/ShwasherSys/ShwasherSys.Application/Common/CommonAppService.cs

@@ -29,6 +29,7 @@ using IwbZero.Session;
 using MailKit;
 using Microsoft.AspNet.Identity;
 using Microsoft.AspNet.SignalR;
+using NPOI.SS.Formula.Functions;
 using ShwasherSys.Authorization.Users;
 using ShwasherSys.BaseSysInfo;
 using ShwasherSys.BaseSysInfo.States;
@@ -933,8 +934,9 @@ namespace ShwasherSys.Common
                 currentProductStore.TimeLastMod = Clock.Now;
                 currentProductStore.UserIDLastMod = AbpSession.UserId.ToString();
                 await CurrentProductStoreHouseRepository.UpdateAsync(currentProductStore);
-                orderBookStore.Status = OrderBookStoreStatusEnum.UnLock.ToInt();
-                await OrderBookStoreRepository.UpdateAsync(orderBookStore);
+                //orderBookStore.Status = OrderBookStoreStatusEnum.UnLock.ToInt();
+                //await OrderBookStoreRepository.UpdateAsync(orderBookStore);//先解锁库存
+                await OrderBookStoreRepository.DeleteAsync(orderBookStore);//软删除掉锁定的记录
             }
             BusinessLogTypeEnum.OrderLog.WriteLog(BusinessLogRepository, "订单明细删除解除冻结仓库库存", $"仓库库存解除冻结成功!orderItem:{orderItem.Id},UserId:{AbpSession.UserId}", logExt1: $"{orderBookStores.ToJsonString()}");
         }

+ 4 - 0
src_0nline/ShwasherSys/ShwasherSys.Application/Order/IOrderBookStoreAppService.cs

@@ -19,6 +19,10 @@ namespace ShwasherSys.Order
 
         Task LockStore(BookStoreAddsDto input);
 
+        Task UnLockItem(int id);
+
         Task<Boolean> CheckExistLockStore(int id);
+
+        Task<bool> CheckExistLockingStore(int id);
     }
 }

+ 5 - 1
src_0nline/ShwasherSys/ShwasherSys.Application/Order/IOrderItemsApplicationService.cs

@@ -5,6 +5,7 @@ using IwbZero.AppServiceBase;
 using ShwasherSys.Common.Dto;
 using ShwasherSys.CustomerInfo;
 using ShwasherSys.Order.Dto;
+using ShwasherSys.OrderSendInfo;
 
 namespace ShwasherSys.Order
 {
@@ -60,7 +61,10 @@ namespace ShwasherSys.Order
         Task<List<ProductionProcessDto>> QueryProductProcess(int orderItemId);
 
 
-        Task<OrderItem> SendBookStore(int orderItemId);
+        //Task<OrderItem> SendBookStore(int orderItemId);
+
+        Task<OrderItem> SendBookStoreItem(int orderItemId, int id);
+        Task<List<ViewOrderSend>> QuerySendItem(int id);
 
     }
 }

+ 30 - 5
src_0nline/ShwasherSys/ShwasherSys.Application/Order/OrderBookStoreApplicationService.cs

@@ -21,9 +21,9 @@ using ShwasherSys.ProductStoreInfo;
 namespace ShwasherSys.Order
 {
     [AbpAuthorize, DisableAuditing]
-    public class OrderBookStoreApplicationService: ApplicationService,IOrderBookStoreAppService
+    public class OrderBookStoreAppService: ApplicationService,IOrderBookStoreAppService
     {
-        public OrderBookStoreApplicationService(IRepository<OrderBookStore,long> repository, IRepository<CurrentProductStoreHouse> currentStoreRepository,
+        public OrderBookStoreAppService(IRepository<OrderBookStore,long> repository, IRepository<CurrentProductStoreHouse> currentStoreRepository,
             IRepository<BusinessLog> businessLogRepository)
         {
             _repository = repository;
@@ -36,7 +36,7 @@ namespace ShwasherSys.Order
         public new IIwbSession AbpSession { get; set; }
         public async Task<List<OrderBookStore>> GetDataByOrderItemId(int id)
         {
-           return await _repository.GetAllListAsync(i=>i.OrderItemId == id);
+            return await _repository.GetAllListAsync(i=>i.OrderItemId == id);
         }
 
         //public async Task UnLockStoreByOrderItemId(int id)
@@ -104,10 +104,35 @@ namespace ShwasherSys.Order
             }
             BusinessLogTypeEnum.OrderLog.WriteLog(BusinessLogRepository, "订单明细锁定仓库库存", $"仓库库存冻结创建成功!orderItem:{input.OrderItemId},UserName:{AbpSession.UserName}",logExt1:$"{input.AddItems.ToJsonString()}");
         }
-        //查看当前订单明细是否存在已经冻结的库存
+        /**
+         * 删除已经锁定的记录
+         */
+        public async Task UnLockItem(int id)
+        {
+            var entity = await _repository.GetAsync(id);
+            if (entity == null)
+            {
+                CheckErrors(IdentityResult.Failed("为查询到相应的锁定明细!"));
+            }
+            await _repository.DeleteAsync(entity);
+            CurrentProductStoreHouse currentProduct =
+                await _currentStoreRepository.FirstOrDefaultAsync(i =>
+                    i.CurrentProductStoreHouseNo == entity.CurrentProductStoreHouseNo);
+            currentProduct.FreezeQuantity -= entity.Quantity ?? 0;
+            await _currentStoreRepository.UpdateAsync(currentProduct);
+        }
+
+        //查看当前订单明细是否存在冻结的库存
         public async Task<bool> CheckExistLockStore(int id)
         {
-            return (await _repository.CountAsync(i=>i.OrderItemId== id && i.Status == OrderBookStoreStatusEnum.Locking.ToInt()))>0;
+            return (await _repository.CountAsync(i => i.OrderItemId == id ))>0;
+        }
+
+        //查看当前订单明细是否存在已经冻结并且未解锁的库存
+        public async Task<bool> CheckExistLockingStore(int id)
+        {
+            int status = OrderBookStoreStatusEnum.Locking.ToInt();
+            return (await _repository.CountAsync(i => i.OrderItemId == id && i.Status == status)) > 0;
         }
 
         #region MyRegion

+ 148 - 61
src_0nline/ShwasherSys/ShwasherSys.Application/Order/OrderItemsApplicationService.cs

@@ -51,10 +51,12 @@ namespace ShwasherSys.Order
         protected IRepository<OrderSendExceed> OrderSendExceedRepository;
         protected IRepository<ScheduleOrderSend> ScheduleOrderSendRepository;
         protected IRepository<OrderBookStore,long> OrderBookStoreRepository;
+        protected IRepository<ViewOrderSend> ViewOrderSendRepository;
         protected ICommonAppService CommonAppService { get; }
         protected IQueryAppService QueryAppService { get; }
         protected ISqlExecuter SqlExecuter { get; }
-        public OrderItemsAppService(IRepository<OrderItem, int> repository, IRepository<CustomerDefaultProduct> customerDefaultProductRepository, IRepository<OrderHeader, string> orderHeaderRepository, IRepository<ViewOrderItems> viewOrderItemsRepository, IRepository<OrderSend> orderSendRepository, IIwbSettingManager settingManager, IRepository<ProductOutStore> productOutStoreRepository, IRepository<CurrentProductStoreHouse> currentProductStoreHouseRepository, IRepository<ViewBookedProductNum, string> viewBookedProductNumRepository, IRepository<ViewCanProductStore, string> viewCanProductStoreRepository, IRepository<BusinessLog> businessLogRepository, IStatesAppService statesAppService, ICommonAppService commonAppService, IRepository<OrderSendExceed> orderSendExceedRepository, ISqlExecuter sqlExecuter, IQueryAppService queryAppService, IRepository<ScheduleOrderSend> scheduleOrderSendRepository,IRepository<OrderBookStore,long> orderBookStoreRepository) : base(repository)
+
+        public OrderItemsAppService(IRepository<OrderItem, int> repository, IRepository<CustomerDefaultProduct> customerDefaultProductRepository, IRepository<OrderHeader, string> orderHeaderRepository, IRepository<ViewOrderItems> viewOrderItemsRepository, IRepository<OrderSend> orderSendRepository, IIwbSettingManager settingManager, IRepository<ProductOutStore> productOutStoreRepository, IRepository<CurrentProductStoreHouse> currentProductStoreHouseRepository, IRepository<ViewBookedProductNum, string> viewBookedProductNumRepository, IRepository<ViewCanProductStore, string> viewCanProductStoreRepository, IRepository<BusinessLog> businessLogRepository, IStatesAppService statesAppService, ICommonAppService commonAppService, IRepository<OrderSendExceed> orderSendExceedRepository, ISqlExecuter sqlExecuter, IQueryAppService queryAppService, IRepository<ScheduleOrderSend> scheduleOrderSendRepository,IRepository<OrderBookStore,long> orderBookStoreRepository, IRepository<ViewOrderSend>  viewOrderSendRepository) : base(repository)
         {
             CustomerDefaultProductRepository = customerDefaultProductRepository;
             OrderHeaderRepository = orderHeaderRepository;
@@ -73,6 +75,7 @@ namespace ShwasherSys.Order
             QueryAppService = queryAppService;
             ScheduleOrderSendRepository = scheduleOrderSendRepository;
             OrderBookStoreRepository = orderBookStoreRepository;
+            ViewOrderSendRepository = viewOrderSendRepository;
         }
 
 		protected override string GetPermissionName { get; set; } = PermissionNames.PagesOrderInfoOrderMg;
@@ -985,82 +988,166 @@ namespace ShwasherSys.Order
         #endregion
 
         #region 订单发货
+
+        public async Task<List<ViewOrderSend>> QuerySendItem(int id)
+        {
+            var sendItems = await ViewOrderSendRepository.GetAllListAsync(i=>i.OrderItemId == id);
+            return sendItems;
+        }
         /**
-         * 发货前先将提前锁定的库存发货
+         * 单条锁定的库存记录发货
          */
-        public async Task<OrderItem> SendBookStore(int orderItemId)
+        public async Task<OrderItem> SendBookStoreItem(int orderItemId,int id)
         {
             var orderItem = Repository.Get(orderItemId);
-            var orderBookStores = await OrderBookStoreRepository.GetAllListAsync(i=>i.OrderItemId==orderItemId&&i.Status==OrderBookStoreStatusEnum.Locking.ToInt());
-            var allSend = orderBookStores.Select(i=>i.Quantity).Sum();
-            await InsertOrderSendExceed(allSend??0, orderItem);//如果超过订单数量,需要在超额部分中添加记录
+            var bookstore = await OrderBookStoreRepository.GetAsync(id);
+            var allSendQuantity = GetItemSend(orderItemId);
+            await InsertOrderSendExceed(allSendQuantity + bookstore.Quantity??0, orderItem);//如果超过订单数量,需要在超额部分中添加记录
             //如果超过订单数量直接变更订单状态
-            if (allSend >= orderItem.Quantity)
+            if ((allSendQuantity + bookstore.Quantity ?? 0) >= orderItem.Quantity)
             {
                 orderItem.OrderItemStatusId = OrderItemStatusEnum.Send.ToInt();
                 orderItem.TimeLastMod = DateTime.Now;
                 orderItem.UserIDLastMod = AbpSession.UserName;
                 await Repository.UpdateAsync(orderItem);//更新订单明细状态
-                BusinessLogTypeEnum.OrderLog.WriteLog(BusinessLogRepository, "订单明细状态变更", $"订单明细发货完成,发货数量{allSend}!订单明细:{orderItem.ToJsonString()}");
+                BusinessLogTypeEnum.OrderLog.WriteLog(BusinessLogRepository, "订单明细状态变更", $"订单明细发货完成,发货数量{(allSendQuantity + bookstore.Quantity ?? 0)}!订单明细:{orderItem.ToJsonString()}");
             }
-            foreach (OrderBookStore bookStore in orderBookStores)
+            if (await CommonAppService.CheckProductCanSendToCustomer(bookstore.ProductBatchNum, bookstore.CustomerId))
             {
-                if (await CommonAppService.CheckProductCanSendToCustomer(bookStore.ProductBatchNum, bookStore.CustomerId))
-                {
-                    CheckErrors(IwbIdentityResult.Failed($"批次({bookStore.ProductBatchNum})不能发货给客户({bookStore.CustomerId}),请检查后再试..."));
-                }
-                //var currentStore =await CurrentProductStoreHouseRepository.FirstOrDefaultAsync(i =>
-                //    i.CurrentProductStoreHouseNo == bookStore.CurrentProductStoreHouseNo);
+                CheckErrors(IwbIdentityResult.Failed($"批次({bookstore.ProductBatchNum})不能发货给客户({bookstore.CustomerId}),请检查后再试..."));
+            }
+            OrderSend orderSend = new OrderSend()
+            {
+                OrderItemId = orderItemId,
+                OrderUnitId = orderItem.OrderUnitId,
+                SendDate = Clock.Now,
+                SendQuantity = bookstore.Quantity ?? 0,
+                UserIDLastMod = AbpSession.UserName,
+                TimeLastMod = Clock.Now,
+                TimeCreated = Clock.Now,
+                QuantityPerPack = bookstore.QuantityPerPack,
+                PackageCount = bookstore.PackageCount,
+                ProductBatchNum = bookstore.ProductBatchNum,
+                StoreLocationNo = bookstore.StoreLocationNo,
+                CurrentProductStoreHouseNo = bookstore.CurrentProductStoreHouseNo,
+                CreatorUserId = AbpSession.UserName,
+            };
+            if (orderItem.ProductNo != bookstore.ProductNo)
+            {
+                orderSend.Remark = $"替换发货,用编号:{bookstore.ProductNo}替换{orderItem.ProductNo}";
+            }
+            await CalcLogisticsFeeAndMoldFee(orderSend, orderItem);//计算是否需要添加模具费和运费
+
+            var sendId = OrderSendRepository.InsertAndGetId(orderSend); //添加发货记录
+
+            //库存变更逻辑,添加仓库出库申请
+            ProductOutStore loProductOutStore = new ProductOutStore
+            {
+                ApplyOutDate = Clock.Now,
+                ApplyStatus = OutStoreApplyStatusEnum.Applying.ToInt(),
+                StoreHouseId = 1,
+                IsClose = false,
+                CreatorUserId = AbpSession.UserName,
+                CurrentProductStoreHouseNo = bookstore.CurrentProductStoreHouseNo,
+                IsConfirm = false,
+                Quantity = bookstore.Quantity ?? 0,
+                ProductionOrderNo = bookstore.ProductBatchNum ?? "",
+                ProductNo = bookstore.ProductNo,
+                TimeLastMod = Clock.Now,
+                TimeCreated = Clock.Now,
+                UserIDLastMod = AbpSession.UserName,
+                OrderSendId = sendId,
+                ApplyOutStoreSourceType = OutStoreApplyTypeEnum.SendGood.ToInt()
+            };
+            await ProductOutStoreRepository.InsertAsync(loProductOutStore);
+            BusinessLogTypeEnum.OrderLog.WriteLog(BusinessLogRepository, "预先冻结库存发货", $"订单明细发货操作,发货数量{bookstore.Quantity}!订单明细:{orderItem.ToJsonString()},出库库存记录:{loProductOutStore.ToJsonString()}");
+            //todo 发货之后锁定库存需要状态变更为已解锁
+            bookstore.Status = OrderBookStoreStatusEnum.UnLock.ToInt();
+            await OrderBookStoreRepository.UpdateAsync(bookstore);
+            return orderItem;
+        }
+        /**
+         * 发货前先将提前锁定的库存发货
+         */
+        //public async Task<OrderItem> SendBookStore(int orderItemId)
+        //{
+        //    var orderItem = Repository.Get(orderItemId);
+        //    int lockStatus = OrderBookStoreStatusEnum.Locking.ToInt();
+        //    var orderBookStores = await OrderBookStoreRepository.GetAllListAsync(i=>i.OrderItemId==orderItemId && i.Status== lockStatus);//查询当前订单明细中是否存在未发货解锁的库存记录
+        //    var allSend = orderBookStores.Select(i=>i.Quantity).Sum();
+        //    await InsertOrderSendExceed(allSend??0, orderItem);//如果超过订单数量,需要在超额部分中添加记录
+        //    //如果超过订单数量直接变更订单状态
+        //    if (allSend >= orderItem.Quantity)
+        //    {
+        //        orderItem.OrderItemStatusId = OrderItemStatusEnum.Send.ToInt();
+        //        orderItem.TimeLastMod = DateTime.Now;
+        //        orderItem.UserIDLastMod = AbpSession.UserName;
+        //        await Repository.UpdateAsync(orderItem);//更新订单明细状态
+        //        BusinessLogTypeEnum.OrderLog.WriteLog(BusinessLogRepository, "订单明细状态变更", $"订单明细发货完成,发货数量{allSend}!订单明细:{orderItem.ToJsonString()}");
+        //    }
+        //    foreach (OrderBookStore bookStore in orderBookStores)
+        //    {
+        //        if (await CommonAppService.CheckProductCanSendToCustomer(bookStore.ProductBatchNum, bookStore.CustomerId))
+        //        {
+        //            CheckErrors(IwbIdentityResult.Failed($"批次({bookStore.ProductBatchNum})不能发货给客户({bookStore.CustomerId}),请检查后再试..."));
+        //        }
+        //        //var currentStore =await CurrentProductStoreHouseRepository.FirstOrDefaultAsync(i =>
+        //        //    i.CurrentProductStoreHouseNo == bookStore.CurrentProductStoreHouseNo);
                
-                OrderSend orderSend = new OrderSend()
-                {
-                    OrderItemId = orderItemId,
-                    OrderUnitId = orderItem.OrderUnitId,
-                    SendDate = Clock.Now,
-                    SendQuantity = bookStore.Quantity??0,
-                    UserIDLastMod = AbpSession.UserName,
-                    TimeLastMod = Clock.Now,
-                    TimeCreated = Clock.Now,
-                    QuantityPerPack = bookStore.QuantityPerPack,
-                    PackageCount = bookStore.PackageCount,
-                    ProductBatchNum = bookStore.ProductBatchNum,
-                    StoreLocationNo = bookStore.StoreLocationNo,
-                    CurrentProductStoreHouseNo = bookStore.CurrentProductStoreHouseNo,
-                    CreatorUserId = AbpSession.UserName,
-                };
-                if (orderItem.ProductNo != bookStore.ProductNo)
-                {
-                    orderSend.Remark = $"替换发货,用编号:{bookStore.ProductNo}替换{orderItem.ProductNo}";
-                }
-                await CalcLogisticsFeeAndMoldFee(orderSend, orderItem);//计算是否需要添加模具费和运费
+        //        OrderSend orderSend = new OrderSend()
+        //        {
+        //            OrderItemId = orderItemId,
+        //            OrderUnitId = orderItem.OrderUnitId,
+        //            SendDate = Clock.Now,
+        //            SendQuantity = bookStore.Quantity??0,
+        //            UserIDLastMod = AbpSession.UserName,
+        //            TimeLastMod = Clock.Now,
+        //            TimeCreated = Clock.Now,
+        //            QuantityPerPack = bookStore.QuantityPerPack,
+        //            PackageCount = bookStore.PackageCount,
+        //            ProductBatchNum = bookStore.ProductBatchNum,
+        //            StoreLocationNo = bookStore.StoreLocationNo,
+        //            CurrentProductStoreHouseNo = bookStore.CurrentProductStoreHouseNo,
+        //            CreatorUserId = AbpSession.UserName,
+        //        };
+        //        if (orderItem.ProductNo != bookStore.ProductNo)
+        //        {
+        //            orderSend.Remark = $"替换发货,用编号:{bookStore.ProductNo}替换{orderItem.ProductNo}";
+        //        }
+        //        await CalcLogisticsFeeAndMoldFee(orderSend, orderItem);//计算是否需要添加模具费和运费
                
-                var sendId = OrderSendRepository.InsertAndGetId(orderSend); //添加发货记录
+        //        var sendId = OrderSendRepository.InsertAndGetId(orderSend); //添加发货记录
+
+        //        //库存变更逻辑,添加仓库出库申请
+        //        ProductOutStore loProductOutStore = new ProductOutStore
+        //        {
+        //            ApplyOutDate = Clock.Now,
+        //            ApplyStatus = OutStoreApplyStatusEnum.Applying.ToInt(),
+        //            StoreHouseId = 1,
+        //            IsClose = false,
+        //            CreatorUserId = AbpSession.UserName,
+        //            CurrentProductStoreHouseNo = bookStore.CurrentProductStoreHouseNo,
+        //            IsConfirm = false,
+        //            Quantity = bookStore.Quantity??0,
+        //            ProductionOrderNo = bookStore.ProductBatchNum ?? "",
+        //            ProductNo = bookStore.ProductNo,
+        //            TimeLastMod = Clock.Now,
+        //            TimeCreated = Clock.Now,
+        //            UserIDLastMod = AbpSession.UserName,
+        //            OrderSendId = sendId,
+        //            ApplyOutStoreSourceType = OutStoreApplyTypeEnum.SendGood.ToInt()
+        //        };
+        //        await ProductOutStoreRepository.InsertAsync(loProductOutStore);
+        //        BusinessLogTypeEnum.OrderLog.WriteLog(BusinessLogRepository, "预先冻结库存发货", $"订单明细发货操作,发货数量{bookStore.Quantity}!订单明细:{orderItem.ToJsonString()},出库库存记录:{loProductOutStore.ToJsonString()}");
+        //        //todo 发货之后锁定库存需要状态变更为已解锁
+        //        bookStore.Status = OrderBookStoreStatusEnum.UnLock.ToInt();
+        //        await OrderBookStoreRepository.UpdateAsync(bookStore);
+        //    }
 
-                //库存变更逻辑,添加仓库出库申请
-                ProductOutStore loProductOutStore = new ProductOutStore
-                {
-                    ApplyOutDate = Clock.Now,
-                    ApplyStatus = OutStoreApplyStatusEnum.Applying.ToInt(),
-                    StoreHouseId = 1,
-                    IsClose = false,
-                    CreatorUserId = AbpSession.UserName,
-                    CurrentProductStoreHouseNo = bookStore.CurrentProductStoreHouseNo,
-                    IsConfirm = false,
-                    Quantity = bookStore.Quantity??0,
-                    ProductionOrderNo = bookStore.ProductBatchNum ?? "",
-                    ProductNo = bookStore.ProductNo,
-                    TimeLastMod = Clock.Now,
-                    TimeCreated = Clock.Now,
-                    UserIDLastMod = AbpSession.UserName,
-                    OrderSendId = sendId,
-                    ApplyOutStoreSourceType = OutStoreApplyTypeEnum.SendGood.ToInt()
-                };
-                await ProductOutStoreRepository.InsertAsync(loProductOutStore);
-                BusinessLogTypeEnum.OrderLog.WriteLog(BusinessLogRepository, "预先冻结库存发货", $"订单明细发货操作,发货数量{bookStore.Quantity}!订单明细:{orderItem.ToJsonString()},出库库存记录:{loProductOutStore.ToJsonString()}");
-            }
 
-            return orderItem;
-        }
+        //    //await OrderBookStoreRepository.DeleteAsync(i => i.OrderItemId == orderItemId);//发货成功后软删除掉锁定的记录
+        //    return orderItem;
+        //}
         /**
          * 计算发货记录中的模具费和运费
          */

+ 1 - 1
src_0nline/ShwasherSys/ShwasherSys.Core/Order/ViewOrderItems.cs

@@ -114,6 +114,6 @@ namespace ShwasherSys.Order
         /// 模具费
         /// </summary>
         public decimal MoldFeeAfterTax { get; set; } = 0;
-
+        
     }
 }

+ 131 - 275
src_0nline/ShwasherSys/ShwasherSys.Web/Views/OrderInfo/OrderStatusMg.cshtml

@@ -1,5 +1,4 @@
-using System.Net.Mime
-@using System.Web.UI.HtmlControls
+@using System.Web.UI.HtmlControls
 @using Abp.Authorization
 @using IwbZero.Session
 @using ShwasherSys
@@ -138,6 +137,28 @@ new SearchItem("saleMan", "业务员",showField:"saleManName").SetSearchIcon("qu
 	.down-direction2 {
 		transform: rotate(180deg);
 	}
+	.lock_box {
+        width: 100%;
+        height: auto;
+        border-radius: 5px;
+        border: 1px solid #ccc;
+        margin-bottom: 2px;
+    }
+	.lock_box_header {
+        width: 100%;
+        background: #cccccc;
+        color: #000080;
+        border-radius: 4px 4px 0 0 ;
+        font-size: 12px;
+        font-weight: bolder;
+        padding: 2px;
+        display: flex;
+        flex-flow: row nowrap;
+        justify-content: space-between;
+        align-items: center;
+	}
+	
+	
 </style>
 
 <div class="table-box mr-4  iwb-bootstrap-table">
@@ -239,7 +260,7 @@ new SearchItem("saleMan", "业务员",showField:"saleManName").SetSearchIcon("qu
 					<th data-align="center" data-field="moldFee">模具费</th>
 				}
 				<th data-align="center" data-field="quantity" data-formatter="QuantityFormatter">总数</th>
-				<th data-align="center" data-field="isSendQuantity">已发数</th>
+				<th data-align="center" data-field="isSendQuantity" data-formatter="SendItemFormatter">已发数</th>
 				<th data-align="center" data-field="remainingQuantity">剩余数</th>
 				@if (isCanViewPrice)
 				{
@@ -257,26 +278,7 @@ new SearchItem("saleMan", "业务员",showField:"saleManName").SetSearchIcon("qu
 @section modal{
 
 	<section>
-		<!--审核之后冻结库存modal-->
-		<div class="modal fade" id="modalShowLockStore" role="dialog" tabindex="-1" aria-labelledby="ModalLabel">
-			<div class="modal-dialog  modal-dialog-centered" role="document" style="width: 850px;">
-				<div class="modal-content">
-					<div class="modal-header">
-						<div class="box-title" style="line-height: 25px; color: #f9f9f9; display: block;">
-							<label class="iwb-label col-md-2 control-label iwb-label-required" for="productId_lockstore" style="padding: 3px 3px; color: red;">订单明细已经锁定库存</label>
-							<input type="hidden" id="orderItemId_lock_send_key" />
-						</div>
-                        <div style="position: absolute; right: 5px; top: 8px">
-							<button class="btn btn-info" onclick="lockStoreSendAction()">锁定库存发货</button>
-                            <button class="btn btn-default" onclick="$('#modalShowLockStore').modal('hide');">取消</button>
-                        </div>
-					</div>
-					<div class="modal-body" id="modalShowLockStore_body">
-						
-					</div>
-				</div>
-			</div>
-		</div>
+	
 		<div class="modal fade" id="modalLockStore" role="dialog" tabindex="-1" aria-labelledby="ModalLabel">
 			<div class="modal-dialog  modal-dialog-centered" role="document" style="width: 850px;">
 				<div class="modal-content">
@@ -299,26 +301,51 @@ new SearchItem("saleMan", "业务员",showField:"saleManName").SetSearchIcon("qu
 							</div>
 						</div>
 						<div style="position: absolute; right: 5px; top: 8px">
-							<button class="btn btn-info" onclick="lockStoreAction()">锁定库存</button>
+							@*<button class="btn btn-info" onclick="lockStoreAction()">锁定库存</button>*@
 							<button class="btn btn-default" onclick="$('#modalLockStore').modal('hide');$('#productId_lockstore').val('')">取消</button>
 						</div>
 					</div>
-					<div class="modal-body">
-						<form id="formStore">
+                    <div class="modal-body">
+                        <div class="lock_box">
+                            <div class="lock_box_header">已锁定冻结的库存记录</div>
+                            <div id="locked_box_content" class="table-box mr-4  iwb-bootstrap-table">
+                                <table id="LockedStoreTable" data-striped="true" data-click-to-select="false" data-height="100"
+                                       data-single-select="false">
+                                    <thead>
+                                    <tr class="row">
+										<th data-align="center" data-field="productBatchNum">批次号 </th>
+										<th data-align="center" data-field="productNo">产品编号</th>
+										<th data-align="center" data-field="storeLocationNo">库位</th>
+										<th data-align="center" data-field="quantity">冻结数量(千件)</th>
+										<th data-align="center" data-field="quantityPerPack">千件/每包</th>
+										<th data-align="center" data-field="status" data-formatter="LockedStatusFormatter">状态</th>
+										<th data-align="center"  data-formatter="LockedStoreActionFormatter">操作</th>
+                                    </tr>
+                                    </thead>
+                                </table>
+                            </div>
+                        </div>
+                        <div class="lock_box">
+                            <div class="lock_box_header">锁定冻结的库存记录<span><button class="btn btn-info"  onclick="lockStoreAction()">锁定库存</button></span></div>
+                            <div id="locking_box_content" class="table-box mr-4  iwb-bootstrap-table">
+                                <form id="formStore">
+                                    <table class="table table-striped lockstore">
+                                        <tbody>
+                                        <tr>
+                                            <th style="width: 150px">批次号</th>
+                                            <th style="width: 150px">库位</th>
+                                            <th style="width: 150px">可用数量(千件)</th>
+                                            <th style="width: 200px">冻结数量</th>
+                                            <th style="width: 200px">千件/每包</th>
+                                        </tr>
+                                        </tbody>
+                                    </table>
+                                </form>
+                            </div>
+                        </div>
 
-							<table class="table table-striped lockstore">
-								<tbody>
-									<tr>
-										<th style="width: 150px">批次号</th>
-										<th style="width: 150px">库位</th>
-										<th style="width: 150px">可用数量(千件)</th>
-										<th style="width: 200px">发货数量</th>
-										<th style="width: 200px">千件/每包</th>
-									</tr>
-								</tbody>
-							</table>
-						</form>
-					</div>
+                      
+                    </div>
 				</div>
 			</div>
 		</div>
@@ -517,21 +544,55 @@ new SearchItem("saleMan", "业务员",showField:"saleManName").SetSearchIcon("qu
 			</div>
 
 		</div>
-		<div class="modal fade" id="showProductProcess" role="dialog" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
-			<div class="modal-dialog  modal-dialog-centered" role="document" style="width: 600px">
+        <div class="modal fade" id="showProductProcess" role="dialog" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
+            <div class="modal-dialog  modal-dialog-centered" role="document" style="width: 600px">
+                <div class="modal-content">
+                    @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("生产进度", ""))
+                    <div class="timeline-small">
+                        <div class="timeline-small-body">
+                            <ul>
+                            </ul>
+                        </div>
+                    </div>
+                    @Html.Partial("Modals/_ModalFooter", "1")
+                </div>
+            </div>
+
+        </div>
+        <!--显示订单明细已发货记录-->
+
+        <div class="modal fade" id="orderSendItemModal" role="dialog" tabindex="-1" >
+            <div class="modal-dialog  modal-dialog-centered" role="document" style="width: 980px">
 				<div class="modal-content">
-					@Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("生产进度", ""))
-					<div class="timeline-small">
-						<div class="timeline-small-body">
-							<ul>
-							</ul>
-						</div>
+					@Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("订单明细发货记录", ""))
+					<div class="table-box mr-4  iwb-bootstrap-table">
+						<table id="sendItemTable" data-striped="true" data-click-to-select="false" data-height="300"
+							   data-single-select="false">
+							<thead>
+								<tr class="row">
+									@*<th data-field="state" data-checkbox="true"></th>*@
+									<th data-align="center" data-field="stockNo">客户订单号 </th>
+									<th data-align="center" data-field="sendQuantity">数量</th>
+									<th data-align="center" data-field="orderUnitName">单位</th>
+									@*<th data-align="center" data-field="customerId">客户编号</th>*@
+									<th data-align="center" data-field="productNo">产品编号</th>
+									<th data-align="center" data-field="productName">产品名称</th>
+									<th data-align="center" data-field="model">规格</th>
+									@*<th data-align="center" data-field="surfaceColor">表色</th>
+									<th data-align="center" data-field="rigidity">硬度</th>*@
+                                    <th data-align="center" data-field="orderDate">订单日期</th>
+									<th data-align="center" data-field="sendDate" data-formatter="DateFormatter">送货日期</th>
+									<th data-align="center" data-field="linkName">联系人</th>
+
+								</tr>
+							</thead>
+						</table>
+					</div>
+						@Html.Partial("Modals/_ModalFooter", "1")
 					</div>
-					@Html.Partial("Modals/_ModalFooter", "1")
 				</div>
-			</div>
 
-		</div>
+        </div>
 	</section>
 	<section>
 		@Html.Partial("Modals/Query/_Customer", "KeyWords-4")
@@ -884,9 +945,10 @@ new SearchItem("saleMan", "业务员",showField:"saleManName").SetSearchIcon("qu
             });
         }
 
-        function f_SendOrderItem(id, quantity, isSendQuantity, productNo) {
+        function f_SendOrderItem(id, quantity, isSendQuantity, productNo, customerId) {
+			console.log("customerId", customerId)
 			var showSendModal = function () {
-				$("#productId_lockstore").val('') //清空锁定库存模态框Id
+				
 				$("#productId").val(productNo);
 				$("#orderItemNo_ForSend").val(id);
 				if (!isSendQuantity || !(isSendQuantity > 0)) {
@@ -906,16 +968,22 @@ new SearchItem("saleMan", "业务员",showField:"saleManName").SetSearchIcon("qu
 			}
             SaveAjax({
 				url: window.appUrl +
-					"OrderBookStore/CheckExistLockStore?id=" +id,
+					"OrderBookStore/CheckExistLockingStore?id=" +id,
 				isAlert: false,
 				isValidate: false,
                 success: function (res) {
                     //先检查是否存在锁定库存的记录,存在需要先发锁定的库存
 					if (res) {
                         abp.message.warn("订单存在锁定的库存记录,需要先发锁定的库存!");
-						renderLockedStoreTable("modalShowLockStore_body", id)
-						$("#modalShowLockStore").modal("show");
+                        $("#productId_lockstore").val(productNo);
+						$("#quantity_lockstore_key").val(quantity);
+						$("#orderItemId_lockstore_key").val(id);
+						$("#customerId_lockstore_key").val(customerId);
+                        renderLockedStoreTable(id)
+						reloadLockStoreTable(productNo, quantity, customerId)
+						$("#modalLockStore").modal("show")
                     } else {
+						$("#productId_lockstore").val('') //清空锁定库存模态框Id
 						showSendModal()
                     }
 				}
@@ -1229,6 +1297,7 @@ new SearchItem("saleMan", "业务员",showField:"saleManName").SetSearchIcon("qu
 
         function ActionsItemFormatter(v, r) {
             var str = "";
+            console.log(r)
             if (r.orderItemStatusId === 15) {
                 str = '<span class="table-action" onclick="f_SendOrderItem(\'' +
                     r.id +
@@ -1238,6 +1307,8 @@ new SearchItem("saleMan", "业务员",showField:"saleManName").SetSearchIcon("qu
                     r.isSendQuantity +
                     '\',\'' +
                     r.productNo +
+					'\',\'' +
+					r.customerId +
                     '\')"><i class="iconfont icon-right"></i>发货</span>';
             } else if (r.orderItemStatusId === 9) {
                 str = '<span class="table-action" onclick="f_CloseOrderItem(\'' +
@@ -1600,7 +1671,11 @@ new SearchItem("saleMan", "业务员",showField:"saleManName").SetSearchIcon("qu
                 '</span>';
             return str;
         }
-
+        function SendItemFormatter(v,r){
+            var str = `<span style="text-decoration:underline;" onclick="f_showSendItem(${r.id})">${v?v:0}</span>`;//orderSendItemModal
+            return str;
+        }
+        
         function f_showChangeQuantity(id, quantity, s) {
             if (s != @OrderItemStatusEnum.NewCreate.ToInt() && s != @OrderItemStatusEnum.Audited.ToInt()) {
                 abp.message.warn("已发货(或已结束),不能操作!");
@@ -1700,226 +1775,7 @@ new SearchItem("saleMan", "业务员",showField:"saleManName").SetSearchIcon("qu
   //          return '<span class="label label-primary">' + name + '</span>';
   //      }
 	</script>
-    <!--2024 -->
-    <script>
-        function f_lockStore() {
-            var items = $tableOrderItem.bootstrapTable("getSelections");
-			if (items.length !== 1) {
-				abp.message.warn("请选中一条记录操作!");
-                return
-            }
-			data = items[0]
-			if (data.orderItemStatusId != @OrderItemStatusEnum.Audited.ToInt()) {
-                abp.message.warn("订单明细状态为已审核才能锁定库存!");
-                return;
-            }
-            SaveAjax({
-				url: window.appUrl + "OrderBookStore/CheckExistLockStore?id=" + orderItemId,
-				isAlert: false,
-                isValidate: false,
-                success: function (res) {
-                    if (!res) {
-						$("#quantity_lockstore_key").val(data.quantity);
-						$("#orderItemId_lockstore_key").val(data.id);
-						$("#customerId_lockstore_key").val(data.customerId);
-						$("#productId_lockstore").val(data.productNo);
-						reloadLockStoreTable(data.productNo, data.quantity, data.customerId)
-						$("#modalLockStore").modal("show");//modalShowLockStore_body
-                    } else {
-						renderLockedStoreTable("modalShowLockStore_body", orderItemId)
-						$("#modalShowLockStore").modal("show");
-                    }
-                }
-            })
-
-			
-        }
-        //没有锁定库存记录的,输入锁定库存
-        function reloadLockStoreTable(productNo, quantity, customerId) {
-			var $tbody = $(".table.table-striped.lockstore > tbody");
-			$tbody.find("tr:not(:first)").remove();
-			SaveAjax({
-				url: window.appUrl + "Query/QueryStoreFilter?productNo=" + productNo + '&customerId=' + customerId,
-				isAlert: false,
-				isValidate: false,
-				success: function (res) {
-					if (res && res.length > 0) {
-						res.forEach(function (r) {
-							var sTr = '<tr>';
-							sTr += '<td class="currentProductStoreHouseNo" style="display:none;">' +
-								r.currentProductStoreHouseNo +
-								'</td>';
-							sTr += '<td class="productionOrderNo">' + r.productionOrderNo + '</td>';
-							sTr += '<td class="storeLocationNo">' + r.storeLocationNo + '</td>';
-							var isCanUser = formatNum(Number(r.quantity), Number(r.freezeQuantity), 3);
-							sTr += '<td>' + isCanUser + '</td>';
-							sTr +=
-								'<td style="position:relative"><input type="text"  name="SendQuantity" class="form-control number sendQuantity form-input-send"  min="0"  max="' +
-								isCanUser +
-								'"/></td>';
-							sTr +=
-								'<td style="position:relative"><input type="text"  name="AvgSendQuantity" class="form-control number avgQuantity form-input-send"  min="0"/></td>';
-							sTr += '</tr>';
-							$tbody.append(sTr);
-
-						});
-					}
-				}
-			});
-        }
-
-        //展示订单明细已经锁定的库存信息
-        function renderLockedStoreTable(domId, orderItemId) {
-            let $parent = $("#" + domId)
-            $parent.empty()
-			$("#orderItemId_lock_send_key").val(orderItemId)
-			let table = `<table class="table table-striped showLock">
-	                    <tbody>
-					                    <tr>
-						                    <th style="width: 150px">批次号</th>
-						                    <th style="width: 150px">产品编号</th>
-						                    <th style="width: 150px">库位</th>
-						                    <th style="width: 200px">冻结数量(千件)</th>
-						                    <th style="width: 200px">千件/每包</th>
-					                    </tr>
-
-	                    </tbody>
-                        </table>`
-            $table = $(table)
-            $tbody = $table.children("tbody")
-
-            SaveAjax({
-                url: window.appUrl + "OrderBookStore/GetDataByOrderItemId?id=" + orderItemId,
-				isAlert: false,
-                isValidate: false,
-                success: function (res) {
-					res.forEach(function (r) {
-                        var sTr = '<tr>';
-						sTr += '<td class="productionOrderNo">' + r.productBatchNum + '</td>';
-						sTr += '<td class="productNo">' + r.productNo + '</td>';
-						sTr += '<td class="storeLocationNo">' + r.storeLocationNo + '</td>';
-						sTr += '<td class="quantity">' + r.quantity + '</td>';
-						sTr += '<td class="quantityPerPack">' + r.quantityPerPack + '</td>';
-						sTr += '</tr>';
-						$tbody.append(sTr);
-                    })
-					$parent.prepend($table)
-                }
-            })
-			
-        }
-
-        //锁定库存
-        function lockStoreAction() {
-			var customerId = $("#customerId_lockstore_key").val();
-			var productNo = $("#productId_lockstore").val();
-			var quantity = $("#quantity_lockstore").val();//订单明细数量
-			var orderItemId = $("#orderItemId_lockstore_key").val();
-			var $tbody = $(".table.table-striped.lockstore > tbody");
-			var trDatas = $tbody.find("tr:not(:first)");
-			var sendAll = 0;
-			var dataParam = {
-				AddItems: [],
-				OrderItemId: orderItemId,
-			};
-			if (trDatas) {
-				for (var i = 0; i < trDatas.length; i++) {
-					var sendItem = {};
-					var sendQuantity = $(trDatas[i]).find(".sendQuantity").val();
-					if (!sendQuantity || Number(sendQuantity) <= 0) {
-						continue;
-					}
-					sendItem.Quantity = Number(sendQuantity);
-
-					var quantityPerPack = $(trDatas[i]).find(".avgQuantity").val();
-					if (!quantityPerPack || Number(quantityPerPack) <= 0) {
-						quantityPerPack = sendQuantity;
-					}
-					sendItem.QuantityPerPack = Number(avgQuantity);
 
-					var currentProductStoreHouseNo = $(trDatas[i]).find(".currentProductStoreHouseNo").text();
-					if (currentProductStoreHouseNo) {
-						sendItem.CurrentProductStoreHouseNo = currentProductStoreHouseNo;;
-					}
-
-					var productionOrderNo = $(trDatas[i]).find(".productionOrderNo").text();
-					if (productionOrderNo) {
-						sendItem.ProductBatchNum = productionOrderNo;
-					} else {
-						sendItem.ProductBatchNum = "00000000000";
-					}
-
-					var storeLocationNo = $(trDatas[i]).find(".storeLocationNo").text();
-					if (storeLocationNo) {
-						sendItem.StoreLocationNo = storeLocationNo;
-                    }
-                    sendItem.ProductNo = productNo;
-                    sendItem.CustomerId = customerId;
-                    dataParam.AddItems.push(sendItem);
-					sendAll += sendItem.Quantity
-				}
-
-			}
-			if (sendAll <= 0) {
-				abp.message.warn("锁定发货总量需要大于0千件!");
-				return;
-			}
-			 
-			var save = function () {
-				SaveAjax({
-					url: window.appUrl + "OrderBookStore/LockStore",
-					//contentType: 'application/json',
-					dataType: "json",
-					form: $("#formStore"),
-					data: dataParam,
-					isAlert: false,
-					isValidate: true,
-					success: function (res) {
-						if (res) {
-							$("#modalLockStore").modal("hide");
-						}
-					}
-				});
-			}
-
-			if (sendAll > Number(quantity)) {
-				var temp = formatNum(Number(sendAll),
-					Number(quantity) + Number(quantity * 0.05),
-					3);
-				if (temp > 0) {
-					abp.message.warn("锁定库存总量已超出订单发货量5%,不能继续操作!");
-					return;
-				}
-				abp.message.confirm("锁定库存总量已超出订单发货量,是否要继续锁定?",
-					"确认锁定库存",
-					function (isConfirmed) {
-						if (isConfirmed) {
-							save();
-						}
-					});
-			} else {
-				save();
-			}
-
-        }
-        //锁定库存发货
-        function lockStoreSendAction() {
-            var orderItemId = $("#orderItemId_lock_send_key").val()
-			SaveAjax({
-				url: window.appUrl + "OrderItems/SendBookStore?orderItemId=" + orderItemId,
-				isAlert: false,
-				isValidate: false,
-				success: function (res) {
-					RefreshOrderItemTable(res.orderNo);
-					$("#modalShowLockStore").modal("hide");
-				}
-			})
-        }
-	
-    </script>
-    <script>
-
-	</script>
     <script>
 
 		//将数字转换成金额显示 n是小数点后位数

+ 232 - 1
src_0nline/ShwasherSys/ShwasherSys.Web/Views/OrderInfo/js/OrderStatusMg.js

@@ -29,4 +29,235 @@
         }
     });
  
-}
+}
+//<!------------------2024 start----------------->
+
+function f_lockStore() {
+	var items = $tableOrderItem.bootstrapTable("getSelections");
+	if (items.length !== 1) {
+		abp.message.warn("请选中一条记录操作!");
+		return
+	}
+	data = items[0]
+	// 15:已审核
+	if (data.orderItemStatusId != 15) {
+		abp.message.warn("订单明细状态为已审核才能锁定库存!");
+		return;
+	}
+	$("#quantity_lockstore_key").val(data.quantity);
+	$("#orderItemId_lockstore_key").val(data.id);
+	$("#customerId_lockstore_key").val(data.customerId);
+	$("#productId_lockstore").val(data.productNo);
+	reloadLockStoreTable(data.productNo, data.quantity, data.customerId)
+	renderLockedStoreTable(data.id)
+	$("#modalLockStore").modal("show");//modalShowLockStore_body
+}
+//输入锁定库存
+function reloadLockStoreTable(productNo, quantity, customerId) {
+	var $tbody = $(".table.table-striped.lockstore > tbody");
+	$tbody.find("tr:not(:first)").remove();
+	SaveAjax({
+		url: window.appUrl + "Query/QueryStoreFilter?productNo=" + productNo + '&customerId=' + customerId,
+		isAlert: false,
+		isValidate: false,
+		success: function (res) {
+			if (res && res.length > 0) {
+				res.forEach(function (r) {
+					var sTr = '<tr>';
+					sTr += '<td class="currentProductStoreHouseNo" style="display:none;">' +
+						r.currentProductStoreHouseNo +
+						'</td>';
+					sTr += '<td class="productionOrderNo">' + r.productionOrderNo + '</td>';
+					sTr += '<td class="storeLocationNo">' + r.storeLocationNo + '</td>';
+					var isCanUser = formatNum(Number(r.quantity), Number(r.freezeQuantity), 3);
+					sTr += '<td>' + isCanUser + '</td>';
+					sTr +=
+						'<td style="position:relative"><input type="text"  name="SendQuantity" class="form-control number sendQuantity form-input-send"  min="0"  max="' +
+						isCanUser +
+						'"/></td>';
+					sTr +=
+						'<td style="position:relative"><input type="text"  name="AvgSendQuantity" class="form-control number avgQuantity form-input-send"  min="0"/></td>';
+					sTr += '</tr>';
+					$tbody.append(sTr);
+
+				});
+			}
+		}
+	});
+}
+
+//展示订单明细已经锁定的库存信息
+function renderLockedStoreTable(orderItemId) {
+	$("#LockedStoreTable").bootstrapTable("destroy");
+	SaveAjax({
+		url: window.appUrl + "OrderBookStore/GetDataByOrderItemId?id=" + orderItemId,
+		isAlert: false,
+		isValidate: false,
+		success: function (res) {
+			$("#LockedStoreTable").bootstrapTable({ data: res })
+		}
+	})
+
+}
+
+//获取已锁定的总数量
+function getLockStoreAllQuantity() {
+	let data = $("#LockedStoreTable").bootstrapTable('getData');
+	return data.reduce((pre,cur) => {
+		return pre+cur.quantity
+	},0)
+}
+
+//锁定库存
+function lockStoreAction() {
+	var customerId = $("#customerId_lockstore_key").val();
+	var productNo = $("#productId_lockstore").val();
+	var quantity = $("#quantity_lockstore_key").val();//订单明细数量
+	var orderItemId = $("#orderItemId_lockstore_key").val();
+	var $tbody = $(".table.table-striped.lockstore > tbody");
+	var trDatas = $tbody.find("tr:not(:first)");
+	var sendAll = 0;
+	var dataParam = {
+		AddItems: [],
+		OrderItemId: orderItemId,
+	};
+	if (trDatas) {
+		for (var i = 0; i < trDatas.length; i++) {
+			var sendItem = {};
+			var sendQuantity = $(trDatas[i]).find(".sendQuantity").val();
+			if (!sendQuantity || Number(sendQuantity) <= 0) {
+				continue;
+			}
+			sendItem.Quantity = Number(sendQuantity);
+
+			var quantityPerPack = $(trDatas[i]).find(".avgQuantity").val();
+			if (!quantityPerPack || Number(quantityPerPack) <= 0) {
+				quantityPerPack = sendQuantity;
+			}
+			sendItem.QuantityPerPack = Number(quantityPerPack);
+
+			var currentProductStoreHouseNo = $(trDatas[i]).find(".currentProductStoreHouseNo").text();
+			if (currentProductStoreHouseNo) {
+				sendItem.CurrentProductStoreHouseNo = currentProductStoreHouseNo;;
+			}
+
+			var productionOrderNo = $(trDatas[i]).find(".productionOrderNo").text();
+			if (productionOrderNo) {
+				sendItem.ProductBatchNum = productionOrderNo;
+			} else {
+				sendItem.ProductBatchNum = "00000000000";
+			}
+
+			var storeLocationNo = $(trDatas[i]).find(".storeLocationNo").text();
+			if (storeLocationNo) {
+				sendItem.StoreLocationNo = storeLocationNo;
+			}
+			sendItem.ProductNo = productNo;
+			sendItem.CustomerId = customerId;
+			dataParam.AddItems.push(sendItem);
+			sendAll += sendItem.Quantity
+		}
+
+	}
+	if (sendAll <= 0) {
+		abp.message.warn("锁定发货总量需要大于0千件!");
+		return;
+	}
+	let hasLockQuantity = getLockStoreAllQuantity()
+	var save = function () {
+		SaveAjax({
+			url: window.appUrl + "OrderBookStore/LockStore",
+			//contentType: 'application/json',
+			dataType: "json",
+			form: $("#formStore"),
+			data: dataParam,
+			isAlert: false,
+			isValidate: true,
+			success: function (res) {
+				abp.message.success("锁定库存总量成功!");
+				//$("#modalLockStore").modal("hide");
+				renderLockedStoreTable(orderItemId)
+				reloadLockStoreTable($("#productId_lockstore").val(), $("#quantity_lockstore_key").val(), $("#customerId_lockstore_key").val())
+			}
+		});
+	}
+	let warnMsg = "是否要继续锁定?"
+	let allQuantity = sendAll + hasLockQuantity
+	if (allQuantity > quantity) {
+		let exceed = (Number(allQuantity - quantity) / Number(quantity)) * 100
+		if (exceed > 5) {
+			warnMsg = "发货数量不能超过 订单明细总数量的5%!"
+			abp.message.warn(warnMsg);
+			return
+		}
+		warnMsg = "锁定数量已经超过了订单数量!"
+	}
+	abp.message.confirm(warnMsg, "确认锁定库存", function (isConfirmed) {
+		if (isConfirmed) {
+			save();
+		}
+	});
+}
+
+function LockedStatusFormatter(v, r) {
+	return `<span class="label label-success">${v == 1 ?"已发货":"未发货"}</span>`
+}
+function LockedStoreActionFormatter(v, r) {
+	if (r.status == 0) {
+		return `<span class="table-action" onclick="f_unLockItem(${r.id})"><i class="iconfont icon-right"></i>解除锁定</span>
+	<span class="table-action" onclick="f_sendLockItem(${r.id})"><i class="iconfont icon-right"></i>发货</span>`
+	}
+}
+//锁定库存解锁(软删除)
+function f_unLockItem(id) {
+   abp.message.confirm("确认解除锁定?", function (isConfirmed) {
+        if (isConfirmed) {
+            SaveAjax({
+				url: window.appUrl + 'OrderBookStore/UnLockItem?id=' + id,
+                isValidate: false,
+                isAlert: false,
+                success: function (res) {
+					abp.notify.success("解除锁定成功!");
+					renderLockedStoreTable($("#orderItemId_lockstore_key").val())
+					reloadLockStoreTable($("#productId_lockstore").val(), $("#quantity_lockstore_key").val(), $("#customerId_lockstore_key").val())
+                }
+            });
+        }
+    });
+}
+//锁定库存发货
+function f_sendLockItem(id) {
+	var orderItemId = $("#orderItemId_lockstore_key").val()
+	abp.message.confirm("确认将锁定的库存记录进行发货?", "确认发货", function (isConfirmed) {
+		if (isConfirmed) {
+			SaveAjax({
+				url: window.appUrl + "OrderItems/SendBookStoreItem?orderItemId=" + orderItemId+"&id="+id,
+				isValidate: false,
+				isAlert: false,
+				success: function (res) {
+					abp.notify.success("发货成功!");
+					renderLockedStoreTable($("#orderItemId_lockstore_key").val())
+					reloadLockStoreTable($("#productId_lockstore").val(), $("#quantity_lockstore_key").val(), $("#customerId_lockstore_key").val())
+					RefreshOrderItemTable(res.orderNo);
+				}
+			});
+		}
+	});
+}
+// 订单明细的发货记录
+function f_showSendItem(orderItemId) {
+	$("#sendItemTable").bootstrapTable("destroy");
+	SaveAjax({
+		url: window.appUrl + "OrderItems/QuerySendItem?id=" + orderItemId,
+		dataType: "json",
+		isAlert: false,
+		isValidate: false,
+		success: function (res) {
+			$("#sendItemTable").bootstrapTable({ data: res })
+			$('#sendItemTable tbody').sortable({ containment: "#sendItemTable tbody", cursor: "move" });
+		}
+	})
+	$('#orderSendItemModal').modal('show');
+}
+
+//<!------------------2024 end----------------->