Bläddra i källkod

客户资料历史记录代码编写

LEIYI 3 månader sedan
förälder
incheckning
afc8d7400f

+ 48 - 13
OASystem/OASystem.Api/Controllers/MarketCustomerResourcesController.cs

@@ -11,6 +11,7 @@ using System.Data;
 using System.Diagnostics;
 using System.Linq;
 using OASystem.Domain.Attributes;
+using EyeSoft.Extensions;
 
 namespace OASystem.API.Controllers
 {
@@ -271,15 +272,8 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> QueryUserSelect()
         {
-            try
-            {
-                Result resTable = _clientDataRepository.QueryUserSelect();
-                return Ok(JsonView(true, resTable.Msg, resTable.Data));
-            }
-            catch (Exception)
-            {
-                return Ok(JsonView(false, "程序错误!"));
-            }
+            Result resTable = _clientDataRepository.QueryUserSelect();
+            return Ok(JsonView(true, resTable.Msg, resTable.Data));
         }
 
         /// <summary>
@@ -626,18 +620,59 @@ namespace OASystem.API.Controllers
         }
 
         /// <summary>
-        /// 客户资料数据 excel 下载
+        /// 客户资料数据 历史记录 Init
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> NewClientDataRecordInit(NewClientDataRecordInitDto dto)
+        {
+
+            #region 参数验证
+            if (dto.UserId < 0) return Ok(JsonView(false, MsgTips.UserId));
+            if (!SharingStaticData.PortTypes.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
+            if (dto.PageId < 0) return Ok(JsonView(false, MsgTips.PageId));
+            #endregion
+
+            #region 页面操作权限验证
+            var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
+
+            if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
+            #endregion
+            var enumfiltrates = new string[] { "NoOperation", "Audit", "Login" };
+            var operations = EnumHelper.GetEnumDescriptions(typeof(OperationEnum), enumfiltrates);
+
+            object userDatas = Array.Empty<object>();
+            if (dto.UserId == 21)
+            {
+                var userIds = await _sqlSugar.Queryable<Crm_ClientDataAndUser>().Where(x => x.IsDel == 0).Select(x => x.usersId).Distinct().ToListAsync();
+                if (userIds.Any())
+                {
+                    userDatas = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && userIds.Contains(x.Id)).Select(x => new { value = x.Id, text = x.CnName }).ToListAsync();
+                }
+            }
+
+            var data = new {
+                operations = operations,
+                userDatas = userDatas
+            };
+            return Ok(JsonView(data));
+
+        }
+
+        /// <summary>
+        /// 客户资料数据 历史记录
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
         [HttpPost]
-        [ApiLog("Crm_NewClientData", OperationEnum.Download)]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> NewClientDataRecord(NewClientDataRecordDto dto)
         {
             #region 参数验证
             if (dto.UserId < 0) return Ok(JsonView(false, MsgTips.UserId));
-            if (SharingStaticData.PortTypes.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
+            if (!SharingStaticData.PortTypes.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
             if (dto.PageId < 0) return Ok(JsonView(false, MsgTips.PageId));
             #endregion
 
@@ -647,7 +682,7 @@ namespace OASystem.API.Controllers
             if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
             #endregion
 
-            return Ok(JsonView(await _clientDataRepository.NewClientDataRecord(dto)));
+            return Ok(await _clientDataRepository.NewClientDataRecord(dto));
 
         }
 

+ 22 - 0
OASystem/OASystem.Domain/AutoMappers/_baseMappingProfile.cs

@@ -24,6 +24,7 @@ using OASystem.Domain.Dtos.PersonnelModule;
 using OASystem.Domain.Dtos.Statistics;
 using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.Statistics;
+using AutoMapper.Internal;
 
 namespace OASystem.Domain.AutoMappers
 {
@@ -307,6 +308,7 @@ namespace OASystem.Domain.AutoMappers
             CreateMap<NewClientOpDto, Crm_NewClientData>();
             CreateMap<Crm_NewClientData, NewClientDataView>();
             CreateMap<Crm_NewClientData, NewClientDataExcelDownloadView>();
+            CreateMap<NewClientDataRecordInfoView, NewClientDataRecordView>();
             #endregion
             #endregion
 
@@ -364,4 +366,24 @@ namespace OASystem.Domain.AutoMappers
             #endregion
         }
     }
+
+    public class AutoMapperConfig
+    {
+        /// <summary>
+        /// 验证配置
+        /// </summary>
+        public static void Initialize()
+        {
+            var config = new MapperConfiguration(cfg =>
+            {
+                cfg.Internal().AllowAdditiveTypeMapCreation = true;
+                cfg.AddProfile<_baseMappingProfile>();
+            });
+
+            var mapper = config.CreateMapper();
+
+            // 验证配置
+            config.AssertConfigurationIsValid();
+        }
+    }
 }

