Processor.js 114 KB

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