diff --git a/OpenAuth.Mvc/wwwroot/js/utils.js b/OpenAuth.Mvc/wwwroot/js/utils.js index 4e482fd0..797beb9e 100644 --- a/OpenAuth.Mvc/wwwroot/js/utils.js +++ b/OpenAuth.Mvc/wwwroot/js/utils.js @@ -1,4 +1,11 @@ - +/* + * @Author: yubaolee | ahfu~ <954478625@qq.com> + * @Date: 2024-11-29 22:16:54 + * @LastEditTime: 2025-03-06 23:29:51 + * @Description: + * Copyright (c) 2025 by yubaolee | ahfu~ , All Rights Reserved. + */ + layui.define("jquery", function (exports) { var jQuery = layui.jquery, $ = layui.jquery; @@ -29,30 +36,60 @@ layui.define("jquery", function (exports) { loadMenus: function (modulecode) { var dom = $(this); $.ajax("/ModuleManager/LoadAuthorizedMenus?modulecode=" + modulecode, - { - async: false - , success: function (data) { - var obj = JSON.parse(data); - var sb = ''; - $.each(obj, - function () { - var element = this; - sb += (""); - }); + if (element.Icon != null && element.Icon != '') { + sb += (""); + } + sb += (element.Name + ""); + }); - dom.html(sb); - } - }); + dom.html(sb); + } + }); } }); + // 修改laytable点击行选中checkbox + clickTableRow = function (table, id, filter) { + // 监听行单击事件 + table.on('row(' + filter + ')', function (obj) { + // 先取消所有行的checkbox的选中状态 + var tableBox = obj.tr.parents('.layui-table-box'); + tableBox.find('.layui-table-body tr').each(function () { + $(this).find('input[type="checkbox"]').prop('checked', false); + var index = $(this).data('index'); + table.cache[id][index].LAY_CHECKED = false; + }); + + // 取消选中行 + table.setRowChecked(id, { + index: 'all', // 所有行 + checked: false // 此处若设置 true,则表示全选 + }); + + + // 设置当前行选中,这个方法可以让checkStatus()获取到值,但它不能改变checkbox的选中状态😓 + table.setRowChecked(id, { + index: obj.tr.data('index') + }); + + // 设置当前行checkbox 选中 + obj.tr.find('input[type="checkbox"]').prop('checked', true); + obj.data.LAY_CHECKED = true; + + }); + } exports('utils'); }); \ No newline at end of file diff --git a/OpenAuth.Mvc/wwwroot/userJs/modules.js b/OpenAuth.Mvc/wwwroot/userJs/modules.js index 72cf6910..81c0749f 100644 --- a/OpenAuth.Mvc/wwwroot/userJs/modules.js +++ b/OpenAuth.Mvc/wwwroot/userJs/modules.js @@ -62,7 +62,6 @@ layui.config({ } }); } - //菜单列表 var menucon = {}; //table的参数,如搜索key,点击tree的id var menuList = function (options) { @@ -213,6 +212,7 @@ layui.config({ }; }(); + clickTableRow(table,'mainList', 'list'); //监听行单击事件 table.on('row(list)', function (obj) { menuList({moduleId: obj.data.Id}); diff --git a/OpenAuth.Mvc/wwwroot/userJs/orgs.js b/OpenAuth.Mvc/wwwroot/userJs/orgs.js index 12c78741..246c1599 100644 --- a/OpenAuth.Mvc/wwwroot/userJs/orgs.js +++ b/OpenAuth.Mvc/wwwroot/userJs/orgs.js @@ -31,6 +31,7 @@ } }); } + clickTableRow(table,'mainList', 'list'); //左边树状机构列表 var ztree = function () { var url = '/UserSession/GetOrgs'; diff --git a/OpenAuth.Mvc/wwwroot/userJs/resources.js b/OpenAuth.Mvc/wwwroot/userJs/resources.js index c8c50ec0..998f8cd0 100644 --- a/OpenAuth.Mvc/wwwroot/userJs/resources.js +++ b/OpenAuth.Mvc/wwwroot/userJs/resources.js @@ -20,7 +20,7 @@ //加载表头 $.getJSON('/Resources/Load', - {page: 1, limit: 1}, + { page: 1, limit: 1 }, function (data) { var columns = data.columnFields.filter(u => u.IsList === true).map(function (e) { return { @@ -60,6 +60,7 @@ }); }; mainList(); + clickTableRow(table,'mainList', 'list'); //添加(编辑)对话框 var editDlg = function () { @@ -140,7 +141,7 @@ } , search: function () { //搜索 - mainList({key: $('#key').val()}); + mainList({ key: $('#key').val() }); } , btnRefresh: function () { mainList(); diff --git a/OpenAuth.Mvc/wwwroot/userJs/roles.js b/OpenAuth.Mvc/wwwroot/userJs/roles.js index 3df9c7c2..3acc11e7 100644 --- a/OpenAuth.Mvc/wwwroot/userJs/roles.js +++ b/OpenAuth.Mvc/wwwroot/userJs/roles.js @@ -42,6 +42,7 @@ layui.config({ } mainList(); + clickTableRow(table,'mainList', 'list'); //添加(编辑)对话框 var editDlg = function() { diff --git a/OpenAuth.Mvc/wwwroot/userJs/users.js b/OpenAuth.Mvc/wwwroot/userJs/users.js index e3f1374b..9537b616 100644 --- a/OpenAuth.Mvc/wwwroot/userJs/users.js +++ b/OpenAuth.Mvc/wwwroot/userJs/users.js @@ -34,6 +34,7 @@ layui.config({ } }); } + clickTableRow(table,'mainList', 'list'); //左边树状机构列表 var ztree = function () { var url = '/UserSession/GetOrgs';