模板复制

dev
嵇文龙 4 weeks ago
parent e6fa12ede7
commit 25194a86a3

@ -59,11 +59,18 @@ namespace DS.WMS.Core.Fee.Interface
/// <returns></returns>
Task<DataResult> BulkEditDetailsAsync(List<FeeCustTemplateDetail> details);
/// <summary>
/// 复制模板
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
Task<DataResult> CopyAsync(params long[] ids);
/// <summary>
/// 根据ID批量删除
/// </summary>
/// <param name="model"></param>
/// <param name="ids"></param>
/// <returns></returns>
Task<DataResult> DeleteAsync(IdModel model);
Task<DataResult> DeleteAsync(params long[] ids);
}
}

@ -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
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public async Task<DataResult> BulkEditAsync(List<FeeCustTemplate> list)
public async Task<DataResult> BulkEditAsync(List<FeeCustTemplate> 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));
}
/// <summary>
/// 复制模板
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public async Task<DataResult> CopyAsync(params long[] ids)
{
long userId = long.Parse(User.UserId);
DateTime dt = DateTime.Now;
var list = await TenantDb.Queryable<FeeCustTemplate>().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));
}
/// <summary>
/// 根据ID批量删除
/// </summary>
/// <param name="model"></param>
/// <param name="ids"></param>
/// <returns></returns>
public async Task<DataResult> DeleteAsync(IdModel model)
public async Task<DataResult> DeleteAsync(params long[] ids)
{
bool flag = await TenantDb.DeleteNav<FeeCustTemplate>(x => model.Ids.Contains(x.Id))
bool flag = await TenantDb.DeleteNav<FeeCustTemplate>(x => ids.Contains(x.Id))
.Include(x => x.Details).ExecuteCommandAsync();
return flag ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}

@ -166,6 +166,19 @@ namespace DS.WMS.FeeApi.Controllers
return await _invokeService.BulkEditDetailsAsync(details);
}
/// <summary>
/// 复制模板
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public async Task<DataResult> CopyAsync([FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await _invokeService.CopyAsync(model.Ids);
}
/// <summary>
/// 详情
/// </summary>
@ -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);
}
/// <summary>

Loading…
Cancel
Save