dialogSysRoleMenu.js 2.2 KB

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