123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.ma.PDAPower', {
- extend : 'Ext.app.Controller',
- requires: ['erp.util.FormUtil','erp.view.core.grid.HeaderFilter','erp.view.core.plugin.CopyPasteMenu'],
- views : [ 'ma.PDAPower', 'core.button.Distribute', 'core.grid.PDAGroupPower', 'core.trigger.DbfindTrigger',
- 'core.trigger.EmpTrigger', 'core.button.Sync', 'core.trigger.MultiDbfindTrigger','core.trigger.SearchField'],
- init : function() {
- var me = this;
- me.FormUtil = Ext.create('erp.util.FormUtil');
- this.control({
- 'treepanel[id=powertree]' : {
- afterrender : function(tree) {
- me.loadTree(tree);
- },
- itemmousedown : function(selModel, record) {
- var tree = selModel.ownerCt;
- me.loadTree(tree, record);
- },
- scrollershow: function(scroller) {
- if (scroller && scroller.scrollEl) {
- scroller.clearManagedListeners();
- scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
- }
- }
- },
- 'multidbfindtrigger[name=em_position]': {
- aftertrigger: function(t, rs) {
- if(rs.length > 0) {
- var m = t.ownerCt;
- Ext.Array.each(rs, function(r, i){
- if(i == 0) {
- t.jo_id = r.get('jo_id');
- t.setValue(r.get('jo_name'));
- } else {
- m.insert(m.items.length - 2, {
- xtype: 'multidbfindtrigger',
- name: 'em_position',
- fieldLabel: '复制到',
- jo_id: r.get('jo_id'),
- value: r.get('jo_name'),
- p: 2,
- editable: false,
- autoDbfind: false,
- clearable: true
- });
- }
- });
- } else {
- f.setValue(null);
- f.jo_id = null;
- }
- }
- }
- });
- },
- loadTree : function(tree, record) {
- var pid = 0, me = this;
- if (record) {
- if (record.get('leaf')) {
- me.loadPower(record);
- return;
- } else {
- if (record.isExpanded() && record.childNodes.length > 0) {
- record.collapse(true, true);// 收拢
- return;
- } else {
- if (record.childNodes.length != 0) {
- record.expand(false, true);// 展开
- return;
- }
- }
- }
- pid = record.get('id');
- }
- tree.setLoading(true);
- Ext.Ajax.request({
- url : basePath + 'ma/PDAlazyTree.action',
- params : {
- parentId : pid,
- condition : 'sn_limit=1'
- },
- callback : function(options, success, response) {
- tree.setLoading(false);
- var res = new Ext.decode(response.responseText);
- if (res.tree) {
- if (record) {
- record.appendChild(res.tree);
- record.expand(false, true);// 展开
- } else {
- tree.store.setRootNode({
- text : 'root',
- id : 'root',
- expanded : true,
- children : res.tree
- });
- }
- } else if (res.exceptionInfo) {
- showError(res.exceptionInfo);
- }
- }
- });
- },
- loadPower : function(record) {
- var caller = record.get('caller'), set = Ext.getCmp('grid');
- set.ejp_caller = caller;
- set.down('tbtext').setText('<font color=gray>权限名:</font>' + record.get('text'));
- if (!Ext.isEmpty(caller)) {
- set.getGroupData();
- } else {
- set.store.removeAll();
- }
- }
- });
|