Processor.js 110 KB

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