Processor.js 106 KB

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