Просмотр исходного кода

暂收完成,待确定是否通过顶级创客Id循环查询,待测试

DuGuYang 3 лет назад
Родитель
Сommit
dba79e2398

+ 60 - 13
Areas/Admin/Controllers/MainServer/UserRankWhiteController.cs

@@ -50,7 +50,7 @@ namespace MySystem.Areas.Admin.Controllers
         /// 创客预设职级列表
         /// </summary>
         /// <returns></returns>
-        public JsonResult IndexData(UserRankWhite data, string MakerCode, string RealName, string StatusSelect, int page = 1, int limit = 30)
+        public JsonResult IndexData(UserRankWhite data, string MakerCode, string RealName, string StatusSelect, string TopMakerCode, string UpdateDateData, int page = 1, int limit = 30)
         {
 
             Dictionary<string, string> Fields = new Dictionary<string, string>();
@@ -71,6 +71,42 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 condition += " and Status=" + StatusSelect;
             }
+            //顶级创客编号
+            if (!string.IsNullOrEmpty(TopMakerCode))
+            {
+                var topUser = db.Users.FirstOrDefault(m => m.MakerCode == TopMakerCode) ?? new Users();
+                var childIds = "";
+                // if (!string.IsNullOrEmpty(topUser.ParentNav))
+                // {
+                //     string[] ParentNavList = topUser.ParentNav.Trim(',').Replace(",,", ",").Split(',');
+                //     var topUserId = "," + topUser.Id + ",";
+                //     if (ParentNavList.Length > 1)
+                //     {
+                //         var childUser = db.Users.Where(m => m.ParentNav.Contains(topUserId)).ToList();
+                //         foreach (var item in childUser)
+                //         {
+                //             childIds = item.Id + ",";
+                //         }
+                //         childIds = childIds.TrimEnd(',');
+                //     }
+                // }
+                var topUserId = "," + topUser.Id + ",";
+                var childUser = db.Users.Where(m => m.ParentNav.Contains(topUserId)).ToList();
+                foreach (var item in childUser)
+                {
+                    childIds += item.Id + ",";
+                }
+                childIds = childIds.TrimEnd(',');
+                condition += " and UserId in (" + childIds + ")";
+            }
+            //到期时间
+            if (!string.IsNullOrEmpty(UpdateDateData))
+            {
+                string[] datelist = UpdateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
+                string start = datelist[0];
+                string end = datelist[1];
+                condition += " and UpdateDate>='" + start + " 00:00:00' and UpdateDate<='" + end + " 23:59:59'";
+            }
 
             Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserRankWhite", Fields, "Id desc", "0", page, limit, condition);
             List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
@@ -82,17 +118,28 @@ namespace MySystem.Areas.Admin.Controllers
                 dic["MakerCode"] = user.MakerCode;
                 dic["RealName"] = user.RealName;
                 if (user.ParentUserId > 0)
