Processor.js 110 KB

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