Browse Source

完成导入权限错误提示
修复创建权限数据不规范

DuGuYang 3 years ago
parent
commit
95230f3791

+ 26 - 39
Areas/Admin/Controllers/MainServer/SchoolMakerStudyController.cs

@@ -297,12 +297,34 @@ namespace MySystem.Areas.Admin.Controllers
                 string MakerCode = dr[0].ToString(); // 创客编号
                 string Auths = dr[1].ToString(); // 权限
                 string[] Auth = Auths.Split(',');
+                var fAuth = "";
                 var userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new UserForMakerCode();
                 var userInfo = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
+                var time = 0;
                 if (userInfo.Id == 0)
                 {
                     error += "创客" + MakerCode + "不存在" + '\n';
                 }
+                foreach (var item in Auth)
+                {
+                    var col = bsdb.Col.FirstOrDefault(m => m.ColId == item) ?? new BsModels.Col();
+                    if (col.Id == 0)
+                    {
+                        error += "权限编号" + item + "不存在" + '\n';
+                    }
+                    else
+                    {
+                        time += 1;
+                        if (time == 1)
+                        {
+                            fAuth += "," + item + ",";
+                        }
+                        else
+                        {
+                            fAuth += item + ",";
+                        }
+                    }
+                }
                 if (!string.IsNullOrEmpty(error))
                 {
                     return "Warning|" + error;
@@ -311,31 +333,12 @@ namespace MySystem.Areas.Admin.Controllers
                 if (check)
                 {
                     var auth = db.UserCardRecord.FirstOrDefault(m => m.Id == userInfo.Id) ?? new UserCardRecord();
-                    // auth.SeoDescription = auth.SeoDescription.TrimEnd(',');
-                    var time = 0;
                     foreach (var item in Auth)
                     {
-                        var col = bsdb.Col.FirstOrDefault(m => m.ColId == item) ?? new BsModels.Col();
-                        if (col.Id == 0)
-                        {
-                            error += "权限编号" + item + "不存在" + '\n';
-                        }
-                        else
+
+                        if (!auth.SeoDescription.Contains("," + item + ","))
                         {
-                            time += 1;
-                            if (!auth.SeoDescription.Contains("," + item + ","))
-                            {
-                                // if (time == 1)
-                                // {
-                                //     auth.SeoDescription += "," + item + ",";
-                                // }
-                                // else
-                                // {
-                                //     auth.SeoDescription += item + ",";
-                                // }
-                                auth.SeoDescription += item + ",";
-
-                            }
+                            auth.SeoDescription += item + ",";
                         }
                     }
                     auth.UpdateDate = DateTime.Now;
@@ -344,28 +347,12 @@ namespace MySystem.Areas.Admin.Controllers
                 }
                 else
                 {
-                    foreach (var item in Auth)
-                    {
-                        var col = bsdb.Col.FirstOrDefault(m => m.ColId == item) ?? new BsModels.Col();
-                        if (col.Id == 0)
-                        {
-                            error += "权限编号" + item + "不存在" + '\n';
-                        }
-                        else
-                        {
-                            Auths += "," + item + ",";
-                        }
-                    }
-                    if (!string.IsNullOrEmpty(error))
-                    {
-                        return "Warning|" + error;
-                    }
                     var query = db.UserCardRecord.Add(new UserCardRecord()
                     {
                         Id = userInfo.Id,
                         CreateDate = DateTime.Now, //创建时间
                         CreateMan = SysUserName + "-" + SysRealName,
-                        SeoDescription = "," + Auths + ",",
+                        SeoDescription = fAuth,
                     }).Entity;
                     db.SaveChanges();
                 }

+ 5 - 0
wwwroot/layuiadmin/modules_main/SchoolMakerStudy_Admin.js

@@ -10,6 +10,11 @@ function ConfirmImport() {
                 layer.msg("导入成功", { time: 2000 }, function () {
                     window.location.reload();
                 });
+            }else if (data.indexOf("Warning") == 0) {
+                var datalist = data.split('|');
+                layer.alert(datalist[1], { time: 20000 }, function () {
+                    window.location.reload();
+                });
             } else {
                 layer.msg(data);
             }