Processor.js 122 KB

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