Bladeren bron

添加人民币汇率及项状态处理功能

在 `GroupsController.cs` 中添加人民币(CNY)汇率信息,以确保在初始化汇率列表时包含该货币。
在 `EnterExitCostQuoteView.cs` 中为 `InitBasicItemView` 和 `QuoteItemInfo` 类添加 `IsOnlyRemark` 属性,以标识某些项是否仅为备注。
更新 `EnterExitCostQuoteRepository.cs` 中的 `InitBasicItemAsync` 方法,确保在创建对象时包含 `IsOnlyRemark` 属性,并在选择报价项时也包含该属性。
重构 `EnterExitCostQuoteRepository.cs` 中的代码以提高可读性,并添加对前台删除项数据的验证和处理,确保在更新项时能够正确处理已删除的项并更新数据库状态。
LEIYI 1 dag geleden
bovenliggende
commit
e406acce41

+ 2 - 1
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -13257,6 +13257,7 @@ FROM
                 if (!info1.Rates.Any())
                 {
                     var rates = await GeneralMethod.EnterExitCostInitRate();
+                    rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
                     info1.Rates = rates.ToArray();
                 }
                 return Ok(JsonView(info1));
@@ -13284,7 +13285,6 @@ FROM
                 }
             }
 
-
             var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
             if (info.Code != StatusCodes.Status200OK)
             {
@@ -13632,6 +13632,7 @@ FROM
             if (!info.Rates.Any())
             {
                 var rates = await GeneralMethod.EnterExitCostInitRate();
+                rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
                 info.Rates = rates.ToArray();
             }
 

+ 2 - 0
OASystem/OASystem.Domain/ViewModels/Groups/EnterExitCostQuoteView.cs

@@ -18,6 +18,7 @@ namespace OASystem.Domain.ViewModels.Groups
     {
         public int Id { get; set; }
         public string Name { get; set; }
+        public bool IsOnlyRemark { get; set; } = false;
         public int Index { get; set; }
     }
 
@@ -75,6 +76,7 @@ namespace OASystem.Domain.ViewModels.Groups
         public int QuoteId { get; set; }
         public int ItemId { get; set; }
         public string ItemName { get; set; }
+        public bool IsOnlyRemark { get; set; }
 
         public string ItemWrapName
         {

+ 66 - 8
OASystem/OASystem.Infrastructure/Repositories/Groups/EnterExitCostQuoteRepository.cs

@@ -43,13 +43,23 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 }).ToListAsync();
 
             var newList = origList.Select(x => new InitBasicItemView
-            {
-                Id = x.Id,
-                Name = removeNl ? x.Name.Replace("\\r\\n", "") : x.Name,
-                Index = int.TryParse(x.Index, out int index) ? index : -1
-            })
+                {
+                    Id = x.Id,
+                    Name = removeNl ? x.Name.Replace("\\r\\n", "") : x.Name,
+                    Index = int.TryParse(x.Index, out int index) ? index : -1
+                })
                 .OrderBy(x => x.Index)
                 .ToList();
+
+            var onlyItems = new List<int>() {
+                1358, //邀请函发放对象
+                1360, //邀请函发放时间
+            };
+
+            newList.ForEach(x =>
+            {
+                if (onlyItems.Contains(x.Id)) x.IsOnlyRemark = true;
+            });
             return newList;
         }
 
@@ -173,7 +183,15 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
             if (basicItems.Any())
             {
-                viewInfo.FeeItems = basicItems.Select(x => new QuoteItemInfo { ItemId = x.Id, ItemName = x.Name, Index = x.Index }).OrderBy(x => x.Index).ToArray();
+                viewInfo.FeeItems = basicItems.Select(x => 
+                    new QuoteItemInfo { 
+                        ItemId = x.Id, 
+                        ItemName = x.Name,
+                        IsOnlyRemark = x.IsOnlyRemark, 
+                        Index = x.Index 
+                    })
+                    .OrderBy(x => x.Index)
+                    .ToArray();
             }
 
             var quoteInfo = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>()
@@ -225,7 +243,16 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
             if (basicItems.Any())
             {
-                viewInfo.FeeItems = basicItems.Select(x => new QuoteItemInfo { ItemId = x.Id, ItemName = x.Name, Index = x.Index }).OrderBy(x => x.Index).ToArray();
+                viewInfo.FeeItems = basicItems.Select(x =>
+                    new QuoteItemInfo
+                    {
+                        ItemId = x.Id,
+                        ItemName = x.Name,
+                        IsOnlyRemark = x.IsOnlyRemark,
+                        Index = x.Index
+                    })
+                    .OrderBy(x => x.Index)
+                    .ToArray();
             }
 
             var quoteInfo = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>()
@@ -340,7 +367,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
             }
             else if (!isNull) //编辑
             {
-                var quoteUpd = await _sqlSugar.Updateable(quoteInfo).IgnoreColumns(x => new { x.CreateUserId, x.CreateTime, x.IsDel }).ExecuteCommandAsync();
+                var quoteUpd = await _sqlSugar.Updateable(quoteInfo)
+                    .IgnoreColumns(x => new { x.CreateUserId, x.CreateTime, x.IsDel })
+                    .ExecuteCommandAsync();
                 if (quoteUpd < 1)
                 {
                     jw.Msg = "编辑失败!";
@@ -363,6 +392,35 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
                 if (updItems.Any())
                 {
+                    //验证及处理前台删除项数据
+                    var perDelItems = await _sqlSugar.Queryable<Grp_EnterExitCostQuoteItem>()
+                        .Where(x => x.IsDel == 0 && x.QuoteId == quoteId)
+                        .ToListAsync();
+                    if (perDelItems.Any())
+                    {
+                        var delItems = perDelItems.Where(x => !updItems.Select(y => y.Id).Contains(x.Id)).ToList();
+                        if (delItems.Any())
+                        {
+                            var newDelItems = delItems.Select(x =>
+                                new Grp_EnterExitCostQuoteItem
+                                {
+                                    Id = x.Id,
+                                    DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+                                    DeleteUserId = dto.CurrUserId,
+                                    IsDel = 1
+                                }).ToList();
+                            var delItemStatus = await _sqlSugar.Updateable(newDelItems)
+                                .UpdateColumns(x => new { x.DeleteTime, x.DeleteUserId, x.IsDel })
+                                .ExecuteCommandAsync();
+                            if (delItemStatus < 1)
+                            {
+                                jw.Msg = "移除项费用失败!";
+                                _sqlSugar.RollbackTran();
+                                return jw;
+                            }
+                        }
+                    }
+
                     var updItem = await _sqlSugar.Updateable(updItems).IgnoreColumns(x => new { x.CreateUserId, x.CreateTime, x.IsDel }).ExecuteCommandAsync();
                     if (updItem < 1)
                     {