PDAPower.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.ma.PDAPower', {
  3. extend : 'Ext.app.Controller',
  4. requires: ['erp.util.FormUtil','erp.view.core.grid.HeaderFilter','erp.view.core.plugin.CopyPasteMenu'],
  5. views : [ 'ma.PDAPower', 'core.button.Distribute', 'core.grid.PDAGroupPower', 'core.trigger.DbfindTrigger',
  6. 'core.trigger.EmpTrigger', 'core.button.Sync', 'core.trigger.MultiDbfindTrigger','core.trigger.SearchField'],
  7. init : function() {
  8. var me = this;
  9. me.FormUtil = Ext.create('erp.util.FormUtil');
  10. this.control({
  11. 'treepanel[id=powertree]' : {
  12. afterrender : function(tree) {
  13. me.loadTree(tree);
  14. },
  15. itemmousedown : function(selModel, record) {
  16. var tree = selModel.ownerCt;
  17. me.loadTree(tree, record);
  18. },
  19. scrollershow: function(scroller) {
  20. if (scroller && scroller.scrollEl) {
  21. scroller.clearManagedListeners();
  22. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  23. }
  24. }
  25. },
  26. 'multidbfindtrigger[name=em_position]': {
  27. aftertrigger: function(t, rs) {
  28. if(rs.length > 0) {
  29. var m = t.ownerCt;
  30. Ext.Array.each(rs, function(r, i){
  31. if(i == 0) {
  32. t.jo_id = r.get('jo_id');
  33. t.setValue(r.get('jo_name'));
  34. } else {
  35. m.insert(m.items.length - 2, {
  36. xtype: 'multidbfindtrigger',
  37. name: 'em_position',
  38. fieldLabel: '复制到',
  39. jo_id: r.get('jo_id'),
  40. value: r.get('jo_name'),
  41. p: 2,
  42. editable: false,
  43. autoDbfind: false,
  44. clearable: true
  45. });
  46. }
  47. });
  48. } else {
  49. f.setValue(null);
  50. f.jo_id = null;
  51. }
  52. }
  53. }
  54. });
  55. },
  56. loadTree : function(tree, record) {
  57. var pid = 0, me = this;
  58. if (record) {
  59. if (record.get('leaf')) {
  60. me.loadPower(record);
  61. return;
  62. } else {
  63. if (record.isExpanded() && record.childNodes.length > 0) {
  64. record.collapse(true, true);// 收拢
  65. return;
  66. } else {
  67. if (record.childNodes.length != 0) {
  68. record.expand(false, true);// 展开
  69. return;
  70. }
  71. }
  72. }
  73. pid = record.get('id');
  74. }
  75. tree.setLoading(true);
  76. Ext.Ajax.request({
  77. url : basePath + 'ma/PDAlazyTree.action',
  78. params : {
  79. parentId : pid,
  80. condition : 'sn_limit=1'
  81. },
  82. callback : function(options, success, response) {
  83. tree.setLoading(false);
  84. var res = new Ext.decode(response.responseText);
  85. if (res.tree) {
  86. if (record) {
  87. record.appendChild(res.tree);
  88. record.expand(false, true);// 展开
  89. } else {
  90. tree.store.setRootNode({
  91. text : 'root',
  92. id : 'root',
  93. expanded : true,
  94. children : res.tree
  95. });
  96. }
  97. } else if (res.exceptionInfo) {
  98. showError(res.exceptionInfo);
  99. }
  100. }
  101. });
  102. },
  103. loadPower : function(record) {
  104. var caller = record.get('caller'), set = Ext.getCmp('grid');
  105. set.ejp_caller = caller;
  106. set.down('tbtext').setText('<font color=gray>权限名:</font>' + record.get('text'));
  107. if (!Ext.isEmpty(caller)) {
  108. set.getGroupData();
  109. } else {
  110. set.store.removeAll();
  111. }
  112. }
  113. });