Explorar el Código

1.注册员工工号按公司去除去重
2.员工信息 Api:EditUser 移除请求字段 HrAudit 更改相应代码
3.员工信息 Api:PersonnelAudit 新增字段 UserId 更改相应代码
4.人事审核通过后添加员工基础页面(按职位分配)

leiy hace 11 meses
padre
commit
5a1d28aa97

+ 0 - 1
OASystem/OASystem.Api/Controllers/AuthController.cs

@@ -249,7 +249,6 @@ namespace OASystem.API.Controllers
             //var qiYeWeChatCreateData = await _qiYeWeChatApiServic.CreateAsync(request);
             #endregion
 
-
             var userData = _loginRep.Register(dto);
             if (userData.Result.Code != 0)
             {

+ 26 - 20
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -1147,18 +1147,18 @@ namespace OASystem.API.Controllers
                     JobPostId = dto.JobPostId,
                     Ext = dto.Ext,
                     UsePeriod = dto.UsePeriod,
-                    HrAudit = dto.HrAudit
+                    //HrAudit = dto.HrAudit
                 });
                 if (!res) 
                 {
                     return Ok(JsonView(false, "修改失败!"));
                 }
+
                 return Ok(JsonView(true, "修改成功!"));
             }
             catch (Exception)
             {
                 return Ok(JsonView(false, "程序错误!"));
-                throw;
             }
         }
 
@@ -1269,7 +1269,9 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, "程序错误!"));
             }
         }
+
         /// <summary>
+        /// 员工信息 
         /// 人事审核
         /// </summary>
         /// <param name="dto"></param>
@@ -1278,27 +1280,31 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PersonnelAudit(PersonnelAuditDto dto)
         {
-            try
-            {
-                if (dto == null)
-                {
-                    return Ok(JsonView(false, "参数不能为空!"));
-                }
-                bool res = await _userRep.UpdateAsync<Sys_Users>(a => a.Id == dto.Id, a => new Sys_Users
-                {
-                    HrAudit=dto.isAudit
-                });
-                if (!res)
-                {
-                    return Ok(JsonView(false, "操作失败!"));
-                }
-                return Ok(JsonView(true, "操作成功!"));
+            if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
+            if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
+            if (dto.IsAudit < 1 || dto.IsAudit > 2) return Ok(JsonView(false, "请传入有效的IsAudit参数!1:通过 2拒绝"));
 
-            }
-            catch (Exception)
+            bool res = await _userRep.UpdateAsync<Sys_Users>(a =>
+                                      a.Id == dto.Id,
+                                      a => new Sys_Users
+                                      {
+                                          HrAudit = dto.IsAudit
+                                      });
+            if (res)
             {
-                return Ok(JsonView(false, "程序错误!"));
+                //审核成功添加员工基础页面权限
+                var userData = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == dto.Id).First();
+                int depId = 0, postId = 0;
+                if (userData != null) { depId = userData.DepId; postId = userData.JobPostId; }
+
+                bool s = DefaultPostAuth(depId, postId, dto.Id);
+                string str = $"基础页面权限添加失败!";
+                if (s) str = $"基础页面权限添加成功!";
+
+                return Ok(JsonView(true, $"操作成功!{str}"));
             }
+            return Ok(JsonView(false, "操作失败!"));
+
         }
         #endregion
 

+ 64 - 1
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -33,6 +33,70 @@ namespace OASystem.API.OAMethodLib
         private readonly static MessageRepository _messageRep = AutofacIocManager.Instance.GetService<MessageRepository>();
         private readonly static IHubContext<ChatHub, IChatClient> _hubContext = AutofacIocManager.Instance.GetService<IHubContext<ChatHub, IChatClient>>();
 
