Processor.js 131 KB

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