Person.js 117 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "lp."+MWF.language, null, false);
  3. //MWF.xDesktop.requireApp("Selector", "Actions.RestActions", null, false);
  4. MWF.xApplication.Selector.Person = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "count": 0,
  10. "title": MWF.xApplication.Selector.LP.selectPerson,
  11. "groups": [],
  12. "roles": [],
  13. "values": [],
  14. "exclude" : [],
  15. "zIndex": 1000,
  16. "expand": true,
  17. "embedded" : false, //是否嵌入在其他容器中
  18. "selectAllEnable" : false, //是否允许全选
  19. "selectAllRange" : "direct", //全选直属人员 还是 所有下级人员
  20. "level1Indent" : 10, //第一级的缩进
  21. "indent" : 10, //后续的缩进
  22. "hasLetter" : true, //字母
  23. "hasTop" : false, //可选、已选的标题
  24. "hasShuttle" : false, //穿梭按钮
  25. "searchbarInTopNode" : true, //搜索框在标题上还是另起一行
  26. "hasSelectedSearchbar" : false, //已选是不是有搜索框
  27. "noSelectedContainer" : false, //是否隐藏右侧已选区域
  28. "contentUrl" : "", //和默认的页面布局不一样的话,可以传入页面布局HTML URL
  29. "injectToBody" : false, //当传入HTML URL的时候是否插入到document.body, false的时候插入到this.container
  30. "selectSingleItem" : false, //当只有一个候选项的时候,是否默认选中
  31. "flatCategory" : false, //扁平化展现分类,
  32. "selectType" : "person",
  33. "isCheckStatus" : true,
  34. "showSelectedCount" : false,
  35. "itemHeight" : 29,
  36. "identityItemWidth" : 0, //选项宽度,如果不为0,设置为float:left,
  37. "showEmptyText" : true
  38. },
  39. initialize: function(container, options){
  40. this.active = true;
  41. this.setOptions(options);
  42. this.path = "../x_component_Selector/$Selector/";
  43. this.cssPath = "../x_component_Selector/$Selector/"+this.options.style+"/css.wcss";
  44. this._loadCss(true);
  45. this.container = $(container);
  46. Object.defineProperties(this, {
  47. "orgAction": {"get": function(){return o2.Actions.get("x_organization_assemble_control");}},
  48. "processAction": {"get": function(){return o2.Actions.get("x_processplatform_assemble_surface");}},
  49. "designerAction": {"get": function(){return o2.Actions.get("x_processplatform_assemble_designer");}},
  50. "portalAction": {"get": function(){return o2.Actions.get("x_portal_assemble_surface");}},
  51. "portalDesignerAction": {"get": function(){return o2.Actions.get("x_portal_assemble_designer");}},
  52. "cmsAction": {"get": function(){return o2.Actions.get("x_cms_assemble_control");}},
  53. "queryAction": {"get": function(){return o2.Actions.get("x_query_assemble_designer");}}
  54. });
  55. // this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  56. // //this.org2Action = MWF.Actions.get("x_organization_assemble_express");
  57. // this.processAction = MWF.Actions.get("x_processplatform_assemble_surface");
  58. // this.designerAction = MWF.Actions.get("x_processplatform_assemble_designer");
  59. // this.portalAction = MWF.Actions.get("x_portal_assemble_surface");
  60. // this.portalDesignerAction = MWF.Actions.get("x_portal_assemble_designer");
  61. // this.cmsAction = MWF.Actions.get("x_cms_assemble_control");
  62. // this.queryAction = MWF.Actions.get("x_query_assemble_designer");
  63. //this.action = new MWF.xApplication.Selector.Actions.RestActions();
  64. this.lastPeople = "";
  65. this.pageCount = "13";
  66. this.selectedItems = []; //所有已选项
  67. this.items = []; //所有选择项
  68. this.subCategorys = []; //直接的分类
  69. this.subItems = []; //直接的选择项
  70. },
  71. load: function(){
  72. this.fireEvent("queryLoad",[this]);
  73. if( this.options.contentUrl ){
  74. this.loadWithUrl()
  75. }else{
  76. if (layout.mobile){
  77. this.loadMobile();
  78. }else{
  79. this.loadPc();
  80. }
  81. this.fireEvent("load");
  82. }
  83. },
  84. loadMobile: function(){
  85. this.maskRelativeNode = $(document.body);
  86. this.maskRelativeNode.mask({
  87. "destroyOnHide": true,
  88. "style": this.css.maskNode
  89. });
  90. this.node = new Element("div", {"styles": this.css.containerNodeMobile});
  91. this.node.setStyle("z-index", this.options.zIndex.toInt()+1);
  92. this.node.setStyle("height", ( $(document.body).getSize().y ) + "px");
  93. this.titleNode = new Element("div", {
  94. "styles": this.css.titleNodeMobile
  95. }).inject(this.node);
  96. this.titleCancelActionNode = new Element("div", {
  97. "styles": this.css.titleCancelActionNodeMobile,
  98. "text": MWF.SelectorLP.back
  99. }).inject(this.titleNode);
  100. this.titleOkActionNode = new Element("div", {
  101. "styles": this.css.titleOkActionNodeMobile,
  102. "text": MWF.SelectorLP.ok
  103. }).inject(this.titleNode);
  104. this.titleTextNode = new Element("div", {
  105. "styles": this.css.titleTextNodeMobile,
  106. "text": this.options.title
  107. }).inject(this.titleNode);
  108. this.contentNode = new Element("div", {
  109. "styles": this.css.contentNode
  110. }).inject(this.node);
  111. var size = $(document.body).getSize();
  112. var height = size.y-40;
  113. //var height = size.y;
  114. this.contentNode.setStyle("height", ""+height+"px");
  115. this.loadContent();
  116. this.node.inject($(document.body));
  117. this.node.setStyles({
  118. "top": "0px",
  119. "left": "0px"
  120. });
  121. this.setEvent();
  122. },
  123. setMaskResize: function(){
  124. var size = this.container.getSize();
  125. this.mask.resize();
  126. this.maskInterval = window.setInterval(function(){
  127. var resize = this.container.getSize();
  128. if ((size.x!==resize.x) || (size.y!==resize.y)){
  129. this.mask.position();
  130. this.mask.resize();
  131. size.x = resize.x;
  132. size.y = resize.y;
  133. }
  134. }.bind(this), 66);
  135. },
  136. loadPc: function(){
  137. if( this.options.embedded ){
  138. this.node = new Element("div", {
  139. "styles": this.css.containerNode_embedded, //(this.options.count.toInt()===1) ? this.css.containerNodeSingle_embedded : this.css.containerNode_embedded,
  140. "events": {
  141. "click": function(e){e.stopPropagation();},
  142. "mousedown": function(e){e.stopPropagation();},
  143. "mouseover": function(e){e.stopPropagation();},
  144. "mouseout": function(e){e.stopPropagation();},
  145. "keydown": function(e){e.stopPropagation();}
  146. }
  147. });
  148. this.contentNode = new Element("div", {
  149. "styles": this.css.contentNode_embedded ? this.css.contentNode_embedded : this.css.contentNode
  150. }).inject(this.node);
  151. this.loadContent();
  152. if( this.options.width || this.options.height ){
  153. this.setSize()
  154. }
  155. this.node.inject(this.container);
  156. } else {
  157. this.css.maskNode["z-index"] = this.options.zIndex;
  158. var position = this.container.getPosition(this.container.getOffsetParent());
  159. this.mask = new Mask(this.container, {
  160. "destroyOnHide": true,
  161. "style": this.css.maskNode,
  162. "useIframeShim": true,
  163. "iframeShimOptions": {"browsers": true},
  164. "onShow": function () {
  165. this.shim.shim.setStyles({
  166. "opacity": 0,
  167. "top": "" + position.y + "px",
  168. "left": "" + position.x + "px"
  169. });
  170. }
  171. //
  172. // "destroyOnHide": true,
  173. // "style": this.css.maskNode,
  174. // "useIframeShim": true,
  175. // "iframeShimOptions": {"browsers": true},
  176. // "onShow": function(){
  177. // this.shim.shim.setStyles({
  178. // "opacity": 0,
  179. // "top": ""+position.y+"px",
  180. // "left": ""+position.x+"px"
  181. // });
  182. // }
  183. });
  184. this.mask.show();
  185. this.setMaskResize();
  186. // this.container.setStyle("z-index", this.options.zIndex);
  187. this.node = new Element("div", {
  188. "styles": this.options.noSelectedContainer ? this.css.containerNodeSingle : this.css.containerNode, //(this.options.count.toInt()===1)
  189. "events": {
  190. "click": function(e){e.stopPropagation();},
  191. "mousedown": function(e){e.stopPropagation();},
  192. "mouseover": function(e){e.stopPropagation();},
  193. "mouseout": function(e){e.stopPropagation();},
  194. "keydown": function(e){e.stopPropagation();}
  195. }
  196. });
  197. this.node.setStyle("z-index", this.options.zIndex.toInt()+1);
  198. this.titleNode = new Element("div.titleNode", {
  199. "styles": this.css.titleNode
  200. }).inject(this.node);
  201. this.titleActionNode = new Element("div", {
  202. "styles": this.css.titleActionNode
  203. }).inject(this.titleNode);
  204. this.titleTextNode = new Element("div", {
  205. "styles": this.css.titleTextNode,
  206. "text": this.options.title
  207. }).inject(this.titleNode);
  208. this.contentNode = new Element("div", {
  209. "styles": this.css.contentNode
  210. }).inject(this.node);
  211. this.loadContent();
  212. this.actionNode = new Element("div", {
  213. "styles": this.css.actionNode
  214. }).inject(this.node);
  215. //if (this.options.count.toInt() === 1) this.actionNode.setStyle("text-align", "center");
  216. this.loadAction();
  217. this.node.inject(this.container);
  218. this.node.position({
  219. relativeTo: this.container,
  220. position: "center",
  221. edge: "center"
  222. });
  223. var size = this.container.getSize();
  224. var nodeSize = this.node.getSize();
  225. this.node.makeDraggable({
  226. "handle": this.titleNode,
  227. "limit": {
  228. "x": [0, size.x - nodeSize.x],
  229. "y": [0, size.y - nodeSize.y]
  230. }
  231. });
  232. if( this.options.width || this.options.height ){
  233. this.setSize()
  234. }
  235. this.setEvent();
  236. }
  237. },
  238. loadWithUrl : function(){
  239. var request = new Request.HTML({
  240. url: this.options.contentUrl,
  241. method: "GET",
  242. async: false,
  243. onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
  244. this.node = responseTree[0];
  245. this.loadContentWithHTML();
  246. this.fireEvent("load");
  247. }.bind(this),
  248. onFailure: function(xhr){
  249. alert(xhr);
  250. }
  251. });
  252. request.send();
  253. },
  254. loadContentWithHTML : function(){
  255. var container = this.options.injectToBody ? $(document.body) : this.container;
  256. if( !this.options.embedded ){
  257. this.maskRelativeNode = container;
  258. this.css.maskNode["z-index"] = this.options.zIndex;
  259. this.maskRelativeNode.mask({
  260. "destroyOnHide": true,
  261. "style": this.css.maskNode
  262. });
  263. }
  264. if( !this.options.embedded ) {
  265. this.node.setStyles(this.css.containerNodeMobile);
  266. this.node.setStyle("z-index", this.options.zIndex.toInt() + 1);
  267. }
  268. this.node.setStyle("height", ( container.getSize().y ) + "px");
  269. this.titleNode = this.node.getElement(".MWF_selector_titleNode");
  270. this.titleTextNode = this.node.getElement(".MWF_selector_titleTextNode");
  271. this.titleCancelActionNode = this.node.getElement(".MWF_selector_titleCancelActionNode");
  272. this.titleOkActionNode = this.node.getElement(".MWF_selector_titleOkActionNode");
  273. this.contentNode = this.node.getElement(".MWF_selector_contentNode");
  274. this.selectNode = this.node.getElement(".MWF_selector_selectNode");
  275. this.searchInputDiv = this.node.getElement(".MWF_selector_searchInputDiv");
  276. this.searchInput = this.node.getElement(".MWF_selector_searchInput");
  277. this.flatCategoryScrollNode = this.node.getElement(".MWF_selector_flatCategoryScrollNode");
  278. this.flatCategoryNode = this.node.getElement(".MWF_selector_flatCategoryNode");
  279. if( this.options.flatCategory && this.flatCategoryScrollNode ){
  280. this.isFlatCategory = true;
  281. this.flatSubCategoryNodeList = [];
  282. }
  283. this.letterAreaNode = this.node.getElement(".MWF_selector_letterAreaNode");
  284. this.itemAreaScrollNode = this.node.getElement(".MWF_selector_itemAreaScrollNode");
  285. this.itemAreaNode = this.node.getElement(".MWF_selector_itemAreaNode");
  286. this.itemSearchAreaScrollNode = this.node.getElement(".MWF_selector_itemSearchAreaScrollNode");
  287. this.itemSearchAreaNode = this.node.getElement(".MWF_selector_itemSearchAreaNode");
  288. this.selectedScrollNode = this.node.getElement(".MWF_selector_selectedScrollNode");
  289. this.selectedNode = this.node.getElement(".MWF_selector_selectedNode");
  290. this.selectedItemSearchAreaNode = this.node.getElement(".MWF_selector_selectedItemSearchAreaNode");
  291. this.actionNode = this.node.getElement(".MWF_selector_actionNode");
  292. this.okActionNode = this.node.getElement(".MWF_selector_okActionNode");
  293. this.cancelActionNode = this.node.getElement(".MWF_selector_cancelActionNode");
  294. if (this.titleNode) this.titleNode.setStyles(this.css.titleNodeMobile);
  295. if (this.titleTextNode){
  296. this.titleTextNode.setStyles(this.css.titleTextNodeMobile);
  297. if(this.options.title)this.titleTextNode.set("text", this.options.title);
  298. }
  299. if (this.titleCancelActionNode) this.titleCancelActionNode.setStyles(this.css.titleCancelActionNodeMobile);
  300. if (this.titleOkActionNode) this.titleOkActionNode.setStyles(this.css.titleOkActionNodeMobile);
  301. if (this.contentNode) this.contentNode.setStyles(this.css.contentNode);
  302. if (this.selectNode) this.selectNode.setStyles(this.css.selectNodeMobile);
  303. if (this.searchInputDiv) this.searchInputDiv.setStyles(this.css.searchInputDiv);
  304. if (this.searchInput) this.searchInput.setStyles( (this.options.count.toInt()===1 || this.options.noSelectedContainer) ? this.css.searchInputSingle : this.css.searchInput );
  305. if (this.letterAreaNode) this.letterAreaNode.setStyles(this.css.letterAreaNode);
  306. if (this.itemAreaScrollNode) this.itemAreaScrollNode.setStyles(this.css.itemAreaScrollNode);
  307. if (this.itemAreaNode) this.itemAreaNode.setStyles(this.css.itemAreaNode);
  308. if (this.itemSearchAreaScrollNode) this.itemSearchAreaScrollNode.setStyles(this.css.itemSearchAreaScrollNode);
  309. if (this.itemSearchAreaNode) this.itemSearchAreaNode.setStyles(this.css.itemAreaNode);
  310. if (this.selectedScrollNode) this.selectedScrollNode.setStyles(this.css.selectedScrollNode);
  311. if (this.selectedNode) this.selectedNode.setStyles(this.css.selectedNode);
  312. if (this.selectedItemSearchAreaNode) this.selectedItemSearchAreaNode.setStyles(this.css.itemAreaNode);
  313. if (this.actionNode) this.actionNode.setStyles(this.css.actionNode);
  314. if (this.okActionNode) {
  315. this.okActionNode.setStyles(this.css.okActionNode);
  316. this.okActionNode.set("text", MWF.SelectorLP.ok);
  317. }
  318. if (this.cancelActionNode) {
  319. this.cancelActionNode.setStyles(this.css.cancelActionNode);
  320. this.cancelActionNode.set("text", MWF.SelectorLP.cancel);
  321. }
  322. this.loadContent();
  323. if( this.actionNode ){
  324. this.loadAction();
  325. }
  326. this.node.inject( container );
  327. if( !this.options.embedded ){
  328. this.node.setStyles({
  329. "top": "0px",
  330. "left": "0px"
  331. });
  332. }
  333. this.setEvent();
  334. },
  335. getUnitIdentityCount : function(){
  336. },
  337. getUnitSelecteIndentityCount : function( unitLevelName ){ //根据组织获取已选身份数
  338. var count;
  339. this.selectedItems.each( function (item) {
  340. if( item.data.unitLevelName.indexOf( unitLevelName ) === 0 )count++;
  341. }.bind(this));
  342. return count;
  343. },
  344. getGroupNestCount : function(){
  345. // o2.Actions.load("x_organization_assemble_express").
  346. },
  347. getGroupSelecteIndentityCount : function( groupName ){ //根据组织获取已选身份数
  348. var count;
  349. this.selectedItems.each( function (item) {
  350. if( item.data.unitLevelName.indexOf( unitLevelName ) === 0 )count++;
  351. }.bind(this));
  352. return count;
  353. },
  354. setEvent: function(){
  355. if (this.titleActionNode){
  356. this.titleActionNode.addEvent("click", function(){
  357. this.fireEvent("cancel");
  358. this.close();
  359. }.bind(this));
  360. }
  361. if (this.titleCancelActionNode){
  362. this.titleCancelActionNode.addEvent("click", function(){
  363. this.fireEvent("cancel");
  364. this.close();
  365. }.bind(this));
  366. }
  367. if (this.titleOkActionNode){
  368. this.titleOkActionNode.addEvent("click", function(){
  369. this.fireEvent("complete", [this.selectedItems]);
  370. if( this.options.closeOnclickOk !== false )this.close();
  371. }.bind(this));
  372. }
  373. },
  374. close: function(){
  375. this.fireEvent("close");
  376. this.node.destroy();
  377. //if (this.mask) this.mask.hide();
  378. if( !this.options.embedded ){
  379. (this.maskRelativeNode || this.container).unmask();
  380. }
  381. if (this.maskInterval){
  382. window.clearInterval(this.maskInterval);
  383. this.maskInterval = null;
  384. }
  385. this.active = false;
  386. MWF.release(this);
  387. delete this;
  388. },
  389. loadAction: function(){
  390. if( !this.okActionNode ){
  391. this.okActionNode = new Element("button", {
  392. "styles": this.css.okActionNode,
  393. "text": MWF.SelectorLP.ok
  394. }).inject(this.actionNode);
  395. }
  396. if( !this.cancelActionNode ){
  397. this.cancelActionNode = new Element("button", {
  398. "styles": this.css.cancelActionNode,
  399. "text": MWF.SelectorLP.cancel
  400. }).inject(this.actionNode);
  401. }
  402. this.okActionNode.addEvent("click", function(){
  403. this.fireEvent("complete", [this.selectedItems]);
  404. if( this.options.closeOnclickOk !== false )this.close();
  405. }.bind(this));
  406. this.cancelActionNode.addEvent("click", function(){this.fireEvent("cancel"); this.close();}.bind(this));
  407. },
  408. loadContent: function( contentNode, isHTML ){
  409. this.fireEvent("queryLoadContent",[this]);
  410. if( contentNode )this.contentNode = contentNode;
  411. if( this.options.contentUrl || isHTML ){
  412. // if (this.options.count.toInt()!==1){
  413. // this.loadSelectedNodeHTML();
  414. // this.loadSelectNodeHTML(contentNode);
  415. // }else{
  416. // this.setSelectedItem();
  417. // this.loadSelectNodeHTML(contentNode);
  418. // }
  419. this.loadSelectedNodeHTML();
  420. this.loadSelectNodeHTML(contentNode);
  421. }else{
  422. if (layout.mobile){
  423. // if (this.options.count.toInt()!==1) this.loadSelectedNodeMobile();
  424. this.loadSelectedNodeMobile();
  425. this.loadSelectNodeMobile();
  426. }else{
  427. this.loadSelectNode();
  428. if( this.options.hasShuttle ){
  429. this.loadShuttleNode();
  430. }
  431. //if (this.options.count.toInt()!==1) this.loadSelectedNode();
  432. this.loadSelectedNode();
  433. }
  434. }
  435. this.fireEvent("postLoadContent", [this]);
  436. },
  437. getOffsetX : function(node){
  438. return (node.getStyle("margin-left").toInt() || 0 )+
  439. (node.getStyle("margin-right").toInt() || 0 ) +
  440. (node.getStyle("padding-left").toInt() || 0 ) +
  441. (node.getStyle("padding-right").toInt() || 0 ) +
  442. (node.getStyle("border-left-width").toInt() || 0 ) +
  443. (node.getStyle("border-right-width").toInt() || 0 );
  444. },
  445. getOffsetY : function(node){
  446. return (node.getStyle("margin-top").toInt() || 0 ) +
  447. (node.getStyle("margin-bottom").toInt() || 0 ) +
  448. (node.getStyle("padding-top").toInt() || 0 ) +
  449. (node.getStyle("padding-bottom").toInt() || 0 )+
  450. (node.getStyle("border-top-width").toInt() || 0 ) +
  451. (node.getStyle("border-bottom-width").toInt() || 0 );
  452. },
  453. loadSelectNodeHTML: function(contentNode){
  454. var size;
  455. var height;
  456. if( contentNode ){
  457. size = contentNode.getSize();
  458. height = size.y;
  459. if( height === 0 ){
  460. height = contentNode.getStyle("height").toInt();
  461. }
  462. }else{
  463. var container = this.options.injectToBody ? $(document.body) : this.container;
  464. //var containerSize = this.container.getSize();
  465. //var bodySize = $(document.body).getSize();
  466. size = container.getSize();
  467. if(size.y === 0){
  468. size.y = $(document.body).getSize().y
  469. }
  470. //size = {
  471. // "x" : Math.min( containerSize.x, bodySize.x ),
  472. // "y" : Math.min( containerSize.y, bodySize.y )
  473. //};
  474. if(this.node){
  475. var zoom = this.node.getStyle("zoom").toInt() || 0;
  476. if( zoom ){
  477. size.x = size.x * 100 / zoom;
  478. size.y = size.y * 100 / zoom;
  479. }
  480. this.node.setStyles({
  481. "width" : size.x+"px",
  482. "height" : size.y+"px"
  483. })
  484. }
  485. height = size.y-this.getOffsetY( this.contentNode );
  486. if( this.titleNode ){
  487. height = height - this.getOffsetY( this.titleNode ) - ( this.titleNode.getStyle("height").toInt() || 0 )
  488. }
  489. if( this.actionNode ){
  490. height = height - this.getOffsetY( this.actionNode ) - ( this.actionNode.getStyle("height").toInt() || 0 )
  491. }
  492. this.contentNode.setStyle("height", ""+height+"px");
  493. }
  494. var isFormWithAction = window.location.href.toLowerCase().indexOf("workmobilewithaction.html") > -1;
  495. this.selectNode.setStyle("height", ""+height+"px");
  496. if( this.searchInput ){
  497. this.initSearchInput();
  498. height = height - this.getOffsetY( this.searchInputDiv ) - ( this.searchInputDiv.getStyle("height").toInt() || 0 )
  499. }
  500. if( this.options.hasLetter && this.letterAreaNode ){
  501. width = size.x - 18;
  502. this.letterAreaNode.setStyle("width", "" + width + "px");
  503. this.loadLetters();
  504. height = height - this.getOffsetY( this.letterAreaNode ) - ( this.letterAreaNode.getStyle("height").toInt() || 0 )
  505. }
  506. this.itemAreaScrollNode.setStyle("height", ""+height+"px");
  507. this.itemAreaScrollNode.setStyle("overflow", "auto");
  508. if(this.itemSearchAreaScrollNode){
  509. this.itemSearchAreaScrollNode.setStyles({
  510. "display": "none",
  511. "height": ""+height+"px",
  512. "overflow" : "hidden"
  513. });
  514. }
  515. this.itemSearchAreaNode.setStyle("display", "none");
  516. this.initLoadSelectItems();
  517. this.checkLoadSelectItems();
  518. },
  519. loadSelectNodeMobile: function(){
  520. this.selectNode = new Element("div.selectNode", {
  521. "styles": this.css.selectNodeMobile
  522. }).inject(this.contentNode);
  523. var containerSize = this.container.getSize();
  524. var bodySize = $(document.body).getSize();
  525. var size = {
  526. "x" : Math.min( containerSize.x, bodySize.x ),
  527. "y" : Math.min( containerSize.y, bodySize.y )
  528. };
  529. var isFormWithAction = window.location.href.toLowerCase().indexOf("workmobilewithaction.html") > -1;
  530. var height;
  531. if( isFormWithAction ){
  532. height = size.y-40-20-6-20;
  533. }else{
  534. height = size.y;
  535. }
  536. this.selectNode.setStyle("height", ""+height+"px");
  537. this.searchInputDiv = new Element("div.searchInputDiv", {
  538. "styles": this.css.searchInputDiv
  539. }).inject(this.selectNode);
  540. this.searchInput = new Element("input.searchInput", {
  541. "styles": (this.options.count.toInt()===1 || this.options.noSelectedContainer) ? this.css.searchInputSingle : this.css.searchInput,
  542. "type": "text"
  543. }).inject(this.searchInputDiv);
  544. var width = size.x-20-18;
  545. this.searchInput.setStyle("width", ""+width+"px");
  546. this.searchInput.setStyle("height", "20px");
  547. this.initSearchInput();
  548. if( this.options.hasLetter ) {
  549. this.letterAreaNode = new Element("div", {
  550. "styles": this.css.letterAreaMobileNode
  551. }).inject(this.selectNode);
  552. width = size.x - 18;
  553. this.letterAreaNode.setStyle("width", "" + width + "px");
  554. this.loadLetters();
  555. }
  556. this.itemAreaScrollNode = new Element("div.itemAreaScrollNode", {
  557. "styles": this.css.itemAreaScrollNode
  558. }).inject(this.selectNode);
  559. if( isFormWithAction ){
  560. height = size.y-40-20-78-20;
  561. }else{
  562. height = size.y-42-31-40;
  563. }
  564. this.itemAreaScrollNode.setStyle("height", ""+height+"px");
  565. this.itemAreaScrollNode.setStyle("overflow", "auto");
  566. this.itemAreaNode = new Element("div.itemAreaNode", {
  567. "styles": this.css.itemAreaNode
  568. }).inject(this.itemAreaScrollNode);
  569. this.itemSearchAreaNode = new Element("div.itemSearchAreaNode", {
  570. "styles": this.css.itemAreaNode
  571. }).inject(this.itemAreaScrollNode);
  572. this.itemSearchAreaNode.setStyle("display", "none");
  573. //MWF.require("MWF.widget.ScrollBar", function(){
  574. // var _self = this;
  575. // new MWF.widget.ScrollBar(this.itemAreaScrollNode, {
  576. // "style":"xApp_Organization_Explorer",
  577. // "where": "before",
  578. // "distance": 30,
  579. // "friction": 4,
  580. // "axis": {"x": false, "y": true},
  581. // "onScroll": function(y){
  582. // _self._scrollEvent(y);
  583. // }
  584. // });
  585. //}.bind(this));
  586. this.initLoadSelectItems();
  587. this.checkLoadSelectItems();
  588. },
  589. loadSelectedNodeHTML: function(){
  590. this.setSelectedItem();
  591. //MWF.require("MWF.widget.ScrollBar", function(){
  592. // var _self = this;
  593. // new MWF.widget.ScrollBar(this.selectedScrollNode, {
  594. // "style":"xApp_Organization_Explorer", "where": "before", "distance": 100, "friction": 4,"axis": {"x": false, "y": true}
  595. // });
  596. //}.bind(this));
  597. if(this.selectedScrollNode)this.selectedScrollNode.setStyle("display", "none");
  598. },
  599. checkLoadSelectItems: function(){
  600. if (!this.options.groups.length && !this.options.roles.length){
  601. this.loadSelectItems();
  602. }else{
  603. this.loadSelectItemsByCondition();
  604. }
  605. },
  606. loadShuttleNode : function(){
  607. if(this.shuttleNode)return;
  608. this.shuttleNode = new Element("div.shuttleNode", {
  609. "styles": this.css.shuttleNode
  610. }).inject(this.contentNode);
  611. this.shuttleInnerNode = new Element("div.shuttleInnerNode", {
  612. "styles": this.css.shuttleInnerNode
  613. }).inject(this.shuttleNode);
  614. this.goRightNode = new Element("div.goRightNode", {
  615. "styles": this.css.goRightNode
  616. }).inject(this.shuttleInnerNode);
  617. this.goLeftNode = new Element("div.goLeftNode", {
  618. "styles": this.css.goLeftNode
  619. }).inject(this.shuttleInnerNode);
  620. },
  621. loadSelectNode: function(){
  622. this.selectNode = new Element("div.selectNode", {
  623. "styles": this.css.selectNode //(this.options.count.toInt()===1) ? this.css.selectNodeSingle : this.css.selectNode
  624. }).inject(this.contentNode);
  625. if( this.options.hasTop ){ //if( this.options.embedded && this.options.count.toInt()!==1 ){
  626. this.selectTopNode = new Element("div.selectTopNode",{
  627. "styles" : this.css.selectTopNode
  628. }).inject( this.selectNode );
  629. this.selectTopTextNode = new Element("div",{
  630. "text" : MWF.SelectorLP.waitingSelect,
  631. "styles" : this.css.selectTopTextNode
  632. }).inject( this.selectTopNode );
  633. }
  634. if( this.options.searchbarInTopNode ){
  635. this.searchInputDiv = new Element("div", {
  636. "styles": this.css.searchInputDiv
  637. }).inject( this.selectTopNode || this.selectNode);
  638. }else{
  639. this.searchInputDiv = new Element("div.searchInputDiv", {
  640. "styles": this.css.searchInputDiv
  641. }).inject( this.selectNode);
  642. }
  643. this.searchInput = new Element("input", {
  644. "styles": this.css.searchInput, //(this.options.count.toInt()===1) ? this.css.searchInputSingle : this.css.searchInput,
  645. "placeholder" : MWF.SelectorLP.searchDescription,
  646. "type": "text"
  647. }).inject(this.searchInputDiv);
  648. this.initSearchInput();
  649. if( this.options.hasLetter ){
  650. this.letterAreaNode = new Element("div", {
  651. "styles": this.css.letterAreaNode
  652. }).inject(this.selectNode);
  653. this.loadLetters();
  654. }
  655. this.itemAreaScrollNode = new Element("div", {
  656. "styles": this.css.itemAreaScrollNode
  657. }).inject(this.selectNode);
  658. this.itemAreaNode = new Element("div", {
  659. "styles": this.css.itemAreaNode
  660. }).inject(this.itemAreaScrollNode);
  661. this.itemSearchAreaNode = new Element("div", {
  662. "styles": this.css.itemAreaNode
  663. }).inject(this.itemAreaScrollNode);
  664. this.itemSearchAreaNode.setStyle("display", "none");
  665. this.loadSelectNodeScroll();
  666. this.initLoadSelectItems();
  667. this.checkLoadSelectItems();
  668. },
  669. loadSelectNodeScroll: function(){
  670. var overflowY = this.itemAreaScrollNode.getStyle("overflow-y");
  671. if( typeOf(overflowY)==="string" && (overflowY.toLowerCase() === "auto" || overflowY.toLowerCase() === "scroll") )return;
  672. MWF.require("MWF.widget.ScrollBar", function(){
  673. var _self = this;
  674. new MWF.widget.ScrollBar(this.itemAreaScrollNode, {
  675. "style":"xApp_Organization_Explorer",
  676. "where": "before",
  677. "distance": 30,
  678. "friction": 4,
  679. "axis": {"x": false, "y": true},
  680. "onScroll": function(y){
  681. _self._scrollEvent(y);
  682. }
  683. });
  684. }.bind(this));
  685. },
  686. initSearchInput: function(){
  687. this.searchInput.addEvents({
  688. "keydown": function(e){
  689. var iTimerID = this.searchInput.retrieve("searchTimer", null);
  690. if (iTimerID){
  691. window.clearTimeout(iTimerID);
  692. this.searchInput.eliminate("searchTimer");
  693. }
  694. iTimerID = window.setTimeout(function(){
  695. this.search();
  696. }.bind(this), 800);
  697. this.searchInput.store("searchTimer", iTimerID);
  698. }.bind(this),
  699. "change": function(e){
  700. var key = this.searchInput.get("value");
  701. if (!key) this.initSearchArea(false);
  702. }.bind(this),
  703. "blur": function(){
  704. var key = this.searchInput.get("value");
  705. if (!key) this.initSearchArea(false);
  706. }.bind(this)
  707. });
  708. },
  709. initSearchArea: function(flag){
  710. this.searchItems = [];
  711. if (flag){
  712. this.itemSearchAreaNode.empty();
  713. this.itemAreaNode.setStyle("display", "none");
  714. if( this.itemSearchAreaNode.getParent() !== this.itemAreaScrollNode ){
  715. this.itemAreaScrollNode.setStyle("display", "none");
  716. }
  717. if(this.flatCategoryScrollNode){
  718. this.flatCategoryScrollNode.setStyle("display", "none");
  719. }
  720. if( this.itemSearchAreaScrollNode )this.itemSearchAreaScrollNode.setStyle("display", "block");
  721. this.itemSearchAreaNode.setStyle("display", "block");
  722. }else{
  723. this.itemAreaScrollNode.setStyle("display", "block");
  724. this.itemAreaNode.setStyle("display", "block");
  725. if(this.flatCategoryScrollNode && this.flatSubCategoryNodeList && this.flatSubCategoryNodeList.length > 1 ){
  726. this.flatCategoryScrollNode.setStyle("display", "block");
  727. }
  728. if( this.itemSearchAreaScrollNode )this.itemSearchAreaScrollNode.setStyle("display", "none");
  729. this.itemSearchAreaNode.setStyle("display", "none");
  730. }
  731. },
  732. search: function(){
  733. if (!this.options.groups.length && !this.options.roles.length && !this.options.forceSearchInItem ){
  734. var key = this.searchInput.get("value");
  735. if (key){
  736. this._listItemByKey(function(json){
  737. this.initSearchArea(true);
  738. json.data.each(function(data){
  739. if( !this.isExcluded( data ) ) {
  740. var itemSearch = this._newItemSearch(data, this, this.itemSearchAreaNode);
  741. this.searchItems.push( itemSearch );
  742. }
  743. //this._newItem(data, this, this.itemSearchAreaNode);
  744. }.bind(this));
  745. }.bind(this), null, key);
  746. }else{
  747. this.initSearchArea(false);
  748. }
  749. }else{
  750. var key = this.searchInput.get("value");
  751. if (key){
  752. this.initSearchArea(true);
  753. this.searchInItems(key);
  754. }else{
  755. this.initSearchArea(false);
  756. }
  757. }
  758. },
  759. searchInItems: function(key){
  760. var createdId = [];
  761. this.createItemsSearchData(function(){
  762. var word = key.toLowerCase();
  763. this.itemsSearchData.each(function(obj){
  764. var text = obj.text+"#"+obj.pinyin+"#"+obj.firstPY;
  765. var id = obj.data.distinguishedName || obj.data.id || obj.data.name || obj.data.text;
  766. if (text.indexOf(word)!==-1){
  767. if (createdId.indexOf( id )===-1){
  768. this._newItem(obj.data, this, this.itemSearchAreaNode);
  769. createdId.push( id );
  770. }
  771. }
  772. }.bind(this));
  773. //delete createdId;
  774. }.bind(this));
  775. return createdId;
  776. },
  777. createItemsSearchData: function(callback){
  778. if (!this.itemsSearchData){
  779. this.itemsSearchData = [];
  780. MWF.require("MWF.widget.PinYin", function(){
  781. var initIds = [];
  782. this.items.each(function(item){
  783. var id = item.data.distinguishedName || item.data.id || item.data.name || item.data.text;
  784. if (initIds.indexOf( id )==-1){
  785. var text = item._getShowName().toLowerCase();
  786. var pinyin = text.toPY().toLowerCase();
  787. var firstPY = text.toPYFirst().toLowerCase();
  788. this.itemsSearchData.push({
  789. "text": text,
  790. "pinyin": pinyin,
  791. "firstPY": firstPY,
  792. "data": item.data
  793. });
  794. initIds.push( id );
  795. }
  796. }.bind(this));
  797. delete initIds;
  798. if (callback) callback();
  799. }.bind(this));
  800. }else{
  801. if (callback) callback();
  802. }
  803. },
  804. initSelectedSearchInput: function(){
  805. this.selectedSearchInput.addEvents({
  806. "keydown": function(e){
  807. var iTimerID = this.selectedSearchInput.retrieve("searchTimer", null);
  808. if (iTimerID){
  809. window.clearTimeout(iTimerID);
  810. this.selectedSearchInput.eliminate("searchTimer");
  811. }
  812. iTimerID = window.setTimeout(function(){
  813. this.selectedSearch();
  814. }.bind(this), 800);
  815. this.selectedSearchInput.store("searchTimer", iTimerID);
  816. }.bind(this),
  817. "change": function(e){
  818. var key = this.selectedSearchInput.get("value");
  819. if (!key) this.selectedSearch();
  820. }.bind(this),
  821. "blur": function(){
  822. var key = this.selectedSearchInput.get("value");
  823. if (!key) this.selectedSearch();
  824. }.bind(this)
  825. });
  826. },
  827. selectedSearch: function(){
  828. var key = this.selectedSearchInput.get("value");
  829. if (key){
  830. this.selectedSearchInItems(key);
  831. }else{
  832. this.showAllSelectedItem()
  833. }
  834. },
  835. selectedSearchInItems: function(key){
  836. var word = key.toLowerCase();
  837. MWF.require("MWF.widget.PinYin", function() {
  838. this.selectedItems.each(function (item) {
  839. if (!item.searchedText) {
  840. var text = item._getShowName().toLowerCase();
  841. var pinyin = text.toPY().toLowerCase();
  842. var firstPY = text.toPYFirst().toLowerCase();
  843. item.searchedText = text + "#" + pinyin + "#" + firstPY
  844. }
  845. if (item.searchedText.indexOf(word) !== -1) {
  846. item.node.show()
  847. } else {
  848. item.node.hide()
  849. }
  850. }.bind(this));
  851. }.bind(this), null, false);
  852. },
  853. showAllSelectedItem: function(){
  854. this.selectedItems.each(function(item){
  855. item.node.show()
  856. })
  857. },
  858. loadSelectedNode: function( callback ){
  859. if( this.selectedContainerNode )return;
  860. this.selectedContainerNode = new Element("div", {
  861. "styles": this.css.selectedContainerNode
  862. }).inject(this.contentNode);
  863. if( this.options.noSelectedContainer ){
  864. this.selectedContainerNode.hide();
  865. }
  866. //if( this.options.embedded && this.options.count.toInt()!==1 ){
  867. if( this.options.hasTop ){
  868. this.selectedTopNode = new Element("div",{
  869. "styles" : this.css.selectedTopNode
  870. }).inject( this.selectedContainerNode );
  871. this.selectedTopTextNode = new Element("div",{
  872. "text" : MWF.SelectorLP.selected,
  873. "styles" : this.css.selectedTopTextNode
  874. }).inject( this.selectedTopNode );
  875. this.emptySelectedNode = new Element("div",{
  876. "text" : MWF.SelectorLP.empty,
  877. "styles" : this.css.selectedTopActionNode,
  878. "events" : {
  879. "click" : function(){
  880. this.emptySelectedItems()
  881. }.bind(this)
  882. }
  883. }).inject( this.selectedTopNode );
  884. }
  885. if( this.options.hasSelectedSearchbar ){
  886. if( this.options.searchbarInTopNode ){
  887. this.selectedSearchInputDiv = new Element("div", {
  888. "styles": this.css.searchInputDiv
  889. }).inject( this.selectedTopNode || this.selectedContainerNode);
  890. }else{
  891. this.selectedSearchInputDiv = new Element("div.selectedSearchInputDiv", {
  892. "styles": this.css.searchInputDiv
  893. }).inject( this.selectedContainerNode);
  894. }
  895. this.selectedSearchInput = new Element("input", {
  896. "styles": this.css.searchInput, //(this.options.count.toInt()===1) ? this.css.searchInputSingle : this.css.searchInput,
  897. "placeholder" : MWF.SelectorLP.searchDescription,
  898. "type": "text"
  899. }).inject(this.selectedSearchInputDiv);
  900. this.initSelectedSearchInput();
  901. }
  902. this.selectedScrollNode = new Element("div.selectedScrollNode", {
  903. "styles": this.css.selectedScrollNode
  904. }).inject(this.selectedContainerNode);
  905. this.selectedNode = new Element("div.selectedNode", {
  906. "styles": this.css.selectedNode
  907. }).inject(this.selectedScrollNode);
  908. if( this.options.hasSelectedSearchbar ){
  909. this.selectedItemSearchAreaNode = new Element("div.selectedItemSearchAreaNode", {
  910. "styles": this.css.itemAreaNode
  911. }).inject(this.selectedScrollNode);
  912. this.selectedItemSearchAreaNode.setStyle("display", "none");
  913. }
  914. this.setSelectedItem();
  915. this.loadSelectedNodeScroll();
  916. if(callback)callback();
  917. },
  918. emptySelectedItems : function(){
  919. while (this.selectedItems.length){
  920. this.selectedItems[0].clickItem();
  921. }
  922. },
  923. loadSelectedNodeScroll: function(){
  924. var overflowY = this.selectedScrollNode.getStyle("overflow-y");
  925. if( typeOf(overflowY)==="string" && (overflowY.toLowerCase() === "auto" || overflowY.toLowerCase() === "scroll") )return;
  926. MWF.require("MWF.widget.ScrollBar", function(){
  927. var _self = this;
  928. new MWF.widget.ScrollBar(this.selectedScrollNode, {
  929. "style":"xApp_Organization_Explorer", "where": "before", "distance": 100, "friction": 4,"axis": {"x": false, "y": true}
  930. });
  931. }.bind(this));
  932. },
  933. loadSelectedNodeMobile: function(){
  934. this.selectedScrollNode = new Element("div.selectedScrollNode", {
  935. "styles": this.css.selectedScrollNode
  936. }).inject(this.contentNode);
  937. this.selectedNode = new Element("div.selectedNode", {
  938. "styles": this.css.selectedNode
  939. }).inject(this.selectedScrollNode);
  940. this.setSelectedItem();
  941. // MWF.require("MWF.widget.ScrollBar", function(){
  942. // var _self = this;
  943. // new MWF.widget.ScrollBar(this.selectedScrollNode, {
  944. // "style":"xApp_Organization_Explorer", "where": "before", "distance": 100, "friction": 4,"axis": {"x": false, "y": true}
  945. // });
  946. // }.bind(this));
  947. this.selectedScrollNode.setStyle("display", "none");
  948. },
  949. setSelectedItem: function(){
  950. if (this.options.values.length){
  951. this.options.values.each(function(v, i){
  952. if (typeOf(v)==="object"){
  953. this.selectedItems.push(this._newItemSelected(v, this, null));
  954. }else{
  955. this._getItem(function(json){
  956. this.options.values[i] = json.data;
  957. this.selectedItems.push(this._newItemSelected(json.data, this, null));
  958. }.bind(this), null, v, false);
  959. }
  960. // this._getItem(function(json){
  961. // this.selectedItems.push(this._newItemSelected(json.data, this, null));
  962. // }.bind(this), null, v, false);
  963. }.bind(this));
  964. }
  965. },
  966. loadLetters: function(){
  967. var _self = this;
  968. letters = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
  969. var letterNodeCss = this.css.letterNode;
  970. var letterNodeCss_over = this.css.letterNode_over;
  971. if (layout.mobile){
  972. letterNodeCss = this.css.letterNode_mobile || letterNodeCss;
  973. letterNodeCss_over = this.css.letterNode_mobile_over || letterNodeCss_over;
  974. var size = this.container.getSize();
  975. var w = (layout.mobile) ? (size.x-18)/13 : (size.x-20-4-18)/13;
  976. //letterNode.setStyle("width", ""+w+"px");
  977. letterNodeCss.width = ""+w+"px";
  978. letterNodeCss_over.width = ""+w+"px";
  979. }
  980. letters.each(function(l){
  981. var letterNode = new Element("div", {
  982. "styles": letterNodeCss,
  983. "text": l
  984. }).inject(this.letterAreaNode);
  985. if (layout.mobile){
  986. letterNode.addEvents({
  987. "click": function(){
  988. _self.listPersonByPinyin(this);
  989. }
  990. });
  991. }else{
  992. letterNode.addEvents({
  993. "mouseover": function(e){
  994. e.target.setStyles(letterNodeCss_over);
  995. var showNode = new Element("div", {
  996. "styles": this.css.letterShowNode,
  997. "text": e.target.get("text")
  998. }).inject(this.selectNode);
  999. showNode.position({
  1000. relativeTo: this.itemAreaScrollNode,
  1001. position: "center",
  1002. edge: "center"
  1003. });
  1004. e.target.store("showNode", showNode);
  1005. }.bind(this),
  1006. "mouseout": function(e){
  1007. var showNode = e.target.retrieve("showNode");
  1008. showNode.destroy();
  1009. e.target.setStyles(letterNodeCss);
  1010. }.bind(this),
  1011. "click": function(){
  1012. _self.listPersonByPinyin(this);
  1013. }
  1014. });
  1015. }
  1016. }.bind(this));
  1017. },
  1018. listPersonByPinyin: function(node){
  1019. this.searchInput.focus();
  1020. var pinyin = this.searchInput.get("value");
  1021. pinyin = pinyin+node.get("text");
  1022. this.searchInput.set("value", pinyin);
  1023. if (!this.options.groups.length && !this.options.roles.length){
  1024. if (pinyin){
  1025. this._listItemByPinyin(function(json){
  1026. this.initSearchArea(true);
  1027. json.data.each(function(data){
  1028. // var flag = true;
  1029. // if (this.options.departments){
  1030. // if (this.options.departments.length){
  1031. // if (this.options.departments.indexOf(data.departmentName)==-1) flag = false;
  1032. // }
  1033. // }
  1034. // if (this.options.companys){
  1035. // if (this.options.companys.length){
  1036. // if (this.options.companys.indexOf(data.company)==-1) flag = false;
  1037. // }
  1038. // }
  1039. if( !this.isExcluded( data ) ) {
  1040. this._newItemSearch(data, this, this.itemSearchAreaNode);
  1041. }
  1042. //this._newItem(data, this, this.itemSearchAreaNode);
  1043. //this._newItem(data, this, this.itemSearchAreaNode);
  1044. }.bind(this));
  1045. }.bind(this), null, pinyin.toLowerCase());
  1046. }
  1047. }else{
  1048. if (pinyin){
  1049. this.initSearchArea(true);
  1050. this.searchInItems(pinyin);
  1051. }else{
  1052. this.initSearchArea(false);
  1053. }
  1054. }
  1055. },
  1056. initLoadSelectItems: function(){
  1057. this.loaddingItems = false;
  1058. this.isItemLoaded = false;
  1059. this.loadItemsQueue = 0;
  1060. this.initSearchArea(false);
  1061. },
  1062. //loadSelectItems: function(addToNext){
  1063. // if (!this.isItemLoaded){
  1064. // if (!this.loaddingItems){
  1065. // this.loaddingItems = true;
  1066. // var count = 20;
  1067. // this._listItemNext(this.getLastLoadedItemId(), count, function(json){
  1068. // if (json.data.length){
  1069. // json.data.each(function(data){
  1070. // var item = this._newItem(data, this, this.itemAreaNode);
  1071. // this.items.push(item);
  1072. // }.bind(this));
  1073. // this.loaddingItems = false;
  1074. //
  1075. // if (json.data.length<count){
  1076. // this.isItemLoaded = true;
  1077. // }else{
  1078. // if (this.loadItemsQueue>0){
  1079. // this.loadItemsQueue--;
  1080. // this.loadSelectItems();
  1081. // }
  1082. // }
  1083. // }else{
  1084. // this.isItemLoaded = true;
  1085. // this.loaddingItems = false;
  1086. // }
  1087. // }.bind(this));
  1088. // }else{
  1089. // if (addToNext) this.loadItemsQueue++;
  1090. // }
  1091. // }
  1092. //},
  1093. loadSelectItems: function(addToNext, lastExcludeCount ){
  1094. //lastExcludeCount 参数:表示本次加载是为了补足上次load的时候被排除的数量
  1095. if (!this.isItemLoaded){
  1096. if (!this.loaddingItems){
  1097. this.loaddingItems = true;
  1098. var count = 20;
  1099. this._listItemNext(this.getLastLoadedItemId(), count, function(json){
  1100. if (json.data.length){
  1101. var excludedCount = 0;
  1102. json.data.each(function(data, i){
  1103. if( this.isExcluded( data ) ){
  1104. excludedCount++;
  1105. if( i+1 === count )this.tailExcludeItemId = data.distinguishedName
  1106. }else{
  1107. var item = this._newItem(data, this, this.itemAreaNode);
  1108. this.items.push(item);
  1109. if( i+1 === count )this.tailExcludeItemId = null;
  1110. }
  1111. }.bind(this));
  1112. this.loaddingItems = false;
  1113. if( lastExcludeCount ){ //如果是因为上次load的时候被排除而加载的
  1114. if( count - lastExcludeCount - excludedCount < 0 ){ //如果本次load的数量还不够补足排除的数量,需要再次load
  1115. excludedCount = lastExcludeCount + excludedCount - count; //把不足的数量作为再次load的参数
  1116. this.loadItemsQueue++
  1117. }
  1118. }else if( excludedCount > 0 ){ //把排除的数量作为再次load的参数
  1119. this.loadItemsQueue++
  1120. }
  1121. if (json.data.length<count){
  1122. this.isItemLoaded = true;
  1123. }else{
  1124. if (this.loadItemsQueue>0){
  1125. this.loadItemsQueue--;
  1126. this.loadSelectItems( addToNext, excludedCount );
  1127. }
  1128. }
  1129. }else{
  1130. this.isItemLoaded = true;
  1131. this.loaddingItems = false;
  1132. }
  1133. if( this.afterLoadSelectItem )this.afterLoadSelectItem();
  1134. }.bind(this));
  1135. }else{
  1136. if (addToNext) this.loadItemsQueue++;
  1137. }
  1138. }
  1139. },
  1140. getLastLoadedItemId: function(){
  1141. if( this.tailExcludeItemId )return this.tailExcludeItemId;
  1142. return (this.items.length) ? this.items[this.items.length-1].data.distinguishedName : "(0)";
  1143. },
  1144. //loadSelectItemsByCondition: function(){
  1145. // this.options.groups.each(function(group){
  1146. //
  1147. // this.orgAction.listGroupByKey(function(json){
  1148. // if (json.data.length){
  1149. // var groupData = json.data[0];
  1150. // var category = this._newItemCategory("ItemGroupCategory", groupData, this, this.itemAreaNode);
  1151. // this._getChildrenItemIds(groupData).each(function(id){
  1152. // this._getItem(function(json){
  1153. // var item = this._newItem(json.data, this, category.children);
  1154. // this.items.push(item);
  1155. // }.bind(this), null, id);
  1156. // }.bind(this));
  1157. // }
  1158. // }.bind(this), null, group);
  1159. // }.bind(this));
  1160. //
  1161. // this.options.roles.each(function(role){
  1162. // this.orgAction.listRoleByKey(function(json){
  1163. // if (json.data.length){
  1164. // var roleData = json.data[0];
  1165. // var category = this._newItemCategory("ItemRoleCategory", roleData, this, this.itemAreaNode);
  1166. // this._getChildrenItemIds(roleData).each(function(id){
  1167. // this._getItem(function(json){
  1168. // var item = this._newItem(json.data, this, category.children);
  1169. // this.items.push(item);
  1170. // }.bind(this), null, id)
  1171. // }.bind(this));
  1172. // }
  1173. // }.bind(this), null, role);
  1174. // }.bind(this));
  1175. //},
  1176. loadSelectItemsByCondition: function(){
  1177. this.options.groups.each(function(group){
  1178. this.orgAction.listGroupByKey(function(json){
  1179. if (json.data.length){
  1180. var groupData = json.data[0];
  1181. var category = this._newItemCategory("ItemGroupCategory", groupData, this, this.itemAreaNode);
  1182. this.subCategorys.push(category);
  1183. this._getChildrenItemIds(groupData).each(function(id){
  1184. this._getItem(function(json){
  1185. if( !this.isExcluded( json.data ) ) {
  1186. var item = this._newItem(json.data, this, category.children);
  1187. this.items.push(item);
  1188. }
  1189. }.bind(this), null, id);
  1190. }.bind(this));
  1191. }
  1192. }.bind(this), null, group);
  1193. }.bind(this));
  1194. this.options.roles.each(function(role){
  1195. this.orgAction.listRoleByKey(function(json){
  1196. if (json.data.length){
  1197. var roleData = json.data[0];
  1198. var category = this._newItemCategory("ItemRoleCategory", roleData, this, this.itemAreaNode);
  1199. this.subCategorys.push(category);
  1200. this._getChildrenItemIds(roleData).each(function(id){
  1201. this._getItem(function(json){
  1202. if( !this.isExcluded( json.data ) ) {
  1203. var item = this._newItem(json.data, this, category.children);
  1204. this.items.push(item);
  1205. }
  1206. }.bind(this), null, id)
  1207. }.bind(this));
  1208. }
  1209. }.bind(this), null, role);
  1210. }.bind(this));
  1211. },
  1212. isExcluded : function( d ){
  1213. if( this.options.exclude.length === 0 )return false;
  1214. if( !this.excludeFlagMap ){
  1215. this.excludeFlagMap = {};
  1216. this.options.exclude.each( function( e ){
  1217. if( !e )return;
  1218. this.excludeFlagMap[ typeOf( e ) === "string" ? e : ( e.distinguishedName || e.id || e.unique || e.employee || e.levelName) ] = true;
  1219. }.bind(this));
  1220. }
  1221. var map = this.excludeFlagMap;
  1222. return ( d.distinguishedName && map[ d.distinguishedName ] ) ||
  1223. ( d.id && map[ d.id ] ) ||
  1224. ( d.unique && map[ d.unique ] ) ||
  1225. ( d.employee && map[ d.employee ] ) ||
  1226. ( d.levelName && map[ d.levelName ] );
  1227. },
  1228. _getChildrenItemIds: function(data){
  1229. return data.personList;
  1230. },
  1231. _newItemCategory: function(type, data, selector, item){
  1232. return new MWF.xApplication.Selector.Person[type](data, selector, item)
  1233. },
  1234. _listItemByKey: function(callback, failure, key){
  1235. this.orgAction.listPersonByKey(function(json){
  1236. if (callback) callback.apply(this, [json]);
  1237. }.bind(this), failure, key);
  1238. },
  1239. _getItem: function(callback, failure, id, async){
  1240. this.orgAction.getPerson(function(json){
  1241. if (callback) callback.apply(this, [json]);
  1242. }.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
  1243. },
  1244. _newItemSelected: function(data, selector, item, selectedNode){
  1245. return new MWF.xApplication.Selector.Person.ItemSelected(data, selector, item, selectedNode)
  1246. },
  1247. _listItemByPinyin: function(callback, failure, key){
  1248. this.orgAction.listPersonByPinyin(function(json){
  1249. if (callback) callback.apply(this, [json]);
  1250. }.bind(this), failure, key);
  1251. },
  1252. _newItem: function(data, selector, container){
  1253. return new MWF.xApplication.Selector.Person.Item(data, selector, container);
  1254. },
  1255. _newItemSearch: function(data, selector, container){
  1256. return this._newItem(data, selector, container);
  1257. },
  1258. _listItemNext: function(last, count, callback){
  1259. this.orgAction.listPersonNext(last, count, function(json){
  1260. if (callback) callback.apply(this, [json]);
  1261. }.bind(this));
  1262. },
  1263. _scrollEvent: function(y){
  1264. if (!this.options.groups.length && !this.options.roles.length){
  1265. var scrollSize = this.itemAreaScrollNode.getScrollSize();
  1266. var clientSize = this.itemAreaScrollNode.getSize();
  1267. var scrollHeight = scrollSize.y-clientSize.y;
  1268. if (y+30>scrollHeight) {
  1269. if (!this.isItemLoaded) this.loadSelectItems();
  1270. }
  1271. }
  1272. },
  1273. afterLoadSelectItem : function(){
  1274. if( this.items.length === 0 && this.subItems.length === 0 && this.subCategorys.length === 0 ){
  1275. this.noSelectableItemTextDiv = new Element("div", {
  1276. text : MWF.SelectorLP.noSelectableItemText,
  1277. styles : this.css.noSelectableItemText
  1278. }).inject( this.itemAreaNode );
  1279. }
  1280. if( this.options.selectSingleItem ){
  1281. this.selectSingleItem()
  1282. }
  1283. this.fireEvent("afterLoadSelectItem", [this]);
  1284. },
  1285. selectSingleItem: function(){
  1286. if( !this.options.contentUrl && !layout.mobile){
  1287. if( this.options.hasShuttle && !this.shuttleNode ){
  1288. this.loadShuttleNode();
  1289. }
  1290. if( !this.selectedContainerNode ) {
  1291. this.loadSelectedNode(function () {
  1292. this._selectSingleItem();
  1293. }.bind(this));
  1294. }else{
  1295. this._selectSingleItem();
  1296. }
  1297. }else{
  1298. this._selectSingleItem();
  1299. }
  1300. },
  1301. _selectSingleItem : function(){
  1302. var checkItem = function () {
  1303. if(this.items.length === 1 || this.subItems.length === 1 ){
  1304. if( this.items.length === 1 && this.subItems.length === 0 ){
  1305. if( !this.items[0].isSelected )this.items[0].clickItem();
  1306. }else if( this.items.length === 0 && this.subItems.length === 1 ){
  1307. if( !this.items[0].isSelected )this.subItems[0].clickItem();
  1308. }else if( this.items.length === 1 && this.subItems.length === 1 ){
  1309. if( this.items[0] === this.subItems[0] ){
  1310. if( !this.items[0].isSelected )this.items[0].clickItem();
  1311. }
  1312. }
  1313. }
  1314. }.bind(this);
  1315. var checkCategoryItem = function (category) {
  1316. if( !category.subCategorys || category.subCategorys.length === 0 ){
  1317. if( category.subItems && category.subItems.length === 1 ){
  1318. if( !category.subItems[0].isSelected )category.subItems[0].clickItem();
  1319. }
  1320. }else if(category.subCategorys.length === 1){
  1321. if( !category.subCategorys[0]._hasChild || !category.subCategorys[0]._hasChild() ){ //category.subCategorys[0].isItem &&
  1322. if( !category.subItems[0].isSelected )category.subItems[0].clickItem();
  1323. }else{
  1324. checkCategory( category.subCategorys[0] )
  1325. }
  1326. }else{
  1327. var list = [];
  1328. for( var i=0; i<category.subCategorys.length; i++ ){
  1329. if( category.subCategorys[i]._hasChild && category.subCategorys[i]._hasChild() ){
  1330. list.push( category.subCategorys[i] );
  1331. }
  1332. }
  1333. if( list.length === 1 ){
  1334. if( !category.subItems || category.subItems.length === 0 ){
  1335. checkCategory( list[0] );
  1336. }
  1337. }
  1338. if( list.length === 0 ){
  1339. if( category.subItems && category.subItems.length === 1 ){
  1340. if( !category.subItems[0].isSelected )category.subItems[0].clickItem();
  1341. }
  1342. }
  1343. }
  1344. };
  1345. var checkCategory = function ( category ) {
  1346. if( category.loaded ){
  1347. checkCategoryItem( category )
  1348. }else if( category.loading ){
  1349. window.setTimeout( function () {
  1350. checkCategory( category )
  1351. }, 100 )
  1352. }
  1353. };
  1354. if( this.subCategorys.length === 1 ) {
  1355. checkCategory( this.subCategorys[0] );
  1356. }else if( this.subCategorys.length === 0 ){
  1357. checkItem();
  1358. }
  1359. },
  1360. setSize : function(){
  1361. if( !this.options.width && !this.options.height )return;
  1362. var getOffsetX = function(node){
  1363. return (node.getStyle("margin-left").toInt() || 0 )+
  1364. (node.getStyle("margin-right").toInt() || 0 ) +
  1365. (node.getStyle("padding-left").toInt() || 0 ) +
  1366. (node.getStyle("padding-right").toInt() || 0 ) +
  1367. (node.getStyle("border-left-width").toInt() || 0 ) +
  1368. (node.getStyle("border-right-width").toInt() || 0 );
  1369. };
  1370. var getOffsetY = function(node){
  1371. return (node.getStyle("margin-top").toInt() || 0 ) +
  1372. (node.getStyle("margin-bottom").toInt() || 0 ) +
  1373. (node.getStyle("padding-top").toInt() || 0 ) +
  1374. (node.getStyle("padding-bottom").toInt() || 0 )+
  1375. (node.getStyle("border-top-width").toInt() || 0 ) +
  1376. (node.getStyle("border-bottom-width").toInt() || 0 );
  1377. };
  1378. if( this.options.width && this.options.width === "auto" ){
  1379. //if (this.options.count.toInt() !== 1){
  1380. if( this.node )this.node.setStyle("width", "auto");
  1381. this.selectNode.setStyles({
  1382. "width": "50%",
  1383. "float" : "left"
  1384. });
  1385. //this.searchInput.setStyle("width", "99%");
  1386. if(this.letterAreaNode ){
  1387. this.letterAreaNode.setStyle("width", "auto");
  1388. }
  1389. this.selectedContainerNode.setStyle("width", "auto");
  1390. var overflowY = this.selectedScrollNode.getStyle("overflow-y");
  1391. if( typeOf(overflowY)==="string" && (overflowY.toLowerCase() === "auto" || overflowY.toLowerCase() === "scroll") ){
  1392. this.selectedScrollNode.setStyle("width", "auto");
  1393. }else{
  1394. this.selectedScrollNode.setStyle("margin-right", "8px");
  1395. }
  1396. //}else{
  1397. // this.node.setStyle("width", "auto");
  1398. // this.selectNode.setStyle("width", "auto");
  1399. //}
  1400. }else if( this.options.width && typeOf( this.options.width.toInt() ) === "number" ){
  1401. var nodeWidth;
  1402. if( this.node ){
  1403. nodeWidth = this.options.width.toInt() - getOffsetX(this.node);
  1404. this.node.setStyle("width", nodeWidth);
  1405. }else{
  1406. nodeWidth = this.options.width.toInt();
  1407. }
  1408. nodeWidth = nodeWidth - getOffsetX( this.contentNode );
  1409. if( this.shuttleNode ){
  1410. nodeWidth = nodeWidth - getOffsetX(this.shuttleNode) - this.shuttleNode.getStyle("width").toInt();
  1411. }
  1412. //if (this.options.count.toInt() !== 1){
  1413. var width = nodeWidth - getOffsetX(this.selectNode) - getOffsetX(this.selectedContainerNode);
  1414. var halfWidth = this.options.noSelectedContainer ? width : Math.floor(width / 2);
  1415. this.selectNode.setStyle("width", halfWidth);
  1416. //this.searchInput.setStyle("width", halfWidth - 6);
  1417. if(this.letterAreaNode ){
  1418. this.letterAreaNode.setStyle("width", halfWidth - 19);
  1419. }
  1420. this.selectedContainerNode.setStyle("width", halfWidth);
  1421. var overflowY = this.selectedScrollNode.getStyle("overflow-y");
  1422. if( typeOf(overflowY)==="string" && (overflowY.toLowerCase() === "auto" || overflowY.toLowerCase() === "scroll") ){
  1423. this.selectedScrollNode.setStyle("width", halfWidth);
  1424. }else{
  1425. this.selectedScrollNode.setStyle("width", halfWidth - 8);
  1426. }
  1427. //}else{
  1428. // var width = nodeWidth - getOffsetX(this.selectNode);
  1429. // this.selectNode.setStyle("width", width);
  1430. //}
  1431. }
  1432. if( this.options.height && typeOf( this.options.height.toInt() ) === "number" ){
  1433. var nodeHeight;
  1434. if( this.node ){
  1435. nodeHeight = this.options.height.toInt() - getOffsetY(this.node);
  1436. this.node.setStyle("height", nodeHeight);
  1437. }else{
  1438. nodeHeight = this.options.height.toInt();
  1439. }
  1440. nodeHeight = nodeHeight - getOffsetY( this.contentNode );
  1441. if( this.titleNode ){
  1442. nodeHeight = nodeHeight - getOffsetY( this.titleNode ) - this.titleNode.getStyle("height").toInt();
  1443. }
  1444. if( this.actionNode ){
  1445. nodeHeight = nodeHeight - getOffsetY( this.actionNode ) - this.actionNode.getStyle("height").toInt();
  1446. }
  1447. var selectNodeHeight = nodeHeight - getOffsetY(this.selectNode);
  1448. this.selectNode.setStyle("height", selectNodeHeight);
  1449. if( this.shuttleNode ){
  1450. this.shuttleNode.setStyle("height", selectNodeHeight);
  1451. var shuttleInnerHieght = getOffsetY( this.shuttleInnerNode ) + this.shuttleInnerNode.getStyle("height").toInt();
  1452. this.shuttleInnerNode.setStyle("margin-top", (selectNodeHeight-shuttleInnerHieght)/2 +"px" )
  1453. }
  1454. var itemAreaScrollNodeHeight = selectNodeHeight - getOffsetY( this.searchInputDiv ) - this.searchInputDiv.getStyle("height").toInt();
  1455. if( !this.options.searchbarInTopNode && this.selectTopNode ){
  1456. itemAreaScrollNodeHeight = itemAreaScrollNodeHeight - getOffsetY( this.selectTopNode ) - this.selectTopNode.getStyle("height").toInt();
  1457. }
  1458. if(this.letterAreaNode ){
  1459. itemAreaScrollNodeHeight = itemAreaScrollNodeHeight - getOffsetY( this.letterAreaNode ) - this.letterAreaNode.getStyle("height").toInt();
  1460. }
  1461. itemAreaScrollNodeHeight = itemAreaScrollNodeHeight - getOffsetY( this.itemAreaScrollNode );
  1462. this.itemAreaScrollNode.setStyle("height", itemAreaScrollNodeHeight);
  1463. var selectedContainerNodeHeight = nodeHeight - getOffsetY(this.selectedContainerNode);
  1464. this.selectedContainerNode.setStyle("height", selectedContainerNodeHeight);
  1465. var selectedScrollNodeHeight = selectedContainerNodeHeight;
  1466. if( this.selectedTopNode ) {
  1467. selectedScrollNodeHeight = selectedScrollNodeHeight - getOffsetY(this.selectedTopNode) - this.selectedTopNode.getStyle("height").toInt();
  1468. }
  1469. if( !this.options.searchbarInTopNode && this.selectedSearchInputDiv ){
  1470. selectedScrollNodeHeight = selectedScrollNodeHeight - getOffsetY( this.selectedSearchInputDiv ) - this.selectedSearchInputDiv.getStyle("height").toInt();
  1471. }
  1472. this.selectedScrollNode.setStyle("height", selectedScrollNodeHeight);
  1473. }
  1474. this.fireEvent("setSize",[this])
  1475. },
  1476. addFlatCategoryItem : function( categoryItemNode, hasChildrenItem, itemNodeContainer, isCreateSubCategoryListNode ){
  1477. if(!this.flatSubCategoryNodeList)this.flatSubCategoryNodeList = [];
  1478. if( hasChildrenItem )this.flatSubCategoryNodeList.push( categoryItemNode );
  1479. if( !this.isFlatCategoryLoaded && this.flatSubCategoryNodeList.length > 1 ){
  1480. this.flatCategoryScrollNode.show();
  1481. this.flatCategoryScrollNode.setStyles( this.css.flatCategoryScrollNode );
  1482. var height = this.itemAreaScrollNode.getStyle("height").toInt();
  1483. this.flatCategoryScrollNode.setStyle("height", ""+height+"px");
  1484. this.flatCategoryNode.setStyles( this.css.flatCategoryNode );
  1485. this.isFlatCategoryLoaded = true;
  1486. this.itemAreaScrollNode.setStyles( this.css.itemAreaScrollNode_flatCategory );
  1487. //alert(this.flatSubCategoryNodeList[0].outerHTML)
  1488. }
  1489. if( hasChildrenItem )categoryItemNode.inject( itemNodeContainer || this.flatCategoryNode );
  1490. var subCategoryListNode;
  1491. if( isCreateSubCategoryListNode ){
  1492. subCategoryListNode = new Element("div.subCategoryListNode").inject( itemNodeContainer || this.flatCategoryNode );
  1493. }
  1494. //this.setFlatCategorySequence(categoryItemNode, itemNodeContainer, subCategoryListNode);
  1495. if( hasChildrenItem ){
  1496. //if( this.checkClickFlatCategoryItem(categoryItemNode, itemNodeContainer) ){
  1497. // categoryItemNode.click();
  1498. //}
  1499. if( !this.currentCategoryItemNode ){
  1500. categoryItemNode.click();
  1501. this.currentCategoryItemNode = categoryItemNode
  1502. }else{
  1503. //var date = new Date();
  1504. var first = this.flatCategoryNode.getElement(".flatCategoryItemNode");
  1505. //if(first)console.log(first.get("title"));
  1506. //console.log(new Date() - date );
  1507. //console.log(" " );
  1508. if( first ){
  1509. var dn1 = first.retrieve("dn");
  1510. var dn2 = this.currentCategoryItemNode.retrieve("dn");
  1511. if( dn1 && dn2 ){
  1512. if( dn1 != dn2 ){
  1513. categoryItemNode.click();
  1514. this.currentCategoryItemNode = categoryItemNode
  1515. }
  1516. }else{
  1517. var title1 = first.get("title");
  1518. var title2 = this.currentCategoryItemNode.get("title");
  1519. if( title1 && title1 ){
  1520. if( title1 != title2 ){
  1521. categoryItemNode.click();
  1522. this.currentCategoryItemNode = categoryItemNode
  1523. }
  1524. }else{
  1525. var text1 = first.get("text");
  1526. var text2 = this.currentCategoryItemNode.get("text");
  1527. if( text1 != text2 ){
  1528. categoryItemNode.click();
  1529. this.currentCategoryItemNode = categoryItemNode
  1530. }
  1531. }
  1532. }
  1533. }
  1534. }
  1535. }
  1536. return subCategoryListNode;
  1537. }
  1538. //checkClickFlatCategoryItem : function(categoryItemNode, itemNodeContainer){
  1539. // if( !this.flatCategorySeqObj_current ){
  1540. // this.flatCategorySeqObj_current = categoryItemNode.retrieve("seq");
  1541. // //console.log(this.flatCategorySeqObj_current)
  1542. // return true;
  1543. // }
  1544. // var seq_cur = this.flatCategorySeqObj_current;
  1545. // var seq = categoryItemNode ? categoryItemNode.retrieve("seq") : [];
  1546. // for( var i=0; i<seq.length; i++ ){
  1547. // if( seq_cur[i] && seq[i] < seq_cur[i] ){
  1548. // //console.log(seq)
  1549. // this.flatCategorySeqObj_current = seq;
  1550. // return true;
  1551. // }else if( !seq_cur[i] || seq[i] > seq_cur[i] ){
  1552. // return false;
  1553. // }
  1554. // }
  1555. // return false;
  1556. //},
  1557. //setFlatCategorySequence: function(categoryItemNode, itemNodeContainer, subCategoryListNode){
  1558. // if( !this.flatCategorySeqObj )this.flatCategorySeqObj = {};
  1559. // var parentSeq = itemNodeContainer ? itemNodeContainer.retrieve("seq") : [];
  1560. // var seq = Array.clone( parentSeq );
  1561. // if( this.flatCategorySeqObj[ parentSeq.length ] ){
  1562. // seq.push( this.flatCategorySeqObj[ parentSeq.length ] + 1 );
  1563. // this.flatCategorySeqObj[parentSeq.length] = this.flatCategorySeqObj[parentSeq.length]+1;
  1564. //
  1565. // categoryItemNode.store( "seq", seq );
  1566. // categoryItemNode.set( "seq", seq );
  1567. //
  1568. // if(subCategoryListNode){
  1569. // seq = Array.clone( seq );
  1570. // seq[ seq.length - 1 ] = seq[ seq.length - 1 ]+1;
  1571. // this.flatCategorySeqObj[parentSeq.length] = this.flatCategorySeqObj[parentSeq.length]+1;
  1572. // subCategoryListNode.store("seq", seq );
  1573. // subCategoryListNode.set( "seq", seq );
  1574. // }
  1575. // }else{
  1576. // seq.push( 1 );
  1577. // this.flatCategorySeqObj[ parentSeq.length ] = 1;
  1578. // categoryItemNode.store( "seq", seq );
  1579. // categoryItemNode.set( "seq", seq );
  1580. //
  1581. // if(subCategoryListNode) {
  1582. // seq = Array.clone(seq);
  1583. // seq[seq.length - 1] = seq[seq.length - 1]+1;
  1584. // this.flatCategorySeqObj[parentSeq.length] = this.flatCategorySeqObj[parentSeq.length]+1;
  1585. // subCategoryListNode.store("seq", seq);
  1586. // subCategoryListNode.set("seq", seq);
  1587. // }
  1588. // }
  1589. //}
  1590. });
  1591. MWF.xApplication.Selector.Person.Item = new Class({
  1592. initialize: function(data, selector, container, level, category, delay){
  1593. this.clazz = "Item";
  1594. this.data = data;
  1595. this.selector = selector;
  1596. this.container = container;
  1597. this.isSelected = false;
  1598. this.level = (level) ? level.toInt() : 1;
  1599. this.category = category;
  1600. this.subItems = [];
  1601. this.subCategorys = [];
  1602. if(!delay)this.load();
  1603. },
  1604. _getShowName: function(){
  1605. return this.data.name + ( this.data.employee ? ("("+this.data.employee+")") : "" );
  1606. },
  1607. _getTtiteText: function(){
  1608. return this.data.name + ( this.data.employee ? ("("+this.data.employee+")") : "" );
  1609. },
  1610. _setIcon: function(){
  1611. var style = this.selector.options.style;
  1612. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/personicon.png)");
  1613. },
  1614. load: function(){
  1615. if( this.clazz === "Item" ){
  1616. this.selector.fireEvent("queryLoadItem",[this]);
  1617. }
  1618. if( !this.node )this.node = new Element("div", {
  1619. "styles": this.selector.css.selectorItem
  1620. }).inject(this.container);
  1621. this.levelNode = new Element("div", {
  1622. "styles": this.selector.css.selectorItemLevelNode
  1623. }).inject(this.node);
  1624. if( this.selector.options.selectType !== "identity" || this.selector.options.identityItemWidth === 0 ) {
  1625. var indent = this.selector.options.level1Indent + (this.level - 1) * this.selector.options.indent;
  1626. this.levelNode.setStyle("width", "" + indent + "px");
  1627. }
  1628. this.iconNode = new Element("div", {
  1629. "styles": this.selector.css.selectorItemIconNode
  1630. }).inject(this.node);
  1631. this._setIcon();
  1632. this.actionNode = new Element("div", {
  1633. "styles": this.selector.css.selectorItemActionNode
  1634. }).inject(this.node);
  1635. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single ){
  1636. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
  1637. }
  1638. this.textNode = new Element("div", {
  1639. "styles": this.selector.css.selectorItemTextNode,
  1640. "text": this._getShowName(),
  1641. "title": this._getTtiteText()
  1642. }).inject(this.node);
  1643. this.textNode.store("indent", indent);
  1644. var m = this.textNode.getStyle("margin-left").toFloat()+indent;
  1645. this.textNode.setStyle("margin-left", ""+m+"px");
  1646. if( this.selector.options.identityItemWidth && this.selector.options.selectType === "identity"){
  1647. this.node.setStyles({
  1648. "float" : "left",
  1649. "min-width" : this.selector.options.identityItemWidth + "px"
  1650. })
  1651. }
  1652. if(this.postLoad)this.postLoad();
  1653. this.loadSubItem();
  1654. this.setEvent();
  1655. this.check();
  1656. if( this.clazz === "Item" ) {
  1657. this.selector.fireEvent("postLoadItem", [this]);
  1658. }
  1659. },
  1660. loadSubItem: function(){},
  1661. disable : function(){
  1662. this.node.hide();
  1663. this.disabled = true;
  1664. },
  1665. enable : function(){
  1666. this.node.show();
  1667. this.disabled = false;
  1668. },
  1669. check: function(){
  1670. //if (this.selector.options.count.toInt()===1){
  1671. // this.checkSelectedSingle();
  1672. //}else{
  1673. this.checkSelected();
  1674. //}
  1675. },
  1676. checkSelectedSingle: function(){
  1677. var selectedItem = this.selector.options.values.filter(function(item, index){
  1678. if (typeOf(item)==="object") return this.data.distinguishedName === item.distinguishedName;
  1679. if (typeOf(item)==="string") return this.data.distinguishedName === item;
  1680. return false;
  1681. }.bind(this));
  1682. if (selectedItem.length){
  1683. this.selectedSingle();
  1684. }
  1685. },
  1686. checkSelected: function(){
  1687. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  1688. return item.data.distinguishedName === this.data.distinguishedName;
  1689. }.bind(this));
  1690. if (selectedItem.length){
  1691. //selectedItem[0].item = this;
  1692. selectedItem[0].addItem(this);
  1693. this.selectedItem = selectedItem[0];
  1694. this.setSelected();
  1695. }
  1696. },
  1697. checkTextNodeIndent : function( textNode, styles ){
  1698. var indent = textNode.retrieve("indent");
  1699. if( indent && styles && styles["margin-left"] ){
  1700. var m = styles["margin-left"].toFloat()+indent;
  1701. textNode.setStyle("margin-left", ""+m+"px");
  1702. }
  1703. },
  1704. setSelected: function(){
  1705. this.isSelected = true;
  1706. this.node.setStyles(this.selector.css.selectorItem_selected);
  1707. this.textNode.setStyles(this.selector.css.selectorItemTextNode_selected);
  1708. this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode_selected );
  1709. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  1710. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected ){
  1711. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
  1712. }
  1713. // if( this.category ){
  1714. // this.category.checkSelectAll();
  1715. // }
  1716. },
  1717. setEvent: function(){
  1718. this.node.addEvents({
  1719. "mouseover": function(){
  1720. this.overItem();
  1721. }.bind(this),
  1722. "mouseout": function(){
  1723. this.outItem();
  1724. }.bind(this),
  1725. "click": function(){
  1726. this.clickItem( null, true );
  1727. }.bind(this)
  1728. });
  1729. },
  1730. clickItem: function( callback, checkValid ){
  1731. if ( layout.mobile && this.selector.options.count.toInt()===1){
  1732. this.selectedSingle( checkValid );
  1733. }else{
  1734. if (this.isSelected){
  1735. this.unSelected( checkValid );
  1736. }else{
  1737. this.selected( checkValid );
  1738. }
  1739. }
  1740. },
  1741. overItem: function(){
  1742. if (!this.isSelected ){
  1743. this.node.setStyles(this.selector.css.selectorItem_over);
  1744. }else if( this.selector.css.selectorItem_over_force ){
  1745. this.node.setStyles(this.selector.css.selectorItem_over_force);
  1746. }
  1747. if (!this.isSelected){
  1748. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_over);
  1749. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_over ){
  1750. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_over );
  1751. }
  1752. }else if( this.selector.css.selectorItemActionNode_over_force ){
  1753. this.node.setStyles(this.selector.css.selectorItemActionNode_over_force);
  1754. }
  1755. },
  1756. outItem: function(){
  1757. if (!this.isSelected){
  1758. this.node.setStyles(this.selector.css.selectorItem);
  1759. }else if( this.selector.css.selectorItem_over_force ){
  1760. this.node.setStyles(this.selector.css.selectorItem_selected);
  1761. }
  1762. if (!this.isSelected){
  1763. this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1764. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single ){
  1765. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
  1766. }
  1767. }else if( this.selector.css.selectorItemActionNode_over_force ){
  1768. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  1769. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected ){
  1770. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
  1771. }
  1772. }
  1773. },
  1774. selectedSingle: function( checkValid ){
  1775. if (!this.isSelected){
  1776. if (this.selector.currentItem) this.selector.currentItem.unSelectedSingle();
  1777. this.getData(function(){
  1778. this.selector.currentItem = this;
  1779. this.isSelected = true;
  1780. this.selector.selectedItems.push(this);
  1781. this.node.setStyles(this.selector.css.selectorItem_selected);
  1782. this.textNode.setStyles(this.selector.css.selectorItemTextNode_selected);
  1783. this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode_selected );
  1784. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  1785. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected ){
  1786. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
  1787. }
  1788. this.selector.fireEvent("selectItem",[this]);
  1789. if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
  1790. }.bind(this));
  1791. }else {
  1792. this.unSelectedSingle( checkValid );
  1793. }
  1794. },
  1795. getData: function(callback){
  1796. if (callback) callback();
  1797. },
  1798. unSelectedSingle: function(checkValid){
  1799. this.selector.currentItem = null;
  1800. this.isSelected = false;
  1801. this.selector.selectedItems.erase(this);
  1802. this.node.setStyles(this.selector.css.selectorItem);
  1803. this.textNode.setStyles(this.selector.css.selectorItemTextNode);
  1804. this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode );
  1805. this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1806. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single ){
  1807. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
  1808. }
  1809. this.selector.fireEvent("unselectItem",[this]);
  1810. if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
  1811. },
  1812. selected: function( checkValid, callback, selectedNode ){
  1813. var count = this.selector.options.maxCount || this.selector.options.count;
  1814. count = count.toInt();
  1815. if (!count) count = 0;
  1816. if( count == 1 && this.selector.emptySelectedItems){
  1817. this.selector.emptySelectedItems();
  1818. }
  1819. if ((count===0) || (this.selector.selectedItems.length+1)<=count) {
  1820. this.isSelected = true;
  1821. if( this.node ){
  1822. this.node.setStyles(this.selector.css.selectorItem_selected);
  1823. this.textNode.setStyles(this.selector.css.selectorItemTextNode_selected);
  1824. this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode_selected );
  1825. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  1826. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected ){
  1827. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
  1828. }
  1829. }
  1830. this.selectedItem = this.selector._newItemSelected(this.data, this.selector, this, selectedNode);
  1831. this.selectedItem.check();
  1832. this.selector.selectedItems.push(this.selectedItem);
  1833. // if( this.category ){
  1834. // this.category.checkSelectAll();
  1835. // }
  1836. this.selector.fireEvent("selectItem",[this]);
  1837. if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
  1838. if(callback)callback();
  1839. }else{
  1840. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+count+"个选项", this.node);
  1841. }
  1842. },
  1843. unSelected: function( checkValid, callback ){
  1844. this.isSelected = false;
  1845. if( this.node ){
  1846. this.node.setStyles(this.selector.css.selectorItem);
  1847. this.textNode.setStyles(this.selector.css.selectorItemTextNode);
  1848. this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode );
  1849. this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1850. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single ){
  1851. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
  1852. }
  1853. }
  1854. if( this.category ){
  1855. this.category.checkUnselectAll();
  1856. }
  1857. if( this.selector.searchItems && this.selector.searchItems.length ){
  1858. this.selector.searchItems.each( function(itemSearch){
  1859. var sd = itemSearch.data;
  1860. var d = this.data;
  1861. if(
  1862. ( sd.distinguishedName && (sd.distinguishedName === d.distinguishedName) ) ||
  1863. ( sd.id && (sd.id === d.id) ) ||
  1864. ( sd.unique && (sd.unique === d.unique) ) ||
  1865. ( sd.employee && (sd.employee === d.employee) ) ||
  1866. ( sd.levelName && (sd.levelName === d.levelName) )
  1867. ){
  1868. itemSearch.isSelected = false;
  1869. itemSearch.node.setStyles(this.selector.css.selectorItem);
  1870. itemSearch.textNode.setStyles(this.selector.css.selectorItemTextNode);
  1871. this.checkTextNodeIndent( itemSearch.textNode, this.selector.css.selectorItemTextNode );
  1872. itemSearch.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1873. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single ){
  1874. itemSearch.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
  1875. }
  1876. }
  1877. }.bind(this))
  1878. }
  1879. if (this.selectedItem){
  1880. this.selector.selectedItems.erase(this.selectedItem);
  1881. this.selectedItem.items.each(function(item){
  1882. if (item != this){
  1883. item.isSelected = false;
  1884. item.node.setStyles(this.selector.css.selectorItem);
  1885. item.textNode.setStyles(this.selector.css.selectorItemTextNode);
  1886. this.checkTextNodeIndent( item.textNode, this.selector.css.selectorItemTextNode );
  1887. item.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1888. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single ){
  1889. item.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
  1890. }
  1891. }
  1892. }.bind(this));
  1893. this.selectedItem.destroy();
  1894. this.selectedItem = null;
  1895. }
  1896. this.selector.fireEvent("unselectItem",[this]);
  1897. if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
  1898. if(callback)callback();
  1899. },
  1900. postLoad : function(){},
  1901. getParentCategoryByLevel : function( level ){
  1902. var category = this.category;
  1903. do{
  1904. if( category.level === level ){
  1905. return category;
  1906. }else{
  1907. category = category.category;
  1908. }
  1909. }while( category )
  1910. }
  1911. });
  1912. MWF.xApplication.Selector.Person.ItemSelected = new Class({
  1913. Extends: MWF.xApplication.Selector.Person.Item,
  1914. initialize: function(data, selector, item, selectedNode){
  1915. this.data = data;
  1916. this.selector = selector;
  1917. this.container = selectedNode || this.selector.selectedNode;
  1918. this.isSelected = false;
  1919. this.clazz = "ItemSelected";
  1920. this.items = [];
  1921. if (item) this.items.push(item);
  1922. this.level = 0;
  1923. this.node = new Element("div", {
  1924. "styles": this.selector.css.selectorItem
  1925. }).inject(this.container);
  1926. this.node.setStyle("display","none");
  1927. this.getData(function(){
  1928. this.node.setStyle("display","");
  1929. this.load();
  1930. }.bind(this));
  1931. },
  1932. postLoad : function(){
  1933. if( this.selector.css.selectorSelectedItemActionNode ){
  1934. this.actionNode.setStyles( this.selector.css.selectorSelectedItemActionNode );
  1935. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorSelectedItemActionNode_single ){
  1936. this.actionNode.setStyles( this.selector.css.selectorSelectedItemActionNode_single );
  1937. }
  1938. }
  1939. if( this.selector.css.selectorSelectedItemTextNode ){
  1940. this.textNode.setStyles(this.selector.css.selectorSelectedItemTextNode);
  1941. }
  1942. },
  1943. getData: function(callback){
  1944. if (callback) callback();
  1945. },
  1946. clickItem: function( callback, checkValid ){
  1947. if (this.items.length){
  1948. this.items.each(function(item){
  1949. item.unSelected( checkValid );
  1950. });
  1951. if( checkValid )this.selector.fireEvent("valid", [this.selector, this])
  1952. }else{
  1953. //this.item.selectedItem = null;
  1954. //this.item.isSelected = false;
  1955. this.destroy();
  1956. this.selector.selectedItems.erase(this);
  1957. if( checkValid )this.selector.fireEvent("valid", [this.selector, this])
  1958. }
  1959. },
  1960. //overItem: function(){
  1961. // if (!this.isSelected){
  1962. // this.node.setStyles(this.selector.css.selectorItem_over);
  1963. // this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected_over);
  1964. // }
  1965. //},
  1966. overItem: function(){
  1967. if (!this.isSelected ){
  1968. if( this.selector.css.selectorItem_selected_over ){
  1969. this.node.setStyles(this.selector.css.selectorItem_selected_over);
  1970. }else{
  1971. this.node.setStyles(this.selector.css.selectorItem_over);
  1972. }
  1973. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected_over);
  1974. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected_over ){
  1975. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected_over );
  1976. }
  1977. }
  1978. },
  1979. outItem: function(){
  1980. if (!this.isSelected){
  1981. var styles = this.selector.css.selectorSelectedItem || this.selector.css.selectorItem;
  1982. this.node.setStyles(styles);
  1983. }else if( this.selector.css.selectorItem_over_force ){
  1984. this.node.setStyles(this.selector.css.selectorItem_selected);
  1985. }
  1986. if (!this.isSelected){
  1987. var styles = this.selector.css.selectorSelectedItemActionNode || this.selector.css.selectorItemActionNode;
  1988. this.actionNode.setStyles(styles);
  1989. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) &&
  1990. ( this.selector.css.selectorSelectedItemActionNode_single || this.selector.css.selectorItemActionNode_single ) ){
  1991. this.actionNode.setStyles( this.selector.css.selectorSelectedItemActionNode_single || this.selector.css.selectorItemActionNode_single );
  1992. }
  1993. }else if( this.selector.css.selectorItemActionNode_over_force ){
  1994. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  1995. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected ){
  1996. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
  1997. }
  1998. }
  1999. },
  2000. addItem: function(item){
  2001. if (this.items.indexOf(item)===-1) this.items.push(item);
  2002. },
  2003. check: function(){
  2004. if (this.selector.items.length){
  2005. var items = this.selector.items.filter(function(item, index){
  2006. return item.data.distinguishedName === this.data.distinguishedName;
  2007. }.bind(this));
  2008. this.items = items;
  2009. if (items.length){
  2010. items.each(function(item){
  2011. item.selectedItem = this;
  2012. item.setSelected();
  2013. }.bind(this));
  2014. }
  2015. }
  2016. },
  2017. destroy: function(){
  2018. if(this.node){
  2019. // var parent = this.node.getParent(".categorySelectedNode");
  2020. // if( parent && !this.node.getPrevious() && !this.node.getNext() ){ //parent.getChildren().length <= 1
  2021. // parent.destroy();
  2022. // }else{
  2023. this.node.destroy();
  2024. // }
  2025. }
  2026. delete this;
  2027. }
  2028. });
  2029. MWF.xApplication.Selector.Person.ItemCategory = new Class({
  2030. Extends: MWF.xApplication.Selector.Person.Item,
  2031. initialize: function(data, selector, container, level, parentCategory, delay){
  2032. this.data = data;
  2033. this.selector = selector;
  2034. this.container = container;
  2035. this.isSelected = false;
  2036. this.level = (level) ? level.toInt() : 1;
  2037. this.category = parentCategory;
  2038. this.subItems = [];
  2039. this.subCategorys = [];
  2040. if(!delay)this.load();
  2041. },
  2042. load : function(){
  2043. if( this.selector.isFlatCategory ){
  2044. this.loadForFlat();
  2045. }else{
  2046. this.loadForNormal();
  2047. }
  2048. },
  2049. loadForFlat : function(){
  2050. this.selector.fireEvent("queryLoadCategory",[this]);
  2051. //this.createNode();
  2052. this.node = new Element("div.flatCategoryItemNode", {
  2053. "styles": this.selector.css.flatCategoryItemNode,
  2054. "title" : this._getTtiteText()
  2055. });
  2056. this.node.store( "category", this );
  2057. this.node.store( "dn", this.data.distinguishedName );
  2058. this.textNode = new Element("div", {
  2059. "styles": this.selector.css.flatCategoryItemTextNode,
  2060. "text": this._getShowName()
  2061. }).inject(this.node);
  2062. //var level = this.level;
  2063. //var category = this;
  2064. //while( category.category ){
  2065. // level = category.category + "_" + level;
  2066. // category = category.category;
  2067. //}
  2068. this.children = new Element("div", {
  2069. "styles": this.selector.css.selectorItemCategoryChildrenNode
  2070. }).inject(this.selector.itemAreaNode); //this.container
  2071. //if (!this.selector.options.expand)
  2072. this.children.setStyle("display", "none");
  2073. if( this.selector.options.selectAllEnable && this.selector.options.count.toInt()!==1 ){
  2074. var selectAllWrap = new Element("div",{
  2075. styles : this.selector.css.flatCategory_selectAllWrap
  2076. }).inject(this.children);
  2077. this.selectAllNode = new Element("div", {
  2078. "styles": this.selector.css.flatCategory_selectAll,
  2079. "text" : "全选"
  2080. }).inject(selectAllWrap);
  2081. this.selectAllNode.addEvent( "click", function(ev){
  2082. if( this.isSelectedAll ){
  2083. this.selector.options.selectAllRange === "all" ? this.unselectAllNested(ev, null, true ) : this.unselectAll(ev, null, true);
  2084. this.selector.fireEvent("unselectCatgory",[this])
  2085. }else{
  2086. this.selector.options.selectAllRange === "all" ? this.selectAllNested(ev, true) : this.selectAll(ev, true);
  2087. this.selector.fireEvent("selectCatgory",[this])
  2088. }
  2089. ev.stopPropagation();
  2090. }.bind(this));
  2091. }
  2092. // var subIdList = this.selector._getChildrenItemIds(this.data);
  2093. // if (subIdList){
  2094. // var count = subIdList.length;
  2095. // this.childrenHeight = count*this.selector.options.itemHeight;
  2096. // this.children.setStyle("height", ""+this.childrenHeight+"px");
  2097. // }
  2098. //if (!this._hasChild()){
  2099. // this.textNode.setStyle("color", "#333");
  2100. //}
  2101. if( this.selectAllNode ){
  2102. if( this.selector.options.selectAllRange === "direct" && !this._hasChildItem() ){
  2103. this.selectAllNode.setStyle("display", "none");
  2104. }
  2105. }
  2106. this.node.addEvents({
  2107. //"mouseover": function(){
  2108. // if (!this.isSelected )this.node.setStyles(this.selector.css.flatCategoryItemNode_over );
  2109. //}.bind(this),
  2110. //"mouseout": function(){
  2111. // if (!this.isSelected )this.node.setStyles(this.selector.css.flatCategoryItemNode );
  2112. //}.bind(this),
  2113. "click": function(){
  2114. if( this.selector.currentFlatCategory === this )return;
  2115. if( this.selector.currentFlatCategory ){
  2116. this.selector.currentFlatCategory.clickFlatCategoryItem(null, true); //取消原来选择的
  2117. }
  2118. this.selector.currentFlatCategory = this;
  2119. this.clickFlatCategoryItem();
  2120. }.bind(this)
  2121. });
  2122. //this.setEvent();
  2123. var isCreateSubCategoryListNode = this._hasChildCategory ? this._hasChildCategory() : true;
  2124. var nodeContainer;
  2125. if( this.nodeContainer ){
  2126. nodeContainer = this.nodeContainer;
  2127. }else{
  2128. nodeContainer = (this.category && this.category.subCategoryListNode) ? this.category.subCategoryListNode : null;
  2129. }
  2130. this.subCategoryListNode = this.selector.addFlatCategoryItem( this.node, this._hasChildItem(), nodeContainer, isCreateSubCategoryListNode );
  2131. this.check();
  2132. if( this.loadCategoryChildren )this.loadCategoryChildren();
  2133. //this.afterLoad();
  2134. this.selector.fireEvent("postLoadCategory",[this]);
  2135. },
  2136. loadForNormal : function(){
  2137. this.selector.fireEvent("queryLoadCategory",[this]);
  2138. this.createNode();
  2139. this.levelNode = new Element("div", {
  2140. "styles": this.selector.css.selectorItemLevelNode
  2141. }).inject(this.node);
  2142. if(this.selector.options.selectType !== "identity" || this.selector.options.identityItemWidth === 0 ){
  2143. var indent = this.selector.options.level1Indent + (this.level - 1) * this.selector.options.indent;
  2144. this.levelNode.setStyle("width", "" + indent + "px");
  2145. }else{
  2146. this.node.setStyle("clear","both");
  2147. }
  2148. this.iconNode = new Element("div", {
  2149. "styles": this.selector.css.selectorItemCategoryIconNode || this.selector.css.selectorItemIconNode
  2150. }).inject(this.node);
  2151. this._setIcon();
  2152. this.actionNode = new Element("div", {
  2153. "styles": (this.selector.options.expand) ? this.selector.css.selectorItemCategoryActionNode_expand : this.selector.css.selectorItemCategoryActionNode_collapse
  2154. }).inject(this.node);
  2155. if( this.selector.options.selectAllEnable && this.selector.options.count.toInt()!==1 ){
  2156. this.selectAllNode = new Element("div", {
  2157. "styles": this.selector.css.selectorItemCategoryActionNode_selectAll,
  2158. "title" : "全选下级"
  2159. }).inject(this.node);
  2160. this.selectAllNode.addEvent( "click", function(ev){
  2161. if( this.isSelectedAll ){
  2162. // this.unselectAll(ev);
  2163. this.selector.options.selectAllRange === "all" ? this.unselectAllNested(ev, null, true ) : this.unselectAll(ev, null, true);
  2164. this.selector.fireEvent("unselectCatgory",[this]);
  2165. }else{
  2166. // this.selectAll(ev);
  2167. if( this.selector.options.selectAllRange === "all" ){
  2168. var node = new Element("div.categorySelectedNode").inject( this.selector.selectedNode );
  2169. this.selectAllNested(ev, true, node );
  2170. }else{
  2171. this.selectAll(ev, true)
  2172. }
  2173. this.selector.fireEvent("selectCatgory",[this]);
  2174. }
  2175. ev.stopPropagation();
  2176. }.bind(this));
  2177. if( this.selector.css.selectorItemCategoryActionNode_selectAll_over ){
  2178. this.selectAllNode.addEvents( {
  2179. "mouseover" : function(ev){
  2180. if( !this.isSelectedAll )this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_over );
  2181. //ev.stopPropagation();
  2182. }.bind(this),
  2183. "mouseout" : function(ev){
  2184. if( !this.isSelectedAll )this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll );
  2185. //ev.stopPropagation();
  2186. }.bind(this)
  2187. })
  2188. }
  2189. }
  2190. this.textNode = new Element("div", {
  2191. "styles": this.selector.css.selectorItemCategoryTextNode,
  2192. "text": this._getShowName()
  2193. }).inject(this.node);
  2194. var m = this.textNode.getStyle("margin-left").toFloat()+indent;
  2195. this.textNode.setStyle("margin-left", ""+m+"px");
  2196. this.children = new Element("div.children", {
  2197. "styles": this.selector.css.selectorItemCategoryChildrenNode
  2198. }).inject(this.node, "after");
  2199. if (!this.selector.options.expand) this.children.setStyle("display", "none");
  2200. if( this.selector.options.expandEmptyCategory && !this._hasChildItem() ){ //点击允许展开空分类
  2201. this.children.hide();
  2202. this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse);
  2203. this.isExpand = false;
  2204. }else{
  2205. var subIdList = this.selector._getChildrenItemIds(this.data);
  2206. if (subIdList){
  2207. var count = subIdList.length;
  2208. this.childrenHeight = count*this.selector.options.itemHeight;
  2209. this.children.setStyle("height", ""+this.childrenHeight+"px");
  2210. }
  2211. if(this.selector.options.identityItemWidth && this.selector.options.selectType === "identity"){
  2212. var indent = this.level === 0 ? this.selector.options.level1Indent : this.selector.options.indent;
  2213. this.children.setStyles({
  2214. "padding-left": "" + indent + "px",
  2215. "overflow" : "hidden"
  2216. });
  2217. }
  2218. if ( !this._hasChild()){
  2219. this.actionNode.setStyle("background", "transparent");
  2220. this.textNode.setStyle("color", "#777");
  2221. }
  2222. if( this.selectAllNode ){
  2223. if( this.selector.options.selectAllRange === "direct" && !this._hasChildItem() ){
  2224. this.selectAllNode.setStyle("display", "none");
  2225. }
  2226. }
  2227. }
  2228. this.setEvent();
  2229. this.check();
  2230. this.afterLoad();
  2231. this.selector.fireEvent("postLoadCategory",[this]);
  2232. },
  2233. createNode: function(){
  2234. this.node = new Element("div", {
  2235. "styles": this.selector.css.selectorItemCategory,
  2236. "title" : this._getTtiteText()
  2237. }).inject(this.container);
  2238. },
  2239. isSelectAllEnable : function(){
  2240. },
  2241. unselectAll : function(ev, exclude, checkValid ){
  2242. var excludeList = exclude || [];
  2243. if( exclude && typeOf(exclude) !== "array" )excludeList = [exclude];
  2244. ( this.subItems || [] ).each( function(item){
  2245. if(item.isSelected && !excludeList.contains(item) ){
  2246. item.unSelected( checkValid );
  2247. }
  2248. }.bind(this));
  2249. if( this.selectAllNode ){
  2250. if( this.selector.isFlatCategory ){
  2251. this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll );
  2252. }else if(this.selector.css.selectorItemCategoryActionNode_selectAll){
  2253. this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll );
  2254. }
  2255. }
  2256. this.isSelectedAll = false;
  2257. },
  2258. unselectAllNested : function( ev, exclude, checkValid ){
  2259. this.unselectAll(ev, exclude, checkValid);
  2260. if( this.subCategorys && this.subCategorys.length ){
  2261. this.subCategorys.each( function( category ){
  2262. category.unselectAllNested( ev, exclude, checkValid )
  2263. })
  2264. }
  2265. },
  2266. selectAllNested : function( ev, checkValid, selectedNode ){
  2267. var node;
  2268. if(selectedNode)node = new Element("div.categorySelectedNode").inject( selectedNode );
  2269. this.selectAll(ev, checkValid, node);
  2270. if( this.subCategorys && this.subCategorys.length ){
  2271. this.subCategorys.each( function( category ){
  2272. if(selectedNode)var node = new Element("div.categorySelectedNode").inject( selectedNode );
  2273. category.selectAllNested(ev, checkValid, node)
  2274. })
  2275. }
  2276. },
  2277. selectAll: function(ev, checkValid, selectedNode){
  2278. if( this.loaded || this.selector.isFlatCategory ){
  2279. this._selectAll( ev, checkValid, selectedNode );
  2280. }else{
  2281. this.clickItem( function(){
  2282. this._selectAll( ev, checkValid, selectedNode );
  2283. //this.children.setStyles({
  2284. // "display": "none",
  2285. // "height": "0px"
  2286. //});
  2287. //this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse);
  2288. }.bind(this));
  2289. }
  2290. },
  2291. _selectAll : function( ev, checkValid, selectedNode ){
  2292. if( this.selector.options.selectAllRange === "direct" && ( !this.subItems || !this.subItems.length ) )return;
  2293. var count = this.selector.options.maxCount || this.selector.options.count;
  2294. if (!count) count = 0;
  2295. var selectedSubItemCount = 0;
  2296. this.subItems.each( function(item){
  2297. if(item.isSelected)selectedSubItemCount++
  2298. }.bind(this));
  2299. if ((count.toInt()===0) || (this.selector.selectedItems.length+(this.subItems.length-selectedSubItemCount))<=count){
  2300. var checkedCount = 0;
  2301. var doSelectAll = function () {
  2302. this.subItems.each( function(item){
  2303. if(!item.isSelected && !item.disabled )item.selected( false, function () {
  2304. checkedCount++;
  2305. if( this.subItems.length === checkedCount ){
  2306. if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
  2307. }
  2308. }.bind(this), selectedNode);
  2309. }.bind(this));
  2310. if( this.selectAllNode ){
  2311. if( this.selector.isFlatCategory ){
  2312. this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll_selected );
  2313. }else if(this.selector.css.selectorItemCategoryActionNode_selectAll_selected){
  2314. this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_selected );
  2315. }
  2316. }
  2317. this.isSelectedAll = true;
  2318. }.bind(this);
  2319. if( this._beforeSelectAll ){
  2320. this._beforeSelectAll( doSelectAll );
  2321. }else{
  2322. doSelectAll();
  2323. }
  2324. }else{
  2325. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+count+"个选项", this.node);
  2326. }
  2327. },
  2328. checkSelectAll : function(){
  2329. if( this.isSelectedAll )return;
  2330. if( !this.selectAllNode )return;
  2331. if( !this.subItems )return;
  2332. var isAllItemSelected = true;
  2333. for( var i=0; i< this.subItems.length; i++ ){
  2334. if( !this.subItems[i].isSelected ){
  2335. isAllItemSelected = false;
  2336. break;
  2337. }
  2338. }
  2339. if( isAllItemSelected ){
  2340. if( this.selector.isFlatCategory ){
  2341. this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll_selected );
  2342. }else if( this.selector.css.selectorItemCategoryActionNode_selectAll_selected ){
  2343. this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_selected );
  2344. }
  2345. this.isSelectedAll = true;
  2346. }
  2347. },
  2348. checkUnselectAll : function(){
  2349. if( !this.isSelectedAll )return;
  2350. if( !this.selectAllNode )return;
  2351. if( !this.subItems )return;
  2352. var hasSelectedItem = false;
  2353. for( var i=0; i< this.subItems.length; i++ ){
  2354. if( this.subItems[i].isSelected ){
  2355. hasSelectedItem = true;
  2356. break;
  2357. }
  2358. }
  2359. if( !hasSelectedItem ){
  2360. if( this.selector.isFlatCategory ){
  2361. this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll );
  2362. }else if( this.selector.css.selectorItemCategoryActionNode_selectAll ){
  2363. this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll );
  2364. }
  2365. this.isSelectedAll = false;
  2366. }
  2367. },
  2368. afterLoad: function(){
  2369. if (this.level===1) this.clickItem();
  2370. },
  2371. clickFlatCategoryItem : function( callback, hidden ){
  2372. if (this._hasChildItem()){
  2373. var display = this.children.getStyle("display");
  2374. if( hidden ){
  2375. this.children.setStyles({ "display": "none" });
  2376. this.node.setStyles( this.selector.css.flatCategoryItemNode );
  2377. this.isExpand = false;
  2378. }else if (display === "none"){
  2379. this.children.setStyles({
  2380. "display": "block",
  2381. "height": "auto"
  2382. });
  2383. this.node.setStyles( this.selector.css.flatCategoryItemNode_selected );
  2384. this.isExpand = true;
  2385. }else{
  2386. this.children.setStyles({
  2387. "display": "none"
  2388. });
  2389. this.node.setStyles( this.selector.css.flatCategoryItemNode );
  2390. this.isExpand = false;
  2391. }
  2392. if(callback)callback()
  2393. }
  2394. },
  2395. clickItem: function( callback ){
  2396. if (this._hasChild() || this.selector.options.expandEmptyCategory ){
  2397. if (!this.fx){
  2398. this.fx = new Fx.Tween(this.children, {
  2399. "duration": 200
  2400. // "transition": Fx.Transitions.Cubic.easeIn
  2401. });
  2402. }
  2403. if (!this.fx.isRunning()){
  2404. var display = this.children.getStyle("display");
  2405. if (display === "none"){
  2406. this.selector.fireEvent("expand", [this] );
  2407. this.children.setStyles({
  2408. "display": "block",
  2409. "height": "0px"
  2410. });
  2411. this.fx.start("height", "0px", ""+this.childrenHeight+"px");
  2412. this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand);
  2413. this.isExpand = true;
  2414. }else{
  2415. this.selector.fireEvent("collapse", [this] );
  2416. if (!this.childrenHeight) this.childrenHeight = this.children.getStyle("height").toFloat();
  2417. this.fx.start("height", ""+this.childrenHeight+"px", "0px").chain(function(){
  2418. this.children.setStyles({
  2419. "display": "none",
  2420. "height": "0px"
  2421. });
  2422. }.bind(this));
  2423. this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse);
  2424. this.isExpand = false;
  2425. }
  2426. }
  2427. if(callback)callback()
  2428. }
  2429. },
  2430. overItem: function(){
  2431. //if (!this.isSelected){
  2432. // this.node.setStyles(this.selector.css.selectorItem_over);
  2433. // this.actionNode.setStyles(this.selector.css.selectorItemActionNode_over);
  2434. //}
  2435. if( this.selector.css.selectorItemCategory_over ){
  2436. this.node.setStyles(this.selector.css.selectorItemCategory_over);
  2437. }
  2438. var display = this.children.getStyle("display");
  2439. if( display === "none" ){
  2440. if( this._hasChild() && this.selector.css.selectorItemCategoryActionNode_collapse_over ){
  2441. this.actionNode.setStyles( this.selector.css.selectorItemCategoryActionNode_collapse_over )
  2442. }
  2443. }else{
  2444. if( this._hasChild() && this.selector.css.selectorItemCategoryActionNode_expand_over ){
  2445. this.actionNode.setStyles( this.selector.css.selectorItemCategoryActionNode_expand_over )
  2446. }
  2447. }
  2448. },
  2449. outItem: function(){
  2450. //if (!this.isSelected){
  2451. // this.node.setStyles(this.selector.css.selectorItem);
  2452. // this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  2453. //}
  2454. if( this.selector.css.selectorItemCategory_over ){
  2455. this.node.setStyles(this.selector.css.selectorItemCategory);
  2456. }
  2457. var display = this.children.getStyle("display");
  2458. if( display === "none" ){
  2459. if( this._hasChild() && this.selector.css.selectorItemCategoryActionNode_collapse_over ){
  2460. this.actionNode.setStyles( this.selector.css.selectorItemCategoryActionNode_collapse )
  2461. }
  2462. }else{
  2463. if( this._hasChild() && this.selector.css.selectorItemCategoryActionNode_expand_over ){
  2464. this.actionNode.setStyles( this.selector.css.selectorItemCategoryActionNode_expand )
  2465. }
  2466. }
  2467. },
  2468. _hasChild: function(){
  2469. var subIdList = this.selector._getChildrenItemIds(this.data);
  2470. if (subIdList) if (subIdList.length) return true;
  2471. return false;
  2472. },
  2473. _hasChildCategory: function(){
  2474. return null;
  2475. },
  2476. _hasChildItem: function(){
  2477. return this._hasChild();
  2478. },
  2479. _getTtiteText: function(){
  2480. if( this.data.levelName ){
  2481. return this.data.name+"("+ this.data.levelName +")";
  2482. }else{
  2483. return this.data.name;
  2484. }
  2485. }
  2486. });
  2487. MWF.xApplication.Selector.Person.ItemGroupCategory = new Class({
  2488. Extends: MWF.xApplication.Selector.Person.ItemCategory,
  2489. _getShowName: function(){
  2490. return this.data.name;
  2491. },
  2492. _setIcon: function(){
  2493. var style = this.selector.options.style;
  2494. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/groupicon.png)");
  2495. }
  2496. });
  2497. MWF.xApplication.Selector.Person.ItemRoleCategory = new Class({
  2498. Extends: MWF.xApplication.Selector.Person.ItemCategory,
  2499. _getShowName: function(){
  2500. return this.data.name;
  2501. },
  2502. _setIcon: function(){
  2503. var style = this.selector.options.style;
  2504. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/roleicon.png)");
  2505. }
  2506. });
  2507. MWF.xApplication.Selector.Person.Filter = new Class({
  2508. Implements: [Options, Events],
  2509. options: {
  2510. "style": "default",
  2511. "groups": [],
  2512. "roles": []
  2513. },
  2514. initialize: function(value, options){
  2515. this.setOptions(options);
  2516. this.value = value;
  2517. this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  2518. },
  2519. filter: function(value, callback){
  2520. this.value = value;
  2521. var key = this.value;
  2522. if (this.options.groups.length || this.options.roles.length) key = {"key": key, "groupList": this.options.groupList, "roleList": this.options.roleList};
  2523. this.orgAction.listPersonByKey(function(json){
  2524. data = json.data;
  2525. if (callback) callback(data)
  2526. }.bind(this), null, key);
  2527. }
  2528. });