-                { 
+                {
                     Users puser = db.Users.FirstOrDefault(m => m.Id == user.ParentUserId) ?? new Users();
                     dic["ParentMakerCode"] = puser.MakerCode;
                     dic["ParentRealName"] = puser.RealName;
                 }
                 if (!string.IsNullOrEmpty(user.ParentNav))
-                { 
-                    int TopId = int.Parse(user.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
-                    Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
-                    dic["TopMakerCode"] = tuser.MakerCode;
-                    dic["TopRealName"] = tuser.RealName;
+                {
+                    string[] ParentNavList = user.ParentNav.Trim(',').Replace(",,", ",").Split(',');
+                    if (ParentNavList.Length > 1)
+                    {
+                        int TopId = int.Parse(user.ParentNav.Trim(',').Replace(",,", ",").Split(',')[1]);
+                        Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
+                        dic["TopMakerCode"] = tuser.MakerCode;
+                        dic["TopRealName"] = tuser.RealName;
+                    }
+                    else
+                    {
+                        int TopId = int.Parse(user.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
+                        Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
+                        dic["TopMakerCode"] = tuser.MakerCode;
+                        dic["TopRealName"] = tuser.RealName;
+                    }
                 }
                 dic["Status"] = dic["Status"].ToString() == "1" ? "有效" : "无效";
             }
@@ -129,7 +176,7 @@ namespace MySystem.Areas.Admin.Controllers
         {
             bool check = db.UserForMakerCode.Any(m => m.MakerCode == MakerCode);
             if (!check)
-            { 
+            {
                 return "创客编号不存在";
             }
             Dictionary<string, object> Fields = new Dictionary<string, object>();
@@ -152,7 +199,7 @@ namespace MySystem.Areas.Admin.Controllers
 
             UserRank rank = RedisDbconn.Instance.Get<UserRank>("UserRank:" + user.UserId);
             if (rank != null)
-            { 
+            {
                 rank.WhiteRank = data.Rank;
                 RedisDbconn.Instance.Set("UserRank:" + user.UserId, rank);
             }
@@ -175,11 +222,11 @@ namespace MySystem.Areas.Admin.Controllers
 
             UserRankWhite editData = db.UserRankWhite.FirstOrDefault(m => m.Id == Id) ?? new UserRankWhite();
             ViewBag.data = editData;
-            
+
             Users user = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
             ViewBag.MakerCode = user.MakerCode;
             ViewBag.RealName = user.RealName;
-            
+
             return View();
         }
 
@@ -364,13 +411,13 @@ namespace MySystem.Areas.Admin.Controllers
                 dic["MakerCode"] = user.MakerCode;
                 dic["RealName"] = user.RealName;
                 if (user.ParentUserId > 0)
-                { 
+                {
                     Users puser = db.Users.FirstOrDefault(m => m.Id == user.ParentUserId) ?? new Users();
                     dic["ParentMakerCode"] = puser.MakerCode;
                     dic["ParentRealName"] = puser.RealName;
                 }
                 if (!string.IsNullOrEmpty(user.ParentNav))
-                { 
+                {
                     int TopId = int.Parse(user.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
                     Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
                     dic["TopMakerCode"] = tuser.MakerCode;

+ 13 - 0
Areas/Admin/Views/MainServer/UserRankWhite/Index.cshtml

@@ -59,6 +59,19 @@
                             </select>
                         </div>
                     </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">顶级创客编号</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="TopMakerCode" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">到期时间</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" readonly name="UpdateDateData" id="UpdateDate"
+                                placeholder="" autocomplete="off">
+                        </div>
+                    </div>
                     <div class="layui-inline ml50">
                         <button class="layui-btn" lay-submit lay-filter="LAY-list-front-search">
                             <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询

+ 89 - 62
wwwroot/layuiadmin/modules_main/UserRankWhite_Admin.js

@@ -31,49 +31,76 @@ layui.config({
     //- 筛选条件-日期
     var laydate = layui.laydate;
     var layCreateDate = laydate.render({
-elem: '#CreateDate',
-type: 'date',
-range: true,
-trigger: 'click',
-change: function (value, date, endDate) {
-var op = true;
-if (date.year == endDate.year && endDate.month - date.month <= 1) {
-if (endDate.month - date.month == 1 && endDate.date > date.date) {
-op = false;
-layCreateDate.hint('日期范围请不要超过1个月');
-setTimeout(function () {
-$(".laydate-btns-confirm").addClass("laydate-disabled");
-}, 1);
-}
-} else {
-op = false;
-layCreateDate.hint('日期范围请不要超过1个月');
-setTimeout(function () {
-$(".laydate-btns-confirm").addClass("laydate-disabled");
-}, 1);
-}
-if (op) {
-$('#CreateDate').val(value);
-}
-}
-});
+        elem: '#CreateDate',
+        type: 'date',
+        range: true,
+        trigger: 'click',
+        change: function (value, date, endDate) {
+            var op = true;
+            if (date.year == endDate.year && endDate.month - date.month <= 1) {
+                if (endDate.month - date.month == 1 && endDate.date > date.date) {
+                    op = false;
+                    layCreateDate.hint('日期范围请不要超过1个月');
+                    setTimeout(function () {
+                        $(".laydate-btns-confirm").addClass("laydate-disabled");
+                    }, 1);
+                }
+            } else {
+                op = false;
+                layCreateDate.hint('日期范围请不要超过1个月');
+                setTimeout(function () {
+                    $(".laydate-btns-confirm").addClass("laydate-disabled");
+                }, 1);
+            }
+            if (op) {
+                $('#CreateDate').val(value);
+            }
+        }
+    });
+    var layUpdateDate = laydate.render({
+        elem: '#UpdateDate',
+        type: 'date',
+        range: true,
+        trigger: 'click',
+        change: function (value, date, endDate) {
+            var op = true;
+            if (date.year == endDate.year && endDate.month - date.month <= 1) {
+                if (endDate.month - date.month == 1 && endDate.date > date.date) {
+                    op = false;
+                    layUpdateDate.hint('日期范围请不要超过1个月');
+                    setTimeout(function () {
+                        $(".laydate-btns-confirm").addClass("laydate-disabled");
+                    }, 1);
+                }
+            } else {
+                op = false;
+                layUpdateDate.hint('日期范围请不要超过1个月');
+                setTimeout(function () {
+                    $(".laydate-btns-confirm").addClass("laydate-disabled");
+                }, 1);
+            }
+            if (op) {
+                $('#UpdateDate').val(value);
+            }
+        }
+    });
 
 
     //excel导入
-    excel = layui.excel;        
+    excel = layui.excel;
     $('#ExcelFile').change(function (e) {
         var files = e.target.files;
-        excel.importExcel(files, { }, function (data) {
+        excel.importExcel(files, {}, function (data) {
             ExcelData = data[0].sheet1;
         });
     });
 
     //监听单元格编辑
-    table.on('edit(LAY-list-manage)', function(obj){
+    table.on('edit(LAY-list-manage)', function (obj) {
         var value = obj.value //得到修改后的值
-        ,data = obj.data //得到所在行所有键值
-        ,field = obj.field; //得到字段
-        if(field == "Sort"){
+            , data = obj.data //得到所在行所有键值
+            , field = obj.field; //得到字段
+        if (field == "Sort") {
             $.ajax({
                 type: "POST",
                 url: "/Admin/UserRankWhite/Sort?r=" + Math.random(1),
@@ -84,27 +111,27 @@ $('#CreateDate').val(value);
             });
         }
     });
-    
+
     //列表数据
     table.render({
         elem: '#LAY-list-manage'
         , url: '/Admin/UserRankWhite/IndexData' //模拟接口
         , cols: [[
             { type: 'checkbox', fixed: 'left' }
-            ,{field:'MakerCode', width: 200, title:'创客编号', sort: true}
-            ,{field:'RealName', width: 200, title:'创客姓名', sort: true}
-            ,{field:'ParentMakerCode', width: 200, title:'上级创客编号', sort: true}
-            ,{field:'ParentRealName', width: 200, title:'上级创客名称', sort: true}
-            // ,{field:'TopMakerCode', width: 200, title:'顶级创客编号', sort: true}
-            // ,{field:'TopRealName', width: 200, title:'顶级创客名称', sort: true}
-            ,{field:'Rank', width: 200, title:'等级名称', sort: true}
-            ,{field:'Status', width: 200, title:'有效状态', sort: true}
-            ,{field:'CreateDate', width: 200, title:'创建时间', sort: true}
-            ,{field:'UpdateDate', width: 200, title:'过期时间', sort: true}
+            , { field: 'MakerCode', width: 200, title: '创客编号', sort: true }
+            , { field: 'RealName', width: 200, title: '创客姓名', sort: true }
+            , { field: 'ParentMakerCode', width: 200, title: '上级创客编号', sort: true }
+            , { field: 'ParentRealName', width: 200, title: '上级创客名称', sort: true }
+            , { field: 'TopMakerCode', width: 200, title: '顶级创客编号', sort: true }
+            , { field: 'TopRealName', width: 200, title: '顶级创客名称', sort: true }
+            , { field: 'Rank', width: 200, title: '等级名称', sort: true }
+            , { field: 'Status', width: 200, title: '有效状态', sort: true }
+            , { field: 'CreateDate', width: 200, title: '创建时间', sort: true }
+            , { field: 'UpdateDate', width: 200, title: '过期时间', sort: true }
             , { title: '操作', align: 'center', width: 100, fixed: 'right', toolbar: '#table-list-tools' }
         ]]
         , where: {
-            
+
         }
         , page: true
         , limit: 30
@@ -126,7 +153,7 @@ $('#CreateDate').val(value);
                     data: "Id=" + data.Id,
                     dataType: "text",
                     success: function (data) {
-                        if (data == "success") {                            
+                        if (data == "success") {
                             obj.del();
                             layer.close(index);
                         } else {
@@ -149,20 +176,20 @@ $('#CreateDate').val(value);
                         , submitID = 'LAY-list-front-submit'
                         , submit = layero.find('iframe').contents().find('#' + submitID);
 
-                    setTimeout(function () { 
+                    setTimeout(function () {
                         layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
                             var errObj = $(this).find('.layui-form-danger');
                             if (errObj.length > 0) {
                                 iframeWindow.element.tabChange('mytabbar', String(i + 1));
                                 submit.click();
                             }
-                        });                        
+                        });
                     }, 300);
 
-                    
-                    
-                    
-                    
+
+
+
+
 
                     //监听提交
                     iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
@@ -173,7 +200,7 @@ $('#CreateDate').val(value);
                         }
                         //提交 Ajax 成功后,静态更新表格中的数据
                         //$.ajax({});
-                        
+
                         $.ajax({
                             type: "POST",
                             url: "/Admin/UserRankWhite/Edit?r=" + Math.random(1),
@@ -265,7 +292,7 @@ $('#CreateDate').val(value);
                         , submitID = 'LAY-list-front-submit'
                         , submit = layero.find('iframe').contents().find('#' + submitID);
 
-                    setTimeout(function () { 
+                    setTimeout(function () {
                         layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
                             var errObj = $(this).find('.layui-form-danger');
                             if (errObj.length > 0) {
@@ -275,10 +302,10 @@ $('#CreateDate').val(value);
                         });
                     }, 300);
 
-                    
-                    
-                    
-                    
+
+
+
+
 
                     //监听提交
                     iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
@@ -289,7 +316,7 @@ $('#CreateDate').val(value);
                         }
                         //提交 Ajax 成功后,静态更新表格中的数据
                         //$.ajax({});
-                        
+
                         $.ajax({
                             type: "POST",
                             url: "/Admin/UserRankWhite/Add?r=" + Math.random(1),
@@ -343,9 +370,9 @@ $('#CreateDate').val(value);
         , Open: function () {
             var checkStatus = table.checkStatus('LAY-list-manage')
                 , data = checkStatus.data; //得到选中的数据
-            if(data.length < 1){
+            if (data.length < 1) {
                 parent.layer.msg("请选择要开启的项");
-            }else{
+            } else {
                 var ids = "";
                 $.each(data, function (index, value) {
                     ids += data[index].Id + ",";
@@ -372,9 +399,9 @@ $('#CreateDate').val(value);
         , Close: function () {
             var checkStatus = table.checkStatus('LAY-list-manage')
                 , data = checkStatus.data; //得到选中的数据
-            if(data.length < 1){
+            if (data.length < 1) {
                 parent.layer.msg("请选择要关闭的项");
-            }else{
+            } else {
                 var ids = "";
                 $.each(data, function (index, value) {
                     ids += data[index].Id + ",";