Processor.js 123 KB

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