Processor.js 107 KB

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