+        #region 员工注册默认添加基础页面
+
+        /// <summary>
+        /// 默认职位权限 View
+        /// </summary>
+        public static bool DefaultPostAuth(int depId,int postId, int userId)
+        {
+            if (depId < 1) return false;
+            if (postId < 1) return false;
+            if (userId < 1) return false;
+
+            List<DefaultPostPageAuthView> _defaultData = AppSettingsHelper.Get<DefaultPostPageAuthView>("DefaultPostPageData");
+
+            if (_defaultData.Count < 1) return false;
+
+            List<int> pageData = new List<int>();
+            //添加公司公共页面
+            pageData.AddRange(_defaultData.Find(it => it.DepId == -1)?.PostPageAuths[0].PageIds ?? new List<int>());
+            //添加部门页面
+            var depPublicPageData = _defaultData.Find(it => it.DepId == depId);
+            if (depPublicPageData != null) //特殊部门 
+            {
+                //公共页面
+                pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == -1)?.PageIds ?? new List<int>());
+                //岗位页面
+                pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == postId)?.PageIds ?? new List<int>());
+
+            }
+            else //通用部门
+            {
+                pageData.AddRange(_defaultData.Find(it => it.DepId == 0)?.PostPageAuths[0].PageIds ?? new List<int>());
+            }
+
+            if (pageData.Count > 0)
+            {
+                //页面操作权限数据(添加修改等...)
+                var pageFunctionData = _dirRep._sqlSugar.Queryable<Sys_SystemMenuAndFunction>().Where(it => pageData.Contains(it.SmId) && it.IsDel == 0 ).ToList();
+
+                var defaultPageData = pageFunctionData.Select(it => new Sys_UserAuthority() { 
+                    UId = userId,
+                    SmId = it.SmId,
+                    FId = it.FId,
+                    CreateUserId = 4, //管理员
+                    CreateTime = DateTime.Now,
+                    IsDel = 0,
+                    IsTemp = 1
+                }).ToList();
+
+                if (defaultPageData.Count > 0)
+                {
+                    //添加页面操作权限
+                    var s = _dirRep._sqlSugar.Fastest<Sys_UserAuthority>().PageSize(100000).BulkCopy(defaultPageData);
+                    if (s > 0)
+                    {
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+
+
+        #endregion
+
         #region 消息 
         /// <summary>
         /// 消息 发布And 通知
@@ -1215,7 +1279,6 @@ namespace OASystem.API.OAMethodLib
 
         #endregion
 
-
         #region 数字验证
         /// <summary>
         /// 验证数字字符串

+ 130 - 2
OASystem/OASystem.Api/appsettings.json

@@ -189,7 +189,7 @@
     {
       "CTableId": 1015, //CtableId 超支费用
       "PageIdDatas": [ //页面Id
-        174 
+        174
       ]
     }
   ],
@@ -199,7 +199,7 @@
     {
       "TypeId": 1022, //系统公告
       "MsgTypeIds": [
-        1  // 公告消息
+        1 // 公告消息
       ]
     },
     {
@@ -217,5 +217,133 @@
         6 //任务进度更新消息
       ]
     }
+  ],
+
+
+  //职位默认页面权限
+  "DefaultPostPageData": [
+    {
+      "DepId": -1, //部门: 公司公共页面
+      "PostPageAuths": [
+        {
+          "PostId": -1,
+          "PageIds": [
+            42, //Page: 日常费用付款申请
+            16 //Page: 员工资料列表
+          ]
+        }
+      ]
+    },
+    {
+      "DepId": 0, //部门:人事部,信息部,策划部(部门页面一致归类在一起)
+      "PostPageAuths": [
+        {
+          "PostId": 0, //职位:普通员工(除经理主管外/公共页面)
+          "PageIds": [
+            149 //Page: 主页(员工)
+          ]
+        }
+      ]
+    },
+    {
+      "DepId": 1, //部门: 总经办
+      "PostPageAuths": [
+        {
+          "PostId": 3, //职位: 总经理助理
+          "PageIds": [
+            150 //Page: 主页(总助)
+          ]
+        }
+      ]
+    },
+    {
+      "DepId": 6, //部门:市场部
+      "PostPageAuths": [
+        {
+          "PostId": 21, //职位:普通员工(除经理主管外)
+          "PageIds": [
+            153, //Page: 主页(市场部)
+            118, //Page: 出入境费用明细
+            168, //Page: 出入境国家三公费用标准
+            89 //Page: 公司客户资料
+          ]
+        }
+      ]
+    },
+    {
+      "DepId": 3, //部门:财务部
+      "PostPageAuths": [
+        {
+          "PostId": 10, //职位:会计
+          "PageIds": [
+            151 //Page: 主页(财务)
+          ]
+        }
+      ]
+    },
+    {
+      "DepId": 7, //国交部
+      "PostPageAuths": [
+        {
+          "PostId": -1, //职位:部门公共页面
+          "PageIds": [
+            154, //Page: 主页(国交)
+            40, //Page: 其他款项
+            174 //Page: 超支费用
+          ]
+        },
+        {
+          "PostId": 0, //职位:经理/主管
+          "PageIds": [
+            27, //Page: 团组操作
+            104, //Page: 接团客户名单
+            118, //Page: 出入境费用明细
+            168 //Page: 出入境国家三公费用标准
+          ]
+        },
+        {
+          "PostId": 26, //职位:签证
+          "PageIds": [
+            31, //Page: 签证费用录入
+            158, //Page: OCR识别
+            32 //Page: 保险录入
+          ]
+        },
+        {
+          "PostId": 27, //职位:商邀
+          "PageIds": [
+            25, //Page: 邀请资料
+            29, //Page: 邀请公务费用
+            166, //Page: 公务出访
+            167 //Page:导出邀请函
+          ]
+        },
+        {
+          "PostId": 28, //职位:OP
+          "PageIds": [
+            24, //Page: 导游地接资料
+            30, //Page: 地接费用录入
+            122, //Page: OP行程单
+            111 //Page: 车公司资料
+          ]
+        },
+        {
+          "PostId": 24, //职位:机票
+          "PageIds": [
+            114, //Page: 机票行程代码录
+            120, //Page: 三字码资料表
+            160, //Page: 代理出票合作方
+            161 //Page: 机票费用录入
+          ]
+        },
+        {
+          "PostId": 25, //职位:酒店
+          "PageIds": [
+            23, //Page: 酒店资料 
+            28 //Page: 酒店预订
+          ]
+        }
+      ]
+    }
   ]
 }

