dialogRoleMenu.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. define(function (require) {
  2. return function (context) {
  3. var $dlg, $tree;
  4. return {
  5. xtype: 'dialog',
  6. dialogId: 'dialogRoleMenu',
  7. title: '角色权限',
  8. width: 500,
  9. height: 650,
  10. onOpen: function () {
  11. $dlg = $(this);
  12. $.yvan.ajax({
  13. loadingMask: false,
  14. url: api('/sys/role/getMenuByRoleId'),
  15. type: 'GET',
  16. data: {
  17. roleId: context.roleId
  18. },
  19. success: function (data) {
  20. $dlg.find('form');
  21. $dlg.down('tree').tree({
  22. checkbox: true,
  23. data: data.data
  24. }).tree('collapseAll');
  25. }
  26. });
  27. },
  28. toolbar: {
  29. xtype: 'toolbar',
  30. items: [
  31. {
  32. text: '全部折叠', onClick: function () {
  33. $tree.tree('collapseAll');
  34. }
  35. }, {
  36. text: '全部展开', onClick: function () {
  37. $tree.tree('expandAll');
  38. }
  39. }
  40. ]
  41. },
  42. center: {
  43. css: {'overflow-x': 'hidden'},
  44. items: {
  45. onRender: function () {
  46. $tree = $(this);
  47. },
  48. xtype: 'tree',
  49. css: {'margin': '5px 10px'}
  50. }
  51. },
  52. buttons: [
  53. {
  54. text: "提交", iconCls: "fa fa-save", onClick: function () {
  55. var nodeIds = $tree.tree('getChecked', ['checked', 'indeterminate']).map(function (r) {
  56. return r.id;
  57. });
  58. $.yvan.postJson({
  59. url: api('/sys/role/saveRoleMenu'),
  60. data: {
  61. roleId: context.roleId,
  62. treedata: nodeIds
  63. },
  64. success: function (data) {
  65. $.yvan.msg('操作成功');
  66. $dlg.window('close');
  67. if ($.type(context.confirm) === 'function') {
  68. context.confirm();
  69. }
  70. }
  71. });
  72. }
  73. }, {
  74. text: "关闭", iconCls: "fa fa-times", onClick: function () {
  75. $dlg.dialog('close');
  76. }
  77. }
  78. ]
  79. };
  80. };
  81. });