本文整理匯總了TypeScript中ts/opg.api.findById方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript api.findById方法的具體用法?TypeScript api.findById怎麽用?TypeScript api.findById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ts/opg.api
的用法示例。
在下文中一共展示了api.findById方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
).done(()=> {
if (id) {
opg.api.findById({id: id}, function (data) {
form.jsonToFields(data);
});
}
});
示例2:
).done(()=> {
if (id) {
opg.api.findById({id: id}, data => {
form.jsonToFields(data);
if (data.roleIds) {
let checkedIds = data.roleIds;
checkedIds.map(v => {
reservedCheckedRolesHash[v] = true;
});
console.warn('findById', data, reservedCheckedRolesHash);
//選中全部被選擇的
let l = data.roleIds.length;
while (l--) {
$('#' + tree1.treeName + 'Chk_' + data.roleIds[l]).prop('checked', true);
}
//將子節點選中的條數與全部子節點比較
l = data.roleIds.length;
while (l--) {
let curRoleId = data.roleIds[l];
let sp = $('#' + tree1.treeName + 'Sp_' + curRoleId);
if(sp.length){
if (sp.hasClass('folder')) {
let ul = $('#' + tree1.treeName + 'Ul_' + curRoleId);
ul.find(':checkbox').prop('checked' , true);
}
delete reservedCheckedRolesHash[curRoleId];
}
}
}
});
}
else {
$('#trRoleTree').before(`<tr style="height: 32px;">
<td class="lead"><b class="text-red">*</b>用戶密碼</td>
<td colspan="3"><label><input type="password" name="password" autocomplete="off" placeholder="密碼8-15位,大小寫字母與數字混合" style="width: 100%;"></label></td>
</tr>`);
}
});
示例3: while
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);
}
}
}
//.........這裏部分代碼省略.........