Processor.js 114 KB

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