| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- Ext.define('erp.view.hr.employee.HrOrgStrTree',{
- extend: 'Ext.tree.Panel',
- alias: 'widget.hrOrgStrTree',
- id: 'tree-panel',
- border : false,
- enableDD : false,
- split: true,
- width : '100%',
- height: '100%',
- expandedNodes: [],
- title: "<font color=#a1a1a1; size=2>员工组织架构</font>",
- toggleCollapse: function() {
- if (this.collapsed) {
- this.expand(this.animCollapse);
- } else {
- this.title = '员工组织架构';
- this.collapse(this.collapseDirection, this.animCollapse);
- }
- return this;
- },
- rootVisible: false,
- singleExpand: true,
- containerScroll : true,
- collapsible : true,
- autoScroll: true,
- store: Ext.create('Ext.data.TreeStore', {
- root : {
- text: 'root',
- id: 'root',
- expanded: true
- }
- }),
- dockedItems: [{
- xtype: 'toolbar',
- items: [{
- text: '新增',
- handler: function(){
- win = Ext.create('Ext.Window', {
- id: 'vendoruu-win',
- title: '组织新增人员',
- height: 200,
- width: 400,
- defaults: {
- anchor: '100%'
- },
- items: [{
- xtype: 'textfield',
- fieldLabel: '员工编号',
- name:'em_code',
- value: ''
- },{
- xtype: 'textfield',
- fieldLabel: '员工姓名',
- name:'em_name',
- value: ''
- },{
- xtype: 'dbfindtrigger',
- fieldLabel: '组织名称',
- name:'em_defaultorname',
- value: ''
- },{
- xtype: 'textfield',
- fieldLabel: '组织ID',
- name:'em_defaultorid',
- value: ''
- }],
- closeAction: 'hide',
- buttonAlign: 'center',
- layout: {
- type: 'vbox',
- align: 'center'
- },
- buttons: [{
- text:'保存',
- cls: 'x-btn-blue',
- handler: function(btn) {
- var em_id = Ext.getCmp('em_id').value;
- if(em_id==null){
- showError("员工ID不能为空!");
- return;
- }
- var em_defaultorid = Ext.getCmp('em_defaultorid').value;
- var em_defaultorname = Ext.getCmp('em_defaultorname').value;
- if(em_defaultorname==null){
- showError("组织名称不能为空!");
- return;
- }
- Ext.Ajax.request({
- url : basePath + 'hr/HrOrgStrTree/updateEmployee.action',
- params: {
- em_id:em_id,
- hrOrgid:em_defaultorid,
- hrOrgName:em_defaultorname
- },
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.success){
- alert("该人员已成功被组织添加!");
- } else if(res.exceptionInfo){
- showError(res.exceptionInfo);
- }
- }
- });
- }
- }, {
- text: $I18N.common.button.erpCloseButton,
- cls: 'x-btn-blue',
- handler: function(btn) {
- btn.ownerCt.ownerCt.hide();
- }
- }]
- });
- win.show();
- }
- }, {
- text: '更新',
- handler: function(){
- var check = Ext.getCmp('tree-panel').getSelectionModel();
- var emid = check.lastSelected.data.id;
- win = Ext.create('Ext.Window', {
- id: 'vendoruu-win',
- title: '更新人员组织',
- height: 200,
- width: 400,
- defaults: {
- anchor: '100%'
- },
- items: [{
- xtype: 'textfield',
- fieldLabel: '员工ID',
- name:'em_id',
- value: check.lastSelected.data.id
- },{
- xtype: 'textfield',
- fieldLabel: '员工姓名',
- name:'em_name',
- value: check.lastSelected.data.text
- },{
- xtype: 'dbfindtrigger',
- fieldLabel: '组织名称',
- name:'em_defaultorname',
- value: ''
- },{
- xtype: 'textfield',
- fieldLabel: '组织ID',
- name:'em_defaultorid',
- value: ''
- }],
- closeAction: 'hide',
- buttonAlign: 'center',
- layout: {
- type: 'vbox',
- align: 'center'
- },
- buttons: [{
- text:'更新',
- cls: 'x-btn-blue',
- handler: function(btn) {
- var em_id = Ext.getCmp('em_id').value;
- if(em_id==null){
- showError("员工ID不能为空!");
- return;
- }
- var em_defaultorid = Ext.getCmp('em_defaultorid').value;
- var em_defaultorname = Ext.getCmp('em_defaultorname').value;
- if(em_defaultorname==null){
- showError("组织名称不能为空!");
- return;
- }
- Ext.Ajax.request({
- url : basePath + 'hr/HrOrgStrTree/updateEmployee.action',
- params: {
- em_id:em_id,
- hrOrgid:em_defaultorid,
- hrOrgName:em_defaultorname
- },
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.success){
- alert("人员组织更新成功!");
-
- } else if(res.exceptionInfo){
- showError(res.exceptionInfo);
- }
- }
- });
- }
- }, {
- text: $I18N.common.button.erpCloseButton,
- cls: 'x-btn-blue',
- handler: function(btn) {
- btn.ownerCt.ownerCt.hide();
- }
- }]
- });
- /*var formCondition = "em_id="+emid;
- var win = new Ext.window.Window({
- id : 'win',
- title: '更新人员组织',
- height: "90%",
- width: "70%",
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- items: [{
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_' + emid+ '" src="' + basePath +
- 'jsps/hr/employee/updateHrorg.jsp?formCondition='+formCondition+'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
- }]
- });*/
- win.show();
- }},{
- text: '删除',
- handler: function(){
- warnMsg("确定要从组织中删除该人员吗?", function(btn){
- if(btn == 'yes'){
- var check = Ext.getCmp('tree-panel').getSelectionModel();
- var emid = check.lastSelected.data.id;
- Ext.Ajax.request({
- url : basePath + 'hr/HrOrgStrTree/deleteEmployee.action',
- params: {
- id: emid
- },
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- }
- if(localJson.success){
- alert("该人员已经成功从组织中删除!");
- }
- }
- });
- }
- });
- }
- }]
- }],
- tools: [{
- id: 'refresh',
- type: 'refresh',
- tooltip: '刷新',
- handler: function(){
-
- }
- },{
- id: 'search',
- type: 'search',
- tooltip: '查找',
- handler: function(){
-
- }
- }],
- bodyStyle:'background-color:#f1f1f1;',
- initComponent : function(){
- this.getTreeRootNode(0);
- this.callParent(arguments);
- },
- getTreeRootNode: function(parentid){
- Ext.Ajax.request({//拿到tree数据
- url : basePath + 'hr/employee/getAllHrOrgsTree.action',
- params: {
- //parentid: parentid
- },
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.tree){
- var tree = res.tree;
- // console.log(Ext.getCmp('tree-panel'));
- Ext.getCmp('tree-panel').store.setRootNode({
- text: 'root',
- id: 'root',
- expanded: true,
- children: tree
- });
- } else if(res.exceptionInfo){
- showError(res.exceptionInfo);
- }
- Ext.getCmp('tree-panel').listenerNode();
- }
- });
- },
- listenerNode: function(node){
- var me = this;
- var Node = node || Ext.getCmp('tree-panel').store.tree.root;
- Ext.each(Node,function(e){
- e.on('beforecollapse',function(p,o){
- });
- if(e.data['leaf'] == false){
- me.listenerNode(e);
- }
- });
-
- },
- openCloseFun: function(){
- var o = Ext.getCmp("open");
- var c = Ext.getCmp("close");
- var tree = Ext.getCmp('tree-panel');
- if(o.hidden==false&&c.hidden==true){
- tree.expandAll();
- o.hide();
- c.show();
- }else{
- tree.collapseAll();
- o.show();
- c.hide();
- }
- },
- listeners: {//滚动条有时候没反应,添加此监听器
- scrollershow: function(scroller) {
- if (scroller && scroller.scrollEl) {
- scroller.clearManagedListeners();
- scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
- }
- },
- },
- /**
- * 找到所有已展开的节点,包括当前被选中的节点
- * @param record 当前被选中的节点
- */
- getExpandedItems: function(record){
- var me = this;
- me.getRecordParents(record);
- if(record.isLeaf()){
- me.expandedNodes.push(record);
- }
- },
- getRecordParents: function(record, parent){
- var me = this;
- if(!parent){
- parent = me.store.tree.root;
- me.expandedNodes = [];
- }
- if(parent.childNodes.length > 0){
- Ext.each(parent.childNodes, function(){
- if(this.isExpanded()){
- me.expandedNodes.push(this);
- if(this.childNodes.length > 0){
- me.getRecordParents(record, this);
- }
- }
- });
- }
- },
- getExpandItem: function(root){
- var me = this;
- if(!root){
- root = this.store.tree.root;
- }
- var node = null;
- if(root.childNodes.length > 0){
- Ext.each(root.childNodes, function(){
- if(this.isExpanded()){
- node = this;
- if(this.childNodes.length > 0){
- var n = me.getExpandItem(this);
- node = n == null ? node : n;
- }
- }
- });
- }
- return node;
- }
- });
|