Processor.js 106 KB

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