Files
ulthon_admin/extend/base/admin/view/system/auth/authorize.js
2025-03-20 16:57:05 +08:00

50 lines
1.9 KiB
PHP

$(function () {
layui.form.on('checkbox(controller-checkbox)', function (data) {
var elem = data.elem;
var checked = elem.checked;
$(elem).closest('tr').find('input').each(function(i,input){
if(!$(input).prop('disabled')){
$(input).prop('checked', checked);
}
})
});
layui.form.on('checkbox(action-checkbox)', function (data) {
initCheckedStatus();
});
function initCheckedStatus() {
$('.auth-node-tr').each(function (i, elem) {
var checkedCount = 0;
var totalCount = 0;
$(elem).find('[lay-filter="action-checkbox"]').each(function (j, checkbox) {
totalCount++;
if ($(checkbox).prop('checked')) {
checkedCount++;
}
});
var checkedStatus;
if (checkedCount === totalCount) {
checkedStatus = 1; // 全部选中
} else if (checkedCount === 0) {
checkedStatus = -1; // 全部未选中
} else {
checkedStatus = 0; // 部分选中
}
if (checkedStatus === 0) {
$(elem).find('[lay-filter="controller-checkbox"]').prop('checked', false);
$(elem).find('[lay-filter="controller-checkbox"]').prop('indeterminate', true);
} else if (checkedStatus > 0) {
$(elem).find('[lay-filter="controller-checkbox"]').prop('checked', true);
$(elem).find('[lay-filter="controller-checkbox"]').prop('indeterminate', false);
} else {
$(elem).find('[lay-filter="controller-checkbox"]').prop('checked', false);
$(elem).find('[lay-filter="controller-checkbox"]').prop('indeterminate', false);
}
layui.form.render('checkbox');
});
}
initCheckedStatus();
ua.listen();
});