Processor.js 106 KB

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