Processor.js 112 KB

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