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