本文整理匯總了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);
}
}
}
//.........這裏部分代碼省略.........