Processor.js 114 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657
  1. MWF.xApplication.process = MWF.xApplication.process || {};
  2. MWF.xApplication.process.Work = MWF.xApplication.process.Work || {};
  3. MWF.xDesktop.requireApp("process.Work", "lp."+MWF.language, null, false);
  4. MWF.xApplication.process.Work.Processor = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "mediaNode": null,
  10. "opinion": "",
  11. "tabletWidth" : 0,
  12. "tabletHeight" : 0,
  13. "orgHeight" : 276,
  14. "maxOrgCountPerline" : 2,
  15. "isManagerProcess" : false //是否为管理员提交
  16. },
  17. initialize: function(node, task, options, form){
  18. this.setOptions(options);
  19. this.path = "../x_component_process_Work/$Processor/";
  20. this.cssPath = "../x_component_process_Work/$Processor/"+this.options.style+"/css.wcss";
  21. this._loadCss();
  22. this.task = task;
  23. this.node = $(node);
  24. this.selectedRoute = null;
  25. this.form = form;
  26. this.load();
  27. },
  28. load: function(){
  29. if( layout.mobile ){
  30. this.content = new Element("div").inject(this.node);
  31. }else{
  32. this.content = this.node;
  33. }
  34. if( !this.form && this.options.isManagerProcess ){
  35. this.managerProcessNoticeNode = new Element("div", {"styles": this.css.managerProcessNoticeNode, "html": MWF.xApplication.process.Work.LP.managerProcessNotice}).inject(this.content);
  36. this.managerLoginNode = new Element("div", {"styles": this.css.managerLoginNode, "text": MWF.xApplication.process.Work.LP.managerLogin }).inject(this.content);
  37. this.managerLoginNode.addEvent("click", function(ev){
  38. this.managerLogin(ev);
  39. }.bind(this));
  40. //var text = MWF.xApplication.process.Work.LP.managerLoginReturn.replace( "{user}", layout.session.user.name );
  41. //this.managerLoginReturnNode = new Element("div", {"styles": this.css.managerLoginNode, "text": text }).inject(this.content);
  42. //this.managerLoginReturnNode.hide();
  43. //this.managerPerson = layout.session.user.distinguishedName;
  44. //this.managerLoginReturnNode.addEvent("click", function(ev){
  45. // this.managerLoginReturn(ev);
  46. //}.bind(this))
  47. }
  48. this.routeOpinionTile = new Element("div", {"styles": this.css.routeOpinionTile, "text": MWF.xApplication.process.Work.LP.inputOpinion}).inject(this.content);
  49. this.routeOpinionArea = new Element("div", {"styles": this.css.routeOpinionArea}).inject(this.content);
  50. this.setOpinion();
  51. if( this.form ){
  52. if( layout.mobile ){
  53. this.orgsArea = new Element("div", {"styles": this.css.orgsArea}).inject(this.content);
  54. this.orgsTile = new Element("div", {"styles": this.css.orgsTitle, "text": MWF.xApplication.process.Work.LP.selectPerson}).inject(this.orgsArea);
  55. this.orgsArea.hide();
  56. }else{
  57. this.orgsArea = new Element("div", {"styles": this.css.orgsArea}).inject(this.content);
  58. this.orgsTile = new Element("div", {"styles": this.css.orgsTitle, "text": MWF.xApplication.process.Work.LP.selectPerson}).inject(this.orgsArea);
  59. }
  60. }
  61. if( layout.mobile ){
  62. this.buttonsArea = new Element("div", {"styles": this.css.buttonsArea}).inject(this.node);
  63. }else{
  64. this.buttonsArea = new Element("div", {"styles": this.css.buttonsArea}).inject(this.content);
  65. }
  66. this.setButtons();
  67. if( this.form ){
  68. if( layout.mobile ){
  69. this.getRouteGroupList();
  70. if( this.hasDecisionOpinion ){
  71. this.routeContainer = new Element("div", {
  72. "styles" : this.css.routeContainer
  73. }).inject(this.routeOpinionTile, "before");
  74. this.routeGroupTitle = new Element("div", { "styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRouteGroup }).inject(this.routeContainer);
  75. this.routeGroupArea = new Element("div", { "styles": this.css.routeSelectorArea }).inject(this.routeContainer);
  76. this.routeSelectorTile = new Element("div", { "styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute }).inject(this.routeContainer);
  77. this.routeSelectorArea = new Element("div", { "styles": this.css.routeSelectorArea }).inject(this.routeContainer);
  78. this.setRouteGroupList();
  79. }else{
  80. this.routeSelectorTile = new Element("div", {"styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute}).inject(this.routeOpinionTile, "before");
  81. this.routeSelectorArea = new Element("div", {"styles": this.css.routeSelectorArea}).inject(this.routeSelectorTile, "after");
  82. this.setRouteList();
  83. }
  84. }else{
  85. this.getRouteGroupList();
  86. if( this.hasDecisionOpinion ){
  87. //if( this.getMaxOrgLength() > 1 ){
  88. this.routeContainer = new Element("div", {
  89. "styles" : this.css.routeContainer
  90. }).inject(this.routeOpinionTile, "before");
  91. this.routeLeftWarper = new Element("div", { "styles":
  92. this.getMaxOrgLength() > 1 ? this.css.routeLeftWarper : this.css.routeLeftWarper_single
  93. }).inject(this.routeContainer);
  94. this.routeGroupTitle = new Element("div", { "styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRouteGroup }).inject(this.routeLeftWarper);
  95. this.routeGroupArea = new Element("div", { "styles": this.css.routeSelectorArea_hasGroup }).inject(this.routeLeftWarper);
  96. this.routeRightWarper = new Element("div", { "styles":
  97. this.getMaxOrgLength() > 1 ? this.css.routeRightWarper : this.css.routeRightWarper_single
  98. }).inject(this.routeContainer);
  99. this.routeSelectorTile = new Element("div", { "styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute }).inject(this.routeRightWarper);
  100. this.routeSelectorArea = new Element("div", { "styles": this.css.routeSelectorArea_hasGroup }).inject(this.routeRightWarper);
  101. this.setRouteGroupList();
  102. //}else{
  103. // this.routeGroupTile = new Element("div", {"styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute }).inject(this.routeOpinionTile, "before");
  104. // this.routeGroupArea = new Element("div", {"styles": this.css.routeSelectorArea_hasGroup_wide }).inject(this.routeGroupTile, "after");
  105. // this.setRouteGroupList();
  106. //}
  107. }else{
  108. this.routeSelectorTile = new Element("div", {"styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute}).inject(this.routeOpinionTile, "before");
  109. this.routeSelectorArea = new Element("div", {"styles": this.css.routeSelectorArea}).inject(this.routeSelectorTile, "after");
  110. this.setRouteList();
  111. }
  112. }
  113. }else{ //快速处理
  114. this.routeSelectorTile = new Element("div", {"styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute}).inject(this.routeOpinionTile, "before");
  115. this.routeSelectorArea = new Element("div", {"styles": this.css.routeSelectorArea}).inject(this.routeSelectorTile, "after");
  116. this.setRouteList_noform();
  117. this.setSize_noform();
  118. }
  119. this.fireEvent("postLoad");
  120. },
  121. getRouteGroupList : function(){
  122. if( this.routeGroupObject )return this.routeGroupObject;
  123. this.routeGroupObject = {};
  124. this.routeGroupNameList = [];
  125. this.hasDecisionOpinion = false;
  126. var routeList = this.getRouteDataList();
  127. routeList.each(function(route, i){
  128. if( route.hiddenScriptText && this.form && this.form.Macro ){ //如果隐藏路由,返回
  129. if( this.form.Macro.exec(route.hiddenScriptText, this).toString() === "true" )return;
  130. }
  131. if( route.displayNameScriptText && this.form && this.form.Macro ){ //如果有显示名称公式
  132. route.displayName = this.form.Macro.exec(route.displayNameScriptText, this);
  133. }else{
  134. route.displayName = route.name;
  135. }
  136. if( route.decisionOpinion ){
  137. this.hasDecisionOpinion = true;
  138. var decisionOpinionList = route.decisionOpinion.split("#");
  139. decisionOpinionList.each( function( decisionOption ){
  140. this.routeGroupNameList.combine( [decisionOption] );
  141. var d = this.splitByStartNumber( decisionOption );
  142. if( !this.routeGroupObject[ d.name ] )this.routeGroupObject[ d.name ] = [];
  143. this.routeGroupObject[ d.name ].push( route );
  144. }.bind(this))
  145. }else{
  146. var defaultName = MWF.xApplication.process.Work.LP.defaultDecisionOpinionName;
  147. this.routeGroupNameList.combine( [defaultName] );
  148. if( !this.routeGroupObject[ defaultName ] )this.routeGroupObject[ defaultName ] = [];
  149. this.routeGroupObject[ defaultName].push( route );
  150. }
  151. }.bind(this));
  152. return this.routeGroupObject;
  153. },
  154. splitByStartNumber : function( str ){
  155. var obj = {
  156. name : "",
  157. order : ""
  158. };
  159. for( var i=0; i<str.length; i++ ){
  160. if( parseInt(str.substr(i,1)).toString() !== "NaN" ){
  161. obj.order = obj.order + str.substr(i,1);
  162. }else{
  163. obj.name = str.substr( i, str.length );
  164. break;
  165. }
  166. }
  167. return obj;
  168. },
  169. setRouteGroupList : function(){
  170. var _self = this;
  171. //var keys = Object.keys( this.routeGroupObject );
  172. //var length = keys.length;
  173. //var sortArray = MWF.xApplication.process.Work.LP.routeGroupOrderList;
  174. //keys.sort( function( a, b ){
  175. // var aIdx = sortArray.indexOf(a);
  176. // var bIdx = sortArray.indexOf(b);
  177. // if( aIdx === -1 )aIdx = sortArray.length;
  178. // if( bIdx === -1 )aIdx = sortArray.length;
  179. // return aIdx - bIdx;
  180. //});
  181. var keys = this.routeGroupNameList;
  182. keys.sort( function( a, b ){
  183. var aIdx = parseInt(this.splitByStartNumber( a ).order || "9999999");
  184. var bIdx = parseInt(this.splitByStartNumber( b ).order || "9999999");
  185. return aIdx - bIdx;
  186. }.bind(this));
  187. var list = [];
  188. keys.each( function( k ){
  189. list.push( this.splitByStartNumber( k).name )
  190. }.bind(this));
  191. var flag = false;
  192. list.each( function( routeGroupName ){
  193. var routeList = this.routeGroupObject[routeGroupName];
  194. var routeGroupNode = new Element("div", {"styles": this.css.routeGroupNode, "text": routeGroupName}).inject(this.routeGroupArea);
  195. routeGroupNode.store( "routeList", routeList );
  196. routeGroupNode.store( "routeGroupName", routeGroupName );
  197. routeGroupNode.addEvents({
  198. "mouseover": function(e){_self.overRouteGroup(this);},
  199. "mouseout": function(e){_self.outRouteGroup(this);},
  200. "click": function(e){_self.selectRouteGroup(this);}
  201. });
  202. if ( keys.length === 1 ){
  203. this.selectRouteGroup(routeGroupNode);
  204. flag = false;
  205. }else{
  206. flag = true;
  207. }
  208. }.bind(this))
  209. if( flag ){
  210. this.setSize(0);
  211. }
  212. },
  213. overRouteGroup: function(node){
  214. if (this.selectedRouteGroup){
  215. if (this.selectedRouteGroup.get("text") != node.get("text")){
  216. node.setStyles(this.css.routeGroupNode_over);
  217. }
  218. }else{
  219. node.setStyles(this.css.routeGroupNode_over);
  220. }
  221. },
  222. outRouteGroup: function(node){
  223. if (this.selectedRouteGroup){
  224. if (this.selectedRouteGroup.get("text") != node.get("text")){
  225. node.setStyles(this.css.routeGroupNode);
  226. }
  227. }else{
  228. node.setStyles(this.css.routeGroupNode);
  229. }
  230. },
  231. selectRouteGroup: function(node){
  232. if (this.selectedRouteGroup){
  233. if (this.selectedRouteGroup.get("text") != node.get("text")){
  234. this.selectedRouteGroup.setStyles(this.css.routeGroupNode);
  235. //this.selectedRouteGroup.removeClass("mainColor_bg");
  236. this.selectedRouteGroup = node;
  237. this.selectedRouteGroup.setStyles(this.css.routeGroupNode_selected);
  238. //this.selectedRouteGroup.addClass("mainColor_bg");
  239. var routeList = this.selectedRouteGroup.retrieve("routeList");
  240. this.setRouteList( routeList );
  241. }else{
  242. //this.selectedRouteGroup.setStyles(this.css.routeNode);
  243. //this.selectedRouteGroup.getFirst().setStyles(this.css.routeIconNode);
  244. //this.selectedRouteGroup.getLast().setStyles(this.css.routeTextNode);
  245. //
  246. //this.selectedRouteGroup = null;
  247. }
  248. }else{
  249. this.selectedRouteGroup = node;
  250. node.setStyles(this.css.routeGroupNode_selected);
  251. //this.selectedRouteGroup.addClass("mainColor_bg");
  252. var routeList = this.selectedRouteGroup.retrieve("routeList");
  253. this.setRouteList( routeList );
  254. }
  255. this.routeGroupArea.setStyle("background-color", "#FFF");
  256. },
  257. setRouteList_noform: function( routeList ){
  258. var _self = this;
  259. this.routeSelectorArea.empty();
  260. this.selectedRoute = null;
  261. //this.task.routeNameList = ["送审核", "送办理", "送公司领导阅"];
  262. if( !routeList )routeList = this.getRouteDataList();
  263. routeList.each(function(route, i){
  264. var routeName = route.name;
  265. var routeNode = new Element("div", {"styles": this.css.routeNode, "text": routeName}).inject(this.routeSelectorArea);
  266. routeNode.store( "route", route.id );
  267. routeNode.store( "routeName", route.name );
  268. routeNode.addEvents({
  269. "mouseover": function(e){_self.overRoute(this);},
  270. "mouseout": function(e){_self.outRoute(this);},
  271. "click": function(e){_self.selectRoute_noform(this);}
  272. });
  273. if (routeList.length==1 || route.sole ){
  274. this.selectRoute_noform(routeNode);
  275. }
  276. }.bind(this));
  277. },
  278. setRouteList: function( routeList ){
  279. var _self = this;
  280. //if( this.hasDecisionOpinion && this.getMaxOrgLength() === 1 ){
  281. // if( this.routeSelectorArea )this.routeSelectorArea.destroy();
  282. // this.routeSelectorArea = new Element("div", { styles : this.css.routeSelectorArea_hasGroup_single }).inject( this.selectedRouteGroup, "after" );
  283. //}else{
  284. this.routeSelectorArea.empty();
  285. //}
  286. this.selectedRoute = null;
  287. //this.task.routeNameList = ["送审核", "送办理", "送公司领导阅"];
  288. if( !routeList )routeList = this.getRouteDataList();
  289. //this.task.routeNameList.each(function(route, i){
  290. var isSelected = false;
  291. routeList.each(function(route, i){
  292. if( route.hiddenScriptText && this.form && this.form.Macro ){
  293. if( this.form.Macro.exec(route.hiddenScriptText, this).toString() === "true" )return;
  294. }
  295. var routeName = route.name;
  296. if( route.displayNameScriptText && this.form && this.form.Macro ){
  297. routeName = this.form.Macro.exec(route.displayNameScriptText, this);
  298. }
  299. var routeNode = new Element("div", {"styles": this.css.routeNode, "text": routeName}).inject(this.routeSelectorArea);
  300. //var routeIconNode = new Element("div", {"styles": this.css.routeIconNode}).inject(routeNode);
  301. //var routeTextNode = new Element("div", {"styles": this.css.routeTextNode, "text": routeName}).inject(routeNode);
  302. routeNode.store( "route", route.id );
  303. routeNode.store( "routeName", route.name );
  304. routeNode.addEvents({
  305. "mouseover": function(e){_self.overRoute(this);},
  306. "mouseout": function(e){_self.outRoute(this);},
  307. "click": function(e){_self.selectRoute(this);}
  308. });
  309. if (routeList.length==1 || route.sole ){ //sole表示优先路由
  310. this.selectRoute(routeNode);
  311. isSelected = true;
  312. }
  313. }.bind(this));
  314. if( !isSelected ){
  315. this.setSize(0);
  316. }
  317. },
  318. overRoute: function(node){
  319. if (this.selectedRoute){
  320. if (this.selectedRoute.get("text") != node.get("text")){
  321. node.setStyles(this.css.routeNode_over);
  322. node.addClass("lightColor_bg");
  323. //node.setStyle("background-color", "#f7e1d0");
  324. }
  325. }else{
  326. node.setStyles(this.css.routeNode_over);
  327. node.addClass("lightColor_bg");
  328. }
  329. },
  330. outRoute: function(node){
  331. if (this.selectedRoute){
  332. if (this.selectedRoute.get("text") != node.get("text")){
  333. node.setStyles(this.css.routeNode);
  334. node.removeClass("lightColor_bg");
  335. }
  336. }else{
  337. node.setStyles(this.css.routeNode);
  338. node.removeClass("lightColor_bg");
  339. }
  340. },
  341. selectRoute_noform: function(node){
  342. if (this.selectedRoute){
  343. if (this.selectedRoute.get("text") != node.get("text")){
  344. this.selectedRoute.setStyles(this.css.routeNode);
  345. this.selectedRoute.removeClass("mainColor_bg");
  346. this.selectedRoute = node;
  347. node.setStyles(this.css.routeNode_selected);
  348. node.addClass("mainColor_bg");
  349. node.removeClass("lightColor_bg");
  350. }else{
  351. this.selectedRoute.setStyles(this.css.routeNode);
  352. this.selectedRoute.addClass("lightColor_bg");
  353. this.selectedRoute.removeClass("mainColor_bg");
  354. this.selectedRoute = null;
  355. }
  356. }else{
  357. this.selectedRoute = node;
  358. node.setStyles(this.css.routeNode_selected);
  359. node.addClass("mainColor_bg");
  360. node.removeClass("lightColor_bg");
  361. }
  362. this.routeSelectorArea.setStyle("background-color", "#FFF");
  363. },
  364. selectRoute: function(node){
  365. if (this.selectedRoute){
  366. if (this.selectedRoute.get("text") != node.get("text")){
  367. this.selectedRoute.setStyles(this.css.routeNode);
  368. this.selectedRoute.removeClass("mainColor_bg");
  369. //this.selectedRoute.getFirst().setStyles(this.css.routeIconNode);
  370. //this.selectedRoute.getLast().setStyles(this.css.routeTextNode);
  371. this.selectedRoute = node;
  372. node.setStyles(this.css.routeNode_selected);
  373. node.addClass("mainColor_bg");
  374. node.removeClass("lightColor_bg");
  375. //node.setStyle("background-color", "#da7429");
  376. //node.getFirst().setStyle("background-image", "url("+"../x_component_process_Work/$Processor/default/checked.png)");
  377. //node.getLast().setStyle("color", "#FFF");
  378. }else{
  379. this.selectedRoute.setStyles(this.css.routeNode);
  380. this.selectedRoute.addClass("lightColor_bg");
  381. this.selectedRoute.removeClass("mainColor_bg");
  382. //this.selectedRoute.getFirst().setStyles(this.css.routeIconNode);
  383. //this.selectedRoute.getLast().setStyles(this.css.routeTextNode);
  384. this.selectedRoute = null;
  385. }
  386. }else{
  387. this.selectedRoute = node;
  388. node.setStyles(this.css.routeNode_selected);
  389. node.addClass("mainColor_bg");
  390. node.removeClass("lightColor_bg");
  391. //node.setStyle("background-color", "#da7429");
  392. //node.getFirst().setStyle("background-image", "url("+"../x_component_process_Work/$Processor/default/checked.png)");
  393. //node.getLast().setStyle("color", "#FFF");
  394. }
  395. this.routeSelectorArea.setStyle("background-color", "#FFF");
  396. if( layout.mobile ){
  397. this.loadOrgs_mobile( this.selectedRoute ? this.selectedRoute.retrieve("route") : "" );
  398. }else{
  399. this.loadOrgs( this.selectedRoute ? this.selectedRoute.retrieve("route") : "" );
  400. }
  401. //临时添加
  402. if(this.form.data.json.events && this.form.data.json.events.afterSelectRoute){
  403. this.form.Macro.exec(this.form.data.json.events.afterSelectRoute.code, node);
  404. }
  405. },
  406. setOpinion: function(){
  407. this.selectIdeaNode = new Element("div", {"styles": this.css.selectIdeaNode}).inject(this.routeOpinionArea);
  408. this.selectIdeaScrollNode = new Element("div", {"styles": this.css.selectIdeaScrollNode}).inject(this.selectIdeaNode);
  409. this.selectIdeaAreaNode = new Element("div", {"styles": {
  410. "overflow": "hidden"
  411. }}).inject(this.selectIdeaScrollNode);
  412. this.inputOpinionNode = new Element("div", {"styles": this.css.inputOpinionNode}).inject(this.routeOpinionArea);
  413. this.inputTextarea = new Element("textarea", {"styles": this.css.inputTextarea, "value": this.options.opinion || MWF.xApplication.process.Work.LP.inputText}).inject(this.inputOpinionNode);
  414. this.inputTextarea.addEvents({
  415. "focus": function(){if (this.get("value")==MWF.xApplication.process.Work.LP.inputText) this.set("value", "");},
  416. "blur": function(){if (!this.get("value")) this.set("value", MWF.xApplication.process.Work.LP.inputText);},
  417. "keydown": function(){this.inputTextarea.setStyles( this.inputTextareaStyle || this.css.inputTextarea);}.bind(this)
  418. });
  419. this.mediaActionArea = new Element("div", {"styles": this.css.inputOpinionMediaActionArea}).inject(this.inputOpinionNode);
  420. this.handwritingAction = new Element("div", {"styles": this.css.inputOpinionHandwritingAction, "text": MWF.xApplication.process.Work.LP.handwriting}).inject(this.mediaActionArea);
  421. this.handwritingAction.addEvent("click", function(){
  422. if( layout.mobile ){
  423. window.setTimeout( function(){
  424. this.handwriting();
  425. }.bind(this), 100 )
  426. }else{
  427. this.handwriting();
  428. }
  429. }.bind(this));
  430. // if (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia){
  431. // this.audioRecordAction = new Element("div", {"styles": this.css.inputOpinionAudioRecordAction, "text": MWF.xApplication.process.Work.LP.audioRecord}).inject(this.mediaActionArea);
  432. // this.audioRecordAction.addEvent("click", function(){
  433. // this.audioRecord();
  434. // }.bind(this));
  435. // }
  436. if (layout.mobile){
  437. this.selectIdeaNode.inject(this.routeOpinionArea, "after");
  438. }
  439. MWF.require("MWF.widget.ScrollBar", function(){
  440. new MWF.widget.ScrollBar(this.selectIdeaScrollNode, {
  441. "style":"small", "where": "before", "distance": 30, "friction": 4, "indent": false, "axis": {"x": false, "y": true}
  442. });
  443. }.bind(this));
  444. MWF.require("MWF.widget.UUID", function(){
  445. MWF.UD.getDataJson("idea", function(json){
  446. if (json){
  447. if (json.ideas){
  448. this.setIdeaList(json.ideas);
  449. }
  450. }else{
  451. MWF.UD.getPublicData("idea", function(pjson){
  452. if (pjson){
  453. if (pjson.ideas){
  454. this.setIdeaList(pjson.ideas);
  455. }
  456. }
  457. }.bind(this));
  458. }
  459. }.bind(this));
  460. }.bind(this));
  461. },
  462. audioRecord: function(){
  463. if (!this.audioRecordNode) this.createAudioRecord();
  464. this.audioRecordNode.show();
  465. this.audioRecordNode.position({
  466. "relativeTo": this.options.mediaNode || this.node,
  467. "position": "center",
  468. "edge": "center"
  469. });
  470. MWF.require("MWF.widget.AudioRecorder", function () {
  471. this.audioRecorder = new MWF.widget.AudioRecorder(this.audioRecordNode, {
  472. "onSave" : function( blobFile ){
  473. this.soundFile = blobFile;
  474. this.audioRecordNode.hide();
  475. // this.page.get("div_image").node.set("src",base64Image);
  476. }.bind(this),
  477. "onCancel": function(){
  478. this.soundFile = null;
  479. this.audioRecordNode.hide();
  480. }.bind(this)
  481. }, null );
  482. }.bind(this));
  483. },
  484. createAudioRecord: function(){
  485. this.audioRecordNode = new Element("div", {"styles": this.css.handwritingNode}).inject(this.node, "after");
  486. var size = (this.options.mediaNode || this.node).getSize();
  487. // var y = Math.max(size.y, 320);
  488. // var x = Math.max(size.x, 400);
  489. // for (k in this.node.style){
  490. // if (this.node.style[k]) this.audioRecordNode.style[k] = this.node.style[k];
  491. // }
  492. var zidx = this.node.getStyle("z-index");
  493. this.audioRecordNode.setStyles({
  494. "height": ""+size.y+"px",
  495. "width": ""+size.x+"px",
  496. "z-index": zidx+1
  497. });
  498. },
  499. handwriting: function(){
  500. if (!this.handwritingNode) this.createHandwriting();
  501. if(this.handwritingNodeMask)this.handwritingNodeMask.show();
  502. this.handwritingNode.show();
  503. if( layout.mobile ){
  504. this.handwritingNode.setStyles({
  505. "top": "0px",
  506. "left": "0px"
  507. });
  508. }else{
  509. this.handwritingNode.position({
  510. "relativeTo": this.options.mediaNode || this.node,
  511. "position": "center",
  512. "edge": "center"
  513. });
  514. }
  515. },
  516. createHandwriting: function(){
  517. this.handwritingNodeMask = new Element("div.handwritingMask", {"styles": this.css.handwritingMask}).inject(this.node);
  518. this.handwritingNode = new Element("div.handwritingNode", {"styles": this.css.handwritingNode}).inject(this.node, "after");
  519. //var size = (this.options.mediaNode || this.node).getSize();
  520. //var y = size.y;
  521. //var x = size.x;
  522. //兼容以前的默认高宽
  523. var x = 600;
  524. var y = 320;
  525. if (!layout.mobile){
  526. x = Math.max( this.options.tabletWidth || x , 500);
  527. y = Math.max(this.options.tabletHeight ? (parseInt(this.options.tabletHeight) + 110) : y, 320);
  528. //y = Math.max(size.y, 320);
  529. //x = Math.max(size.x, 480);
  530. }else{
  531. var bodySize = $(document.body).getSize();
  532. x = bodySize.x;
  533. y = bodySize.y;
  534. this.options.tabletWidth = 0;
  535. this.options.tabletHeight = 0;
  536. }
  537. // for (k in this.node.style){
  538. // if (this.node.style[k]) this.handwritingNode.style[k] = this.node.style[k];
  539. // }
  540. var zidx = this.node.getStyle("z-index");
  541. this.handwritingNode.setStyles({
  542. "height": ""+y+"px",
  543. "width": ""+x+"px",
  544. "z-index": zidx+1
  545. });
  546. if( layout.mobile ){
  547. debugger;
  548. this.handwritingNode.addEvent('touchmove' , function(e){
  549. e.preventDefault();
  550. });
  551. this.handwritingNode.setStyles({
  552. "top": "0px",
  553. "left": "0px"
  554. });
  555. //this.handwritingNode.position({
  556. // "relativeTo": this.node,
  557. // "position": "center",
  558. // "edge": "center"
  559. //});
  560. }else{
  561. this.handwritingNode.position({
  562. "relativeTo": this.options.mediaNode || this.node,
  563. "position": "center",
  564. "edge": "center"
  565. });
  566. }
  567. this.handwritingAreaNode = new Element("div", {"styles": this.css.handwritingAreaNode}).inject(this.handwritingNode);
  568. this.handwritingActionNode = new Element("div", {"styles": this.css.handwritingActionNode, "text": MWF.xApplication.process.Work.LP.saveWrite}).inject(this.handwritingNode);
  569. var h = this.handwritingActionNode.getSize().y+this.handwritingActionNode.getStyle("margin-top").toInt()+this.handwritingActionNode.getStyle("margin-bottom").toInt();
  570. h = y - h;
  571. this.handwritingAreaNode.setStyle("height", ""+h+"px");
  572. MWF.require("MWF.widget.Tablet", function () {
  573. var handWritingOptions = {
  574. "style": "default",
  575. "contentWidth" : this.options.tabletWidth || 0,
  576. "contentHeight" : this.options.tabletHeight || 0,
  577. "onSave" : function( base64code, base64Image, imageFile ){
  578. this.handwritingFile = imageFile;
  579. this.handwritingNode.hide();
  580. this.handwritingNodeMask.hide();
  581. // this.page.get("div_image").node.set("src",base64Image);
  582. }.bind(this),
  583. "onCancel": function(){
  584. this.handwritingFile = null;
  585. this.handwritingNode.hide();
  586. this.handwritingNodeMask.hide();
  587. }.bind(this)
  588. };
  589. if( layout.mobile ){
  590. handWritingOptions.tools = [
  591. "undo",
  592. "redo", "|",
  593. "reset", "|",
  594. "size",
  595. "cancel"
  596. ]
  597. }
  598. this.tablet = new MWF.widget.Tablet(this.handwritingAreaNode, handWritingOptions, null );
  599. this.tablet.load();
  600. }.bind(this));
  601. this.handwritingActionNode.addEvent("click", function(){
  602. //this.handwritingNode.hide();
  603. if (this.tablet) this.tablet.save();
  604. }.bind(this));
  605. },
  606. setIdeaList: function(ideas){
  607. var _self = this;
  608. ideas.each(function(idea){
  609. if( !idea )return;
  610. new Element("div", {
  611. "styles": this.css.selectIdeaItemNode,
  612. "text": idea,
  613. "events": {
  614. "click": function(){
  615. if (_self.inputTextarea.get("value")==MWF.xApplication.process.Work.LP.inputText){
  616. _self.inputTextarea.set("value", this.get("text"));
  617. }else{
  618. _self.inputTextarea.set("value", _self.inputTextarea.get("value")+", "+this.get("text"));
  619. }
  620. },
  621. "dblclick": function(){
  622. if (_self.inputTextarea.get("value")==MWF.xApplication.process.Work.LP.inputText){
  623. _self.inputTextarea.set("value", this.get("text"));
  624. }else{
  625. _self.inputTextarea.set("value", _self.inputTextarea.get("value")+", "+this.get("text"));
  626. }
  627. },
  628. "mouseover": function(){this.setStyles(_self.css.selectIdeaItemNode_over);},
  629. "mouseout": function(){this.setStyles(_self.css.selectIdeaItemNode);}
  630. }
  631. }).inject(this.selectIdeaAreaNode);
  632. }.bind(this));
  633. },
  634. setButtons: function(){
  635. this.cancelButton = new Element("div", {"styles": this.css.cancelButton}).inject(this.buttonsArea);
  636. var iconNode = new Element("div", {"styles": this.css.cancelIconNode}).inject(this.cancelButton);
  637. var textNode = new Element("div", {"styles": this.css.cancelTextNode, "text": MWF.xApplication.process.Work.LP.cancel}).inject(this.cancelButton);
  638. this.okButton = new Element("div", {"styles": this.css.okButton}).inject(this.buttonsArea);
  639. var iconNode = new Element("div", {"styles": this.css.okIconNode}).inject(this.okButton);
  640. var textNode = new Element("div", {"styles": this.css.okTextNode, "text": MWF.xApplication.process.Work.LP.ok}).inject(this.okButton);
  641. this.cancelButton.addEvent("click", function(){
  642. this.destroy();
  643. this.fireEvent("cancel");
  644. }.bind(this));
  645. this.okButton.addEvent("click", function( ev ){
  646. if( layout.mobile ){
  647. this.submit_mobile(ev)
  648. }else{
  649. this.submit_pc(ev)
  650. }
  651. }.bind(this));
  652. },
  653. submit_mobile : function(ev){
  654. if (this.hasDecisionOpinion && !this.selectedRouteGroup) {
  655. this.routeGroupArea.setStyle("background-color", "#ffe9e9");
  656. MWF.xDesktop.notice(
  657. "error",
  658. {"x": "center", "y": "top"},
  659. MWF.xApplication.process.Work.LP.mustSelectRouteGroup,
  660. this.routeGroupArea,
  661. null, //{"x": 0, "y": 30}
  662. { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 }
  663. );
  664. return false;
  665. }
  666. if (!this.selectedRoute) {
  667. this.routeSelectorArea.setStyle("background-color", "#ffe9e9");
  668. new mBox.Notice({
  669. type: "error",
  670. position: {"x": "center", "y": "top"},
  671. move: false,
  672. target: this.routeSelectorArea,
  673. delayClose: 6000,
  674. content: MWF.xApplication.process.Work.LP.mustSelectRoute
  675. });
  676. return false;
  677. }
  678. var routeName = this.selectedRoute.retrieve("routeName") || this.selectedRoute.get("text");
  679. var opinion = this.inputTextarea.get("value");
  680. if (opinion === MWF.xApplication.process.Work.LP.inputText) opinion = "";
  681. var medias = [];
  682. if (this.handwritingFile) medias.push(this.handwritingFile);
  683. if (this.soundFile) medias.push(this.soundFile);
  684. if (this.videoFile) medias.push(this.videoFile);
  685. var currentRouteId = this.selectedRoute.retrieve("route");
  686. var routeData = this.getRouteData( currentRouteId );
  687. if( !opinion && medias.length === 0 ){
  688. if( routeData.opinionRequired == true ){
  689. this.inputTextarea.setStyle("background-color", "#ffe9e9");
  690. new mBox.Notice({
  691. type: "error",
  692. position: {"x": "center", "y": "top"},
  693. move: false,
  694. target: this.inputTextarea,
  695. delayClose: 6000,
  696. content: MWF.xApplication.process.Work.LP.opinionRequired
  697. });
  698. return false;
  699. }
  700. }
  701. if( routeData.validationScriptText ){
  702. var validation = this.form.Macro.exec(routeData.validationScriptText, this);
  703. if( !validation || validation.toString() !== "true" ){
  704. if( typeOf(validation) === "string" ){
  705. new mBox.Notice({
  706. type: "error",
  707. position: {"x": "center", "y": "top"},
  708. move: false,
  709. target: this.node,
  710. delayClose: 6000,
  711. content: validation
  712. });
  713. return false;
  714. }else{
  715. //"路由校验失败"
  716. new mBox.Notice({
  717. type: "error",
  718. position: {"x": "center", "y": "top"},
  719. move: false,
  720. target: this.node,
  721. delayClose: 6000,
  722. content: MWF.xApplication.process.Work.LP.routeValidFailure
  723. });
  724. return false;
  725. }
  726. }
  727. }
  728. //var array = [routeName, opinion, medias];
  729. //this.node.mask({
  730. // "inject": {"where": "bottom", "target": this.node},
  731. // "destroyOnHide": true,
  732. // "style": {
  733. // "background-color": "#999",
  734. // "opacity": 0.3,
  735. // "z-index":600
  736. // }
  737. //});
  738. //this.fireEvent("submit", array );
  739. var appendTaskOrgItem;
  740. if( routeData.type === "appendTask" && routeData.appendTaskIdentityType === "select" ){
  741. if( !this.orgItems || this.orgItems.length === 0 ){
  742. new mBox.Notice({
  743. type: "error",
  744. position: {"x": "center", "y": "top"},
  745. move: false,
  746. target: this.orgsArea,
  747. delayClose: 6000,
  748. content: MWF.xApplication.process.Work.LP.noAppendTaskIdentityConfig //"没有配置转交人,请联系管理员"
  749. });
  750. return false;
  751. }else{
  752. appendTaskOrgItem = this.orgItems[0]
  753. }
  754. }
  755. if( !this.saveOrgs() )return false;
  756. //this.saveOrgsWithCheckEmpower( function(){
  757. var appandTaskIdentityList;
  758. if( appendTaskOrgItem ){
  759. appandTaskIdentityList = appendTaskOrgItem.getData();
  760. if( !appandTaskIdentityList || appandTaskIdentityList.length === 0){
  761. new mBox.Notice({
  762. type: "error",
  763. position: {"x": "center", "y": "top"},
  764. move: false,
  765. target: this.orgsArea,
  766. delayClose: 6000,
  767. content: MWF.xApplication.process.Work.LP.selectAppendTaskIdentityNotice //"请选择转交人"
  768. });
  769. return;
  770. }
  771. }
  772. if( routeData.validationScriptText ){
  773. var validation = this.form.Macro.exec(routeData.validationScriptText, this);
  774. if( !validation || validation.toString() !== "true" ){
  775. if( typeOf(validation) === "string" ){
  776. MWF.xDesktop.notice(
  777. "error",
  778. {"x": "center", "y": "center"},
  779. validation,
  780. this.node,
  781. {"x": 0, "y": 30},
  782. { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 }
  783. );
  784. return false;
  785. }else{
  786. //"路由校验失败"
  787. MWF.xDesktop.notice(
  788. "error",
  789. {"x": "center", "y": "center"},
  790. MWF.xApplication.process.Work.LP.routeValidFailure,
  791. this.node,
  792. {"x": 0, "y": 30},
  793. { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 }
  794. );
  795. return false;
  796. }
  797. }
  798. }
  799. this.node.mask({
  800. "inject": {"where": "bottom", "target": this.node},
  801. "destroyOnHide": true,
  802. "style": {
  803. "background-color": "#999",
  804. "opacity": 0.3,
  805. "z-index":600
  806. }
  807. });
  808. var array = [ routeName, opinion, medias, appandTaskIdentityList, this.orgItems, function(){
  809. if(appendTaskOrgItem)appendTaskOrgItem.setData([]);
  810. }];
  811. this.fireEvent("submit", array );
  812. //}.bind(this))
  813. },
  814. submit_pc : function(ev){
  815. if (this.hasDecisionOpinion && !this.selectedRouteGroup) {
  816. this.routeGroupArea.setStyle("background-color", "#ffe9e9");
  817. MWF.xDesktop.notice(
  818. "error",
  819. {"x": "center", "y": "top"},
  820. MWF.xApplication.process.Work.LP.mustSelectRouteGroup,
  821. this.routeGroupArea,
  822. null, //{"x": 0, "y": 30}
  823. { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 }
  824. );
  825. return false;
  826. }
  827. if (!this.selectedRoute) {
  828. this.routeSelectorArea.setStyle("background-color", "#ffe9e9");
  829. //new mBox.Notice({
  830. // type: "error",
  831. // position: {"x": "center", "y": "top"},
  832. // move: false,
  833. // target: this.routeSelectorArea,
  834. // delayClose: 6000,
  835. // content: MWF.xApplication.process.Work.LP.mustSelectRoute
  836. //});
  837. MWF.xDesktop.notice(
  838. "error",
  839. {"x": "center", "y": "top"},
  840. MWF.xApplication.process.Work.LP.mustSelectRoute,
  841. this.routeSelectorArea,
  842. null, //{"x": 0, "y": 30}
  843. { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 }
  844. );
  845. return false;
  846. }
  847. var routeName = this.selectedRoute.retrieve("routeName") || this.selectedRoute.get("text");
  848. var opinion = this.inputTextarea.get("value");
  849. if (opinion === MWF.xApplication.process.Work.LP.inputText) opinion = "";
  850. var medias = [];
  851. if (this.handwritingFile) medias.push(this.handwritingFile);
  852. if (this.soundFile) medias.push(this.soundFile);
  853. if (this.videoFile) medias.push(this.videoFile);
  854. var currentRouteId = this.selectedRoute.retrieve("route");
  855. var routeData = this.getRouteData( currentRouteId );
  856. if( !opinion && medias.length === 0 ){
  857. if( routeData.opinionRequired == true ){
  858. this.inputTextarea.setStyle("background-color", "#ffe9e9");
  859. //new mBox.Notice({
  860. // type: "error",
  861. // position: {"x": "center", "y": "top"},
  862. // move: false,
  863. // target: this.inputTextarea,
  864. // delayClose: 6000,
  865. // content: MWF.xApplication.process.Work.LP.opinionRequired
  866. //});
  867. MWF.xDesktop.notice(
  868. "error",
  869. {"x": "center", "y": "top"},
  870. MWF.xApplication.process.Work.LP.opinionRequired,
  871. this.inputTextarea,
  872. null, //{"x": 0, "y": 30}
  873. { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 }
  874. );
  875. return false;
  876. }
  877. }
  878. var appendTaskOrgItem = "";
  879. if( routeData.type === "appendTask" && routeData.appendTaskIdentityType === "select" ){
  880. if( !this.orgItems || this.orgItems.length === 0 ){
  881. //new mBox.Notice({
  882. // type: "error",
  883. // position: {"x": "center", "y": "top"},
  884. // move: false,
  885. // target: this.orgsArea,
  886. // delayClose: 6000,
  887. // content: MWF.xApplication.process.Work.LP.noAppendTaskIdentityConfig //"没有配置转交人,请联系管理员"
  888. //});
  889. MWF.xDesktop.notice(
  890. "error",
  891. {"x": "center", "y": "center"},
  892. MWF.xApplication.process.Work.LP.noAppendTaskIdentityConfig,
  893. this.node,
  894. null, //{"x": 0, "y": 30}
  895. { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 }
  896. );
  897. return false;
  898. }else{
  899. appendTaskOrgItem = this.orgItems[0]
  900. }
  901. }
  902. this.saveOrgsWithCheckEmpower( function(){
  903. var appandTaskIdentityList;
  904. if( appendTaskOrgItem ){
  905. appandTaskIdentityList = appendTaskOrgItem.getData();
  906. if( !appandTaskIdentityList || appandTaskIdentityList.length === 0){
  907. //new mBox.Notice({
  908. // type: "error",
  909. // position: {"x": "center", "y": "top"},
  910. // move: false,
  911. // target: this.orgsArea,
  912. // delayClose: 6000,
  913. // content: MWF.xApplication.process.Work.LP.selectAppendTaskIdentityNotice //"请选择转交人"
  914. //});
  915. MWF.xDesktop.notice(
  916. "error",
  917. {"x": "center", "y": "center"},
  918. MWF.xApplication.process.Work.LP.selectAppendTaskIdentityNotice,
  919. this.node,
  920. {"x": 0, "y": 30},
  921. { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 }
  922. );
  923. return;
  924. }
  925. }
  926. if( routeData.validationScriptText ){
  927. var validation = this.form.Macro.exec(routeData.validationScriptText, this);
  928. if( !validation || validation.toString() !== "true" ){
  929. if( typeOf(validation) === "string" ){
  930. MWF.xDesktop.notice(
  931. "error",
  932. {"x": "center", "y": "center"},
  933. validation,
  934. this.node,
  935. {"x": 0, "y": 30},
  936. { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 }
  937. );
  938. return false;
  939. }else{
  940. //"路由校验失败"
  941. MWF.xDesktop.notice(
  942. "error",
  943. {"x": "center", "y": "center"},
  944. MWF.xApplication.process.Work.LP.routeValidFailure,
  945. this.node,
  946. {"x": 0, "y": 30},
  947. { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 }
  948. );
  949. return false;
  950. }
  951. }
  952. }
  953. this.node.mask({
  954. "inject": {"where": "bottom", "target": this.node},
  955. "destroyOnHide": true,
  956. "style": {
  957. "background-color": "#999",
  958. "opacity": 0.3,
  959. "z-index":600
  960. }
  961. });
  962. var array = [ routeName, opinion, medias, appandTaskIdentityList, this.orgItems, function(){
  963. if(appendTaskOrgItem)appendTaskOrgItem.setData([]);
  964. }];
  965. this.fireEvent("submit", array );
  966. }.bind(this))
  967. },
  968. destroy: function(){
  969. this.node.empty();
  970. delete this.task;
  971. delete this.node;
  972. delete this.routeSelectorTile;
  973. delete this.routeSelectorArea;
  974. delete this.routeOpinionTile;
  975. delete this.routeOpinionArea;
  976. delete this.buttonsArea;
  977. delete this.inputOpinionNode;
  978. delete this.inputTextarea;
  979. delete this.cancelButton;
  980. delete this.okButton;
  981. },
  982. getRouteDataList : function(){
  983. if( !this.routeDataList ){
  984. o2.Actions.get("x_processplatform_assemble_surface").listRoute( {"valueList":this.task.routeList} , function( json ){
  985. json.data.each( function(d){
  986. d.selectConfigList = JSON.parse( d.selectConfig || "[]" );
  987. }.bind(this));
  988. this.routeDataList = json.data;
  989. }.bind(this), null, false );
  990. }
  991. return this.routeDataList;
  992. },
  993. getRouteData : function( routeId ){
  994. var routeList = this.getRouteDataList();
  995. for( var i=0; i<routeList.length; i++ ){
  996. if( routeList[i].id === routeId ){
  997. return routeList[i];
  998. }
  999. }
  1000. },
  1001. getMaxOrgLength : function(){
  1002. var routeList = this.getRouteDataList();
  1003. var length = 0;
  1004. routeList.each( function(route){
  1005. if( route.hiddenScriptText ){ //如果隐藏路由,返回
  1006. if( this.form.Macro.exec(route.hiddenScriptText, this).toString() === "true" )return;
  1007. }
  1008. length = Math.max( length, route.selectConfigList.length);
  1009. }.bind(this));
  1010. return length;
  1011. },
  1012. getOrgData : function( routeId ){
  1013. var routeList = this.getRouteDataList();
  1014. for( var i=0; i<routeList.length; i++ ){
  1015. if( routeList[i].id === routeId ){
  1016. return routeList[i].selectConfigList;
  1017. }
  1018. }
  1019. },
  1020. loadOrgs_mobile : function( route ){
  1021. if( !this.form || !route ){
  1022. this.orgsArea.hide();
  1023. return;
  1024. }else{
  1025. this.orgsArea.show();
  1026. }
  1027. if( !this.orgTableObject )this.orgTableObject = {};
  1028. if( !this.orgItemsObject )this.orgItemsObject = {};
  1029. var isLoaded = false;
  1030. for( var key in this.orgTableObject ){
  1031. if( route === key ){
  1032. this.orgTableObject[key].show();
  1033. this.orgItems = this.orgItemsObject[key] || [];
  1034. var data = this.getOrgData( route );
  1035. isLoaded = true;
  1036. }else{
  1037. this.orgTableObject[key].hide();
  1038. }
  1039. }
  1040. if( isLoaded )return;
  1041. this.orgItems = [];
  1042. this.orgItemsObject[route] = this.orgItems;
  1043. var data = this.getOrgData( route );
  1044. var routeConfig = this.getRouteData( route );
  1045. var ignoreFirstOrgOldData = false; //(routeConfig.type === "appendTask" && routeConfig.appendTaskIdentityType === "select");
  1046. this.setSize( data.length );
  1047. if( data.length ){
  1048. this.orgsArea.show();
  1049. var routeOrgTable = new Element("div",{
  1050. "styles" : this.css.routeOrgTable
  1051. }).inject( this.orgsArea );
  1052. this.orgTableObject[route] = routeOrgTable;
  1053. data.each( function( config, i ){
  1054. var sNode = new Element("div",{
  1055. "styles" : this.css.routeOrgTr
  1056. }).inject( routeOrgTable );
  1057. this.loadOrg_mobile( sNode, config, ignoreFirstOrgOldData && i==0 )
  1058. }.bind(this))
  1059. }else{
  1060. this.orgsArea.hide();
  1061. }
  1062. },
  1063. loadOrg_mobile : function( container, json, ignoreOldData ){
  1064. var titleNode = new Element("div.selectorTitle", {
  1065. "styles" : this.css.selectorTitle
  1066. }).inject(container);
  1067. var titleTextNode = new Element("div.selectorTitleText", {
  1068. "text": json.title,
  1069. "styles" : this.css.selectorTitleText
  1070. }).inject(titleNode);
  1071. var contentNode = new Element("div.selectorContent", {
  1072. "styles" : this.css.selectorContent
  1073. }).inject(container);
  1074. var errorNode = new Element("div.selectorErrorNode", {
  1075. "styles" : this.css.selectorErrorNode
  1076. }).inject(container);
  1077. var org = new MWF.xApplication.process.Work.Processor.Org( contentNode, this.form, json, this, {
  1078. onSelect : function(items, data){
  1079. if( !data || !data.length ){
  1080. contentNode.setStyles( this.css.selectorContent_noItem );
  1081. }else{
  1082. contentNode.setStyles( this.css.selectorContent );
  1083. }
  1084. }.bind(this)
  1085. });
  1086. org.ignoreOldData = ignoreOldData;
  1087. org.errContainer = errorNode;
  1088. org.summitDlalog = this;
  1089. this.orgItems.push( org );
  1090. titleNode.addEvent("click", function(){
  1091. this.load();
  1092. }.bind(org));
  1093. contentNode.addEvent("click", function(){
  1094. this.load();
  1095. }.bind(org));
  1096. var defaultValue = org.getValue();
  1097. org.loadOrgWidget( defaultValue, contentNode );
  1098. if( !defaultValue || defaultValue.length == 0){{
  1099. contentNode.setStyles( this.css.selectorContent_noItem );
  1100. }}
  1101. },
  1102. loadOrgs : function( route ){
  1103. if( !this.form || !route ){
  1104. this.orgsArea.hide();
  1105. this.setSize( 0 );
  1106. return;
  1107. }else{
  1108. this.orgsArea.show();
  1109. }
  1110. if( !this.orgTableObject )this.orgTableObject = {};
  1111. if( !this.orgItemsObject )this.orgItemsObject = {};
  1112. var isLoaded = false;
  1113. for( var key in this.orgTableObject ){
  1114. if( route === key ){
  1115. this.orgTableObject[key].show();
  1116. this.orgItems = this.orgItemsObject[key] || [];
  1117. var data = this.getOrgData( route );
  1118. this.setSize( data.length );
  1119. isLoaded = true;
  1120. }else{
  1121. this.orgTableObject[key].hide();
  1122. }
  1123. }
  1124. if( isLoaded )return;
  1125. this.orgItems = [];
  1126. this.orgItemsObject[route] = this.orgItems;
  1127. var data = this.getOrgData( route );
  1128. var routeConfig = this.getRouteData( route );
  1129. var ignoreFirstOrgOldData = false; //(routeConfig.type === "appendTask" && routeConfig.appendTaskIdentityType === "select");
  1130. this.setSize( data.length );
  1131. if( data.length ){
  1132. this.orgsArea.show();
  1133. var len = data.length;
  1134. var routeOrgTable = new Element("table",{
  1135. "cellspacing" : 0, "cellpadding" : 0, "border" : 0, "width" : "100%",
  1136. "styles" : this.css.routeOrgTable
  1137. }).inject( this.orgsArea );
  1138. this.orgTableObject[route] = routeOrgTable;
  1139. //if( len <= this.options.maxOrgCountPerline ){
  1140. // var width = 1 / len * 100;
  1141. // var tr = new Element("tr").inject( routeOrgTable );
  1142. // for (var n=0; n<len; n++){
  1143. // new Element("td", { "width" : width+"%", "styles" : this.css.routeOrgOddTd }).inject( tr );
  1144. // }
  1145. //}else{
  1146. // var lines = ((len+1)/this.options.maxOrgCountPerline).toInt();
  1147. // var width = 1 / this.options.maxOrgCountPerline * 100;
  1148. // for( var n=0; n<lines; n++ ){
  1149. // var tr = new Element("tr").inject( routeOrgTable );
  1150. // for( var i=0; i<this.options.maxOrgCountPerline; i++ ){
  1151. // new Element("td", { "width" : width+"%", "styles" : this.css.routeOrgOddTd }).inject( tr );
  1152. // }
  1153. // }
  1154. //}
  1155. //
  1156. //var tds = routeOrgTable.getElements("td");
  1157. //data.each( function( config, i ){
  1158. // this.loadOrg( tds[i], config )
  1159. //}.bind(this))
  1160. var lines = ((len+1)/2).toInt();
  1161. for (var n=0; n<lines; n++){
  1162. var tr = new Element("tr").inject( routeOrgTable );
  1163. new Element("td", { "width" : "50%", "valign" : "bottom", "styles" : this.css.routeOrgOddTd }).inject( tr );
  1164. new Element("td", { "width" : "50%", "valign" : "bottom", "styles" : this.css.routeOrgEvenTd }).inject( tr );
  1165. }
  1166. var trs = routeOrgTable.getElements("tr");
  1167. data.each( function( config, i ){
  1168. var sNode;
  1169. var width;
  1170. if (i+1==len && (len % 2===1)){
  1171. sNode = trs[trs.length-1].getFirst("td");
  1172. sNode.set("colspan", 2);
  1173. trs[trs.length-1].getLast("td").destroy();
  1174. sNode.setStyle("border","0px");
  1175. sNode.set("width","100%");
  1176. this.loadOrg( sNode, config, "all", ignoreFirstOrgOldData && i==0)
  1177. }else{
  1178. var row = ((i+2)/2).toInt();
  1179. var tr = trs[row-1];
  1180. sNode = (i % 2===0) ? tr.getFirst("td") : tr.getLast("td");
  1181. this.loadOrg( sNode, config, (i % 2===0) ? "left" : "right", ignoreFirstOrgOldData && i==0 )
  1182. }
  1183. }.bind(this))
  1184. }else{
  1185. this.orgsArea.hide();
  1186. }
  1187. },
  1188. loadOrg : function( container, json, position, ignoreOldData ){
  1189. var titleNode = new Element("div.selectorTitle", {
  1190. "styles" : this.css.selectorTitle
  1191. }).inject(container);
  1192. var titleTextNode = new Element("div.selectorTitleText", {
  1193. "text": json.title,
  1194. "styles" : this.css.selectorTitleText
  1195. }).inject(titleNode);
  1196. var errorNode = new Element("div.selectorErrorNode", {
  1197. "styles" : this.css.selectorErrorNode
  1198. }).inject(titleNode);
  1199. var contentNode = new Element("div.selectorContent", {
  1200. "styles" : this.css.selectorContent
  1201. }).inject(container);
  1202. var org = new MWF.xApplication.process.Work.Processor.Org( contentNode, this.form, json, this );
  1203. org.ignoreOldData = ignoreOldData;
  1204. org.errContainer = errorNode;
  1205. org.summitDlalog = this;
  1206. org.load();
  1207. this.orgItems.push( org )
  1208. },
  1209. showOrgsByRoute : function( route ){
  1210. //debugger;
  1211. this.loadOrgs( route );
  1212. },
  1213. clearAllOrgs : function(){
  1214. //清空组织所选人
  1215. for( var key in this.orgItemsObject ){
  1216. var orgItems = this.orgItemsObject[key] || [];
  1217. orgItems.each( function(org){
  1218. org.setDataToOriginal();
  1219. })
  1220. }
  1221. //
  1222. this.orgTableObject = {};
  1223. this.orgItemsObject = {};
  1224. this.orgsArea.empty();
  1225. },
  1226. getCurrentRouteSelectorList : function(){
  1227. var selectorList = [];
  1228. var currentRoute = this.selectedRoute ? this.selectedRoute.retrieve("route") : "";
  1229. var orgList = this.orgItemsObject[currentRoute];
  1230. if( !orgList )return [];
  1231. orgList.each( function( org ){
  1232. if( org.selector && org.selector.selector ){
  1233. selectorList.push( org.selector.selector );
  1234. }
  1235. }.bind(this))
  1236. return selectorList;
  1237. },
  1238. getCurrentRouteOrgList : function(){
  1239. var currentRoute = this.selectedRoute ? this.selectedRoute.retrieve("route") : "";
  1240. var orgList = this.orgItemsObject[currentRoute];
  1241. return orgList || [];
  1242. },
  1243. getSelectorSelectedData : function( filedName ){
  1244. var data = [];
  1245. var orgList = this.getCurrentRouteOrgList();
  1246. for( var i=0; i<orgList.length; i++ ){
  1247. var org = orgList[i];
  1248. if( org.json.name === filedName ){
  1249. var selector = org.selector.selector;
  1250. selector.selectedItems.each( function(item){
  1251. data.push( item.data )
  1252. })
  1253. }
  1254. }
  1255. return data;
  1256. },
  1257. getOffsetY : function(node){
  1258. return (node.getStyle("margin-top").toInt() || 0 ) +
  1259. (node.getStyle("margin-bottom").toInt() || 0 ) +
  1260. (node.getStyle("padding-top").toInt() || 0 ) +
  1261. (node.getStyle("padding-bottom").toInt() || 0 )+
  1262. (node.getStyle("border-top-width").toInt() || 0 ) +
  1263. (node.getStyle("border-bottom-width").toInt() || 0 );
  1264. },
  1265. setSize_noform : function(){
  1266. var height = 0;
  1267. if( this.managerProcessNoticeNode )height = height + this.getOffsetY(this.managerProcessNoticeNode) + this.managerProcessNoticeNode.getStyle("height").toInt();
  1268. if( this.managerLoginNode )height = height + this.getOffsetY(this.managerLoginNode) + this.managerLoginNode.getStyle("height").toInt();
  1269. if( this.routeSelectorTile )height = height + this.getOffsetY(this.routeSelectorTile) + this.routeSelectorTile.getStyle("height").toInt();
  1270. if( this.routeSelectorArea )height = height + this.getOffsetY(this.routeSelectorArea) + this.routeSelectorArea.getStyle("height").toInt();
  1271. if( this.routeOpinionTile )height = height + this.getOffsetY(this.routeOpinionTile) + this.routeOpinionTile.getStyle("height").toInt();
  1272. if( this.routeOpinionArea )height = height + this.getOffsetY(this.routeOpinionArea) + this.routeOpinionArea.getStyle("height").toInt();
  1273. this.node.setStyle( "height", height );
  1274. this.fireEvent("resize");
  1275. },
  1276. setSize : function( currentOrgLength, flag ){
  1277. if( layout.mobile ){
  1278. this.setSize_mobile();
  1279. }else{
  1280. this.setSize_pc( currentOrgLength, flag );
  1281. }
  1282. //this.node.store("width", this.node.getStyle("width").toInt() + ( flag ? 20 : 0 ));
  1283. if(!flag)this.fireEvent("resize");
  1284. },
  1285. setSize_mobile : function(){
  1286. if( this.buttonsArea ){
  1287. debugger;
  1288. var bodySize = $(document.body).getSize();
  1289. var nodeHeight = bodySize.y - this.getOffsetY(this.node);
  1290. this.node.setStyles({
  1291. "overflow-y": "hidden",
  1292. "height" : nodeHeight
  1293. });
  1294. var buttonsAreaSize = this.buttonsArea.getSize();
  1295. this.content.setStyles({
  1296. "height" : nodeHeight - buttonsAreaSize.y - this.getOffsetY(this.buttonsArea) - this.getOffsetY(this.content),
  1297. "overflow-y" : "auto"
  1298. })
  1299. }
  1300. },
  1301. setSize_pc : function( currentOrgLength, flag ){
  1302. var lines = ((currentOrgLength+1)/2).toInt();
  1303. var height = 0;
  1304. if( this.routeSelectorTile )height = height + this.getOffsetY(this.routeSelectorTile) + this.routeSelectorTile.getStyle("height").toInt();
  1305. if( this.routeSelectorArea )height = height + this.getOffsetY(this.routeSelectorArea) + this.routeSelectorArea.getStyle("height").toInt();
  1306. if( this.routeOpinionTile )height = height + this.getOffsetY(this.routeOpinionTile) + this.routeOpinionTile.getStyle("height").toInt();
  1307. if( this.routeOpinionArea )height = height + this.getOffsetY(this.routeOpinionArea) + this.routeOpinionArea.getStyle("height").toInt();
  1308. //if( this.buttonsArea )height = height + this.getOffsetY(this.buttonsArea) + this.buttonsArea.getStyle("height").toInt();
  1309. if( lines > 0 ){
  1310. if(this.orgsArea)this.orgsArea.show();
  1311. if( flag ){
  1312. // if( this.orgsTile )height = height + this.getOffsetY(this.orgsTile) + this.orgsTile.getStyle("height").toInt();
  1313. this.orgsArea.getChildren().each( function(el){
  1314. height += el.getSize().y + this.getOffsetY( el );
  1315. }.bind(this))
  1316. this.node.setStyle( "height", height );
  1317. }else{
  1318. if( this.orgsTile )height = height + this.getOffsetY(this.orgsTile) + this.orgsTile.getStyle("height").toInt();
  1319. height = height + lines*this.options.orgHeight + this.getOffsetY(this.orgsArea);
  1320. this.node.setStyle( "height", height );
  1321. }
  1322. }else{
  1323. if(this.orgsArea)this.orgsArea.hide();
  1324. this.node.setStyle( "height", height );
  1325. //this.node.store("height", 401 );
  1326. }
  1327. debugger;
  1328. if( this.getMaxOrgLength() > 1 ){
  1329. this.node.setStyles( this.css.node_wide );
  1330. this.inputOpinionNode.setStyles( this.css.inputOpinionNode_wide );
  1331. this.inputTextarea.setStyles( this.css.inputTextarea_wide );
  1332. this.inputTextareaStyle = this.css.inputTextarea_wide;
  1333. this.selectIdeaNode.setStyles( this.css.selectIdeaNode_wide );
  1334. }else{
  1335. this.node.setStyles( this.css.node );
  1336. this.inputOpinionNode.setStyles( this.css.inputOpinionNode );
  1337. this.inputTextarea.setStyles( this.css.inputTextarea );
  1338. this.inputTextareaStyle = this.css.inputTextarea;
  1339. this.selectIdeaNode.setStyles( this.css.selectIdeaNode );
  1340. }
  1341. },
  1342. isErrorHeightOverflow : function(){
  1343. var hasOverflow = false;
  1344. ( this.orgItems || [] ).each( function(item){
  1345. if( item.errorHeightOverflow ){
  1346. hasOverflow = true;
  1347. }
  1348. }.bind(this));
  1349. return hasOverflow;
  1350. },
  1351. checkErrorHeightOverflow : function( force ){
  1352. if( force || this.isErrorHeightOverflow() ){
  1353. this.setSize(this.orgItems.length, true);
  1354. }
  1355. },
  1356. errorHeightChange : function(){
  1357. debugger;
  1358. this.checkErrorHeightOverflow( true )
  1359. },
  1360. validationOrgs : function(){
  1361. if( !this.orgItems || !this.orgItems.length )return true;
  1362. var flag = true;
  1363. this.orgItems.each( function(item){
  1364. if( !item.validation() )flag = false;
  1365. }.bind(this));
  1366. this.checkErrorHeightOverflow();
  1367. return flag;
  1368. },
  1369. isOrgsHasEmpower: function(){
  1370. if( !this.orgItems || !this.orgItems.length )return true;
  1371. var flag = false;
  1372. this.needCheckEmpowerOrg = [];
  1373. this.orgItems.each( function(item){
  1374. if( item.hasEmpowerIdentity() ){
  1375. this.needCheckEmpowerOrg.push(item);
  1376. flag = true;
  1377. }
  1378. }.bind(this));
  1379. return flag;
  1380. },
  1381. saveOrgs : function( keepSilent ){
  1382. if( !this.orgItems || !this.orgItems.length )return true;
  1383. var flag = true;
  1384. this.orgItems.each( function(item){
  1385. if( !item.save( !keepSilent ) )flag = false;
  1386. }.bind(this));
  1387. return flag;
  1388. },
  1389. saveOrgsWithCheckEmpower : function( callback ){
  1390. debugger;
  1391. if( !this.orgItems || !this.orgItems.length ){
  1392. if( callback )callback();
  1393. return true;
  1394. }
  1395. if( !this.validationOrgs() )return false;
  1396. if( layout.mobile ){
  1397. if( callback )callback();
  1398. return true;
  1399. }else{
  1400. if( !this.isOrgsHasEmpower() ){
  1401. if( callback )callback();
  1402. return true;
  1403. }
  1404. //this.checkEmpowerMode = true;
  1405. this.showEmpowerDlg( callback );
  1406. }
  1407. },
  1408. showEmpowerDlg : function( callback ){
  1409. //this.empowerMask = new Element("div", {"styles": this.css.handwritingMask}).inject(this.node);
  1410. //this.needCheckEmpowerOrg.each( function(org){
  1411. // org.saveCheckedEmpowerData();
  1412. //}.bind(this));
  1413. var empowerNode = new Element("div.empowerNode", {"styles": this.css.empowerNode});
  1414. var empowerTitleNode = new Element("div",{
  1415. text : MWF.xApplication.process.Xform.LP.empowerDlgText,
  1416. styles : this.css.empowerTitleNode
  1417. }).inject(empowerNode);
  1418. var orgs = this.needCheckEmpowerOrg;
  1419. var len = orgs.length;
  1420. var lines = ((len+1)/2).toInt();
  1421. var empowerTable = new Element("table",{
  1422. "cellspacing" : 0, "cellpadding" : 0, "border" : 0, "width" : "100%",
  1423. "styles" : this.css.empowerTable
  1424. }).inject( empowerNode );
  1425. for (var n=0; n<lines; n++){
  1426. var tr = new Element("tr").inject( empowerTable );
  1427. new Element("td", { "width" : "50%", "styles" : this.css.empowerOddTd }).inject( tr );
  1428. new Element("td", { "width" : "50%", "styles" : this.css.empowerEvenTd }).inject( tr );
  1429. }
  1430. var trs = empowerTable.getElements("tr");
  1431. orgs.each( function( org, i ){
  1432. var sNode;
  1433. var width;
  1434. if (i+1==len && (len % 2===1)){
  1435. sNode = trs[trs.length-1].getFirst("td");
  1436. sNode.set("colspan", 2);
  1437. trs[trs.length-1].getLast("td").destroy();
  1438. width = "50%";
  1439. }else{
  1440. var row = ((i+2)/2).toInt();
  1441. var tr = trs[row-1];
  1442. sNode = (i % 2===0) ? tr.getFirst("td") : tr.getLast("td");
  1443. }
  1444. var titleNode = new Element("div.empowerAreaTitle", {
  1445. "styles" : this.css.empowerAreaTitle
  1446. }).inject(sNode);
  1447. var titleTextNode = new Element("div.empowerAreaTitleText", {
  1448. "text": org.json.title,
  1449. "styles" : this.css.empowerAreaTitleText
  1450. }).inject(titleNode);
  1451. var selectAllNode = new Element("div",{
  1452. styles : {
  1453. float : "right"
  1454. }
  1455. }).inject(titleNode);
  1456. var contentNode = new Element("div.empowerAreaContent", {
  1457. "styles" : this.css.empowerAreaContent
  1458. }).inject(sNode);
  1459. org.loadCheckEmpower( null, contentNode, selectAllNode );
  1460. }.bind(this));
  1461. empowerNode.setStyle( "height", lines*this.options.orgHeight + 20 );
  1462. //var dlgHeight = Math.min( Math.floor( this.form.app.content.getSize().y * 0.9) , lines*this.options.orgHeight + 151 );
  1463. //var width = this.node.retrieve("width");
  1464. //empowerNode.setStyle( "width", width );
  1465. var width = 840;
  1466. //if( len > 1 ){
  1467. // width = "840"
  1468. //}else{
  1469. // width = "420"
  1470. //}
  1471. empowerNode.setStyle( "width", width+"px" );
  1472. this.node.getParent().mask( {
  1473. "style": this.css.mask
  1474. });
  1475. this.empowerDlg = o2.DL.open({
  1476. "title": MWF.xApplication.process.Xform.LP.selectEmpower,
  1477. "style": this.form.json.dialogStyle || "user",
  1478. "isResize": false,
  1479. "content": empowerNode,
  1480. //"container" : this.node,
  1481. "width": width + 40, //600,
  1482. "height": "auto", //dlgHeight,
  1483. "mark" : false,
  1484. "onPostLoad" : function () {
  1485. if( this.nodeWidth ){
  1486. this.node.setStyle("width", this.nodeWidth+"px" );
  1487. }
  1488. if( this.nodeHeight ){
  1489. this.node.setStyle("height", this.nodeHeight+"px" );
  1490. }
  1491. },
  1492. "buttonList": [
  1493. {
  1494. "type" : "ok",
  1495. "text": MWF.LP.process.button.ok,
  1496. "action": function(d, e){
  1497. //if (this.empowerDlg) this.empowerDlg.okButton.click();
  1498. orgs.each( function( org, i ){
  1499. org.saveCheckedEmpowerData( function(){
  1500. if( i === orgs.length-1 ){
  1501. if( callback )callback();
  1502. this.node.getParent().unmask();
  1503. this.empowerDlg.close();
  1504. }
  1505. }.bind(this))
  1506. }.bind(this))
  1507. }.bind(this)
  1508. },
  1509. {
  1510. "type" : "cancel",
  1511. "text": MWF.LP.process.button.cancel,
  1512. "action": function(){
  1513. this.node.getParent().unmask();
  1514. this.empowerDlg.close();
  1515. }.bind(this)
  1516. }
  1517. ]
  1518. });
  1519. },
  1520. managerLogin : function(e){
  1521. debugger;
  1522. var _self = this;
  1523. var user = (this.task.identityDn || this.task.identity).split("@")[0];
  1524. var text = MWF.xApplication.process.Work.LP.managerLoginConfirmContent.replace("{user}", user );
  1525. MWF.xDesktop.confirm("infor", e, MWF.xApplication.process.Work.LP.managerLoginConfirmTitle, text, 450, 120, function () {
  1526. o2.Actions.load("x_organization_assemble_authentication").AuthenticationAction.switchUser({"credential": ( _self.task.personDn || _self.task.person ) }, function(){
  1527. var text = MWF.xApplication.process.Work.LP.managerLoginSuccess.replace("{user}", user );
  1528. MWF.xDesktop.notice("success", {x: "right", y:"top"}, text );
  1529. window.open(o2.filterUrl("../x_desktop/work.html?workid="+_self.task.work));
  1530. }.bind(this));
  1531. this.close();
  1532. }, function () {
  1533. this.close();
  1534. }, null, null);
  1535. }
  1536. });
  1537. //兼容快速流转,所以需要判断
  1538. if( MWF.xApplication.process.Xform && MWF.xApplication.process.Xform.Form ){
  1539. MWF.xDesktop.requireApp("process.Xform", "Org", null, false);
  1540. MWF.xApplication.process.Work.Processor.Org = new Class({
  1541. Implements: [Options, Events],
  1542. options: {
  1543. moduleEvents : ["queryLoadSelector","postLoadSelector","postLoadContent","queryLoadCategory","postLoadCategory",
  1544. "selectCategory", "unselectCategory","queryLoadItem","postLoadItem","selectItem", "unselectItem","change"]
  1545. },
  1546. initialize: function (container, form, json, processor, options) {
  1547. this.form = form;
  1548. this.json = json;
  1549. this.processor = processor;
  1550. this.container = $(container);
  1551. this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  1552. this.setOptions(options);
  1553. },
  1554. load : function(){
  1555. if( layout.mobile ){
  1556. setTimeout( function(){ //如果有输入法界面,这个时候页面的计算不对,所以等100毫秒
  1557. var options = this.getOptions();
  1558. if(options){
  1559. //this.selector = new MWF.O2Selector(this.container, options);
  1560. this.selector = new MWF.O2Selector($(document.body), options);
  1561. }
  1562. }.bind(this), 100 )
  1563. }else{
  1564. var options = this.getOptions();
  1565. if(options){
  1566. this.selector = new MWF.O2Selector(this.container, options);
  1567. }
  1568. }
  1569. },
  1570. _getOrgOptions: function(){
  1571. this.selectTypeList = typeOf( this.json.selectType ) == "array" ? this.json.selectType : [this.json.selectType];
  1572. if( this.selectTypeList.contains( "identity" ) ) {
  1573. this.identityOptions = new MWF.xApplication.process.Work.Processor.IdentityOptions(this.form, this.json);
  1574. }
  1575. if( this.selectTypeList.contains( "unit" ) ) {
  1576. this.unitOptions = new MWF.xApplication.process.Work.Processor.UnitOptions(this.form, this.json);
  1577. }
  1578. //if( this.selectTypeList.contains( "group" ) ){
  1579. // this.groupOptions = new MWF.APPOrg.GroupOptions( this.form, this.json );
  1580. //}
  1581. },
  1582. getOptions: function(){
  1583. var _self = this;
  1584. this._getOrgOptions();
  1585. if( this.selectTypeList.length === 0 )return false;
  1586. var exclude = [];
  1587. if( this.json.exclude ){
  1588. var v = this.form.Macro.exec(this.json.exclude.code, this);
  1589. exclude = typeOf(v)==="array" ? v : [v];
  1590. }
  1591. var identityOpt;
  1592. if( this.identityOptions ){
  1593. identityOpt = this.identityOptions.getOptions();
  1594. if (this.json.identityRange!=="all"){
  1595. if ( !identityOpt.noUnit && (!identityOpt.units || !identityOpt.units.length) ){
  1596. this.form.notice(MWF.xApplication.process.Xform.LP.noIdentitySelectRange, "error", this.node);
  1597. return false;
  1598. }
  1599. }
  1600. if ( !identityOpt.noUnit && this.json.dutyRange && this.json.dutyRange!=="all"){
  1601. if (!identityOpt.dutys || !identityOpt.dutys.length){
  1602. this.form.notice(MWF.xApplication.process.Xform.LP.noIdentityDutySelectRange, "error", this.node);
  1603. return false;
  1604. }
  1605. }
  1606. if( this.ignoreOldData ){
  1607. identityOpt.values = this._computeValue() || [];
  1608. }else{
  1609. identityOpt.values = this.getValue();
  1610. }
  1611. identityOpt.exclude = exclude;
  1612. }
  1613. var unitOpt;
  1614. if( this.unitOptions ){
  1615. unitOpt = this.unitOptions.getOptions();
  1616. if (this.json.unitRange!=="all"){
  1617. if ( !unitOpt.units || !unitOpt.units.length){
  1618. this.form.notice(MWF.xApplication.process.Xform.LP.noUnitSelectRange, "error", this.node);
  1619. return false;
  1620. }
  1621. }
  1622. if( this.ignoreOldData ){
  1623. unitOpt.values = this._computeValue() || [];
  1624. }else{
  1625. unitOpt.values = this.getValue();
  1626. }
  1627. unitOpt.exclude = exclude;
  1628. }
  1629. //var groupOpt;
  1630. //if( this.groupOptions ){
  1631. // groupOpt = this.groupOptions.getOptions();
  1632. // groupOpt.values = (this.json.isInput) ? [] : values;
  1633. // groupOpt.exclude = exclude;
  1634. //}
  1635. var defaultOpt;
  1636. if( layout.mobile ){
  1637. defaultOpt = {
  1638. "style" : "default",
  1639. "zIndex" : 3000
  1640. };
  1641. }else{
  1642. defaultOpt = {
  1643. "style" : "process",
  1644. "width" : "auto",
  1645. "height" : "240",
  1646. "embedded" : true,
  1647. "hasLetter" : false, //字母
  1648. "hasTop" : true //可选、已选的标题
  1649. };
  1650. }
  1651. if( this.json.events && typeOf(this.json.events) === "object" ){
  1652. Object.each(this.json.events, function(e, key){
  1653. if (e.code){
  1654. if (this.options.moduleEvents.indexOf(key)!==-1){
  1655. //this.addEvent(key, function(event){
  1656. // return this.form.Macro.fire(e.code, this, event);
  1657. //}.bind(this));
  1658. if( key === "postLoadSelector" ) {
  1659. this.addEvent("loadSelector", function (selector) {
  1660. return this.form.Macro.fire(e.code, selector);
  1661. }.bind(this))
  1662. }else if( key === "queryLoadSelector"){
  1663. defaultOpt["onQueryLoad"] = function(target){
  1664. return this.form.Macro.fire(e.code, target);
  1665. }.bind(this)
  1666. }else{
  1667. defaultOpt["on"+key.capitalize()] = function(target){
  1668. return this.form.Macro.fire(e.code, target);
  1669. }.bind(this)
  1670. }
  1671. }
  1672. }
  1673. }.bind(this));
  1674. }
  1675. if( this.needValid() ){
  1676. defaultOpt["onValid"] = function ( selector ) {
  1677. this.validOnSelect();
  1678. }.bind(this);
  1679. }
  1680. if( this.form.json.selectorStyle ){
  1681. defaultOpt = Object.merge( Object.clone(this.form.json.selectorStyle), defaultOpt );
  1682. if( this.form.json.selectorStyle.style )defaultOpt.style = this.form.json.selectorStyle.style;
  1683. }
  1684. var mobileEvents = {
  1685. "onComplete": function(items){
  1686. this.selectOnComplete(items);
  1687. }.bind(this),
  1688. "onCancel": this.selectOnCancel.bind(this),
  1689. "onClose": this.selectOnClose.bind(this)
  1690. };
  1691. if( this.selectTypeList.length === 1 ){
  1692. return Object.merge(
  1693. defaultOpt,
  1694. {
  1695. "type": this.selectTypeList[0],
  1696. "onLoad": function(){
  1697. //this 为 selector
  1698. _self.selectOnLoad(this, this.selector )
  1699. }
  1700. //"onComplete": function(items){
  1701. // this.selectOnComplete(items);
  1702. //}.bind(this),
  1703. //"onCancel": this.selectOnCancel.bind(this),
  1704. //"onClose": this.selectOnClose.bind(this)
  1705. },
  1706. layout.mobile ? mobileEvents : {} ,
  1707. identityOpt || unitOpt
  1708. )
  1709. }else if( this.selectTypeList.length > 1 ){
  1710. var options = {
  1711. "type" : "",
  1712. "types" : this.selectTypeList,
  1713. "onLoad": function(){
  1714. //this 为 selector
  1715. _self.selectOnLoad(this)
  1716. }
  1717. //"onComplete": function(items){
  1718. // this.selectOnComplete(items);
  1719. //}.bind(this),
  1720. //"onCancel": this.selectOnCancel.bind(this),
  1721. //"onClose": this.selectOnClose.bind(this)
  1722. };
  1723. if( identityOpt ){
  1724. options.identityOptions = Object.merge(
  1725. defaultOpt,
  1726. layout.mobile ? mobileEvents : {},
  1727. identityOpt
  1728. );
  1729. }
  1730. if( unitOpt ){
  1731. options.unitOptions = Object.merge(
  1732. defaultOpt,
  1733. layout.mobile ? mobileEvents : {},
  1734. unitOpt
  1735. );
  1736. }
  1737. //if( groupOpt )options.groupOptions = groupOpt;
  1738. return options;
  1739. }
  1740. },
  1741. selectOnComplete: function(items){ //移动端才执行
  1742. var array = [];
  1743. items.each(function(item){
  1744. array.push(item.data);
  1745. }.bind(this));
  1746. var simple = this.json.storeRange === "simple";
  1747. this.checkEmpower( array, function( data ){
  1748. var values = [];
  1749. data.each(function(d){
  1750. values.push(MWF.org.parseOrgData(d, true, simple));
  1751. }.bind(this));
  1752. this.setData(values);
  1753. //this.validationMode();
  1754. //this.validation();
  1755. this.container.empty();
  1756. this.loadOrgWidget(values, this.container);
  1757. this.selector = null;
  1758. this.fireEvent("select", [items, values]);
  1759. }.bind(this))
  1760. },
  1761. selectOnCancel: function(){ //移动端才执行
  1762. //this.validation();
  1763. },
  1764. selectOnLoad: function( selector ){
  1765. //if (this.descriptionNode) this.descriptionNode.setStyle("display", "none");
  1766. this.fireEvent("loadSelector", [selector])
  1767. },
  1768. selectOnClose: function(){
  1769. var v = this._getBusinessData();
  1770. //if (!v || !v.length) if (this.descriptionNode) this.descriptionNode.setStyle("display", "block");
  1771. },
  1772. loadOrgWidget: function(value, node){
  1773. var height = node.getStyle("height").toInt();
  1774. if (node.getStyle("overflow")==="visible" && !height) node.setStyle("overflow", "hidden");
  1775. if (value && value.length){
  1776. value.each(function(data){
  1777. var flag = data.distinguishedName.substr(data.distinguishedName.length-1, 1);
  1778. var copyData = Object.clone(data);
  1779. if( this.json.displayTextScript && this.json.displayTextScript.code ){
  1780. this.currentData = copyData;
  1781. var displayName = this.form.Macro.exec(this.json.displayTextScript.code, this);
  1782. if( displayName ){
  1783. copyData.displayName = displayName;
  1784. }
  1785. this.currentData = null;
  1786. }
  1787. var widget;
  1788. switch (flag.toLowerCase()){
  1789. case "i":
  1790. widget = new MWF.widget.O2Identity(copyData, node, {"style": "xform","lazy":true});
  1791. break;
  1792. case "p":
  1793. widget = new MWF.widget.O2Person(copyData, node, {"style": "xform","lazy":true});
  1794. break;
  1795. case "u":
  1796. widget = new MWF.widget.O2Unit(copyData, node, {"style": "xform","lazy":true});
  1797. break;
  1798. case "g":
  1799. widget = new MWF.widget.O2Group(copyData, node, {"style": "xform","lazy":true});
  1800. break;
  1801. default:
  1802. widget = new MWF.widget.O2Other(copyData, node, {"style": "xform","lazy":true});
  1803. }
  1804. widget.field = this;
  1805. if( layout.mobile ){
  1806. //widget.node.setStyles({
  1807. // "float" : "none"
  1808. //})
  1809. }
  1810. }.bind(this));
  1811. }
  1812. },
  1813. hasEmpowerIdentity : function(){
  1814. var data = this.getData();
  1815. if(!this.empowerChecker )this.empowerChecker = new MWF.xApplication.process.Work.Processor.EmpowerChecker(this.form, this.json, this.processor);
  1816. return this.empowerChecker.hasEmpowerIdentity( data );
  1817. },
  1818. checkEmpower : function( data, callback, container, selectAllNode ){
  1819. if( typeOf(data)==="array" && this.identityOptions && this.json.isCheckEmpower && this.json.identityResultType === "identity" ) {
  1820. if(!this.empowerChecker )this.empowerChecker = new MWF.xApplication.process.Work.Processor.EmpowerChecker(this.form, this.json, this.processor);
  1821. this.empowerChecker.selectAllNode = selectAllNode;
  1822. this.empowerChecker.load(data, callback, container);
  1823. }else{
  1824. if( callback )callback( data );
  1825. }
  1826. },
  1827. loadCheckEmpower : function( callback, container, selectAllNode ){
  1828. this.checkEmpower( this.getData(), callback, container, selectAllNode)
  1829. },
  1830. saveCheckedEmpowerData:function( callback ){
  1831. var data = this.getData();
  1832. var simple = this.json.storeRange === "simple";
  1833. //this.empowerChecker.replaceEmpowerIdentity(data, function( newData ){
  1834. this.empowerChecker.setIgnoreEmpowerFlag(data, function( newData ){
  1835. var values = [];
  1836. newData.each(function(d){
  1837. values.push(MWF.org.parseOrgData(d, true, simple));
  1838. }.bind(this));
  1839. this.setData( values );
  1840. if( callback )callback(values)
  1841. }.bind(this))
  1842. },
  1843. //saveWithCheckEmpower: function( isValid, callback ){
  1844. // var checkEmpowerData = function(){
  1845. // var array = this.getData();
  1846. // this.checkEmpower( array, function( data ){
  1847. // var values = [];
  1848. // data.each(function(d){
  1849. // values.push(MWF.org.parseOrgData(d, true));
  1850. // }.bind(this));
  1851. // this.setData( values );
  1852. // if( callback )callback(values)
  1853. // }.bind(this), container, selectAllNode)
  1854. // }.bind(this)
  1855. // if( isValid ){
  1856. // if( this.validation() ){
  1857. // checkEmpowerData( function(){
  1858. // if(callback)callback();
  1859. // }.bind(this));
  1860. // return true;
  1861. // }else{
  1862. // return false;
  1863. // }
  1864. // }else{
  1865. // //this.setData( this.getData() );
  1866. // checkEmpowerData( function(){
  1867. // if(callback)callback();
  1868. // }.bind(this));
  1869. // return true;
  1870. // }
  1871. //},
  1872. save: function( isValid ){
  1873. if( isValid ){
  1874. if( this.validation() ){
  1875. return true;
  1876. }else{
  1877. this.processor.checkErrorHeightOverflow();
  1878. return false;
  1879. }
  1880. }else{
  1881. this.setData( this.getData() );
  1882. return true;
  1883. }
  1884. },
  1885. resetSelectorData : function(){
  1886. if( this.selector && this.selector.selector ){
  1887. this.selector.selector.emptySelectedItems();
  1888. this.selector.selector.options.values = this.getValue();
  1889. this.selector.selector.setSelectedItem();
  1890. }
  1891. },
  1892. setDataToOriginal : function(){
  1893. var v = this._computeValue();
  1894. this.setData(v || "");
  1895. },
  1896. resetData: function(){
  1897. var v = this.getValue();
  1898. //this.setData((v) ? v.join(", ") : "");
  1899. this.setData(v);
  1900. },
  1901. getData: function(){
  1902. if( this.selector && !layout.mobile ){
  1903. return this.getSelectedData();
  1904. }else{
  1905. return this.getValue();
  1906. }
  1907. },
  1908. getSelectedData : function(){
  1909. if( layout.mobile ){
  1910. return this.getValue();
  1911. }else{
  1912. var simple = this.json.storeRange === "simple";
  1913. var data = [];
  1914. if( this.selector && this.selector.selector){
  1915. this.selector.selector.selectedItems.each( function( item ){
  1916. data.push( MWF.org.parseOrgData(item.data, true, simple) );
  1917. })
  1918. }
  1919. return data;
  1920. }
  1921. },
  1922. getValue: function(){
  1923. var value = this._getBusinessData();
  1924. if (!value) value = this._computeValue();
  1925. return value || "";
  1926. },
  1927. _computeValue: function(){
  1928. var values = [];
  1929. if (this.json.identityValue) {
  1930. this.json.identityValue.each(function(v){ if (v) values.push(v)});
  1931. }
  1932. if (this.json.unitValue) {
  1933. this.json.unitValue.each(function(v){ if (v) values.push(v)});
  1934. }
  1935. if (this.json.dutyValue) {
  1936. var dutys = JSON.decode(this.json.dutyValue);
  1937. var par;
  1938. if (dutys.length){
  1939. dutys.each(function(duty){
  1940. if (duty.code) par = this.form.Macro.exec(duty.code, this);
  1941. var code = "return this.org.getDuty(\""+duty.name+"\", \""+par+"\")";
  1942. var d = this.form.Macro.exec(code, this);
  1943. if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
  1944. d.each(function(dd){if (dd) values.push(dd);});
  1945. }.bind(this));
  1946. }
  1947. }
  1948. if (this.json.defaultValue && this.json.defaultValue.code){
  1949. var fd = this.form.Macro.exec(this.json.defaultValue.code, this);
  1950. if (typeOf(fd)!=="array") fd = (fd) ? [fd] : [];
  1951. fd.each(function(fdd){
  1952. if (fdd){
  1953. if (typeOf(fdd)==="string"){
  1954. var data;
  1955. this.getOrgAction()[this.getValueMethod(fdd)](function(json){ data = json.data }.bind(this), null, fdd, false);
  1956. values.push(data);
  1957. }else{
  1958. values.push(fdd);
  1959. }
  1960. }
  1961. }.bind(this));
  1962. }
  1963. if (this.json.count>0){
  1964. return values.slice(0, this.json.count);
  1965. }
  1966. return values;
  1967. //return (this.json.defaultValue.code) ? this.form.Macro.exec(this.json.defaultValue.code, this): (value || "");
  1968. },
  1969. getOrgAction: function(){
  1970. if (!this.orgAction) this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  1971. //if (!this.orgAction) this.orgAction = new MWF.xApplication.Selector.Actions.RestActions();
  1972. return this.orgAction;
  1973. },
  1974. setData: function(value){
  1975. if (!value) return false;
  1976. var oldValues = this.getValue();
  1977. var values = [];
  1978. var simple = this.json.storeRange === "simple";
  1979. var type = typeOf(value);
  1980. if (type==="array"){
  1981. value.each(function(v){
  1982. var vtype = typeOf(v);
  1983. var data = null;
  1984. if (vtype==="string"){
  1985. this.getOrgAction()[this.getValueMethod(v)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, v, false);
  1986. }
  1987. if (vtype==="object") {
  1988. data = MWF.org.parseOrgData(v, true, simple);
  1989. if(data.woPerson)delete data.woPerson;
  1990. }
  1991. if (data)values.push(data);
  1992. }.bind(this));
  1993. }
  1994. if (type==="string"){
  1995. var vData;
  1996. this.getOrgAction()[this.getValueMethod(value)](function(json){ vData = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, value, false);
  1997. if (vData)values.push(vData);
  1998. }
  1999. if (type==="object"){
  2000. var vData = MWF.org.parseOrgData(value, true, simple);
  2001. if(vData.woPerson)delete vData.woPerson;
  2002. values.push( vData );
  2003. }
  2004. var change = false;
  2005. if (oldValues.length && values.length){
  2006. if (oldValues.length === values.length){
  2007. for (var i=0; i<oldValues.length; i++){
  2008. if ((oldValues[i].distinguishedName!==values[i].distinguishedName) || (oldValues[i].name!==values[i].name) || (oldValues[i].unique!==values[i].unique)){
  2009. change = true;
  2010. break;
  2011. }
  2012. }
  2013. }else{
  2014. change = true;
  2015. }
  2016. }else if (values.length || oldValues.length) {
  2017. change = true;
  2018. }
  2019. this._setBusinessData(values);
  2020. if (change) this.fireEvent("change");
  2021. },
  2022. getValueMethod: function(value){
  2023. if (value){
  2024. var flag = value.substr(value.length-1, 1);
  2025. switch (flag.toLowerCase()){
  2026. case "i":
  2027. return "getIdentity";
  2028. case "p":
  2029. return "getPerson";
  2030. case "u":
  2031. return "getUnit";
  2032. case "g":
  2033. return "getGroup";
  2034. default:
  2035. return (this.json.selectType==="unit") ? "getUnit" : "getIdentity";
  2036. }
  2037. }
  2038. return (this.json.selectType==="unit") ? "getUnit" : "getIdentity";
  2039. },
  2040. _getBusinessData: function(){
  2041. if (this.json.section=="yes"){
  2042. return this._getBusinessSectionData();
  2043. }else {
  2044. if (this.json.type==="Opinion"){
  2045. return this._getBusinessSectionDataByPerson();
  2046. }else{
  2047. return this.form.businessData.data[this.json.name] || "";
  2048. }
  2049. }
  2050. },
  2051. _getBusinessSectionData: function(){
  2052. switch (this.json.sectionBy){
  2053. case "person":
  2054. return this._getBusinessSectionDataByPerson();
  2055. case "unit":
  2056. return this._getBusinessSectionDataByUnit();
  2057. case "activity":
  2058. return this._getBusinessSectionDataByActivity();
  2059. case "splitValue":
  2060. return this._getBusinessSectionDataBySplitValue();
  2061. case "script":
  2062. return this._getBusinessSectionDataByScript(this.json.sectionByScript.code);
  2063. default:
  2064. return this.form.businessData.data[this.json.name] || "";
  2065. }
  2066. },
  2067. _getBusinessSectionDataByPerson: function(){
  2068. this.form.sectionListObj[this.json.name] = layout.desktop.session.user.id;
  2069. var dataObj = this.form.businessData.data[this.json.name];
  2070. return (dataObj) ? (dataObj[layout.desktop.session.user.id] || "") : "";
  2071. },
  2072. _getBusinessSectionDataByUnit: function(){
  2073. this.form.sectionListObj[this.json.name] = "";
  2074. var key = (this.form.businessData.task) ? this.form.businessData.task.unit : "";
  2075. if (key) this.form.sectionListObj[this.json.name] = key;
  2076. var dataObj = this.form.businessData.data[this.json.name];
  2077. if (!dataObj) return "";
  2078. return (key) ? (dataObj[key] || "") : "";
  2079. },
  2080. _getBusinessSectionDataByActivity: function(){
  2081. this.form.sectionListObj[this.json.name] = "";
  2082. var key = (this.form.businessData.work) ? this.form.businessData.work.activity : "";
  2083. if (key) this.form.sectionListObj[this.json.name] = key;
  2084. var dataObj = this.form.businessData.data[this.json.name];
  2085. if (!dataObj) return "";
  2086. return (key) ? (dataObj[key] || "") : "";
  2087. },
  2088. _getBusinessSectionDataBySplitValue: function(){
  2089. this.form.sectionListObj[this.json.name] = "";
  2090. var key = (this.form.businessData.work) ? this.form.businessData.work.splitValue : "";
  2091. if (key) this.form.sectionListObj[this.json.name] = key;
  2092. var dataObj = this.form.businessData.data[this.json.name];
  2093. if (!dataObj) return "";
  2094. return (key) ? (dataObj[key] || "") : "";
  2095. },
  2096. _getBusinessSectionDataByScript: function(code){
  2097. this.form.sectionListObj[this.json.name] = "";
  2098. var dataObj = this.form.businessData.data[this.json.name];
  2099. if (!dataObj) return "";
  2100. var key = this.form.Macro.exec(code, this);
  2101. if (key) this.form.sectionListObj[this.json.name] = key;
  2102. return (key) ? (dataObj[key] || "") : "";
  2103. },
  2104. loadPathData: function(path){
  2105. var data = null;
  2106. this.form.workAction.getJobDataByPath(this.form.businessData.work.job, path, function(json){
  2107. data = json.data || null;
  2108. }, null, false);
  2109. return data;
  2110. },
  2111. _setBusinessData: function(v){
  2112. if (this.json.section=="yes"){
  2113. // var d = this.loadPathData(this.json.name);
  2114. // if (d) this.form.businessData.data[this.json.name] = d;
  2115. this._setBusinessSectionData(v);
  2116. }else {
  2117. if (this.json.type==="Opinion"){
  2118. // var d = this.loadPathData(this.json.name);
  2119. // if (d) this.form.businessData.data[this.json.name] = d;
  2120. this._setBusinessSectionDataByPerson(v);
  2121. }else{
  2122. if (this.form.businessData.data[this.json.name]){
  2123. this.form.businessData.data[this.json.name] = v;
  2124. }else{
  2125. this.form.businessData.data[this.json.name] = v;
  2126. this.form.Macro.environment.setData(this.form.businessData.data);
  2127. }
  2128. if (this.json.isTitle) this.form.businessData.work.title = v;
  2129. }
  2130. }
  2131. },
  2132. _setBusinessSectionData: function(v){
  2133. switch (this.json.sectionBy){
  2134. case "person":
  2135. this._setBusinessSectionDataByPerson(v);
  2136. break;
  2137. case "unit":
  2138. this._setBusinessSectionDataByUnit(v);
  2139. break;
  2140. case "activity":
  2141. this._setBusinessSectionDataByActivity(v);
  2142. break;
  2143. case "splitValue":
  2144. this._setBusinessSectionDataBySplitValue(v);
  2145. break;
  2146. case "script":
  2147. this._setBusinessSectionDataByScript(this.json.sectionByScript.code, v);
  2148. break;
  2149. default:
  2150. if (this.form.businessData.data[this.json.name]){
  2151. this.form.businessData.data[this.json.name] = v;
  2152. }else{
  2153. this.form.businessData.data[this.json.name] = v;
  2154. this.form.Macro.environment.setData(this.form.businessData.data);
  2155. }
  2156. }
  2157. },
  2158. _setBusinessSectionDataByPerson: function(v){
  2159. var resetData = false;
  2160. var key = layout.desktop.session.user.id;
  2161. this.form.sectionListObj[this.json.name] = key;
  2162. var dataObj = this.form.businessData.data[this.json.name];
  2163. if (!dataObj){
  2164. dataObj = {};
  2165. this.form.businessData.data[this.json.name] = dataObj;
  2166. resetData = true;
  2167. }
  2168. if (!dataObj[key]) resetData = true;
  2169. dataObj[key] = v;
  2170. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2171. },
  2172. _setBusinessSectionDataByUnit: function(v){
  2173. var resetData = false;
  2174. var key = (this.form.businessData.task) ? this.form.businessData.task.unit : "";
  2175. if (key){
  2176. this.form.sectionListObj[this.json.name] = key;
  2177. var dataObj = this.form.businessData.data[this.json.name];
  2178. if (!dataObj){
  2179. dataObj = {};
  2180. this.form.businessData.data[this.json.name] = dataObj;
  2181. resetData = true;
  2182. }
  2183. if (!dataObj[key]) resetData = true;
  2184. dataObj[key] = v;
  2185. }
  2186. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2187. },
  2188. _setBusinessSectionDataByActivity: function(v){
  2189. var resetData = false;
  2190. var key = (this.form.businessData.work) ? this.form.businessData.work.activity : "";
  2191. if (key){
  2192. this.form.sectionListObj[this.json.name] = key;
  2193. var dataObj = this.form.businessData.data[this.json.name];
  2194. if (!dataObj){
  2195. dataObj = {};
  2196. this.form.businessData.data[this.json.name] = dataObj;
  2197. resetData = true;
  2198. }
  2199. if (!dataObj[key]) resetData = true;
  2200. dataObj[key] = v;
  2201. }
  2202. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2203. },
  2204. _setBusinessSectionDataBySplitValue: function(v){
  2205. var resetData = false;
  2206. var key = (this.form.businessData.work) ? this.form.businessData.work.splitValue : "";
  2207. if (key){
  2208. this.form.sectionListObj[this.json.name] = key;
  2209. var dataObj = this.form.businessData.data[this.json.name];
  2210. if (!dataObj){
  2211. dataObj = {};
  2212. this.form.businessData.data[this.json.name] = dataObj;
  2213. resetData = true;
  2214. }
  2215. if (!dataObj[key]) resetData = true;
  2216. dataObj[key] = v;
  2217. }
  2218. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2219. },
  2220. _setBusinessSectionDataByScript: function(code, v){
  2221. var resetData = false;
  2222. var key = this.form.Macro.exec(code, this);
  2223. if (key){
  2224. this.form.sectionListObj[this.json.name] = key;
  2225. var dataObj = this.form.businessData.data[this.json.name];
  2226. if (!dataObj){
  2227. dataObj = {};
  2228. this.form.businessData.data[this.json.name] = dataObj;
  2229. resetData = true;
  2230. }
  2231. if (!dataObj[key]) resetData = true;
  2232. dataObj[key] = v;
  2233. }
  2234. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2235. },
  2236. createErrorNode: function(text){
  2237. var _self = this;
  2238. var node;
  2239. if( this.processor.css.errorContentNode ){
  2240. node = new Element("div",{
  2241. "styles" : this.processor.css.errorContentNode,
  2242. "text": text
  2243. });
  2244. if( this.processor.css.errorCloseNode ){
  2245. var closeNode = new Element("div",{
  2246. "styles" : this.processor.css.errorCloseNode ,
  2247. "events": {
  2248. "click" : function(){
  2249. this.destroy();
  2250. if( _self.errorHeightOverflow ){
  2251. _self.errorHeightOverflow = false;
  2252. _self.processor.errorHeightChange();
  2253. }
  2254. }.bind(node)
  2255. }
  2256. }).inject(node);
  2257. }
  2258. }else {
  2259. node = new Element("div");
  2260. var iconNode = new Element("div", {
  2261. "styles": {
  2262. "width": "20px",
  2263. "height": "20px",
  2264. "float": "left",
  2265. "background": "url(" + "../x_component_process_Xform/$Form/default/icon/error.png) center center no-repeat"
  2266. }
  2267. }).inject(node);
  2268. var textNode = new Element("div", {
  2269. "styles": {
  2270. "height" : "auto",
  2271. "min-height": "20px",
  2272. "line-height": "20px",
  2273. "margin-left": "20px",
  2274. "color": "red",
  2275. "word-break": "break-all"
  2276. },
  2277. "text": text
  2278. }).inject(node);
  2279. }
  2280. return node;
  2281. },
  2282. notValidationMode: function(text){
  2283. if (!this.isNotValidationMode){
  2284. //this.isNotValidationMode = true;
  2285. //this.node.store("borderStyle", this.node.getStyles("border-left", "border-right", "border-top", "border-bottom"));
  2286. //this.node.setStyle("border-color", "red");
  2287. this.errNode = this.createErrorNode(text);
  2288. if( this.errContainer ){
  2289. this.errContainer.empty();
  2290. this.errNode.inject(this.errContainer);
  2291. }else{
  2292. this.errNode.inject(this.container, "after");
  2293. }
  2294. var errorSize = this.errNode.getSize();
  2295. debugger;
  2296. if( !layout.mobile && errorSize.y > 26 ){
  2297. this.errorHeightOverflow = true;
  2298. }
  2299. //this.showNotValidationMode(this.node);
  2300. //if (!this.node.isIntoView()) this.node.scrollIntoView();
  2301. }
  2302. },
  2303. needValid: function(){
  2304. return (( this.json.validationCount && typeOf( this.json.validationCount.toInt() ) === "number" ) ||
  2305. (this.json.validation && this.json.validation.code));
  2306. },
  2307. validOnSelect : function(){
  2308. if( !this.errNode )return true;
  2309. var flag=true;
  2310. if( this.json.validationCount && typeOf( this.json.validationCount.toInt() ) === "number" ){
  2311. if( this.selector.selector.selectedItems.length < this.json.validationCount.toInt() ){
  2312. flag = "请至少选择"+this.json.validationCount+"项"
  2313. }
  2314. }
  2315. if( flag === true ){
  2316. if ( this.json.validation && this.json.validation.code){
  2317. var data = this.getData();
  2318. this.setData( data );
  2319. flag = this.form.Macro.exec(this.json.validation.code, this);
  2320. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  2321. }
  2322. }
  2323. if (flag.toString()!="true"){
  2324. this.notValidationMode(flag);
  2325. this.processor.errorHeightChange();
  2326. return false;
  2327. }else if(this.errNode){
  2328. this.errNode.destroy();
  2329. this.errNode = null;
  2330. if( this.errorHeightOverflow ){
  2331. this.errorHeightOverflow = false;
  2332. this.processor.errorHeightChange();
  2333. }
  2334. }
  2335. return true;
  2336. },
  2337. validation: function(){
  2338. var data = this.getData();
  2339. this.setData( data );
  2340. var flag=true;
  2341. if( this.json.validationCount && typeOf( this.json.validationCount.toInt() ) === "number" ){
  2342. if( data.length < this.json.validationCount.toInt() ){
  2343. flag = "请至少选择"+this.json.validationCount+"项"
  2344. }
  2345. }
  2346. if( flag === true ){
  2347. if ( this.json.validation && this.json.validation.code){
  2348. flag = this.form.Macro.exec(this.json.validation.code, this);
  2349. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  2350. }
  2351. }
  2352. if (flag.toString()!="true"){
  2353. this.notValidationMode(flag);
  2354. return false;
  2355. }else if(this.errNode){
  2356. this.errNode.destroy();
  2357. this.errNode = null;
  2358. }
  2359. return true;
  2360. }
  2361. });
  2362. MWF.xApplication.process.Work.Processor.EmpowerChecker = new Class({
  2363. Extends : MWF.APPOrg.EmpowerChecker,
  2364. initialize: function (form, json, processor) {
  2365. this.form = form;
  2366. this.json = json;
  2367. this.processor = processor;
  2368. this.css = this.processor.css;
  2369. this.checkedAllItems = true;
  2370. },
  2371. load : function( data, callback, container ){
  2372. if( typeOf(data)==="array" && this.json.isCheckEmpower && this.json.identityResultType === "identity" ){
  2373. var array = [];
  2374. data.each( function( d ){
  2375. if( d.distinguishedName ){
  2376. var flag = d.distinguishedName.substr(d.distinguishedName.length-1, 1).toLowerCase();
  2377. if( flag === "i" ){
  2378. array.push( d.distinguishedName )
  2379. }
  2380. }
  2381. }.bind(this));
  2382. if( array.length > 0 ){
  2383. o2.Actions.get("x_organization_assemble_express").listEmpowerWithIdentity({
  2384. "application" : (this.form.businessData.work || this.form.businessData.workCompleted).application,
  2385. "process" : (this.form.businessData.work || this.form.businessData.workCompleted).process,
  2386. "work" : (this.form.businessData.work || this.form.businessData.workCompleted).id,
  2387. "identityList" : array
  2388. }, function( json ){
  2389. var arr = [];
  2390. json.data.each( function(d){
  2391. if(d.fromIdentity !== d.toIdentity )arr.push(d);
  2392. });
  2393. if( arr.length > 0 ){
  2394. if( layout.mobile ){
  2395. this.openSelectEmpowerDlg( arr, data, callback, container );
  2396. }else{
  2397. this.openSelectEmpowerDlg_embedded( arr, data, callback, container );
  2398. }
  2399. }else{
  2400. if( callback )callback( data );
  2401. }
  2402. }.bind(this), function(){
  2403. if( callback )callback( data );
  2404. }.bind(this))
  2405. }else{
  2406. if( callback )callback( data );
  2407. }
  2408. }else{
  2409. if( callback )callback( data );
  2410. }
  2411. },
  2412. hasEmpowerIdentity: function( data ){
  2413. var flag = false;
  2414. if( typeOf(data)==="array" && this.json.isCheckEmpower && this.json.identityResultType === "identity" ) {
  2415. var array = [];
  2416. data.each(function (d) {
  2417. if (d.distinguishedName) {
  2418. var flag = d.distinguishedName.substr(d.distinguishedName.length - 1, 1).toLowerCase();
  2419. if (flag === "i")array.push(d.distinguishedName)
  2420. }
  2421. }.bind(this));
  2422. if (array.length > 0) {
  2423. o2.Actions.get("x_organization_assemble_express").listEmpowerWithIdentity({
  2424. "application": (this.form.businessData.work || this.form.businessData.workCompleted).application,
  2425. "process": (this.form.businessData.work || this.form.businessData.workCompleted).process,
  2426. "work" : (this.form.businessData.work || this.form.businessData.workCompleted).id,
  2427. "identityList": array
  2428. }, function (json) {
  2429. var arr = [];
  2430. json.data.each(function (d) {
  2431. if (d.fromIdentity !== d.toIdentity)
  2432. arr.push(d);
  2433. });
  2434. if (arr.length > 0) {
  2435. flag = true;
  2436. }
  2437. }.bind(this), null, false)
  2438. }
  2439. }
  2440. return flag;
  2441. },
  2442. openSelectEmpowerDlg_embedded : function( data, orgData, callback, container ){
  2443. var node = new Element("div", {"styles": this.css.empowerAreaNode});
  2444. //var html = "<div style=\"line-height: 30px; color: #333333; overflow: hidden\">"+MWF.xApplication.process.Xform.LP.empowerDlgText+"</div>";
  2445. var html = "<div style=\"margin-bottom:10px; margin-top:10px; overflow-y:auto;\"></div>";
  2446. node.set("html", html);
  2447. var itemNode = node.getLast();
  2448. this.getEmpowerItems(itemNode, data);
  2449. node.inject( container || this.form.app.content );
  2450. if( this.selectAllNode ){
  2451. var selectNode = this.createSelectAllEmpowerNode();
  2452. selectNode.inject( this.selectAllNode );
  2453. if( this.checkedAllItems ){
  2454. selectNode.store("isSelected", true);
  2455. selectNode.setStyles( this.css.empowerSelectAllItemNode_selected );
  2456. }
  2457. }
  2458. },
  2459. getSelectedData : function( callback ){
  2460. var json = {};
  2461. this.empowerSelectNodes.each(function(node){
  2462. if( node.retrieve("isSelected") ){
  2463. var d = node.retrieve("data");
  2464. json[ d.fromIdentity ] = d;
  2465. }
  2466. }.bind(this));
  2467. if( callback )callback( json );
  2468. }
  2469. });
  2470. MWF.xApplication.process.Work.Processor.UnitOptions = new Class({
  2471. Extends : MWF.APPOrg.UnitOptions
  2472. });
  2473. MWF.xApplication.process.Work.Processor.IdentityOptions = new Class({
  2474. Extends : MWF.APPOrg.IdentityOptions
  2475. });
  2476. }