+ 16 - 1
OASystem/OASystem.Domain/Dtos/CRM/NewClientDataQueryDto.cs

@@ -66,13 +66,27 @@ namespace OASystem.Domain.Dtos.CRM
         public int PageId { get; set; }
     }
 
+    public class NewClientDataRecordInitDto : UserPageFuncDtoBase
+    { }
+
     public class NewClientDataRecordDto : UserPageFuncDtoBase
     {
         public int PageIndex { get; set; } = 1;
 
         public int PageSize { get; set; } = 10;
 
-        public string OpUserName { get; set; }
+        /// <summary>
+        /// 操作类型 全部不传值、多个逗号隔开 
+        /// NoOperation, List, Details, Add, Edit, Del, Audit, Upload, Download, BatchAssignment, Login
+        /// </summary>
+        public string OpTypeLabel { get; set; }
+
+        /// <summary>
+        /// 操作用户  userId=21 时传值
+        /// 全部不传值、多个逗号隔开
+        /// 21, 22, 23
+        /// </summary>
+        public string OpUserLabel { get; set; }
 
         public string BeginTime { get; set; }
         public string EndTime { get; set; }
@@ -290,4 +304,5 @@ namespace OASystem.Domain.Dtos.CRM
         }
     }
 
+    
 }

+ 21 - 0
OASystem/OASystem.Domain/Entities/Customer/Crm_NewClientData.cs

@@ -2,6 +2,7 @@
 using Org.BouncyCastle.Asn1.Ocsp;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -46,6 +47,7 @@ namespace OASystem.Domain.Entities.Customer
         /// <summary>
         /// 地市州Id
         /// </summary>
+        [Description("客户区域")]
         [SugarColumn(ColumnDescription = "客户区域", IsNullable = true, ColumnDataType = "int")]
         public int Lvlid { get => lvlid; set => lvlid = value; }
 
@@ -53,6 +55,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 客户单位
         /// </summary>
         [Encrypted]
