Department.min.js 4.6 KB

1
  1. MWF.xApplication.Organization.Selector=MWF.xApplication.Organization.Selector||{};MWF.xDesktop.requireApp("Organization","Actions.RestActions",null,false);MWF.xDesktop.requireApp("Organization","Selector.Identity",null,false);MWF.xApplication.Organization.Selector.Department=new Class({Extends:MWF.xApplication.Organization.Selector.Identity,options:{style:"default",count:0,title:"Select Department",companys:[],departments:[],values:[],names:[],expand:false},initialize:function(t,e){this.setOptions(e);this.options.groups=[];this.options.roles=[];this.path="/x_component_Organization/Selector/$Selector/";this.cssPath="/x_component_Organization/Selector/$Selector/"+this.options.style+"/css.wcss";this._loadCss();this.container=$(t);this.action=new MWF.xApplication.Organization.Actions.RestActions;this.lastPeople="";this.pageCount="13";this.selectedItems=[];this.items=[]},loadSelectItems:function(t){if(this.options.companys.length){this.options.companys.each(function(t){this.action.listCompanyByKey(function(t){if(t.data.length){t.data.each(function(t){var e=this._newItemCategory("ItemCompanyCategory",t,this,this.itemAreaNode)}.bind(this))}}.bind(this),null,t)}.bind(this))}else{this.action.listTopCompany(function(t){t.data.each(function(t){var e=this._newItemCategory("ItemCompanyCategory",t,this,this.itemAreaNode)}.bind(this))}.bind(this))}},_scrollEvent:function(t){return true},_getChildrenItemIds:function(){return null},_newItemCategory:function(t,e,n,i,o){return new MWF.xApplication.Organization.Selector.Department[t](e,n,i,o)},_listItemByKey:function(t,e,n){this.action.listDepartmentByKey(function(e){if(t)t.apply(this,[e])}.bind(this),e,n)},_getItem:function(t,e,n,i){this.action.getDepartment(function(e){if(t)t.apply(this,[e])}.bind(this),e,n,i)},_newItemSelected:function(t,e,n){return new MWF.xApplication.Organization.Selector.Department.ItemSelected(t,e,n)},_listItemByPinyin:function(t,e,n){this.action.listDepartmentByKey(function(e){if(t)t.apply(this,[e])}.bind(this),e,n)},_newItem:function(t,e,n,i){return new MWF.xApplication.Organization.Selector.Department.Item(t,e,n,i)}});MWF.xApplication.Organization.Selector.Department.Item=new Class({Extends:MWF.xApplication.Organization.Selector.Person.Item,_getShowName:function(){return this.data.name},_setIcon:function(){this.iconNode.setStyle("background-image","url("+"/x_component_Organization/Selector/$Selector/default/icon/departmenticon.png)")},loadSubItem:function(){this.children=new Element("div",{styles:this.selector.css.selectorItemCategoryChildrenNode}).inject(this.node,"after");this.children.setStyle("display","block");this.selector.action.listSubDepartment(function(t){t.data.each(function(t){var e=this.selector._newItem(t,this.selector,this.children,this.level+1)}.bind(this))}.bind(this),null,this.data.id)}});MWF.xApplication.Organization.Selector.Department.ItemSelected=new Class({Extends:MWF.xApplication.Organization.Selector.Person.ItemSelected,_getShowName:function(){return this.data.name},_setIcon:function(){this.iconNode.setStyle("background-image","url("+"/x_component_Organization/Selector/$Selector/default/icon/departmenticon.png)")}});MWF.xApplication.Organization.Selector.Department.ItemCompanyCategory=new Class({Extends:MWF.xApplication.Organization.Selector.Identity.ItemCompanyCategory,loadSub:function(t){if(!this.loaded){this.selector.action.listSubComplexDirect(function(e){e.data.companyList.each(function(t){var e=this.selector._newItemCategory("ItemCompanyCategory",t,this.selector,this.children,this.level+1)}.bind(this));e.data.departmentList.each(function(t){var e=this.selector._newItem(t,this.selector,this.children,this.level+1)}.bind(this));this.loaded=true;if(t)t()}.bind(this),null,this.data.id)}else{if(t)t()}}});MWF.xApplication.Organization.Selector.Department.ItemDepartmentCategory=new Class({Extends:MWF.xApplication.Organization.Selector.Identity.ItemCompanyCategory,createNode:function(){this.node=new Element("div",{styles:this.selector.css.selectorItemCategory_department}).inject(this.container)},loadSub:function(t){if(!this.loaded){this.selector.action.listSubDepartment(function(t){t.data.each(function(t){var e=this.selector._newItem(t,this.selector,this.children,this.level+1)}.bind(this))}.bind(this),null,this.data.id);this.loaded=true;if(t)t()}else{if(t)t()}},_hasChild:function(){var t=this.data.companySubDirectCount?this.data.companySubDirectCount:0;var e=this.data.departmentSubDirectCount?this.data.departmentSubDirectCount:0;var n=t+e;if(n)return true;return false},_getShowName:function(){return this.data.name},_setIcon:function(){this.iconNode.setStyle("background-image","url("+"/x_component_Organization/Selector/$Selector/default/icon/departmenticon.png)")}});