本文整理汇总了TypeScript中ts/opg.api.roleTree方法的典型用法代码示例。如果您正苦于以下问题:TypeScript api.roleTree方法的具体用法?TypeScript api.roleTree怎么用?TypeScript api.roleTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ts/opg.api
的用法示例。
在下文中一共展示了api.roleTree方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: loopNode
opg.api.roleTree({parentRoleId}, (data)=> {
let actions = data.actions, x = actions.length;
while (x--) {
let p = actions[x];
if (!permissions[p.parentId]) {
permissions[p.parentId] = [];
}
permissions[p.parentId].push(p);
}
let menuData = data.menu ? data.menu : [];
function loopNode(list :Array) {
let z = list.length;
while (z--) {
let node = list[z];
if (node.id in permissions) {
node.children = permissions[node.id];
}
if (node.children) {
loopNode(node.children);
}
}
}
loopNode(menuData);
console.log('permissions', permissions);
tree2 = opg('#menuTree').tree({
data: menuData,
root: '菜单列表',
cmd: 'checkAll'
});
/*tree2.jq.on('change', ':checkbox', function (e) {
let elem = $(this), pId = ~~elem.val(), deal = elem.prop('checked');
//console.warn('deal' , this);
if (deal) {
reservedPermissionIdHash[pId] = true;
}
else {
delete reservedPermissionIdHash[pId];
}
});*/
if (id) {
opg.api.findById({roleId: id}, function (data) {
form.jsonToFields(data.role);
let checkedIds = data.checkedIds ? data.checkedIds : [];
checkedIds.map((v)=> {
reservedPermissionIdHash[v] = v;
});
console.log('checkedIds', reservedPermissionIdHash);
if (data.checkedIds) {
//选中全部被选择的
let l = data.checkedIds.length;
while (l--) {
let curId = data.checkedIds[l];
let chk = document.getElementById(`${tree2.treeName}Chk_${curId}`);
if (chk) {
$(chk).prop('checked', true);
delete reservedPermissionIdHash[curId];
}
}
console.warn('reservedPermissionIdHash', data, reservedPermissionIdHash);
//将子节点选中的条数与全部子节点比较
l = data.checkedIds.length;
while (l--) {
let sp = $('#' + tree2.treeName + 'Sp_' + data.checkedIds[l]);
if (sp.hasClass('folder')) {
let ul = $('#' + tree2.treeName + 'Ul_' + data.checkedIds[l]);
/*let li = ul.children('li');
let all = li.length;
if (all != li.children('span').children('label').children(':checkbox:checked').length) {
//console.error('uncheck' , data.checkedIds[l] , all , li.children('span').children(':checkbox:checked').length);
$('#tree' + tree2.guid + 'Chk_' + data.checkedIds[l]).prop('checked', false);
}*/
ul.find(':checkbox').prop('checked', true);
}
}
}
//.........这里部分代码省略.........