Processor.js 107 KB

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