Processor.js 105 KB

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