Identity.min.js 5.7 KB

1
  1. MWF.xApplication.Organization.Selector=MWF.xApplication.Organization.Selector||{};MWF.xDesktop.requireApp("Organization","Actions.RestActions",null,false);MWF.xDesktop.requireApp("Organization","Selector.Person",null,false);MWF.xApplication.Organization.Selector.Identity=new Class({Extends:MWF.xApplication.Organization.Selector.Person,options:{style:"default",count:0,title:"Select Identity",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.departments.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));this.options.departments.each(function(t){this.action.listDepartmentByKey(function(t){if(t.data.length){t.data.each(function(t){var e=this._newItemCategory("ItemDepartmentCategory",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,i,n,o){return new MWF.xApplication.Organization.Selector.Identity[t](e,i,n,o)},_listItemByKey:function(t,e,i){this.action.listIdentityByKey(function(e){if(t)t.apply(this,[e])}.bind(this),e,i)},_getItem:function(t,e,i,n){this.action.getIdentity(function(e){if(t)t.apply(this,[e])}.bind(this),e,i,n)},_newItemSelected:function(t,e,i){return new MWF.xApplication.Organization.Selector.Identity.ItemSelected(t,e,i)},_listItemByPinyin:function(t,e,i){this.action.listIdentityByPinyin(function(e){if(t)t.apply(this,[e])}.bind(this),e,i)},_newItem:function(t,e,i,n){return new MWF.xApplication.Organization.Selector.Identity.Item(t,e,i,n)}});MWF.xApplication.Organization.Selector.Identity.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/personicon.png)")}});MWF.xApplication.Organization.Selector.Identity.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/personicon.png)")}});MWF.xApplication.Organization.Selector.Identity.ItemCompanyCategory=new Class({Extends:MWF.xApplication.Organization.Selector.Person.ItemCategory,_getShowName:function(){return this.data.name},_setIcon:function(){this.iconNode.setStyle("background-image","url("+"/x_component_Organization/Selector/$Selector/default/icon/companyicon.png)")},clickItem:function(){if(this._hasChild()){this.loadSub(function(){var t=this.children.getStyle("display");if(t=="none"){this.children.setStyles({display:"block",height:"auto"});this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand)}else{this.children.setStyles({display:"none",height:"0px"});this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse)}}.bind(this))}},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._newItemCategory("ItemDepartmentCategory",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()}},_hasChild:function(){var t=this.data.companySubDirectCount?this.data.companySubDirectCount:0;var e=this.data.departmentSubDirectCount?this.data.departmentSubDirectCount:0;var i=t+e;if(i)return true;return false}});MWF.xApplication.Organization.Selector.Identity.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){if(this.data.departmentSubDirectCount){this.selector.action.listSubDepartment(function(t){t.data.each(function(t){var e=this.selector._newItemCategory("ItemDepartmentCategory",t,this.selector,this.children,this.level+1)}.bind(this))}.bind(this),null,this.data.id)}if(this.data.identitySubDirectCount){this.selector.action.listIdentity(function(t){t.data.each(function(t){var e=this.selector._newItem(t,this.selector,this.children,this.level+1);this.selector.items.push(e)}.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 i=this.data.identitySubDirectCount?this.data.identitySubDirectCount:0;var n=t+e+i;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)")}});