mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
优化点击行可选中
This commit is contained in:
parent
ba511edf5b
commit
12d327ddac
@ -1,4 +1,11 @@
|
||||
|
||||
/*
|
||||
* @Author: yubaolee <yubaolee@163.com> | 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 += ("<button " + " data-type='" + element.DomId +
|
||||
"' " + " class='layui-btn layui-btn-small " + element.Class +
|
||||
"' " + element.Attr + ">");
|
||||
{
|
||||
async: false
|
||||
, success: function (data) {
|
||||
var obj = JSON.parse(data);
|
||||
var sb = '';
|
||||
$.each(obj,
|
||||
function () {
|
||||
var element = this;
|
||||
sb += ("<button " + " data-type='" + element.DomId +
|
||||
"' " + " class='layui-btn layui-btn-small " + element.Class +
|
||||
"' " + element.Attr + ">");
|
||||
|
||||
if (element.Icon != null && element.Icon != '') {
|
||||
sb += ("<i class='layui-icon "+element.Icon+"'></i>");
|
||||
}
|
||||
sb += (element.Name + "</button>");
|
||||
});
|
||||
if (element.Icon != null && element.Icon != '') {
|
||||
sb += ("<i class='layui-icon " + element.Icon + "'></i>");
|
||||
}
|
||||
sb += (element.Name + "</button>");
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
@ -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});
|
||||
|
@ -31,6 +31,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
clickTableRow(table,'mainList', 'list');
|
||||
//左边树状机构列表
|
||||
var ztree = function () {
|
||||
var url = '/UserSession/GetOrgs';
|
||||
|
@ -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();
|
||||
|
@ -42,6 +42,7 @@ layui.config({
|
||||
}
|
||||
|
||||
mainList();
|
||||
clickTableRow(table,'mainList', 'list');
|
||||
|
||||
//添加(编辑)对话框
|
||||
var editDlg = function() {
|
||||
|
@ -34,6 +34,7 @@ layui.config({
|
||||
}
|
||||
});
|
||||
}
|
||||
clickTableRow(table,'mainList', 'list');
|
||||
//左边树状机构列表
|
||||
var ztree = function () {
|
||||
var url = '/UserSession/GetOrgs';
|
||||
|
Loading…
Reference in New Issue
Block a user