Processor.js 107 KB

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