Identity.min.js 6.3 KB

1
  1. MWF.xApplication.Selector=MWF.xApplication.Selector||{};MWF.xDesktop.requireApp("Selector","Person",null,false);MWF.xApplication.Selector.Identity=new Class({Extends:MWF.xApplication.Selector.Person,options:{style:"default",count:0,title:MWF.xApplication.Selector.LP.selectIdentity,units:[],values:[],zIndex:1e3,expand:false},loadSelectItems:function(t){if(this.options.units.length){this.options.units.each(function(t){if(typeOf(t)==="string"){this.orgAction.listUnitByKey(function(t){if(t.data.length){t.data.each(function(t){var e=this._newItemCategory("ItemCategory",t,this,this.itemAreaNode)}.bind(this))}}.bind(this),null,t)}else{this.orgAction.getUnit(function(t){if(t.data){var e=this._newItemCategory("ItemCategory",t.data,this,this.itemAreaNode)}}.bind(this),null,t.distinguishedName)}}.bind(this))}else{this.orgAction.listTopUnit(function(t){t.data.each(function(t){var e=this._newItemCategory("ItemCategory",t,this,this.itemAreaNode)}.bind(this))}.bind(this))}},checkLoadSelectItems:function(){if(!this.options.units.length){this.loadSelectItems()}else{this.loadSelectItems()}},_scrollEvent:function(t){return true},_getChildrenItemIds:function(){return null},_newItemCategory:function(t,e,i,n,s){return new MWF.xApplication.Selector.Identity[t](e,i,n,s)},_listItemByKey:function(e,t,i){debugger;if(this.options.units.length){var n=[];this.options.units.each(function(t){if(typeOf(t)==="string"){n.push(t)}if(typeOf(t)==="object"){n.push(t.distinguishedName)}});i={key:i,unitList:n}}this.orgAction.listIdentityByKey(function(t){if(e)e.apply(this,[t])}.bind(this),t,i)},_getItem:function(e,t,i,n){this.orgAction.getIdentity(function(t){if(e)e.apply(this,[t])}.bind(this),t,typeOf(i)==="string"?i:i.distinguishedName,n)},_newItemSelected:function(t,e,i){return new MWF.xApplication.Selector.Identity.ItemSelected(t,e,i)},_listItemByPinyin:function(e,t,i){if(this.options.units.length){var n=[];this.options.units.each(function(t){if(typeOf(t)==="string"){n.push(t)}if(typeOf(t)==="object"){n.push(t.distinguishedName)}});i={key:i,unitList:n}}this.orgAction.listIdentityByPinyin(function(t){if(e)e.apply(this,[t])}.bind(this),t,i)},_newItem:function(t,e,i,n){return new MWF.xApplication.Selector.Identity.Item(t,e,i,n)},_newItemSearch:function(t,e,i,n){return new MWF.xApplication.Selector.Identity.SearchItem(t,e,i,n)}});MWF.xApplication.Selector.Identity.Item=new Class({Extends:MWF.xApplication.Selector.Person.Item,_getShowName:function(){return this.data.name},_getTtiteText:function(){return this.data.name+(this.data.unitLevelName?"("+this.data.unitLevelName+")":"")},_setIcon:function(){this.iconNode.setStyle("background-image","url("+"/x_component_Selector/$Selector/default/icon/personicon.png)")},getData:function(e){if(!this.data.woPerson){this.selector.orgAction.getPerson(function(t){this.data.woPerson=t.data;if(e)e()}.bind(this),null,this.data.person)}else{if(e)e()}}});MWF.xApplication.Selector.Identity.SearchItem=new Class({Extends:MWF.xApplication.Selector.Identity.Item,_getShowName:function(){return this.data.name+(this.data.unitLevelName?"("+this.data.unitLevelName+")":"")}});MWF.xApplication.Selector.Identity.ItemSelected=new Class({Extends:MWF.xApplication.Selector.Person.ItemSelected,getData:function(o){if(!this.data.woPerson){if(this.data.person){this.selector.orgAction.getPerson(function(t){this.data.woPerson=t.data;if(o)o()}.bind(this),function(t,e,i){var n=i;if(t){var s=JSON.decode(t.responseText);if(s){n=s.message.trim()||"request json error"}else{n="request json error: "+t.responseText}}MWF.xDesktop.notice("error",{x:"right",y:"top"},n);if(o)o()}.bind(this),this.data.person)}else{MWF.xDesktop.notice("error",{x:"right",y:"top"},MWF.SelectorLP.noPerson.replace(/{name}/g,this.data.name));if(o)o()}}else{if(o)o()}},_getShowName:function(){return this.data.name+(this.data.unitLevelName?"("+this.data.unitLevelName+")":"")},_getTtiteText:function(){return this.data.name+(this.data.unitLevelName?"("+this.data.unitLevelName+")":"")},_setIcon:function(){this.iconNode.setStyle("background-image","url("+"/x_component_Selector/$Selector/default/icon/personicon.png)")}});MWF.xApplication.Selector.Identity.ItemCategory=new Class({Extends:MWF.xApplication.Selector.Person.ItemCategory,createNode:function(){this.node=new Element("div",{styles:this.selector.css.selectorItemCategory_department}).inject(this.container)},_getShowName:function(){return this.data.name},_setIcon:function(){this.iconNode.setStyle("background-image","url("+"/x_component_Selector/$Selector/default/icon/companyicon.png)")},clickItem:function(){if(this._hasChild()){var e=!this.loaded;this.loadSub(function(){if(e){this.children.setStyles({display:"block",height:"auto"});this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand)}else{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(e){if(!this.loaded){this.selector.orgAction.listIdentityWithUnit(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));this.selector.orgAction.listSubUnitDirect(function(t){t.data.each(function(t){var e=this.selector._newItemCategory("ItemCategory",t,this.selector,this.children,this.level+1)}.bind(this));this.loaded=true;if(e)e()}.bind(this),null,this.data.distinguishedName)}.bind(this),null,this.data.distinguishedName)}else{if(e)e()}},_hasChild:function(){var t=this.data.subDirectUnitCount?this.data.subDirectUnitCount:0;var e=this.data.subDirectIdentityCount?this.data.subDirectIdentityCount:0;return t+e}});MWF.xApplication.Selector.Identity.Filter=new Class({Implements:[Options,Events],options:{style:"default",units:[]},initialize:function(t,e){this.setOptions(e);this.value=t;this.orgAction=MWF.Actions.get("x_organization_assemble_control")},filter:function(t,e){this.value=t;var i=this.value;if(this.options.units.length){var n=[];this.options.units.each(function(t){if(typeOf(t)==="string"){n.push(t)}if(typeOf(t)==="object"){n.push(t.distinguishedName)}});i={key:this.value,unitList:n}}var s=null;this.orgAction.listIdentityByKey(function(t){s=t.data;if(e)e(s)}.bind(this),null,i)}});