Processor.js 124 KB

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