define(function (require) { return function (context) { var $dlg, $tree; return { xtype: 'dialog', dialogId: 'dialogRoleMenu', title: '角色权限', width: 500, height: 650, onOpen: function () { $dlg = $(this); $.yvan.ajax({ loadingMask: false, url: api('/sys/role/getMenuByRoleId'), type: 'GET', data: { roleId: context.roleId }, success: function (data) { $dlg.find('form'); $dlg.down('tree').tree({ checkbox: true, data: data.data }).tree('collapseAll'); } }); }, toolbar: { xtype: 'toolbar', items: [ { text: '全部折叠', onClick: function () { $tree.tree('collapseAll'); } }, { text: '全部展开', onClick: function () { $tree.tree('expandAll'); } } ] }, center: { css: {'overflow-x': 'hidden'}, items: { onRender: function () { $tree = $(this); }, xtype: 'tree', css: {'margin': '5px 10px'} } }, buttons: [ { text: "提交", iconCls: "fa fa-save", onClick: function () { var nodeIds = $tree.tree('getChecked', ['checked', 'indeterminate']).map(function (r) { return r.id; }); $.yvan.postJson({ url: api('/sys/role/saveRoleMenu'), data: { roleId: context.roleId, treedata: nodeIds }, success: function (data) { $.yvan.msg('操作成功'); $dlg.window('close'); if ($.type(context.confirm) === 'function') { context.confirm(); } } }); } }, { text: "关闭", iconCls: "fa fa-times", onClick: function () { $dlg.dialog('close'); } } ] }; }; });