Processor.js 114 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660
  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. identityOpt.disabled = true;
  1598. // return false;
  1599. }
  1600. }
  1601. if ( !identityOpt.noUnit && this.json.dutyRange && this.json.dutyRange!=="all"){
  1602. if (!identityOpt.dutys || !identityOpt.dutys.length){
  1603. this.form.notice(MWF.xApplication.process.Xform.LP.noIdentityDutySelectRange, "error", this.node);
  1604. identityOpt.disabled = true;
  1605. // return false;
  1606. }
  1607. }
  1608. if( this.ignoreOldData ){
  1609. identityOpt.values = this._computeValue() || [];
  1610. }else{
  1611. identityOpt.values = this.getValue();
  1612. }
  1613. identityOpt.exclude = exclude;
  1614. }
  1615. var unitOpt;
  1616. if( this.unitOptions ){
  1617. unitOpt = this.unitOptions.getOptions();
  1618. if (this.json.unitRange!=="all"){
  1619. if ( !unitOpt.units || !unitOpt.units.length){
  1620. this.form.notice(MWF.xApplication.process.Xform.LP.noUnitSelectRange, "error", this.node);
  1621. unitOpt.disabled = true;
  1622. // return false;
  1623. }
  1624. }
  1625. if( this.ignoreOldData ){
  1626. unitOpt.values = this._computeValue() || [];
  1627. }else{
  1628. unitOpt.values = this.getValue();
  1629. }
  1630. unitOpt.exclude = exclude;
  1631. }
  1632. //var groupOpt;
  1633. //if( this.groupOptions ){
  1634. // groupOpt = this.groupOptions.getOptions();
  1635. // groupOpt.values = (this.json.isInput) ? [] : values;
  1636. // groupOpt.exclude = exclude;
  1637. //}
  1638. var defaultOpt;
  1639. if( layout.mobile ){
  1640. defaultOpt = {
  1641. "style" : "default",
  1642. "zIndex" : 3000
  1643. };
  1644. }else{
  1645. defaultOpt = {
  1646. "style" : "process",
  1647. "width" : "auto",
  1648. "height" : "240",
  1649. "embedded" : true,
  1650. "hasLetter" : false, //字母
  1651. "hasTop" : true //可选、已选的标题
  1652. };
  1653. }
  1654. if( this.json.events && typeOf(this.json.events) === "object" ){
  1655. Object.each(this.json.events, function(e, key){
  1656. if (e.code){
  1657. if (this.options.moduleEvents.indexOf(key)!==-1){
  1658. //this.addEvent(key, function(event){
  1659. // return this.form.Macro.fire(e.code, this, event);
  1660. //}.bind(this));
  1661. if( key === "postLoadSelector" ) {
  1662. this.addEvent("loadSelector", function (selector) {
  1663. return this.form.Macro.fire(e.code, selector);
  1664. }.bind(this))
  1665. }else if( key === "queryLoadSelector"){
  1666. defaultOpt["onQueryLoad"] = function(target){
  1667. return this.form.Macro.fire(e.code, target);
  1668. }.bind(this)
  1669. }else{
  1670. defaultOpt["on"+key.capitalize()] = function(target){
  1671. return this.form.Macro.fire(e.code, target);
  1672. }.bind(this)
  1673. }
  1674. }
  1675. }
  1676. }.bind(this));
  1677. }
  1678. if( this.needValid() ){
  1679. defaultOpt["onValid"] = function ( selector ) {
  1680. this.validOnSelect();
  1681. }.bind(this);
  1682. }
  1683. if( this.form.json.selectorStyle ){
  1684. defaultOpt = Object.merge( Object.clone(this.form.json.selectorStyle), defaultOpt );
  1685. if( this.form.json.selectorStyle.style )defaultOpt.style = this.form.json.selectorStyle.style;
  1686. }
  1687. var mobileEvents = {
  1688. "onComplete": function(items){
  1689. this.selectOnComplete(items);
  1690. }.bind(this),
  1691. "onCancel": this.selectOnCancel.bind(this),
  1692. "onClose": this.selectOnClose.bind(this)
  1693. };
  1694. if( this.selectTypeList.length === 1 ){
  1695. return Object.merge(
  1696. defaultOpt,
  1697. {
  1698. "type": this.selectTypeList[0],
  1699. "onLoad": function(){
  1700. //this 为 selector
  1701. _self.selectOnLoad(this, this.selector )
  1702. }
  1703. //"onComplete": function(items){
  1704. // this.selectOnComplete(items);
  1705. //}.bind(this),
  1706. //"onCancel": this.selectOnCancel.bind(this),
  1707. //"onClose": this.selectOnClose.bind(this)
  1708. },
  1709. layout.mobile ? mobileEvents : {} ,
  1710. identityOpt || unitOpt
  1711. )
  1712. }else if( this.selectTypeList.length > 1 ){
  1713. var options = {
  1714. "type" : "",
  1715. "types" : this.selectTypeList,
  1716. "onLoad": function(){
  1717. //this 为 selector
  1718. _self.selectOnLoad(this)
  1719. }
  1720. //"onComplete": function(items){
  1721. // this.selectOnComplete(items);
  1722. //}.bind(this),
  1723. //"onCancel": this.selectOnCancel.bind(this),
  1724. //"onClose": this.selectOnClose.bind(this)
  1725. };
  1726. if( identityOpt ){
  1727. options.identityOptions = Object.merge(
  1728. defaultOpt,
  1729. layout.mobile ? mobileEvents : {},
  1730. identityOpt
  1731. );
  1732. }
  1733. if( unitOpt ){
  1734. options.unitOptions = Object.merge(
  1735. defaultOpt,
  1736. layout.mobile ? mobileEvents : {},
  1737. unitOpt
  1738. );
  1739. }
  1740. //if( groupOpt )options.groupOptions = groupOpt;
  1741. return options;
  1742. }
  1743. },
  1744. selectOnComplete: function(items){ //移动端才执行
  1745. var array = [];
  1746. items.each(function(item){
  1747. array.push(item.data);
  1748. }.bind(this));
  1749. var simple = this.json.storeRange === "simple";
  1750. this.checkEmpower( array, function( data ){
  1751. var values = [];
  1752. data.each(function(d){
  1753. values.push(MWF.org.parseOrgData(d, true, simple));
  1754. }.bind(this));
  1755. this.setData(values);
  1756. //this.validationMode();
  1757. //this.validation();
  1758. this.container.empty();
  1759. this.loadOrgWidget(values, this.container);
  1760. this.selector = null;
  1761. this.fireEvent("select", [items, values]);
  1762. }.bind(this))
  1763. },
  1764. selectOnCancel: function(){ //移动端才执行
  1765. //this.validation();
  1766. },
  1767. selectOnLoad: function( selector ){
  1768. //if (this.descriptionNode) this.descriptionNode.setStyle("display", "none");
  1769. this.fireEvent("loadSelector", [selector])
  1770. },
  1771. selectOnClose: function(){
  1772. var v = this._getBusinessData();
  1773. //if (!v || !v.length) if (this.descriptionNode) this.descriptionNode.setStyle("display", "block");
  1774. },
  1775. loadOrgWidget: function(value, node){
  1776. var height = node.getStyle("height").toInt();
  1777. if (node.getStyle("overflow")==="visible" && !height) node.setStyle("overflow", "hidden");
  1778. if (value && value.length){
  1779. value.each(function(data){
  1780. var flag = data.distinguishedName.substr(data.distinguishedName.length-1, 1);
  1781. var copyData = Object.clone(data);
  1782. if( this.json.displayTextScript && this.json.displayTextScript.code ){
  1783. this.currentData = copyData;
  1784. var displayName = this.form.Macro.exec(this.json.displayTextScript.code, this);
  1785. if( displayName ){
  1786. copyData.displayName = displayName;
  1787. }
  1788. this.currentData = null;
  1789. }
  1790. var widget;
  1791. switch (flag.toLowerCase()){
  1792. case "i":
  1793. widget = new MWF.widget.O2Identity(copyData, node, {"style": "xform","lazy":true});
  1794. break;
  1795. case "p":
  1796. widget = new MWF.widget.O2Person(copyData, node, {"style": "xform","lazy":true});
  1797. break;
  1798. case "u":
  1799. widget = new MWF.widget.O2Unit(copyData, node, {"style": "xform","lazy":true});
  1800. break;
  1801. case "g":
  1802. widget = new MWF.widget.O2Group(copyData, node, {"style": "xform","lazy":true});
  1803. break;
  1804. default:
  1805. widget = new MWF.widget.O2Other(copyData, node, {"style": "xform","lazy":true});
  1806. }
  1807. widget.field = this;
  1808. if( layout.mobile ){
  1809. //widget.node.setStyles({
  1810. // "float" : "none"
  1811. //})
  1812. }
  1813. }.bind(this));
  1814. }
  1815. },
  1816. hasEmpowerIdentity : function(){
  1817. var data = this.getData();
  1818. if(!this.empowerChecker )this.empowerChecker = new MWF.xApplication.process.Work.Processor.EmpowerChecker(this.form, this.json, this.processor);
  1819. return this.empowerChecker.hasEmpowerIdentity( data );
  1820. },
  1821. checkEmpower : function( data, callback, container, selectAllNode ){
  1822. if( typeOf(data)==="array" && this.identityOptions && this.json.isCheckEmpower && this.json.identityResultType === "identity" ) {
  1823. if(!this.empowerChecker )this.empowerChecker = new MWF.xApplication.process.Work.Processor.EmpowerChecker(this.form, this.json, this.processor);
  1824. this.empowerChecker.selectAllNode = selectAllNode;
  1825. this.empowerChecker.load(data, callback, container);
  1826. }else{
  1827. if( callback )callback( data );
  1828. }
  1829. },
  1830. loadCheckEmpower : function( callback, container, selectAllNode ){
  1831. this.checkEmpower( this.getData(), callback, container, selectAllNode)
  1832. },
  1833. saveCheckedEmpowerData:function( callback ){
  1834. var data = this.getData();
  1835. var simple = this.json.storeRange === "simple";
  1836. //this.empowerChecker.replaceEmpowerIdentity(data, function( newData ){
  1837. this.empowerChecker.setIgnoreEmpowerFlag(data, function( newData ){
  1838. var values = [];
  1839. newData.each(function(d){
  1840. values.push(MWF.org.parseOrgData(d, true, simple));
  1841. }.bind(this));
  1842. this.setData( values );
  1843. if( callback )callback(values)
  1844. }.bind(this))
  1845. },
  1846. //saveWithCheckEmpower: function( isValid, callback ){
  1847. // var checkEmpowerData = function(){
  1848. // var array = this.getData();
  1849. // this.checkEmpower( array, function( data ){
  1850. // var values = [];
  1851. // data.each(function(d){
  1852. // values.push(MWF.org.parseOrgData(d, true));
  1853. // }.bind(this));
  1854. // this.setData( values );
  1855. // if( callback )callback(values)
  1856. // }.bind(this), container, selectAllNode)
  1857. // }.bind(this)
  1858. // if( isValid ){
  1859. // if( this.validation() ){
  1860. // checkEmpowerData( function(){
  1861. // if(callback)callback();
  1862. // }.bind(this));
  1863. // return true;
  1864. // }else{
  1865. // return false;
  1866. // }
  1867. // }else{
  1868. // //this.setData( this.getData() );
  1869. // checkEmpowerData( function(){
  1870. // if(callback)callback();
  1871. // }.bind(this));
  1872. // return true;
  1873. // }
  1874. //},
  1875. save: function( isValid ){
  1876. if( isValid ){
  1877. if( this.validation() ){
  1878. return true;
  1879. }else{
  1880. this.processor.checkErrorHeightOverflow();
  1881. return false;
  1882. }
  1883. }else{
  1884. this.setData( this.getData() );
  1885. return true;
  1886. }
  1887. },
  1888. resetSelectorData : function(){
  1889. if( this.selector && this.selector.selector ){
  1890. this.selector.selector.emptySelectedItems();
  1891. this.selector.selector.options.values = this.getValue();
  1892. this.selector.selector.setSelectedItem();
  1893. }
  1894. },
  1895. setDataToOriginal : function(){
  1896. var v = this._computeValue();
  1897. this.setData(v || "");
  1898. },
  1899. resetData: function(){
  1900. var v = this.getValue();
  1901. //this.setData((v) ? v.join(", ") : "");
  1902. this.setData(v);
  1903. },
  1904. getData: function(){
  1905. if( this.selector && !layout.mobile ){
  1906. return this.getSelectedData();
  1907. }else{
  1908. return this.getValue();
  1909. }
  1910. },
  1911. getSelectedData : function(){
  1912. if( layout.mobile ){
  1913. return this.getValue();
  1914. }else{
  1915. var simple = this.json.storeRange === "simple";
  1916. var data = [];
  1917. if( this.selector && this.selector.selector){
  1918. this.selector.selector.selectedItems.each( function( item ){
  1919. data.push( MWF.org.parseOrgData(item.data, true, simple) );
  1920. })
  1921. }
  1922. return data;
  1923. }
  1924. },
  1925. getValue: function(){
  1926. var value = this._getBusinessData();
  1927. if (!value) value = this._computeValue();
  1928. return value || "";
  1929. },
  1930. _computeValue: function(){
  1931. var values = [];
  1932. if (this.json.identityValue) {
  1933. this.json.identityValue.each(function(v){ if (v) values.push(v)});
  1934. }
  1935. if (this.json.unitValue) {
  1936. this.json.unitValue.each(function(v){ if (v) values.push(v)});
  1937. }
  1938. if (this.json.dutyValue) {
  1939. var dutys = JSON.decode(this.json.dutyValue);
  1940. var par;
  1941. if (dutys.length){
  1942. dutys.each(function(duty){
  1943. if (duty.code) par = this.form.Macro.exec(duty.code, this);
  1944. var code = "return this.org.getDuty(\""+duty.name+"\", \""+par+"\")";
  1945. var d = this.form.Macro.exec(code, this);
  1946. if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
  1947. d.each(function(dd){if (dd) values.push(dd);});
  1948. }.bind(this));
  1949. }
  1950. }
  1951. if (this.json.defaultValue && this.json.defaultValue.code){
  1952. var fd = this.form.Macro.exec(this.json.defaultValue.code, this);
  1953. if (typeOf(fd)!=="array") fd = (fd) ? [fd] : [];
  1954. fd.each(function(fdd){
  1955. if (fdd){
  1956. if (typeOf(fdd)==="string"){
  1957. var data;
  1958. this.getOrgAction()[this.getValueMethod(fdd)](function(json){ data = json.data }.bind(this), null, fdd, false);
  1959. values.push(data);
  1960. }else{
  1961. values.push(fdd);
  1962. }
  1963. }
  1964. }.bind(this));
  1965. }
  1966. if (this.json.count>0){
  1967. return values.slice(0, this.json.count);
  1968. }
  1969. return values;
  1970. //return (this.json.defaultValue.code) ? this.form.Macro.exec(this.json.defaultValue.code, this): (value || "");
  1971. },
  1972. getOrgAction: function(){
  1973. if (!this.orgAction) this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  1974. //if (!this.orgAction) this.orgAction = new MWF.xApplication.Selector.Actions.RestActions();
  1975. return this.orgAction;
  1976. },
  1977. setData: function(value){
  1978. if (!value) return false;
  1979. var oldValues = this.getValue();
  1980. var values = [];
  1981. var simple = this.json.storeRange === "simple";
  1982. var type = typeOf(value);
  1983. if (type==="array"){
  1984. value.each(function(v){
  1985. var vtype = typeOf(v);
  1986. var data = null;
  1987. if (vtype==="string"){
  1988. this.getOrgAction()[this.getValueMethod(v)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, v, false);
  1989. }
  1990. if (vtype==="object") {
  1991. data = MWF.org.parseOrgData(v, true, simple);
  1992. if(data.woPerson)delete data.woPerson;
  1993. }
  1994. if (data)values.push(data);
  1995. }.bind(this));
  1996. }
  1997. if (type==="string"){
  1998. var vData;
  1999. this.getOrgAction()[this.getValueMethod(value)](function(json){ vData = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, value, false);
  2000. if (vData)values.push(vData);
  2001. }
  2002. if (type==="object"){
  2003. var vData = MWF.org.parseOrgData(value, true, simple);
  2004. if(vData.woPerson)delete vData.woPerson;
  2005. values.push( vData );
  2006. }
  2007. var change = false;
  2008. if (oldValues.length && values.length){
  2009. if (oldValues.length === values.length){
  2010. for (var i=0; i<oldValues.length; i++){
  2011. if ((oldValues[i].distinguishedName!==values[i].distinguishedName) || (oldValues[i].name!==values[i].name) || (oldValues[i].unique!==values[i].unique)){
  2012. change = true;
  2013. break;
  2014. }
  2015. }
  2016. }else{
  2017. change = true;
  2018. }
  2019. }else if (values.length || oldValues.length) {
  2020. change = true;
  2021. }
  2022. this._setBusinessData(values);
  2023. if (change) this.fireEvent("change");
  2024. },
  2025. getValueMethod: function(value){
  2026. if (value){
  2027. var flag = value.substr(value.length-1, 1);
  2028. switch (flag.toLowerCase()){
  2029. case "i":
  2030. return "getIdentity";
  2031. case "p":
  2032. return "getPerson";
  2033. case "u":
  2034. return "getUnit";
  2035. case "g":
  2036. return "getGroup";
  2037. default:
  2038. return (this.json.selectType==="unit") ? "getUnit" : "getIdentity";
  2039. }
  2040. }
  2041. return (this.json.selectType==="unit") ? "getUnit" : "getIdentity";
  2042. },
  2043. _getBusinessData: function(){
  2044. if (this.json.section=="yes"){
  2045. return this._getBusinessSectionData();
  2046. }else {
  2047. if (this.json.type==="Opinion"){
  2048. return this._getBusinessSectionDataByPerson();
  2049. }else{
  2050. return this.form.businessData.data[this.json.name] || "";
  2051. }
  2052. }
  2053. },
  2054. _getBusinessSectionData: function(){
  2055. switch (this.json.sectionBy){
  2056. case "person":
  2057. return this._getBusinessSectionDataByPerson();
  2058. case "unit":
  2059. return this._getBusinessSectionDataByUnit();
  2060. case "activity":
  2061. return this._getBusinessSectionDataByActivity();
  2062. case "splitValue":
  2063. return this._getBusinessSectionDataBySplitValue();
  2064. case "script":
  2065. return this._getBusinessSectionDataByScript(this.json.sectionByScript.code);
  2066. default:
  2067. return this.form.businessData.data[this.json.name] || "";
  2068. }
  2069. },
  2070. _getBusinessSectionDataByPerson: function(){
  2071. this.form.sectionListObj[this.json.name] = layout.desktop.session.user.id;
  2072. var dataObj = this.form.businessData.data[this.json.name];
  2073. return (dataObj) ? (dataObj[layout.desktop.session.user.id] || "") : "";
  2074. },
  2075. _getBusinessSectionDataByUnit: function(){
  2076. this.form.sectionListObj[this.json.name] = "";
  2077. var key = (this.form.businessData.task) ? this.form.businessData.task.unit : "";
  2078. if (key) this.form.sectionListObj[this.json.name] = key;
  2079. var dataObj = this.form.businessData.data[this.json.name];
  2080. if (!dataObj) return "";
  2081. return (key) ? (dataObj[key] || "") : "";
  2082. },
  2083. _getBusinessSectionDataByActivity: function(){
  2084. this.form.sectionListObj[this.json.name] = "";
  2085. var key = (this.form.businessData.work) ? this.form.businessData.work.activity : "";
  2086. if (key) this.form.sectionListObj[this.json.name] = key;
  2087. var dataObj = this.form.businessData.data[this.json.name];
  2088. if (!dataObj) return "";
  2089. return (key) ? (dataObj[key] || "") : "";
  2090. },
  2091. _getBusinessSectionDataBySplitValue: function(){
  2092. this.form.sectionListObj[this.json.name] = "";
  2093. var key = (this.form.businessData.work) ? this.form.businessData.work.splitValue : "";
  2094. if (key) this.form.sectionListObj[this.json.name] = key;
  2095. var dataObj = this.form.businessData.data[this.json.name];
  2096. if (!dataObj) return "";
  2097. return (key) ? (dataObj[key] || "") : "";
  2098. },
  2099. _getBusinessSectionDataByScript: function(code){
  2100. this.form.sectionListObj[this.json.name] = "";
  2101. var dataObj = this.form.businessData.data[this.json.name];
  2102. if (!dataObj) return "";
  2103. var key = this.form.Macro.exec(code, this);
  2104. if (key) this.form.sectionListObj[this.json.name] = key;
  2105. return (key) ? (dataObj[key] || "") : "";
  2106. },
  2107. loadPathData: function(path){
  2108. var data = null;
  2109. this.form.workAction.getJobDataByPath(this.form.businessData.work.job, path, function(json){
  2110. data = json.data || null;
  2111. }, null, false);
  2112. return data;
  2113. },
  2114. _setBusinessData: function(v){
  2115. if (this.json.section=="yes"){
  2116. // var d = this.loadPathData(this.json.name);
  2117. // if (d) this.form.businessData.data[this.json.name] = d;
  2118. this._setBusinessSectionData(v);
  2119. }else {
  2120. if (this.json.type==="Opinion"){
  2121. // var d = this.loadPathData(this.json.name);
  2122. // if (d) this.form.businessData.data[this.json.name] = d;
  2123. this._setBusinessSectionDataByPerson(v);
  2124. }else{
  2125. if (this.form.businessData.data[this.json.name]){
  2126. this.form.businessData.data[this.json.name] = v;
  2127. }else{
  2128. this.form.businessData.data[this.json.name] = v;
  2129. this.form.Macro.environment.setData(this.form.businessData.data);
  2130. }
  2131. if (this.json.isTitle) this.form.businessData.work.title = v;
  2132. }
  2133. }
  2134. },
  2135. _setBusinessSectionData: function(v){
  2136. switch (this.json.sectionBy){
  2137. case "person":
  2138. this._setBusinessSectionDataByPerson(v);
  2139. break;
  2140. case "unit":
  2141. this._setBusinessSectionDataByUnit(v);
  2142. break;
  2143. case "activity":
  2144. this._setBusinessSectionDataByActivity(v);
  2145. break;
  2146. case "splitValue":
  2147. this._setBusinessSectionDataBySplitValue(v);
  2148. break;
  2149. case "script":
  2150. this._setBusinessSectionDataByScript(this.json.sectionByScript.code, v);
  2151. break;
  2152. default:
  2153. if (this.form.businessData.data[this.json.name]){
  2154. this.form.businessData.data[this.json.name] = v;
  2155. }else{
  2156. this.form.businessData.data[this.json.name] = v;
  2157. this.form.Macro.environment.setData(this.form.businessData.data);
  2158. }
  2159. }
  2160. },
  2161. _setBusinessSectionDataByPerson: function(v){
  2162. var resetData = false;
  2163. var key = layout.desktop.session.user.id;
  2164. this.form.sectionListObj[this.json.name] = key;
  2165. var dataObj = this.form.businessData.data[this.json.name];
  2166. if (!dataObj){
  2167. dataObj = {};
  2168. this.form.businessData.data[this.json.name] = dataObj;
  2169. resetData = true;
  2170. }
  2171. if (!dataObj[key]) resetData = true;
  2172. dataObj[key] = v;
  2173. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2174. },
  2175. _setBusinessSectionDataByUnit: function(v){
  2176. var resetData = false;
  2177. var key = (this.form.businessData.task) ? this.form.businessData.task.unit : "";
  2178. if (key){
  2179. this.form.sectionListObj[this.json.name] = key;
  2180. var dataObj = this.form.businessData.data[this.json.name];
  2181. if (!dataObj){
  2182. dataObj = {};
  2183. this.form.businessData.data[this.json.name] = dataObj;
  2184. resetData = true;
  2185. }
  2186. if (!dataObj[key]) resetData = true;
  2187. dataObj[key] = v;
  2188. }
  2189. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2190. },
  2191. _setBusinessSectionDataByActivity: function(v){
  2192. var resetData = false;
  2193. var key = (this.form.businessData.work) ? this.form.businessData.work.activity : "";
  2194. if (key){
  2195. this.form.sectionListObj[this.json.name] = key;
  2196. var dataObj = this.form.businessData.data[this.json.name];
  2197. if (!dataObj){
  2198. dataObj = {};
  2199. this.form.businessData.data[this.json.name] = dataObj;
  2200. resetData = true;
  2201. }
  2202. if (!dataObj[key]) resetData = true;
  2203. dataObj[key] = v;
  2204. }
  2205. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2206. },
  2207. _setBusinessSectionDataBySplitValue: function(v){
  2208. var resetData = false;
  2209. var key = (this.form.businessData.work) ? this.form.businessData.work.splitValue : "";
  2210. if (key){
  2211. this.form.sectionListObj[this.json.name] = key;
  2212. var dataObj = this.form.businessData.data[this.json.name];
  2213. if (!dataObj){
  2214. dataObj = {};
  2215. this.form.businessData.data[this.json.name] = dataObj;
  2216. resetData = true;
  2217. }
  2218. if (!dataObj[key]) resetData = true;
  2219. dataObj[key] = v;
  2220. }
  2221. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2222. },
  2223. _setBusinessSectionDataByScript: function(code, v){
  2224. var resetData = false;
  2225. var key = this.form.Macro.exec(code, this);
  2226. if (key){
  2227. this.form.sectionListObj[this.json.name] = key;
  2228. var dataObj = this.form.businessData.data[this.json.name];
  2229. if (!dataObj){
  2230. dataObj = {};
  2231. this.form.businessData.data[this.json.name] = dataObj;
  2232. resetData = true;
  2233. }
  2234. if (!dataObj[key]) resetData = true;
  2235. dataObj[key] = v;
  2236. }
  2237. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2238. },
  2239. createErrorNode: function(text){
  2240. var _self = this;
  2241. var node;
  2242. if( this.processor.css.errorContentNode ){
  2243. node = new Element("div",{
  2244. "styles" : this.processor.css.errorContentNode,
  2245. "text": text
  2246. });
  2247. if( this.processor.css.errorCloseNode ){
  2248. var closeNode = new Element("div",{
  2249. "styles" : this.processor.css.errorCloseNode ,
  2250. "events": {
  2251. "click" : function(){
  2252. this.destroy();
  2253. if( _self.errorHeightOverflow ){
  2254. _self.errorHeightOverflow = false;
  2255. _self.processor.errorHeightChange();
  2256. }
  2257. }.bind(node)
  2258. }
  2259. }).inject(node);
  2260. }
  2261. }else {
  2262. node = new Element("div");
  2263. var iconNode = new Element("div", {
  2264. "styles": {
  2265. "width": "20px",
  2266. "height": "20px",
  2267. "float": "left",
  2268. "background": "url(" + "../x_component_process_Xform/$Form/default/icon/error.png) center center no-repeat"
  2269. }
  2270. }).inject(node);
  2271. var textNode = new Element("div", {
  2272. "styles": {
  2273. "height" : "auto",
  2274. "min-height": "20px",
  2275. "line-height": "20px",
  2276. "margin-left": "20px",
  2277. "color": "red",
  2278. "word-break": "break-all"
  2279. },
  2280. "text": text
  2281. }).inject(node);
  2282. }
  2283. return node;
  2284. },
  2285. notValidationMode: function(text){
  2286. if (!this.isNotValidationMode){
  2287. //this.isNotValidationMode = true;
  2288. //this.node.store("borderStyle", this.node.getStyles("border-left", "border-right", "border-top", "border-bottom"));
  2289. //this.node.setStyle("border-color", "red");
  2290. this.errNode = this.createErrorNode(text);
  2291. if( this.errContainer ){
  2292. this.errContainer.empty();
  2293. this.errNode.inject(this.errContainer);
  2294. }else{
  2295. this.errNode.inject(this.container, "after");
  2296. }
  2297. var errorSize = this.errNode.getSize();
  2298. debugger;
  2299. if( !layout.mobile && errorSize.y > 26 ){
  2300. this.errorHeightOverflow = true;
  2301. }
  2302. //this.showNotValidationMode(this.node);
  2303. //if (!this.node.isIntoView()) this.node.scrollIntoView();
  2304. }
  2305. },
  2306. needValid: function(){
  2307. return (( this.json.validationCount && typeOf( this.json.validationCount.toInt() ) === "number" ) ||
  2308. (this.json.validation && this.json.validation.code));
  2309. },
  2310. validOnSelect : function(){
  2311. if( !this.errNode )return true;
  2312. var flag=true;
  2313. if( this.json.validationCount && typeOf( this.json.validationCount.toInt() ) === "number" ){
  2314. if( this.selector.selector.selectedItems.length < this.json.validationCount.toInt() ){
  2315. flag = "请至少选择"+this.json.validationCount+"项"
  2316. }
  2317. }
  2318. if( flag === true ){
  2319. if ( this.json.validation && this.json.validation.code){
  2320. var data = this.getData();
  2321. this.setData( data );
  2322. flag = this.form.Macro.exec(this.json.validation.code, this);
  2323. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  2324. }
  2325. }
  2326. if (flag.toString()!="true"){
  2327. this.notValidationMode(flag);
  2328. this.processor.errorHeightChange();
  2329. return false;
  2330. }else if(this.errNode){
  2331. this.errNode.destroy();
  2332. this.errNode = null;
  2333. if( this.errorHeightOverflow ){
  2334. this.errorHeightOverflow = false;
  2335. this.processor.errorHeightChange();
  2336. }
  2337. }
  2338. return true;
  2339. },
  2340. validation: function(){
  2341. var data = this.getData();
  2342. this.setData( data );
  2343. var flag=true;
  2344. if( this.json.validationCount && typeOf( this.json.validationCount.toInt() ) === "number" ){
  2345. if( data.length < this.json.validationCount.toInt() ){
  2346. flag = "请至少选择"+this.json.validationCount+"项"
  2347. }
  2348. }
  2349. if( flag === true ){
  2350. if ( this.json.validation && this.json.validation.code){
  2351. flag = this.form.Macro.exec(this.json.validation.code, this);
  2352. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  2353. }
  2354. }
  2355. if (flag.toString()!="true"){
  2356. this.notValidationMode(flag);
  2357. return false;
  2358. }else if(this.errNode){
  2359. this.errNode.destroy();
  2360. this.errNode = null;
  2361. }
  2362. return true;
  2363. }
  2364. });
  2365. MWF.xApplication.process.Work.Processor.EmpowerChecker = new Class({
  2366. Extends : MWF.APPOrg.EmpowerChecker,
  2367. initialize: function (form, json, processor) {
  2368. this.form = form;
  2369. this.json = json;
  2370. this.processor = processor;
  2371. this.css = this.processor.css;
  2372. this.checkedAllItems = true;
  2373. },
  2374. load : function( data, callback, container ){
  2375. if( typeOf(data)==="array" && this.json.isCheckEmpower && this.json.identityResultType === "identity" ){
  2376. var array = [];
  2377. data.each( function( d ){
  2378. if( d.distinguishedName ){
  2379. var flag = d.distinguishedName.substr(d.distinguishedName.length-1, 1).toLowerCase();
  2380. if( flag === "i" ){
  2381. array.push( d.distinguishedName )
  2382. }
  2383. }
  2384. }.bind(this));
  2385. if( array.length > 0 ){
  2386. o2.Actions.get("x_organization_assemble_express").listEmpowerWithIdentity({
  2387. "application" : (this.form.businessData.work || this.form.businessData.workCompleted).application,
  2388. "process" : (this.form.businessData.work || this.form.businessData.workCompleted).process,
  2389. "work" : (this.form.businessData.work || this.form.businessData.workCompleted).id,
  2390. "identityList" : array
  2391. }, function( json ){
  2392. var arr = [];
  2393. json.data.each( function(d){
  2394. if(d.fromIdentity !== d.toIdentity )arr.push(d);
  2395. });
  2396. if( arr.length > 0 ){
  2397. if( layout.mobile ){
  2398. this.openSelectEmpowerDlg( arr, data, callback, container );
  2399. }else{
  2400. this.openSelectEmpowerDlg_embedded( arr, data, callback, container );
  2401. }
  2402. }else{
  2403. if( callback )callback( data );
  2404. }
  2405. }.bind(this), function(){
  2406. if( callback )callback( data );
  2407. }.bind(this))
  2408. }else{
  2409. if( callback )callback( data );
  2410. }
  2411. }else{
  2412. if( callback )callback( data );
  2413. }
  2414. },
  2415. hasEmpowerIdentity: function( data ){
  2416. var flag = false;
  2417. if( typeOf(data)==="array" && this.json.isCheckEmpower && this.json.identityResultType === "identity" ) {
  2418. var array = [];
  2419. data.each(function (d) {
  2420. if (d.distinguishedName) {
  2421. var flag = d.distinguishedName.substr(d.distinguishedName.length - 1, 1).toLowerCase();
  2422. if (flag === "i")array.push(d.distinguishedName)
  2423. }
  2424. }.bind(this));
  2425. if (array.length > 0) {
  2426. o2.Actions.get("x_organization_assemble_express").listEmpowerWithIdentity({
  2427. "application": (this.form.businessData.work || this.form.businessData.workCompleted).application,
  2428. "process": (this.form.businessData.work || this.form.businessData.workCompleted).process,
  2429. "work" : (this.form.businessData.work || this.form.businessData.workCompleted).id,
  2430. "identityList": array
  2431. }, function (json) {
  2432. var arr = [];
  2433. json.data.each(function (d) {
  2434. if (d.fromIdentity !== d.toIdentity)
  2435. arr.push(d);
  2436. });
  2437. if (arr.length > 0) {
  2438. flag = true;
  2439. }
  2440. }.bind(this), null, false)
  2441. }
  2442. }
  2443. return flag;
  2444. },
  2445. openSelectEmpowerDlg_embedded : function( data, orgData, callback, container ){
  2446. var node = new Element("div", {"styles": this.css.empowerAreaNode});
  2447. //var html = "<div style=\"line-height: 30px; color: #333333; overflow: hidden\">"+MWF.xApplication.process.Xform.LP.empowerDlgText+"</div>";
  2448. var html = "<div style=\"margin-bottom:10px; margin-top:10px; overflow-y:auto;\"></div>";
  2449. node.set("html", html);
  2450. var itemNode = node.getLast();
  2451. this.getEmpowerItems(itemNode, data);
  2452. node.inject( container || this.form.app.content );
  2453. if( this.selectAllNode ){
  2454. var selectNode = this.createSelectAllEmpowerNode();
  2455. selectNode.inject( this.selectAllNode );
  2456. if( this.checkedAllItems ){
  2457. selectNode.store("isSelected", true);
  2458. selectNode.setStyles( this.css.empowerSelectAllItemNode_selected );
  2459. }
  2460. }
  2461. },
  2462. getSelectedData : function( callback ){
  2463. var json = {};
  2464. this.empowerSelectNodes.each(function(node){
  2465. if( node.retrieve("isSelected") ){
  2466. var d = node.retrieve("data");
  2467. json[ d.fromIdentity ] = d;
  2468. }
  2469. }.bind(this));
  2470. if( callback )callback( json );
  2471. }
  2472. });
  2473. MWF.xApplication.process.Work.Processor.UnitOptions = new Class({
  2474. Extends : MWF.APPOrg.UnitOptions
  2475. });
  2476. MWF.xApplication.process.Work.Processor.IdentityOptions = new Class({
  2477. Extends : MWF.APPOrg.IdentityOptions
  2478. });
  2479. }