+ 5 - 2
OASystem/OASystem.Domain/Dtos/System/UserDto.cs

@@ -62,7 +62,7 @@ namespace OASystem.Domain.Dtos.System
         /// <summary>
         /// 人事审核 0未审核(初始状态) 1 已通过(可用)2已拒绝
         /// </summary>
-        public int HrAudit { get; set; }
+        //public int HrAudit { get; set; }
     }
 
     /// <summary>
@@ -220,13 +220,16 @@ namespace OASystem.Domain.Dtos.System
 
     public class PersonnelAuditDto
     {
+        public int UserId { get; set; }
+
         /// <summary>
         /// 数据Id
         /// </summary>
         public int Id { get; set; }
+
         /// <summary>
         /// 审核是否通过 1:通过 2拒绝
         /// </summary>
-        public int isAudit { get; set; }
+        public int IsAudit { get; set; }
     }
 }

+ 36 - 0
OASystem/OASystem.Domain/ViewModels/System/DefaultPostAuthView.cs

@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.System
+{
+    /// <summary>
+    /// 默认职位权限 View
+    /// </summary>
+    public class DefaultPostPageAuthView
+    {
+        /// <summary>
+        /// 部门Id
+        /// </summary>
+        public int DepId { get; set; }
+
+        public List<PostPageAuth> PostPageAuths { get; set; } = new List<PostPageAuth>();
+
+        
+    }
+
+    public class PostPageAuth
+    {
+        /// <summary>
+        /// 职位Id
+        /// </summary>
+        public int PostId { get; set; }
+
+        /// <summary>
+        /// PageId
+        /// </summary>
+        public List<int> PageIds { get; set; } = new List<int>();
+    }
+}

+ 4 - 2
OASystem/OASystem.Infrastructure/Repositories/Login/LoginRepository.cs

@@ -180,7 +180,7 @@ namespace OASystem.Infrastructure.Repositories.Login
         public async Task<string> CreateNumber(int depId) {
             string number = string.Empty;
 
-            string userSql = string.Format("Select * From  Sys_Users Where DepId = {0} And Number != '' Order By Id Desc", depId);
+            string userSql = string.Format("Select * From  Sys_Users Where Number != '' Order By Id Desc", depId);
             var userData = await _sqlSugar.SqlQueryable<Sys_Users>(userSql).ToListAsync();
             //if (userData.Count <= 0) return number;
 
@@ -195,8 +195,10 @@ namespace OASystem.Infrastructure.Repositories.Login
             while (true) 
             {
                 number = numPrefix + numSuffix.ToString();
-                var userData1 = userData.Where(it => it.Number == number).FirstOrDefault();
+
+                var userData1 = userData.Find(it => it.Number == number); //公司验证Number 
                 if (userData1 == null) break;
+
                 numSuffix++;
             }