+        [Description("客户单位")]
         [SugarColumn(ColumnDescription = "客户单位", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string Client { get => client; set => client = value; }
 
@@ -60,6 +63,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 权重
         /// </summary>
         [Encrypted]
+        [Description("权重")]
         [SugarColumn(ColumnDescription = "权重", IsNullable = true, ColumnDataType = "nvarchar(100)")]
         public string Weight { get => weight; set => weight = value; }
 
@@ -67,6 +71,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 客户单位简写
         /// </summary>
         [Encrypted]
+        [Description("客户单位简写")]
         [SugarColumn(ColumnDescription = "客户单位简写", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string ClientShort { get => clientshort; set => clientshort = value; }
 
@@ -74,12 +79,14 @@ namespace OASystem.Domain.Entities.Customer
         /// 联系人
         /// </summary>
         [Encrypted]
+        [Description("联系人")]
         [SugarColumn(ColumnDescription = "联系人", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string Contact { get => contact; set => contact = value; }
 
         /// <summary>
         /// 联系人性别
         /// </summary>
+        [Description("性别")]
         [SugarColumn(ColumnDescription = "性别", IsNullable = true, ColumnDataType = "int")]
         public int Gender { get => gender; set => gender = value; }
 
@@ -87,12 +94,14 @@ namespace OASystem.Domain.Entities.Customer
         /// 护照
         /// </summary>
         [Encrypted]
+        [Description("护照")]
         [SugarColumn(ColumnDescription = "护照", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string Passport { get => passport; set => passport = value; }
 
         /// <summary>
         /// 护照日期
         /// </summary>
+        [Description("护照日期")]
         [SugarColumn(ColumnDescription = "护照日期", IsNullable = true, ColumnDataType = "DateTime")]
         public DateTime? PassportDate { get => passportDate; set => passportDate = value; }
 
@@ -100,6 +109,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 职位
         /// </summary>
         [Encrypted]
+        [Description("职位")]
         [SugarColumn(ColumnDescription = "职位", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string Job { get => job; set => job = value; }
 
@@ -107,6 +117,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 联系手机号
         /// </summary>
         [Encrypted]
+        [Description("手机号")]
         [SugarColumn(ColumnDescription = "手机号", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string Telephone { get => telephone; set => telephone = value; }
 
@@ -114,6 +125,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 联系座机号
         /// </summary>
         [Encrypted]
+        [Description("座机号")]
         [SugarColumn(ColumnDescription = "座机号", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string Phone { get => phone; set => phone = value; }
 
@@ -121,6 +133,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 邮件
         /// </summary>
         [Encrypted]
+        [Description("邮件")]
         [SugarColumn(ColumnDescription = "邮件", IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string Email { get => email; set => email = value; }
 
@@ -128,6 +141,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 所属区域(所在城市)
         /// </summary>
         [Encrypted]
+        [Description("所在城市")]
         [SugarColumn(IsNullable = true, ColumnDataType = "nvarchar(MAX)")]
         public string Location { get => location; set => location = value; }
 
@@ -135,6 +149,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 地址
         /// </summary>
         [Encrypted]
+        [Description("具体地址")]
         [SugarColumn(IsNullable = true, ColumnDataType = "varchar(80)")]
         public string Address { get => address; set => address = value; }
 
@@ -142,6 +157,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 生日
         /// </summary>
         [Encrypted]
+        [Description("生日信息")]
         [SugarColumn(IsNullable = true, ColumnDataType = "string")]
         public string Birthday { get => birthday; set => birthday = value; }
 
@@ -149,6 +165,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 其他信息
         /// </summary>
         [Encrypted]
+        [Description("备注")]
         [SugarColumn(IsNullable = true, ColumnDataType = "nvarchar(MAX)")]
         public string OtherInfo { get => otherinfo; set => otherinfo = value; }
 
@@ -156,24 +173,28 @@ namespace OASystem.Domain.Entities.Customer
         /// 微信
         /// </summary>
         [Encrypted]
+        [Description("微信")]
         [SugarColumn(IsNullable = true, ColumnDataType = "nvarchar(200)")]
         public string Wechat { get => wechat; set => wechat = value; }
 
         /// <summary>
         /// 分类
         /// </summary>
+        [Description("业务归属")]
         [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int Category { get => category; set => category = value; }
 
         /// <summary>
         /// 预计出团
         /// </summary>
+        [Description("今年预计出团")]
         [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int PreDele { get => predele; set => predele = value; }
 
         /// <summary>
         /// 已出团
         /// </summary>
+        [Description("今年已出团")]
         [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int FinlishedDele { get => finlishedDele; set => finlishedDele = value; }
     }

+ 37 - 0
OASystem/OASystem.Domain/Enums/EnumHelper.cs

@@ -92,5 +92,42 @@ namespace OASystem.Domain.Enums
             }
             return nvc;
         }
+
+        /// <summary>
+        /// 获取枚举的所有值及其对应的描述
+        /// </summary>
+        /// <param name="enumType"></param>
+        /// <param name="enumKeys"></param>
+        /// <returns></returns>
+        public static Dictionary<string, string> GetEnumDescriptions(Type enumType, string[]? enumKeys = null)
+        {
+            var descriptions = new Dictionary<string, string>();
+            if (!enumType.IsEnum)
+            {
+                return descriptions;
+                //throw new ArgumentException("Type must be an enum", nameof(enumType));
+            }
+
+
+            foreach (var field in enumType.GetFields(BindingFlags.Static | BindingFlags.GetField | BindingFlags.Public))
+            {
+                var descriptionAttribute = field.GetCustomAttribute<DescriptionAttribute>();
+                var description = descriptionAttribute?.Description ?? field.Name;
+                var name = field.Name;
+                if (enumKeys != null && enumKeys.Any())
+                {
+                    if (!enumKeys.Contains(name))
+                    {
+                        descriptions[name] = description;
+                    }
+                }
+                else {
+                    descriptions[name] = description;
+                }
+
+            }
+
+            return descriptions;
+        }
     }
 }

+ 5 - 5
OASystem/OASystem.Domain/Enums/OperationEnum.cs

@@ -11,21 +11,21 @@ namespace OASystem.Domain.Enums
     /// 操作项目
     /// </summary>
     public enum OperationEnum : int
-    {
+    {    
         /// <summary>
         /// 未操作
         /// </summary>
         [Description("未操作")]
         NoOperation = 0,
         /// <summary>
-        /// 列表
+        /// 查看列表
         /// </summary>
-        [Description("列表")]
+        [Description("查看列表")]
         List = 1,
         /// <summary>
         /// 详情
         /// </summary>
-        [Description("详情")]
+        [Description("查看详情")]
         Details = 2,
         /// <summary>
         /// 添加
@@ -66,6 +66,6 @@ namespace OASystem.Domain.Enums
         /// 登录
         /// </summary>
         [Description("登录")]
-        Login = 9,
+        Login = 10,
     }
 }

+ 116 - 2
OASystem/OASystem.Domain/ViewModels/CRM/NewClientDataView.cs

@@ -1,11 +1,16 @@
-using OASystem.Domain.Attributes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using OASystem.Domain.AesEncryption;
+using OASystem.Domain.Attributes;
 using OASystem.Domain.Entities.Customer;
 using OASystem.Domain.Enums;
 using Org.BouncyCastle.Asn1.Ocsp;
 using Org.BouncyCastle.Asn1.X9;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Linq;
+using System.Reflection;
 using System.Text;
 using System.Threading.Tasks;
 using static Google.Protobuf.Reflection.SourceCodeInfo.Types;
@@ -300,7 +305,7 @@ namespace OASystem.Domain.ViewModels.CRM
     }
 
 
-    public class NewClientDataRecordView
+    public class NewClientDataRecordInfoView
     {
         public int RowIndex { get; set; }
         public int Id { get; set; }
@@ -324,11 +329,120 @@ namespace OASystem.Domain.ViewModels.CRM
                 return OperationItem.GetEnumDescription();
             }
         }
+
+        public int DataId { get; set; }
+        public string Client { get; set; }
+
+        public string ClientLable
+        {
+            get
+            {
+                var lable = string.Empty;
+
+                if (OperationItem == OperationEnum.Add || OperationItem == OperationEnum.Details || OperationItem == OperationEnum.Edit)
+                {
+                    if (!string.IsNullOrEmpty(Client))
+                    {
+                        lable = AesEncryptionHelper.Decrypt(Client);
+                    }
+                }
+                return lable;
+            }
+        }
+
         public int CreateUserId { get; set; }
         public string CreateUserName { get; set; }
         public DateTime CreateTime { get; set; }
         public string UpdatePreData { get; set; }
         public string UpdateBefData { get; set; }
+
+        public string Label
+        {
+            get
+            {
+                string lable = string.Empty;
+                if (OperationItem == OperationEnum.Edit)
+                {
+                    Crm_NewClientData? originalInfo = null;
+                    Crm_NewClientData? newInfo = null;
+                    if (!string.IsNullOrEmpty(UpdatePreData) && IsValidJson(UpdatePreData)) originalInfo = JsonConvert.DeserializeObject<Crm_NewClientData>(UpdatePreData);
+                    if (!string.IsNullOrEmpty(UpdateBefData) && IsValidJson(UpdateBefData)) newInfo = JsonConvert.DeserializeObject<Crm_NewClientData>(UpdateBefData);
+
+                    string operationLabel = $"执行了{OperationItemLable}操作。";
+                    if (originalInfo != null && newInfo != null)
+                    {
+                        string updatedFieldLable = GetUpdatedFields(originalInfo, newInfo);
+                        if (!string.IsNullOrEmpty(updatedFieldLable)) operationLabel = $"{OperationItemLable}了“{ClientLable}”单位的{GetUpdatedFields(originalInfo, newInfo)}数据。";
+                        else operationLabel = $"未{OperationItemLable}“{ClientLable}”单位的数据,但点击了保存。";
+                    }
+                    lable = $"{CreateUserName}{operationLabel}";
+                }
+                else if (OperationItem == OperationEnum.List || OperationItem == OperationEnum.NoOperation) lable = $"{CreateUserName}查看了列表数据。";
+                else if (OperationItem == OperationEnum.Details)
+                {
+                    if (!string.IsNullOrEmpty(ClientLable)) lable = $"{CreateUserName}查看了“{ClientLable}”单位数据。";
+                    else lable = $"{CreateUserName}查看了详情数据。";
+                }
+                else if (OperationItem == OperationEnum.Add)
+                {
+                    if (!string.IsNullOrEmpty(ClientLable)) lable = $"{CreateUserName}添加了“{ClientLable}”单位数据。";
+                    else lable = $"{CreateUserName}添加了数据。";
+                }
+                else if (OperationItem == OperationEnum.Del) {
+                    if (!string.IsNullOrEmpty(ClientLable)) lable = $"{CreateUserName}删除了“{ClientLable}”单位数据。";
+                    else lable = $"{CreateUserName}删除了数据。";
+                }
+                else if (OperationItem == OperationEnum.Download) lable = $"{CreateUserName}下载了“公司客户资料”文件。";
+                else if (OperationItem == OperationEnum.BatchAssignment) lable = $"{CreateUserName}{OperationItemLable}了“公司客户资料”查看权限。";
+
+                return lable;
+            }
+        }
+        private static string GetUpdatedFields(Crm_NewClientData originalInfo, Crm_NewClientData newInfo)
+        {
+            var updatedFields = new List<string>();
+            // 使用反射获取字段名称
+            var columnNames = originalInfo.GetType().GetProperties().Select(p => p.Name).ToList();
+            foreach (var columnName in columnNames)
+            {
+                var originalValue = originalInfo.GetType().GetProperty(columnName).GetValue(originalInfo, null)?.ToString() ?? "";
+                var newValue = newInfo.GetType().GetProperty(columnName).GetValue(newInfo, null)?.ToString() ?? "";
+                if (!originalValue.Equals(newValue) )
+                {
+                    var propertyInfo = typeof(Crm_NewClientData).GetProperty(columnName);
+                    var descriptionAttribute = propertyInfo.GetCustomAttribute<DescriptionAttribute>();
+                    var fieldName = descriptionAttribute?.Description;
+                    if (!string.IsNullOrEmpty(fieldName)) updatedFields.Add(fieldName);
+
+                }
+            }
+            return string.Join("、", updatedFields);
+        }
+
+        /// <summary>
+        /// 验证json字符串是否合法
+        /// </summary>
+        /// <param name="jsonString"></param>
+        /// <returns></returns>
+        private static bool IsValidJson(string jsonString)
+        {
+            try
+            {
+                JToken.Parse(jsonString);
+                return true;
+            }
+            catch (JsonReaderException)
+            {
+                return false;
+            }
+        }
+    }
+
+    public class NewClientDataRecordView
+    {
+        public int RowIndex { get; set; }
+        public string Label { get; set; }
+        public DateTime CreateTime { get; set; }
     }
 
 }

+ 46 - 7
OASystem/OASystem.Infrastructure/Repositories/CRM/NewClientDataRepository.cs

@@ -8,6 +8,7 @@ using NPOI.SS.Formula.Functions;
 using NPOI.SS.UserModel;
 using OASystem.Domain;
 using OASystem.Domain.AesEncryption;
+using OASystem.Domain.AutoMappers;
 using OASystem.Domain.Dtos;
 using OASystem.Domain.Dtos.CRM;
 using OASystem.Domain.Entities.Customer;
@@ -1639,7 +1640,39 @@ namespace OASystem.Infrastructure.Repositories.CRM
 
             string whereSql = string.Empty;
 
-            if (!string.IsNullOrEmpty(dto.OpUserName)) whereSql += string.Format(" AND u.CnName Like '%{0}%'", dto.OpUserName);
+            if (dto.UserId != 21) whereSql += string.Format(" AND tor.CreateUserId = '{0}'", dto.UserId);
+            else
+            {
+                if (!string.IsNullOrEmpty(dto.OpUserLabel))
+                {
+                    var userIdArray = dto.OpUserLabel.Split(',')
+                        .Select(userId =>
+                        {
+                            if (int.TryParse(userId, out int id)) return id;
+                            else return -1;
+
+                        })
+                        .ToArray();
+
+                    if (userIdArray.Any(x => x != -1)) whereSql += string.Format(" AND tor.CreateUserId IN ({0})", string.Join(",", userIdArray.Where(x => x != -1).ToList()));
+                }
+            }
+
+            if (!string.IsNullOrEmpty(dto.OpTypeLabel))
+            {
+                var enumArray = dto.OpTypeLabel.Split(',')
+                    .Select(status =>
+                    {
+                        if (Enum.TryParse(status, out OperationEnum result)) return result;
+                        else return default;
+                    })
+                    .ToList();
+                if (enumArray.Any())
+                {
+                    if (enumArray.Contains(OperationEnum.List)) enumArray.Add(OperationEnum.NoOperation);
+                    if (enumArray.Any()) whereSql += string.Format(" AND tor.OperationItem IN ({0})", string.Join(",", enumArray.Select(status => ((int)status).ToString())));
+                }
+            }
 
             bool beginDateBool = DateTime.TryParse(dto.BeginTime,out _),
                  endDateBool = DateTime.TryParse(dto.EndTime,out _);
@@ -1654,10 +1687,12 @@ namespace OASystem.Infrastructure.Repositories.CRM
   row_number() OVER (
     ORDER BY
       tor.CreateTime DESC
-  ) 'RowIndex',
+  ) 'RowNum',
   tor.Id,
   tor.PortType,
   tor.OperationItem,
+  tor.DataId,
+  ncd.Client,
   tor.CreateUserId,
   u.CnName 'CreateUserName',
   tor.CreateTime,
@@ -1665,17 +1700,21 @@ namespace OASystem.Infrastructure.Repositories.CRM
   tor.UpdateBefData
 FROM
   OA2023DB.dbo.Crm_TableOperationRecord tor
-  LEFT JOIN sys_users u On tor.CreateUserId = u.id
+  LEFT JOIN sys_users u On tor.CreateUserId = u.Id
+  LEFT JOIN Crm_NewClientData ncd On tor.DataId = ncd.Id
 Where
   TableName = 'Crm_NewClientData'
-  {0} 
-ORDER BY
-  CreateTime DESC",whereSql);
+  {0}", whereSql);
 
             RefAsync<int> total = 0;
 
-            var datas =_sqlSugar.SqlQueryable<dynamic>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
+            var datas = await _sqlSugar.SqlQueryable<NewClientDataRecordInfoView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
 
+            var viewData = datas.Select(x => new NewClientDataRecordView() { RowIndex = x.RowIndex, Label = x.Label, CreateTime = x.CreateTime }).ToList();
+            jsonView.Data = viewData;
+            jsonView.Code = 200;
+            jsonView.Count = total;
+            jsonView.Msg = "查询成功!";
 
             return jsonView;
         }