diff --git a/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs index 8a0929a8..6567aab8 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs @@ -59,11 +59,18 @@ namespace DS.WMS.Core.Fee.Interface /// Task BulkEditDetailsAsync(List details); + /// + /// 复制模板 + /// + /// + /// + Task CopyAsync(params long[] ids); + /// /// 根据ID批量删除 /// - /// + /// /// - Task DeleteAsync(IdModel model); + Task DeleteAsync(params long[] ids); } } diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs index 410b217a..ae306228 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs @@ -1,6 +1,5 @@ using DS.Module.Core; using DS.Module.Core.Condition; -using DS.Module.Core.Data; using DS.Module.Core.Extensions; using DS.WMS.Core.Code.Entity; using DS.WMS.Core.Fee.Dtos; @@ -593,7 +592,7 @@ namespace DS.WMS.Core.Fee.Method /// /// /// - public async Task BulkEditAsync(List list) + public async Task BulkEditAsync(List list) { int rows = await TenantDb.Updateable(list).UpdateColumns(x => new { @@ -674,14 +673,50 @@ namespace DS.WMS.Core.Fee.Method return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); } + /// + /// 复制模板 + /// + /// + /// + public async Task CopyAsync(params long[] ids) + { + long userId = long.Parse(User.UserId); + DateTime dt = DateTime.Now; + + var list = await TenantDb.Queryable().Where(x => ids.Contains(x.Id)) + .Includes(x => x.Details).ToListAsync(); + + foreach (var item in list) + { + item.Id = 0; + item.CreateTime = dt; + item.CreateBy = userId; + item.UpdateBy = null; + item.UpdateTime = null; + item.Name += "-Copy"; + item.DeptOrgId ??= User.OrgId; + + foreach (var detail in item.Details) + { + detail.Id = 0; + detail.TemplateId = 0; + detail.CreateBy = userId; + detail.CreateTime = dt; + } + } + + var boolValue = await TenantDb.InsertNav(list).Include(x => x.Details).ExecuteCommandAsync(); + return boolValue ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); + } + /// /// 根据ID批量删除 /// - /// + /// /// - public async Task DeleteAsync(IdModel model) + public async Task DeleteAsync(params long[] ids) { - bool flag = await TenantDb.DeleteNav(x => model.Ids.Contains(x.Id)) + bool flag = await TenantDb.DeleteNav(x => ids.Contains(x.Id)) .Include(x => x.Details).ExecuteCommandAsync(); return flag ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); } diff --git a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs index fd07742f..bfe84c96 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs +++ b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs @@ -166,6 +166,19 @@ namespace DS.WMS.FeeApi.Controllers return await _invokeService.BulkEditDetailsAsync(details); } + /// + /// 复制模板 + /// + /// + /// + public async Task CopyAsync([FromBody] IdModel model) + { + if (!ModelState.IsValid) + return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest); + + return await _invokeService.CopyAsync(model.Ids); + } + /// /// 详情 /// @@ -188,7 +201,7 @@ namespace DS.WMS.FeeApi.Controllers if (!ModelState.IsValid) return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest); - return await _invokeService.DeleteAsync(model); + return await _invokeService.DeleteAsync(model.Ids); } ///