Form.js 178 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891
  1. //MWF.require(["MWF.widget.Common", "MWF.widget.Identity", "MWF.widget.O2Identity"], null, false);
  2. MWF.require(["MWF.widget.Common", "MWF.widget.O2Identity"], null, false);
  3. MWF.xApplication.process = MWF.xApplication.process || {};
  4. MWF.xApplication.process.Xform = MWF.xApplication.process.Xform || {};
  5. MWF.xDesktop.requireApp("process.Xform", "lp." + MWF.language, null, false);
  6. //MWF.xDesktop.requireApp("process.Xform", "Package", null, false);
  7. MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class({
  8. Implements: [Options, Events],
  9. Extends: MWF.widget.Common,
  10. options: {
  11. "style": "default",
  12. "readonly": false,
  13. "cssPath": "",
  14. "macro": "FormContext",
  15. "parameters": null,
  16. "moduleEvents": ["queryLoad",
  17. "beforeLoad",
  18. "postLoad",
  19. "afterLoad",
  20. "beforeSave",
  21. "afterSave",
  22. "beforeClose",
  23. "beforeProcess",
  24. "beforeProcessWork",
  25. "afterProcess",
  26. "beforeReset",
  27. "afterReset",
  28. "beforeRetract",
  29. "afterRetract",
  30. "beforeReroute",
  31. "afterReroute",
  32. "beforeDelete",
  33. "afterDelete",
  34. "beforeModulesLoad",
  35. "resize",
  36. "afterModulesLoad",
  37. "beforeReaded",
  38. "afterReaded"]
  39. },
  40. initialize: function (node, data, options) {
  41. this.setOptions(options);
  42. this.container = $(node);
  43. this.container.setStyle("-webkit-user-select", "text");
  44. if (Browser.firefox) this.container.setStyle("opacity", 0);
  45. this.data = data;
  46. this.json = data.json;
  47. this.html = data.html;
  48. this.path = "../x_component_process_Xform/$Form/";
  49. this.cssPath = this.options.cssPath || "../x_component_process_Xform/$Form/" + this.options.style + "/css.wcss";
  50. this._loadCss();
  51. this.sectionListObj = {};
  52. this.modules = [];
  53. this.all = {};
  54. this.allForName = {};
  55. this.forms = {};
  56. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  57. },
  58. parseCSS: function (css) {
  59. var rex = /(url\(.*\))/g;
  60. var match;
  61. while ((match = rex.exec(css)) !== null) {
  62. var pic = match[0];
  63. var len = pic.length;
  64. var s = pic.substring(pic.length - 2, pic.length - 1);
  65. var n0 = (s === "'" || s === "\"") ? 5 : 4;
  66. var n1 = (s === "'" || s === "\"") ? 2 : 1;
  67. pic = pic.substring(n0, pic.length - n1);
  68. if ((pic.indexOf("x_processplatform_assemble_surface") != -1 || pic.indexOf("x_portal_assemble_surface") != -1)) {
  69. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  70. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  71. if (pic.indexOf("/x_processplatform_assemble_surface") !== -1) {
  72. pic = pic.replace("/x_processplatform_assemble_surface", pic + "/x_processplatform_assemble_surface");
  73. } else if (pic.indexOf("x_processplatform_assemble_surface") !== -1) {
  74. pic = pic.replace("x_processplatform_assemble_surface", pic + "/x_processplatform_assemble_surface");
  75. }
  76. if (pic.indexOf("/x_portal_assemble_surface") !== -1) {
  77. pic = pic.replace("/x_portal_assemble_surface", host2 + "/x_portal_assemble_surface");
  78. } else if (pic.indexOf("x_portal_assemble_surface") !== -1) {
  79. pic = pic.replace("x_portal_assemble_surface", host2 + "/x_portal_assemble_surface");
  80. }
  81. }
  82. pic = "url('" + pic + "')";
  83. var len2 = pic.length;
  84. css = css.substring(0, match.index) + pic + css.substring(rex.lastIndex, css.length);
  85. rex.lastIndex = rex.lastIndex + (len2 - len);
  86. }
  87. return css;
  88. },
  89. loadCss: function () {
  90. cssText = (this.json.css) ? this.json.css.code : "";
  91. //var head = (document.head || document.getElementsByTagName("head")[0] || document.documentElement);
  92. var styleNode = $("style" + this.json.id);
  93. if (styleNode) styleNode.destroy();
  94. if (cssText) {
  95. cssText = this.parseCSS(cssText);
  96. var rex = new RegExp("(.+)(?=\\{)", "g");
  97. var match;
  98. var id = this.json.id.replace(/\-/g, "");
  99. var prefix = ".css" + id + " ";
  100. while ((match = rex.exec(cssText)) !== null) {
  101. var rulesStr = match[0];
  102. if (rulesStr.indexOf(",") != -1) {
  103. var rules = rulesStr.split(/\s*,\s*/g);
  104. rules = rules.map(function (r) {
  105. return prefix + r;
  106. });
  107. var rule = rules.join(", ");
  108. cssText = cssText.substring(0, match.index) + rule + cssText.substring(rex.lastIndex, cssText.length);
  109. rex.lastIndex = rex.lastIndex + (prefix.length * rules.length);
  110. } else {
  111. var rule = prefix + match[0];
  112. cssText = cssText.substring(0, match.index) + rule + cssText.substring(rex.lastIndex, cssText.length);
  113. rex.lastIndex = rex.lastIndex + prefix.length;
  114. }
  115. }
  116. var styleNode = document.createElement("style");
  117. styleNode.setAttribute("type", "text/css");
  118. styleNode.id = "style" + this.json.id;
  119. styleNode.inject(this.container, "before");
  120. if (styleNode.styleSheet) {
  121. var setFunc = function () {
  122. styleNode.styleSheet.cssText = cssText;
  123. };
  124. if (styleNode.styleSheet.disabled) {
  125. setTimeout(setFunc, 10);
  126. } else {
  127. setFunc();
  128. }
  129. } else {
  130. var cssTextNode = document.createTextNode(cssText);
  131. styleNode.appendChild(cssTextNode);
  132. }
  133. return "css" + id;
  134. }
  135. return "";
  136. },
  137. keyLock: function (async) {
  138. var lockData = null;
  139. var key = this.businessData.work.id + "-" + this.businessData.work.activityToken;
  140. o2.Actions.load("x_processplatform_assemble_surface").KeyLockAction.lock({ "key": key }, function (json) {
  141. flagData = json.data;
  142. if (async && flagData.success) this.keyLockTimeoutId = window.setTimeout(function () { this.keyLock(true) }.bind(this), 90000);
  143. if (async && !flagData.success) this.app.reload();
  144. }.bind(this), null, !!async);
  145. return flagData;
  146. },
  147. checkLock: function () {
  148. if (this.businessData.control.allowProcessing && this.businessData.activity.manualMode == "grab") {
  149. this.app.addEvent("queryClose", function () {
  150. if (this.keyLockTimeoutId) window.clearTimeout(this.keyLockTimeoutId);
  151. }.bind(this));
  152. var lockData = this.keyLock();
  153. if (lockData.success) {
  154. this.keyLock(true);
  155. } else {
  156. this.businessData.control.allowProcessing = false;
  157. this.businessData.control.allowSave = false;
  158. this.businessData.control.allowReset = false;
  159. this.businessData.control.allowReroute = false;
  160. this.businessData.control.allowDelete = false;
  161. this.businessData.control.allowAddSplit = false;
  162. this.businessData.control.allowRetract = false;
  163. this.businessData.control.allowRollback = false;
  164. this.lockDataPerson = lockData.person;
  165. // var text = MWF.xApplication.process.Xform.LP.keyLockInfor;
  166. // text = text.replace("{name}", o2.name.cn(lockData.person));
  167. // var title = MWF.xApplication.process.Xform.LP.keyLockTitle;
  168. // this.app.alert("info", "center", title, text, 400, 160);
  169. // o2.DL.open({
  170. // "title": title,
  171. // "text": text,
  172. // "width": 400
  173. // })
  174. }
  175. }
  176. },
  177. load: function (callback) {
  178. this.checkLock();
  179. this.loadExtendStyle(function () {
  180. if (this.app) {
  181. if (this.app.formNode) this.app.formNode.setStyles(this.json.styles);
  182. if (this.app.addEvent) {
  183. this.app.addEvent("resize", function () {
  184. this.fireEvent("resize");
  185. }.bind(this));
  186. this.app.addEvent("queryClose", function () {
  187. this.beforeCloseWork();
  188. }.bind(this));
  189. }
  190. }
  191. if (!this.businessData.control.allowSave) this.setOptions({ "readonly": true });
  192. var cssClass = "";
  193. if (this.json.css && this.json.css.code) cssClass = this.loadCss();
  194. this.loadMacro(function () {
  195. //this.container.setStyle("opacity", 0);
  196. this.container.set("html", this.html);
  197. this.node = this.container.getFirst();
  198. if (cssClass) this.node.addClass(cssClass);
  199. this._loadEvents();
  200. this.loadResource( function () {
  201. this.fireEvent("queryLoad");
  202. if (this.event_resolve){
  203. this.event_resolve(function(){
  204. this.loadForm(callback)
  205. }.bind(this));
  206. }else{
  207. this.loadForm(callback);
  208. }
  209. }.bind(this));
  210. }.bind(this));
  211. }.bind(this));
  212. },
  213. loadResource : function( callback ){
  214. var cb = function () {
  215. if( this.syncScriptLoaded && this.asyncScriptLoaded && this.dictionaryLoaded ){
  216. if(callback)callback();
  217. }
  218. }.bind(this);
  219. this.loadScriptList( cb );
  220. this.loadDictionaryList( cb );
  221. },
  222. loadDictionaryList: function( callback ){
  223. this.dictionaryLoaded = false;
  224. var loadedCount = 0;
  225. if( this.json.dictionaries && this.json.dictionaries.length ){
  226. this.json.dictionaries.map(function (d) {
  227. d.type = d.appType;
  228. d.application = d.application || d.appId || d.appName;
  229. new this.Macro.environment.Dict( d ).get( "", function(){
  230. loadedCount++;
  231. if (this.json.dictionaries.length <= loadedCount){
  232. this.dictionaryLoaded = true;
  233. if(callback)callback();
  234. }
  235. }.bind(this), null, true);
  236. }.bind(this));
  237. }else{
  238. this.dictionaryLoaded = true;
  239. if(callback)callback();
  240. }
  241. },
  242. loadScriptList : function( callback ){
  243. var asyncList = [];
  244. var syncList = [];
  245. this.syncScriptLoaded = false;
  246. this.asyncScriptLoaded = false;
  247. if( this.json.scripts && this.json.scripts.length ){
  248. for( var i=0; i<this.json.scripts.length; i++ ){
  249. var script = this.json.scripts[i];
  250. script.scriptList.map( function ( s ) {
  251. s.type = s.appType;
  252. s.application = s.application || s.appId || s.appName;
  253. });
  254. if( script.async ){
  255. asyncList = asyncList.concat( script.scriptList );
  256. }else{
  257. syncList = syncList.concat( script.scriptList );
  258. }
  259. }
  260. }
  261. var loadSyncList = function () {
  262. if( syncList.length === 0 ){
  263. this.syncScriptLoaded = true;
  264. if(callback)callback();
  265. }else{
  266. this.Macro.environment.include(syncList, function(){
  267. this.syncScriptLoaded = true;
  268. if(callback)callback();
  269. }.bind(this), false);
  270. }
  271. }.bind(this);
  272. var loadAsyncList = function () {
  273. if( asyncList.length === 0 ){
  274. this.asyncScriptLoaded = true;
  275. if(callback)callback();
  276. }else{
  277. this.Macro.environment.include(asyncList, function(){
  278. this.asyncScriptLoaded = true;
  279. if(callback)callback();
  280. }.bind(this), true);
  281. }
  282. }.bind(this);
  283. loadAsyncList();
  284. loadSyncList();
  285. },
  286. loadForm: function(callback){
  287. if (this.lockDataPerson){
  288. var text = MWF.xApplication.process.Xform.LP.keyLockInfor;
  289. text = text.replace("{name}", o2.name.cn(this.lockDataPerson));
  290. var title = MWF.xApplication.process.Xform.LP.keyLockTitle;
  291. this.app.alert("info", "center", title, text, 400, 160);
  292. }
  293. if (this.app) if (this.app.fireEvent) this.app.fireEvent("queryLoad");
  294. this._loadBusinessData();
  295. this.fireEvent("beforeLoad");
  296. if (this.app) if (this.app.fireEvent) this.app.fireEvent("beforeLoad");
  297. this.loadContent(callback);
  298. },
  299. loadExtendStyle: function (callback) {
  300. if (!this.json.styleConfig || !this.json.styleConfig.extendFile) {
  301. if (callback) callback();
  302. return;
  303. }
  304. if (this.json["$version"]=="5.2"){
  305. if (callback) callback();
  306. return;
  307. }
  308. var stylesUrl = "../x_component_process_FormDesigner/Module/Form/skin/" + this.json.styleConfig.extendFile;
  309. MWF.getJSON(stylesUrl, {
  310. "onSuccess": function (responseJSON) {
  311. if (responseJSON && responseJSON.form) {
  312. this.json = Object.merge(this.json, responseJSON.form);
  313. }
  314. if (callback) callback();
  315. }.bind(this),
  316. "onRequestFailure": function () {
  317. if (callback) callback();
  318. }.bind(this),
  319. "onError": function () {
  320. if (callback) callback();
  321. }.bind(this)
  322. }
  323. );
  324. },
  325. loadMacro: function (callback) {
  326. //if (!MWF.Macro[this.options.macro || "FormContext"]){
  327. MWF.require("MWF.xScript.Macro", function () {
  328. this.Macro = new MWF.Macro[this.options.macro || "FormContext"](this);
  329. if (callback) callback();
  330. }.bind(this));
  331. // }else{
  332. // this.Macro = new MWF.Macro[this.options.macro || "FormContext"](this);
  333. // if (callback) callback();
  334. // }
  335. },
  336. loadContent: function (callback) {
  337. this.subformCount = 0;
  338. this.subformLoadedCount = 0;
  339. this.subformLoaded = [this.json.id];
  340. this.subpageCount = 0;
  341. this.subpageLoadedCount = 0;
  342. this.subpageLoaded = [];
  343. this.widgetCount = 0;
  344. this.widgetLoadedCount = 0;
  345. this.widgetLoaded = [];
  346. this._loadHtml();
  347. this._loadForm();
  348. this.fireEvent("beforeModulesLoad");
  349. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeModulesLoad");
  350. this._loadModules(this.node);
  351. if (Browser.firefox) this.container.setStyle("opacity", 1);
  352. if (this.json.mode === "Mobile") {
  353. var node = document.body.getElement(".o2_form_mobile_actions");
  354. if (node) {
  355. node.empty();
  356. this._loadMobileActions(node, callback);
  357. }else {
  358. console.log("没有找到移动端底部操作栏!")
  359. }
  360. } else {
  361. if (callback) callback();
  362. }
  363. this.fireEvent("postLoad");
  364. if (this.app && this.app.fireEvent) this.app.fireEvent("postLoad");
  365. this.checkSubformLoaded(true);
  366. },
  367. checkSubformLoaded: function (isAllSubformLoaded) {
  368. if (isAllSubformLoaded) {
  369. this.isAllSubformLoaded = true;
  370. }
  371. if (!this.isAllSubformLoaded) return;
  372. //console.log( "checkSubformLoaded this.subformCount="+ this.subformCount + " this.subformLoadedCount="+this.subformLoadedCount );
  373. if ((!this.subformCount || this.subformCount === this.subformLoadedCount) &&
  374. (!this.subpageCount || this.subpageCount === this.subpageLoadedCount) &&
  375. (!this.widgetCount || this.widgetCount === this.widgetLoadedCount)
  376. ) {
  377. //this.container.setStyle("opacity", 1);
  378. this.fireEvent("afterModulesLoad");
  379. if (this.app && this.app.fireEvent) this.app.fireEvent("afterModulesLoad");
  380. this.fireEvent("afterLoad");
  381. if (this.app && this.app.fireEvent) this.app.fireEvent("afterLoad");
  382. this.isLoaded = true;
  383. }
  384. },
  385. _loadMobileDefaultTools: function (callback) {
  386. if (this.json.defaultTools) {
  387. if (callback) callback();
  388. } else {
  389. this.json.defaultTools = o2.JSON.get("../x_component_process_FormDesigner/Module/Form/toolbars.json", function (json) {
  390. this.json.defaultTools = json;
  391. if (callback) callback();
  392. }.bind(this));
  393. }
  394. },
  395. _loadMobileActions: function (node, callback) {
  396. var tools = [];
  397. this._loadMobileDefaultTools(function () {
  398. if (this.json.defaultTools) {
  399. this.json.defaultTools.each(function (tool) {
  400. var flag = this._checkDefaultMobileActionItem(tool, this.options.readonly);
  401. if (flag) tools.push(tool);
  402. }.bind(this));
  403. }
  404. if (this.json.tools) {
  405. this.json.tools.each(function (tool) {
  406. var flag = this._checkCustomMobileActionItem(tool, this.options.readonly);
  407. if (flag) tools.push(tool);
  408. }.bind(this));
  409. }
  410. this.mobileTools = tools;
  411. //app上用原来的按钮样式
  412. if (window.o2android) {
  413. if (tools.length) if (node) this._createMobileActions(node, tools);
  414. } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mLog) {
  415. if (tools.length) if (node) this._createMobileActions(node, tools);
  416. } else {
  417. //钉钉 企业微信用新的样式
  418. if (tools.length) if (node) this._createMobileActionsDingdingStyle(node, tools);
  419. }
  420. if (callback) callback();
  421. }.bind(this));
  422. },
  423. // 修改成钉钉 button
  424. _createMobileActionsDingdingStyle: function (node, tools) {
  425. node.show();
  426. var count = tools.length;
  427. if (count <= 2) {
  428. //左边 间隔
  429. var dingdingSplitLeft = new Element("div", { "styles": this.css.html5ActionButtonDingdingSplit, "text": " " }).inject(node);
  430. var splitSize = dingdingSplitLeft.getSize();
  431. var size = document.body.getSize();
  432. var buttonWidth = (size.x - splitSize.x * (count + 1) - (count * 2)) / count;
  433. tools.each(function (tool) {
  434. var actionStyle = this.css.html5ActionButtonDingdingNormal;
  435. if (tool.text === "继续流转" || tool.text === "撤回" || tool.id === "action_processWork" || tool.id === "action_retract") {
  436. actionStyle = this.css.html5ActionButtonDingdingPrimary;
  437. } else if (tool.text === "删除文件" || tool.id === "action_delete") {
  438. actionStyle = this.css.html5ActionButtonDingdingDanger;
  439. }
  440. actionStyle.width = buttonWidth + "px";
  441. var action = new Element("div", { "styles": actionStyle, "text": tool.text }).inject(node);
  442. action.store("tool", tool);
  443. action.addEvent("click", function (e) {
  444. var clickFun = function () {
  445. var t = e.target.retrieve("tool");
  446. e.setDisable = function () { };
  447. if (t.actionScript) {
  448. this._runCustomAction(t.actionScript);
  449. } else {
  450. if (this[t.action]) this[t.action](e);
  451. }
  452. }.bind(this);
  453. if (tool.text === "继续流转" || tool.id === "action_processWork") {
  454. //输入法激活的时候,需要一段时间等待输入法关闭
  455. window.setTimeout(clickFun, 100)
  456. } else {
  457. clickFun();
  458. }
  459. }.bind(this));
  460. new Element("div", { "styles": this.css.html5ActionButtonDingdingSplit, "text": " " }).inject(node);
  461. }.bind(this));
  462. } else {
  463. //左边 间隔
  464. var dingdingSplitLeft = new Element("div", { "styles": this.css.html5ActionButtonDingdingSplit, "text": " " }).inject(node);
  465. var splitSize = dingdingSplitLeft.getSize();
  466. var size = document.body.getSize();
  467. var buttonWidth = (size.x - splitSize.x * 4 - 6) / 5;
  468. for (var i = 0; i < 3; i++) {
  469. tool = tools[i];
  470. var actionStyle = this.css.html5ActionButtonDingdingNormal;
  471. if (tool.text === "继续流转" || tool.text === "撤回") {
  472. actionStyle = this.css.html5ActionButtonDingdingPrimary;
  473. } else if (tool.text === "删除文件") {
  474. actionStyle = this.css.html5ActionButtonDingdingDanger;
  475. }
  476. if (i == 2) {
  477. this.css.html5ActionButtonDingdingMore.width = buttonWidth + "px";
  478. var action = new Element("div", { "styles": this.css.html5ActionButtonDingdingMore, "text": "…" }).inject(node);
  479. action.addEvent("click", function (e) {
  480. this._loadMoreMobileActionsDingdingStyle(tools, 2, node);
  481. }.bind(this));
  482. } else {
  483. actionStyle.width = (buttonWidth * 2) + "px";
  484. var action = new Element("div", { "styles": actionStyle, "text": tool.text }).inject(node);
  485. action.store("tool", tool);
  486. action.addEvent("click", function (e) {
  487. var t = e.target.retrieve("tool");
  488. e.setDisable = function () { }
  489. if (t.actionScript) {
  490. this._runCustomAction(t.actionScript);
  491. } else {
  492. if (this[t.action]) this[t.action](e);
  493. }
  494. }.bind(this));
  495. }
  496. new Element("div", { "styles": this.css.html5ActionButtonDingdingSplit, "text": " " }).inject(node);
  497. }
  498. }
  499. },
  500. _loadMoreMobileActionsDingdingStyle: function (tools, n, node) {
  501. document.body.mask({
  502. "style": {
  503. "background-color": "#cccccc",
  504. "opacity": 0.6
  505. },
  506. "hideOnClick": true,
  507. "onHide": function () {
  508. this.actionMoreArea.setStyle("display", "none");
  509. }.bind(this)
  510. });
  511. if (this.actionMoreArea) {
  512. this.actionMoreArea.setStyle("display", "block");
  513. } else {
  514. var size = document.body.getSize();
  515. this.actionMoreArea = new Element("div", { "styles": this.css.html5ActionOtherArea }).inject(document.body);
  516. var pl = this.actionMoreArea.getStyle("padding-left").toInt();
  517. var pr = this.actionMoreArea.getStyle("padding-right").toInt();
  518. var w = size.x - pl - pr;
  519. this.actionMoreArea.setStyle("width", "" + w + "px");
  520. for (var i = n; i < tools.length; i++) {
  521. tool = tools[i];
  522. var actionStyle = this.css.html5ActionButtonDingdingNormal;
  523. if (tool.text === "继续流转" || tool.text === "撤回") {
  524. actionStyle = this.css.html5ActionButtonDingdingPrimary;
  525. } else if (tool.text === "删除文件") {
  526. actionStyle = this.css.html5ActionButtonDingdingDanger;
  527. }
  528. actionStyle.width = "100%";
  529. var action = new Element("div", { "styles": actionStyle, "text": tool.text }).inject(this.actionMoreArea);
  530. action.store("tool", tool);
  531. action.addEvent("click", function (e) {
  532. var t = e.target.retrieve("tool");
  533. e.setDisable = function () { }
  534. if (t.actionScript) {
  535. this._runCustomAction(t.actionScript);
  536. } else {
  537. if (this[t.action]) this[t.action](e);
  538. }
  539. }.bind(this));
  540. }
  541. }
  542. },
  543. _createMobileActions: function (node, tools) {
  544. node.show();
  545. var count = tools.length;
  546. if (count <= 2) {
  547. this.css.html5ActionButton.width = "100%";
  548. if (count == 2) this.css.html5ActionButton.width = "49%";
  549. tools.each(function (tool) {
  550. var action = new Element("div", { "styles": this.css.html5ActionButton, "text": tool.text }).inject(node);
  551. action.store("tool", tool);
  552. action.addEvent("click", function (e) {
  553. var t = e.target.retrieve("tool");
  554. e.setDisable = function () { }
  555. if (t.actionScript) {
  556. this._runCustomAction(t.actionScript);
  557. } else {
  558. if (this[t.action]) this[t.action](e);
  559. }
  560. }.bind(this));
  561. this._setMobileBottonStyle(action);
  562. }.bind(this));
  563. if (count == 2) new Element("div", { "styles": this.css.html5ActionButtonSplit }).inject(node.getLast(), "before");
  564. } else {
  565. this.css.html5ActionButton.width = "38%"
  566. for (var i = 0; i < 2; i++) {
  567. tool = tools[i];
  568. var action = new Element("div", { "styles": this.css.html5ActionButton, "text": tool.text }).inject(node);
  569. action.store("tool", tool);
  570. action.addEvent("click", function (e) {
  571. var t = e.target.retrieve("tool");
  572. e.setDisable = function () { }
  573. if (t.actionScript) {
  574. this._runCustomAction(t.actionScript);
  575. } else {
  576. if (this[t.action]) this[t.action](e);
  577. }
  578. }.bind(this));
  579. this._setMobileBottonStyle(action);
  580. }
  581. new Element("div", { "styles": this.css.html5ActionButtonSplit }).inject(node.getLast(), "before");
  582. new Element("div", { "styles": this.css.html5ActionButtonSplit }).inject(node);
  583. this.css.html5ActionButton.width = "23%"
  584. var action = new Element("div", { "styles": this.css.html5ActionButton, "text": "…" }).inject(node);
  585. action.addEvent("click", function (e) {
  586. this._loadMoreMobileActions(tools, 2, node);
  587. }.bind(this));
  588. this._setMobileBottonStyle(action);
  589. }
  590. },
  591. _loadMoreMobileActions: function (tools, n, node) {
  592. document.body.mask({
  593. "style": {
  594. "background-color": "#cccccc",
  595. "opacity": 0.6
  596. },
  597. "hideOnClick": true,
  598. "onHide": function () {
  599. this.actionMoreArea.setStyle("display", "none");
  600. }.bind(this)
  601. });
  602. if (this.actionMoreArea) {
  603. this.actionMoreArea.setStyle("display", "block");
  604. } else {
  605. var size = document.body.getSize();
  606. this.actionMoreArea = new Element("div", { "styles": this.css.html5ActionOtherArea }).inject(document.body);
  607. var pl = this.actionMoreArea.getStyle("padding-left").toInt();
  608. var pr = this.actionMoreArea.getStyle("padding-right").toInt();
  609. var w = size.x - pl - pr;
  610. this.actionMoreArea.setStyle("width", "" + w + "px");
  611. for (var i = n; i < tools.length; i++) {
  612. tool = tools[i];
  613. var action = new Element("div", { "styles": this.css.html5ActionOtherButton, "text": tool.text }).inject(this.actionMoreArea);
  614. action.store("tool", tool);
  615. action.addEvent("click", function (e) {
  616. var t = e.target.retrieve("tool");
  617. e.setDisable = function () { }
  618. if (t.actionScript) {
  619. this._runCustomAction(t.actionScript);
  620. } else {
  621. if (this[t.action]) this[t.action](e);
  622. }
  623. }.bind(this));
  624. this._setMobileBottonStyle(action);
  625. }
  626. }
  627. // actionArea.position({
  628. // relativeTo: node,
  629. // position: 'topCenter',
  630. // edge: 'bottomCenter'
  631. // });
  632. },
  633. _setMobileBottonStyle: function (action) {
  634. var _self = this;
  635. action.addEvents({
  636. "mouseover": function (e) { this.setStyles(_self.css.html5ActionButton_over) },
  637. "mouseout": function (e) { this.setStyles(_self.css.html5ActionButton_up) },
  638. "mousedown": function (e) { this.setStyles(_self.css.html5ActionButton_over) },
  639. "mouseup": function (e) { this.setStyles(_self.css.html5ActionButton_up) },
  640. "touchstart": function (e) { this.setStyles(_self.css.html5ActionButton_over) },
  641. "touchcancel": function (e) { this.setStyles(_self.css.html5ActionButton_up) },
  642. "touchend": function (e) { this.setStyles(_self.css.html5ActionButton_up) },
  643. "touchmove": function (e) { this.setStyles(_self.css.html5ActionButton_over) }
  644. });
  645. },
  646. _runCustomAction: function (actionScript) {
  647. //var script = bt.node.retrieve("script");
  648. this.Macro.exec(actionScript, this);
  649. },
  650. _checkCustomMobileActionItem: function (tool, readonly) {
  651. var flag = true;
  652. if (readonly) {
  653. flag = tool.readShow;
  654. } else {
  655. flag = tool.editShow;
  656. }
  657. if (flag) {
  658. flag = true;
  659. if (tool.control) {
  660. flag = this.form.businessData.control[tool.control]
  661. }
  662. if (tool.condition) {
  663. var hideFlag = this.Macro.exec(tool.condition, this);
  664. flag = !hideFlag;
  665. }
  666. }
  667. return flag;
  668. },
  669. _checkDefaultMobileActionItem: function (tool, readonly, noCondition) {
  670. var flag = true;
  671. if (tool.control) {
  672. flag = this.businessData.control[tool.control]
  673. }
  674. if (!noCondition) if (tool.condition) {
  675. var hideFlag = this.Macro.exec(tool.condition, this);
  676. flag = flag && (!hideFlag);
  677. }
  678. if (tool.id == "action_processWork") {
  679. if (!this.businessData.task && this.businessData.work.startTime) {
  680. flag = false;
  681. }
  682. }
  683. if (tool.id == "action_rollback") tool.read = true;
  684. if (readonly) if (!tool.read) flag = false;
  685. return flag;
  686. },
  687. _loadBusinessData: function () {
  688. if (!this.businessData) {
  689. this.businessData = {};
  690. // this.businessData = {
  691. // "data": {
  692. // "select": "222",
  693. // "radio": "bbb",
  694. // "checkbox": ["check1", "check3"],
  695. // "orderData": [
  696. // {
  697. // "orderName": {"namefield": "电脑"},
  698. // "orderCount": {"countField": "3"},
  699. // "priceCount": {"priceField": "9000"}
  700. // },
  701. // {
  702. // "orderName": {"namefield": "路由器"},
  703. // "orderCount": {"countField": "2"},
  704. // "priceCount": {"priceField": "1000"}
  705. // },
  706. // {
  707. // "orderName": {"namefield": "网线"},
  708. // "orderCount": {"countField": "10"},
  709. // "priceCount": {"priceField": "200"}
  710. // }
  711. // ]
  712. //
  713. // }
  714. // };
  715. }
  716. },
  717. _loadHtml: function () {
  718. // this.container.set("html", this.html);
  719. // this.node = this.container.getFirst();
  720. //this.node.setStyle("overflow", "hidden");
  721. this.node.addEvent("selectstart", function (e) {
  722. var select = "text";
  723. if (e.target.getStyle("-webkit-user-select")) {
  724. select = e.target.getStyle("-webkit-user-select").toString().toLowerCase();
  725. }
  726. if (select !== "text" && select !== "auto") e.preventDefault();
  727. });
  728. },
  729. _loadForm: function () {
  730. this._loadStyles();
  731. this._loadCssLinks();
  732. this._loadScriptSrc();
  733. this._loadJsheader();
  734. //this._loadEvents();
  735. },
  736. _loadStyles: function () {
  737. if (this.json.styles) Object.each(this.json.styles, function (value, key) {
  738. if ((value.indexOf("x_processplatform_assemble_surface") != -1 || value.indexOf("x_portal_assemble_surface") != -1)) {
  739. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  740. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  741. if (value.indexOf("/x_processplatform_assemble_surface") !== -1) {
  742. value = value.replace("/x_processplatform_assemble_surface", host1 + "/x_processplatform_assemble_surface");
  743. } else if (value.indexOf("x_processplatform_assemble_surface") !== -1) {
  744. value = value.replace("x_processplatform_assemble_surface", host1 + "/x_processplatform_assemble_surface");
  745. }
  746. if (value.indexOf("/x_portal_assemble_surface") !== -1) {
  747. value = value.replace("/x_portal_assemble_surface", host2 + "/x_portal_assemble_surface");
  748. } else if (value.indexOf("x_portal_assemble_surface") !== -1) {
  749. value = value.replace("x_portal_assemble_surface", host2 + "/x_portal_assemble_surface");
  750. }
  751. }
  752. this.node.setStyle(key, value);
  753. }.bind(this));
  754. //this.node.setStyles(this.json.styles);
  755. },
  756. _loadCssLinks: function () {
  757. var urls = this.json.cssLinks;
  758. urls.each(function (url) {
  759. new Element("link", {
  760. "rel": "stylesheet",
  761. "type": "text/css",
  762. "href": url
  763. }).inject($(document.head));
  764. });
  765. },
  766. _loadScriptSrc: function () {
  767. var urls = this.json.scriptSrc;
  768. urls.each(function (url) {
  769. new Element("script", {
  770. "src": url
  771. }).inject($(document.head));
  772. });
  773. },
  774. _loadJsheader: function () {
  775. var code = (this.json.jsheader) ? this.json.jsheader.code : "";
  776. if (code) Browser.exec(code);
  777. },
  778. _loadEvents: function () {
  779. Object.each(this.json.events, function (e, key) {
  780. if (e.code) {
  781. if (this.options.moduleEvents.indexOf(key) !== -1) {
  782. this.addEvent(key, function (event) {
  783. return this.Macro.fire(e.code, this, event);
  784. }.bind(this));
  785. } else {
  786. if (key === "load") {
  787. this.addEvent("postLoad", function () {
  788. return this.Macro.fire(e.code, this);
  789. }.bind(this));
  790. } else if (key === "submit") {
  791. this.addEvent("beforeProcess", function () {
  792. return this.Macro.fire(e.code, this);
  793. }.bind(this));
  794. } else {
  795. this.node.addEvent(key, function (event) {
  796. return this.Macro.fire(e.code, this, event);
  797. }.bind(this));
  798. }
  799. }
  800. }
  801. }.bind(this));
  802. },
  803. addModuleEvent: function (key, fun) {
  804. if (this.options.moduleEvents.indexOf(key) !== -1) {
  805. this.addEvent(key, function (event) {
  806. return (fun) ? fun(this, event) : null;
  807. }.bind(this));
  808. } else {
  809. if (key === "load") {
  810. this.addEvent("postLoad", function (event) {
  811. return (fun) ? fun(this, event) : null;
  812. }.bind(this));
  813. } else if (key === "submit") {
  814. this.addEvent("beforeProcess", function (event) {
  815. return (fun) ? fun(this, event) : null;
  816. }.bind(this));
  817. } else {
  818. this.node.addEvent(key, function (event) {
  819. return (fun) ? fun(this, event) : null;
  820. }.bind(this));
  821. }
  822. }
  823. },
  824. _getDomjson: function (dom) {
  825. var mwfType = dom.get("MWFtype") || dom.get("mwftype");
  826. switch (mwfType) {
  827. case "form":
  828. return this.json;
  829. case "":
  830. return null;
  831. default:
  832. var id = dom.get("id");
  833. if (!id) id = dom.get("MWFId");
  834. if (id) {
  835. return this.json.moduleList[id];
  836. } else {
  837. return null;
  838. }
  839. }
  840. },
  841. _getModuleNodes: function (dom) {
  842. var moduleNodes = [];
  843. var subDom = dom.getFirst();
  844. while (subDom) {
  845. var mwftype = subDom.get("MWFtype") || subDom.get("mwftype");
  846. if (mwftype) {
  847. var type = mwftype;
  848. if (type.indexOf("$") === -1) {
  849. moduleNodes.push(subDom);
  850. }
  851. // && mwftype !== "tab$Content"
  852. if (mwftype !== "datagrid" && mwftype !== "subSource" && mwftype !== "tab$Content") {
  853. moduleNodes = moduleNodes.concat(this._getModuleNodes(subDom));
  854. }
  855. } else {
  856. moduleNodes = moduleNodes.concat(this._getModuleNodes(subDom));
  857. }
  858. subDom = subDom.getNext();
  859. }
  860. return moduleNodes;
  861. },
  862. _loadModules: function (dom) {
  863. //var subDom = this.node.getFirst();
  864. //while (subDom){
  865. // if (subDom.get("MWFtype")){
  866. // var json = this._getDomjson(subDom);
  867. // var module = this._loadModule(json, subDom);
  868. // this.modules.push(module);
  869. // }
  870. // subDom = subDom.getNext();
  871. //}
  872. var moduleNodes = this._getModuleNodes(dom);
  873. //alert(moduleNodes.length);
  874. moduleNodes.each(function (node) {
  875. var json = this._getDomjson(node);
  876. //if( json.type === "Subform" || json.moduleName === "subform" )this.subformCount++;
  877. //if( json.type === "Subpage" || json.moduleName === "subpage" )this.subpageCount++;
  878. var module = this._loadModule(json, node);
  879. this.modules.push(module);
  880. }.bind(this));
  881. },
  882. _loadModule: function (json, node, beforeLoad) {
  883. //console.log( json.id );
  884. if (json.type === "Subform" || json.moduleName === "subform") this.subformCount++;
  885. //if( json.type === "Subform" || json.moduleName === "subform" ){
  886. // console.log( "add subformcount , this.subformCount = " + this.subformCount );
  887. //}
  888. if (json.type === "Subpage" || json.moduleName === "subpage") this.subpageCount++;
  889. if (json.type === "Widget" || json.moduleName === "widget") this.widgetCount++;
  890. if (!MWF["APP" + json.type]) {
  891. MWF.xDesktop.requireApp("process.Xform", json.type, null, false);
  892. }
  893. var module = new MWF["APP" + json.type](node, json, this);
  894. if (beforeLoad) beforeLoad.apply(module);
  895. if (!this.all[json.id]) this.all[json.id] = module;
  896. if ( json.name ){
  897. if( this.allForName[json.name] ){
  898. var item = this.allForName[json.name];
  899. typeOf(item) === "array" ? item.push( module ) : this.allForName[json.name] = [item, module];
  900. }else{
  901. this.allForName[json.name] = module;
  902. }
  903. }
  904. if (module.field) {
  905. if (!this.forms[json.id]) this.forms[json.id] = module;
  906. }
  907. module.readonly = this.options.readonly;
  908. module.load();
  909. return module;
  910. },
  911. saveOpinion: function (module) {
  912. var op = module._getBusinessSectionDataByPerson();
  913. MWF.UD.getDataJson("userOpinion", function (json) {
  914. if (!json) json = [];
  915. var idx = json.indexOf(op);
  916. if (idx == -1) {
  917. if (json.length >= 50) json.shift();
  918. } else {
  919. json.splice(idx, 1);
  920. }
  921. json.push(op);
  922. MWF.UD.putData("userOpinion", json);
  923. }.bind(this), false);
  924. },
  925. loadPathData: function (path) {
  926. var data = null;
  927. this.workAction.getJobDataByPath(this.businessData.work.job, path, function (json) {
  928. data = json.data || null;
  929. }, null, false);
  930. return data;
  931. },
  932. getData: function (issubmit) {
  933. //var data = Object.clone(this.businessData.data);
  934. var data = this.businessData.data;
  935. Object.each(this.forms, function (module, id) {
  936. if (module.json.type === "Opinion") {
  937. debugger;
  938. if (issubmit) {
  939. this.saveOpinion(module);
  940. var key = layout.desktop.session.user.id;
  941. if( typeOf( data[id] ) === "object" && typeOf(data[id][key])==="string" ){
  942. data[id][key]= "";
  943. }else if( typeOf( data[id] ) === "string" ){
  944. data[id] = "";
  945. }
  946. // delete data[id];
  947. } else {
  948. var v = module.getData();
  949. // var d = this.loadPathData(id);
  950. // if (d) data[id] = d;
  951. data[id] = this.getSectionDataByPerson(v, data[id]);
  952. }
  953. } else {
  954. if (module.json.section === "yes") {
  955. // var d = this.loadPathData(id);
  956. // if (d) data[id] = d;
  957. data[id] = this.getSectionData(module, data[id]);
  958. } else {
  959. data[id] = module.getData();
  960. }
  961. }
  962. }.bind(this));
  963. this.businessData.data = data;
  964. this.Macro.environment.setData(this.businessData.data);
  965. return data;
  966. },
  967. getSectionData: function (module, obj) {
  968. var v = module.getData();
  969. switch (module.json.sectionBy) {
  970. case "person":
  971. return this.getSectionDataByPerson(v, obj);
  972. case "unit":
  973. return this.getSectionDataByUnit(v, obj);
  974. case "activity":
  975. return this.getSectionDataByPActivity(v, obj);
  976. case "splitValue":
  977. return this.getSectionDataBySplitValue(v, obj);
  978. case "script":
  979. return this.getSectionDataByScript(module.json.sectionByScript.code, v, obj);
  980. default:
  981. return v;
  982. }
  983. },
  984. getSectionDataByPerson: function (v, obj) {
  985. var key = layout.desktop.session.user.id;
  986. if (!obj || (typeOf(obj) !== "object")) obj = {};
  987. obj[key] = v;
  988. return obj;
  989. },
  990. getSectionDataByUnit: function (v, obj) {
  991. var key = (this.businessData.task) ? this.businessData.task.unit : "";
  992. if (!obj || (typeOf(obj) !== "object")) obj = {};
  993. if (key) obj[key] = v;
  994. return obj;
  995. },
  996. getSectionDataByPActivity: function (v, obj) {
  997. var key = (this.businessData.work) ? this.businessData.work.activity : "";
  998. if (!obj || (typeOf(obj) !== "object")) obj = {};
  999. if (key) obj[key] = v;
  1000. return obj;
  1001. },
  1002. getSectionDataBySplitValue: function (v, obj) {
  1003. var key = (this.businessData.work) ? this.businessData.work.splitValue : "";
  1004. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1005. if (key) obj[key] = v;
  1006. return obj;
  1007. },
  1008. getSectionDataByScript: function (code, v, obj) {
  1009. var key = this.Macro.exec(code, this);
  1010. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1011. if (key) obj[key] = v;
  1012. return obj;
  1013. },
  1014. setSection: function (json, data) {
  1015. var obj = data[json.name];
  1016. switch (json.sectionBy) {
  1017. case "person":
  1018. return this.setSectionByPerson(obj, json.name);
  1019. case "unit":
  1020. return this.setSectionByUnit(obj, json.name);
  1021. case "activity":
  1022. return this.setSectionByPActivity(obj, json.name);
  1023. case "splitValue":
  1024. return this.setSectionBySplitValue(obj, json.name);
  1025. case "script":
  1026. return this.setSectionByScript(json.sectionByScript.code, obj, json.name);
  1027. default:
  1028. return v;
  1029. }
  1030. },
  1031. setSectionByPerson: function (obj, name) {
  1032. var key = layout.desktop.session.user.id;
  1033. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1034. //obj[key] = v;
  1035. this.sectionListObj[name] = key;
  1036. return obj;
  1037. },
  1038. setSectionByUnit: function (obj, name) {
  1039. var key = (this.businessData.task) ? this.businessData.task.unit : "";
  1040. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1041. this.sectionListObj[name] = key || "";
  1042. //if (key) obj[key] = v;
  1043. return obj;
  1044. },
  1045. setSectionByPActivity: function (obj, name) {
  1046. var key = (this.businessData.work) ? this.businessData.work.activity : "";
  1047. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1048. this.sectionListObj[name] = key || "";
  1049. //if (key) obj[key] = v;
  1050. return obj;
  1051. },
  1052. setSectionBySplitValue: function (obj, name) {
  1053. var key = (this.businessData.work) ? this.businessData.work.splitValue : "";
  1054. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1055. this.sectionListObj[name] = key || "";
  1056. //if (key) obj[key] = v;
  1057. return obj;
  1058. },
  1059. setSectionByScript: function (code, obj, name) {
  1060. var key = this.Macro.exec(code, this);
  1061. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1062. this.sectionListObj[name] = key || "";
  1063. //if (key) obj[key] = v;
  1064. return obj;
  1065. },
  1066. saveWork: function (callback, silent) {
  1067. debugger;
  1068. if (this.businessData.control["allowSave"]) {
  1069. this.fireEvent("beforeSave");
  1070. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeSave");
  1071. this.saveFormData(function (json) {
  1072. if (this.app && !silent) this.app.notice(MWF.xApplication.process.Xform.LP.dataSaved, "success");
  1073. if (callback && typeOf(callback) === "function") callback();
  1074. this.fireEvent("afterSave");
  1075. if (this.app && this.app.fireEvent) this.app.fireEvent("afterSave");
  1076. }.bind(this));
  1077. } else {
  1078. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  1079. //if (failure) failure(null, "Permission Denied", "");
  1080. }
  1081. },
  1082. getSectionList: function () {
  1083. return Object.keys(this.sectionListObj).map(function (p) {
  1084. var o = { "path": p };
  1085. if (this.sectionListObj[p]) o.key = this.sectionListObj[p];
  1086. return o;
  1087. }.bind(this));
  1088. },
  1089. setModifedDataByPathList: function (data, pathList) {
  1090. var d = this.modifedData;
  1091. for (var i = 0; i < pathList.length; i++) {
  1092. if (i === pathList.length - 1) {
  1093. d[pathList[i]] = data;
  1094. } else {
  1095. if (typeOf(d[pathList[i]]) === "object" || typeOf(d[pathList[i]]) === "array") {
  1096. d = d[pathList[i]]
  1097. } else if (typeOf(pathList[i]) === "number") {
  1098. d = d[pathList[i]] = [];
  1099. } else {
  1100. d = d[pathList[i]] = {};
  1101. }
  1102. }
  1103. }
  1104. },
  1105. getOrigianlPathData: function (pathList) {
  1106. var d = this.businessData.originalData;
  1107. for (var i = 0; i < pathList.length; i++) {
  1108. if (i === pathList.length - 1) {
  1109. d = d[pathList[i]];
  1110. } else {
  1111. if (typeOf(d[pathList[i]]) === "object" || typeOf(d[pathList[i]]) === "array") {
  1112. d = d[pathList[i]];
  1113. } else {
  1114. return null;
  1115. }
  1116. }
  1117. }
  1118. return d;
  1119. },
  1120. setModifedData: function (data, pathList) {
  1121. pathList = pathList || [];
  1122. if (typeOf(data) === "object") {
  1123. for (var key in data) {
  1124. var pList = Array.clone(pathList);
  1125. pList.push(key);
  1126. this.setModifedData(data[key], pList);
  1127. }
  1128. } else if (typeOf(data) === "array") {
  1129. var od = this.getOrigianlPathData(pathList);
  1130. if (typeOf(od) !== "array" || od.length !== data.length || JSON.stringify(od) !== JSON.stringify(data)) {
  1131. this.setModifedDataByPathList(data, pathList);
  1132. }
  1133. //}else{
  1134. // for( var i=0; i<data.length; i++ ){
  1135. // this.setModifedData(data[i], pathList.push(i));
  1136. // }
  1137. //}
  1138. } else if (typeOf(data) !== "null") { //后台对null是忽略处理的,认为值没有变化
  1139. var od = this.getOrigianlPathData(pathList);
  1140. if (typeOf(data) !== typeOf(od) || data !== od) {
  1141. this.setModifedDataByPathList(data, pathList);
  1142. }
  1143. }
  1144. },
  1145. saveFormData: function (callback, failure, history, data, issubmit) {
  1146. if (this.businessData.work.startTime) {
  1147. this.saveFormDataInstance(callback, failure, history, data, issubmit);
  1148. } else {
  1149. this.saveFormDataDraft(callback, failure, history, data, issubmit);
  1150. }
  1151. },
  1152. saveFormDataInstance: function (callback, failure, history, data, issubmit) {
  1153. if (this.officeList) {
  1154. this.officeList.each(function (module) {
  1155. module.save(history);
  1156. });
  1157. }
  1158. var data = data || this.getData(issubmit);
  1159. this.modifedData = {};
  1160. this.setModifedData(data);
  1161. this.workAction.saveData(callback || function () { }, failure, this.businessData.work.id, this.modifedData);
  1162. this.businessData.originalData = null;
  1163. this.businessData.originalData = Object.clone(data);
  1164. },
  1165. saveFormDataDraft: function (callback, failure, history, data, issubmit) {
  1166. if (this.officeList) {
  1167. this.officeList.each(function (module) {
  1168. module.save(history);
  1169. });
  1170. }
  1171. var data = data || this.getData(issubmit);
  1172. var draft = {
  1173. "data": data,
  1174. "work": this.businessData.work,
  1175. "identity": this.businessData.work.creatorIdentityDn
  1176. }
  1177. this.workAction.saveDraft(draft, function (json) {
  1178. this.workAction.getDraft(json.data.id, function (json) {
  1179. this.businessData.work = json.data.work;
  1180. this.app.options.draftId = json.data.work.id;
  1181. this.app.options.desktopReload = true;
  1182. this.app.appId = "process.Work" + json.data.work.id;
  1183. if(layout.desktop.apps) {
  1184. delete layout.desktop.apps[this.app.options.appId];
  1185. }else {
  1186. layout.desktop.apps = {};
  1187. }
  1188. layout.desktop.apps[this.app.appId] = this.app;
  1189. if (callback) callback();
  1190. }.bind(this));
  1191. }.bind(this), failure);
  1192. this.businessData.originalData = null;
  1193. this.businessData.originalData = Object.clone(data);
  1194. },
  1195. setProcessorSectionOrgList: function (data) {
  1196. if (!this.routeDataList) this.getRouteDataList();
  1197. var routeList = this.routeDataList;
  1198. //var processorSectionOrg = [];
  1199. for (var i = 0; i < routeList.length; i++) {
  1200. (routeList[i].selectConfigList || []).each(function (config, j) {
  1201. if (config.section == "yes") {
  1202. this.setSection(config, data);
  1203. }
  1204. }.bind(this))
  1205. }
  1206. },
  1207. getRouteDataList: function () {
  1208. if (!this.routeDataList) {
  1209. o2.Actions.get("x_processplatform_assemble_surface").listRoute({ "valueList": this.businessData.task.routeList }, function (json) {
  1210. json.data.each(function (d) {
  1211. d.selectConfigList = JSON.parse(d.selectConfig || "[]");
  1212. }.bind(this));
  1213. this.routeDataList = json.data;
  1214. }.bind(this), null, false);
  1215. }
  1216. return this.routeDataList;
  1217. },
  1218. beforeCloseWork: function () {
  1219. this.fireEvent("beforeClose");
  1220. if (this.app && this.app.fireEvent) {
  1221. this.app.fireEvent("beforeClose");
  1222. // this.fireEvent("afterClose");
  1223. }
  1224. if (!this.options.readonly) {
  1225. if (this.businessData.work && this.businessData.work.id) {
  1226. if (this.app.inBrowser && navigator.sendBeacon) {
  1227. debugger;
  1228. var obj = this.workAction.action.actions["checkDraft"];
  1229. var url = this.workAction.action.address + obj.uri;
  1230. url = url.replace("{id}", this.businessData.work.id);
  1231. navigator.sendBeacon(url);
  1232. } else {
  1233. this.workAction.checkDraft(this.businessData.work.id, function () {
  1234. if (layout.desktop.apps) {
  1235. if (layout.desktop.apps["TaskCenter"] && layout.desktop.apps["TaskCenter"].window) {
  1236. layout.desktop.apps["TaskCenter"].content.unmask();
  1237. layout.desktop.apps["TaskCenter"].refreshAll();
  1238. }
  1239. }
  1240. }.bind(this), null, false);
  1241. }
  1242. }
  1243. } else {
  1244. this.app.refreshTaskCenter();
  1245. }
  1246. },
  1247. closeWork: function () {
  1248. // this.fireEvent("beforeClose");
  1249. // if (this.app && this.app.fireEvent){
  1250. // this.app.fireEvent("beforeClose");
  1251. // // this.fireEvent("afterClose");
  1252. // }
  1253. // debugger;
  1254. // if (!this.options.readonly)
  1255. // if (this.businessData.work) this.workAction.checkDraft(this.businessData.work.id);
  1256. this.app.close();
  1257. },
  1258. getMessageContent: function (data, maxLength, titlelp) {
  1259. var content = "";
  1260. if (data.completed) {
  1261. content += MWF.xApplication.process.Xform.LP.workCompleted;
  1262. } else {
  1263. if (data.properties.nextManualList && data.properties.nextManualList.length) {
  1264. var activityUsers = [];
  1265. data.properties.nextManualList.each(function (a) {
  1266. var ids = [];
  1267. a.taskIdentityList.each(function (i) {
  1268. ids.push(o2.name.cn(i))
  1269. });
  1270. var t = "<b>" + MWF.xApplication.process.Xform.LP.nextActivity + "</b><span style='color: #ea621f'>" + a.activityName + "</span>;<b>" + MWF.xApplication.process.Xform.LP.nextUser + "</b><span style='color: #ea621f'>" + ids.join(",") + "</span>";
  1271. activityUsers.push(t);
  1272. });
  1273. content += activityUsers.join("<br>");
  1274. } else {
  1275. if (data.arrivedActivityName) {
  1276. content += MWF.xApplication.process.Xform.LP.arrivedActivity + data.arrivedActivityName;
  1277. } else {
  1278. content += MWF.xApplication.process.Xform.LP.taskCompleted;
  1279. }
  1280. }
  1281. }
  1282. var title = this.businessData.data.title || this.businessData.data.subject || this.businessData.work.title
  1283. if (maxLength && title.length > maxLength) {
  1284. title = title.substr(0, maxLength) + "..."
  1285. }
  1286. return "<div>" + (titlelp || MWF.xApplication.process.Xform.LP.taskProcessedMessage) + "“" + title + "”</div>" + content;
  1287. },
  1288. addMessage: function (data, notShowBrowserDkg) {
  1289. if (layout.desktop.message) {
  1290. var msg = {
  1291. "subject": MWF.xApplication.process.Xform.LP.taskProcessed,
  1292. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.taskProcessedMessage)
  1293. };
  1294. layout.desktop.message.addTooltip(msg);
  1295. return layout.desktop.message.addMessage(msg);
  1296. } else {
  1297. if (this.app.inBrowser && !notShowBrowserDkg) {
  1298. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.taskProcessedMessage));
  1299. }
  1300. }
  1301. },
  1302. formValidation: function (routeName, opinion, medias) {
  1303. if (this.options.readonly) return true;
  1304. this.Macro.environment.form.currentRouteName = routeName;
  1305. this.Macro.environment.form.opinion = opinion;
  1306. this.Macro.environment.form.medias = medias;
  1307. var flag = true;
  1308. //flag = this.validation();
  1309. Object.each(this.forms, function (field, key) {
  1310. field.validationMode();
  1311. if (!field.validation(routeName, opinion, medias)) flag = false;
  1312. }.bind(this));
  1313. return flag;
  1314. },
  1315. validation: function (routeName, opinion, processor, medias) {
  1316. this.Macro.environment.form.currentRouteName = routeName;
  1317. this.Macro.environment.form.opinion = opinion;
  1318. this.Macro.environment.form.medias = medias;
  1319. var routeFlag = this.validationRoute(processor);
  1320. var opinionFlag = this.validationOpinion(processor);
  1321. return routeFlag && opinionFlag;
  1322. },
  1323. validationRoute: function (processor) {
  1324. if (!this.json.validationRoute) return true;
  1325. if (!this.json.validationRoute.code) return true;
  1326. var flag = this.Macro.exec(this.json.validationRoute.code, this);
  1327. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1328. if (flag.toString() != "true") {
  1329. this.notValidationRouteMode(flag, processor);
  1330. return false;
  1331. }
  1332. return true;
  1333. },
  1334. validationOpinion: function (processor) {
  1335. if (!this.json.validationOpinion) return true;
  1336. if (!this.json.validationOpinion.code) return true;
  1337. var flag = this.Macro.exec(this.json.validationOpinion.code, this);
  1338. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1339. if (flag.toString() != "true") {
  1340. this.notValidationOpinionMode(flag, processor);
  1341. return false;
  1342. }
  1343. return true;
  1344. },
  1345. formCustomValidation: function () {
  1346. if (!this.json.validationFormCustom) return true;
  1347. if (!this.json.validationFormCustom.code) return true;
  1348. var flag = this.Macro.exec(this.json.validationFormCustom.code, this);
  1349. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1350. if (flag.toString() != "true") {
  1351. this.notValidationOpinionMode(flag);
  1352. return false;
  1353. }
  1354. return true;
  1355. },
  1356. notValidationRouteMode: function (flag, processor) {
  1357. if (processor) processor.routeSelectorArea.setStyle("background-color", "#ffe9e9");
  1358. MWF.xDesktop.notice(
  1359. "error",
  1360. { "x": "center", "y": "top" },
  1361. flag,
  1362. (processor) ? processor.routeSelectorArea : this.app.content,
  1363. null, //{"x": 0, "y": 30}
  1364. { "closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000 }
  1365. );
  1366. //new mBox.Notice({
  1367. // type: "error",
  1368. // position: {"x": "center", "y": "top"},
  1369. // move: false,
  1370. // target: (processor) ? processor.routeSelectorArea : this.app.content,
  1371. // delayClose: 6000,
  1372. // content: flag
  1373. //});
  1374. },
  1375. notValidationOpinionMode: function (flag, processor) {
  1376. if (processor) processor.inputTextarea.setStyle("background-color", "#ffe9e9");
  1377. MWF.xDesktop.notice(
  1378. "error",
  1379. (processor) ? { "x": "center", "y": "top" } : { "x": "right", "y": "top" },
  1380. flag,
  1381. (processor) ? processor.inputTextarea : this.app.content,
  1382. null, //{"x": 0, "y": 30}
  1383. { "closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000 }
  1384. );
  1385. //new mBox.Notice({
  1386. // type: "error",
  1387. // position: (processor) ? {"x": "center", "y": "top"} : {"x": "right", "y": "top"},
  1388. // move: false,
  1389. // target: (processor) ? processor.inputTextarea : this.app.content,
  1390. // delayClose: 6000,
  1391. // content: flag
  1392. //});
  1393. },
  1394. //fireRtEvent: function(type, args, delay){
  1395. // type = removeOn(type);
  1396. // var events = this.$events[type];
  1397. // if (!events) return this;
  1398. // if (!events.length) return this;
  1399. // var event = events[events.length-1];
  1400. // args = Array.from(args);
  1401. // if (delay) fn.delay(delay, this, args);
  1402. // else return fn.apply(this, args);
  1403. // return this;
  1404. //},
  1405. getIgnoreImpowerIdentity: function (processorOrgList) {
  1406. debugger;
  1407. var list = [];
  1408. var check = function (org, isProcessOrg) {
  1409. var moduleData = isProcessOrg ? org.getValue() : org.getData();
  1410. var flag = false;
  1411. if (typeOf(moduleData) === "array" && moduleData.length) {
  1412. moduleData.each(function (d) {
  1413. if (d.ignoreEmpower) {
  1414. list.push(d.distinguishedName || d.unique || d.id);
  1415. d.ignoredEmpower = true;
  1416. delete d.ignoreEmpower;
  1417. flag = true;
  1418. }
  1419. })
  1420. }
  1421. if (flag) org.setData(moduleData);
  1422. }
  1423. var modules = this.modules;
  1424. for (var i = 0; i < modules.length; i++) {
  1425. var module = modules[i];
  1426. var moduleName = module.json.moduleName;
  1427. if (!moduleName) moduleName = typeOf(module.json.type) === "string" ? module.json.type.toLowerCase() : "";
  1428. if (moduleName === "org") {
  1429. check(module)
  1430. }
  1431. }
  1432. if (processorOrgList && processorOrgList.length > 0) {
  1433. for (var i = 0; i < processorOrgList.length; i++) {
  1434. check(processorOrgList[i], true)
  1435. }
  1436. }
  1437. return list;
  1438. },
  1439. //saveDocumentEditor
  1440. submitWork: function (routeName, opinion, medias, callback, processor, data, appendTaskIdentityList, processorOrgList, callbackBeforeSave) {
  1441. if (!this.businessData.control["allowProcessing"]) {
  1442. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  1443. this.app.content.unmask();
  1444. if (processor && processor.node) processor.node.unmask();
  1445. return false;
  1446. }
  1447. debugger;
  1448. if (!this.formValidation(routeName, opinion, medias)) {
  1449. this.app.content.unmask();
  1450. //this.app.notice("", "error", target, where, offset);
  1451. if (callback) callback();
  1452. return false;
  1453. }
  1454. if (!this.validation(routeName, opinion, processor, medias)) {
  1455. //this.app.content.unmask();
  1456. if (processor && processor.node) processor.node.unmask();
  1457. //if (callback) callback();
  1458. return false;
  1459. }
  1460. if (!opinion) {
  1461. var idx = this.businessData.task.routeNameList.indexOf(routeName);
  1462. if (this.businessData.task.routeOpinionList[idx]) {
  1463. opinion = this.businessData.task.routeOpinionList[idx];
  1464. }
  1465. // else{
  1466. // opinion = routeName;
  1467. // }
  1468. }
  1469. this.fireEvent("beforeProcess");
  1470. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcess");
  1471. // if (this.documenteditorList) {
  1472. // this.documenteditorList.each(function (module) {
  1473. // module.save(history);
  1474. // });
  1475. // }
  1476. //处理忽略授权
  1477. var ignoreEmpowerIdentityList = this.getIgnoreImpowerIdentity(processorOrgList);
  1478. var _self = this;
  1479. MWF.require("MWF.widget.Mask", function () {
  1480. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  1481. this.mask.loadNode(this.app.content);
  1482. if (callbackBeforeSave) callbackBeforeSave();
  1483. this.fireEvent("beforeSave");
  1484. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeSave");
  1485. this.saveFormData(function (json) {
  1486. this.businessData.task.routeName = routeName;
  1487. this.businessData.task.opinion = opinion || "";
  1488. var mediaIds = [];
  1489. if (medias && medias.length) {
  1490. medias.each(function (file) {
  1491. var formData = new FormData();
  1492. formData.append("file", file);
  1493. formData.append("site", "$mediaOpinion");
  1494. this.workAction.uploadAttachment(this.businessData.work.id, formData, file, function (json) {
  1495. mediaIds.push(json.data.id);
  1496. }.bind(this), null, false);
  1497. }.bind(this));
  1498. }
  1499. if (mediaIds.length) this.businessData.task.mediaOpinion = mediaIds.join(",");
  1500. if (appendTaskIdentityList && appendTaskIdentityList.length) {
  1501. var list = [];
  1502. appendTaskIdentityList.each(function (identity) {
  1503. if (typeOf(identity) === "object") {
  1504. list.push(identity.distinguishedName || identity.unique || identity.id)
  1505. } else {
  1506. list.push(identity);
  1507. }
  1508. }.bind(this));
  1509. this.businessData.task.appendTaskIdentityList = list;
  1510. }
  1511. this.businessData.task.ignoreEmpowerIdentityList = ignoreEmpowerIdentityList;
  1512. this.fireEvent("afterSave");
  1513. if (this.app && this.app.fireEvent) this.app.fireEvent("afterSave");
  1514. this.workAction.processTask(function (json) {
  1515. //if (processor) processor.destroy();
  1516. //if (processNode) processNode.destroy();
  1517. if (callback) callback(json);
  1518. this.taskList = json.data;
  1519. this.fireEvent("afterProcess");
  1520. if (this.app && this.app.fireEvent) this.app.fireEvent("afterProcess");
  1521. // this.notice(MWF.xApplication.process.Xform.LP.taskProcessed, "success");
  1522. this.addMessage(json.data, true);
  1523. if (this.app.taskObject) this.app.taskObject.destroy();
  1524. if (this.closeImmediatelyOnProcess) {
  1525. this.app.close();
  1526. } else if (typeOf(this.showCustomSubmitedDialog) === "function") {
  1527. this.showCustomSubmitedDialog(json.data);
  1528. } else if (layout.mobile) {
  1529. //移动端页面关闭
  1530. _self.finishOnMobile()
  1531. } else {
  1532. if (this.app.inBrowser) {
  1533. if (this.mask) this.mask.hide();
  1534. if (this.json.isPrompt !== false) {
  1535. this.showSubmitedDialog(json.data);
  1536. } else {
  1537. if (this.json.afterProcessAction=="redirect" && this.json.afterProcessRedirectScript && this.json.afterProcessRedirectScript.code){
  1538. var url = this.Macro.exec(this.json.afterProcessRedirectScript.code, this);
  1539. (new URI(url)).go();
  1540. }else{
  1541. this.app.close();
  1542. }
  1543. }
  1544. //}
  1545. } else {
  1546. this.app.close();
  1547. }
  1548. }
  1549. //window.setTimeout(function(){this.app.close();}.bind(this), 2000);
  1550. }.bind(this), null, this.businessData.task.id, this.businessData.task);
  1551. }.bind(this), null, true, data, true);
  1552. }.bind(this));
  1553. },
  1554. showSubmitedDialog: function (data) {
  1555. var content = this.getMessageContent(data, this.json.submitedDlgStyle ? this.json.submitedDlgStyle.maxTitleLength : 60);
  1556. //if( this.json.submitedDlgUseNotice ){
  1557. // MWF.xDesktop.notice("success", {x: "right", y:"top"}, content);
  1558. // if (this.json.isPrompt!==false){
  1559. // if (this.json.promptCloseTime!=0){
  1560. // var t = this.json.promptCloseTime || 2;
  1561. // t = t.toInt()*1000;
  1562. // var _work = this;
  1563. // window.setTimeout(function(){ _work.app.close();}, t);
  1564. // }
  1565. // }else{
  1566. // this.app.close();
  1567. // }
  1568. //}else{
  1569. var div = new Element("div", { "styles": { "margin": "10px 10px 0px 10px", "padding": "5px", "overflow": "hidden", "width": "270px" } }).inject(this.app.content);
  1570. div.set("html", content);
  1571. var timerNode = new Element("div", { "styles": { "margin-top": "5px" } }).inject(div);
  1572. var options = {
  1573. "content": div,
  1574. "isTitle": false,
  1575. "width": 350,
  1576. "height": 180,
  1577. "buttonList": [
  1578. {
  1579. "text": this.app.lp.closePage,
  1580. "action": function () {
  1581. dlg.close();
  1582. if (this.json.afterProcessAction=="redirect" && this.json.afterProcessRedirectScript && this.json.afterProcessRedirectScript.code){
  1583. var url = this.Macro.exec(this.json.afterProcessRedirectScript.code, this);
  1584. (new URI(url)).go();
  1585. }else{
  1586. this.app.close();
  1587. }
  1588. }.bind(this)
  1589. }
  1590. ]
  1591. };
  1592. if (this.json.submitedDlgStyle) {
  1593. options = Object.merge(options, this.json.submitedDlgStyle);
  1594. if (this.json.submitedDlgStyle.contentStyle) {
  1595. div.setStyles(this.json.submitedDlgStyle.contentStyle);
  1596. delete options.contentStyle;
  1597. }
  1598. }
  1599. var size = this.app.content.getSize();
  1600. switch (options.promptPosition || this.json.promptPosition || "righttop") {
  1601. case "lefttop":
  1602. options.top = 10;
  1603. options.left = 10;
  1604. options.fromTop = 10;
  1605. options.fromLeft = 10;
  1606. break;
  1607. case "righttop":
  1608. options.top = 10;
  1609. options.left = size.x - options.width - 10;
  1610. options.fromTop = 10;
  1611. options.fromLeft = size.x - 10;
  1612. break;
  1613. case "leftbottom":
  1614. options.top = size.y - options.height - 10;
  1615. options.left = 10;
  1616. options.fromTop = size.y - 10;
  1617. options.fromLeft = 10;
  1618. break;
  1619. case "rightbottom":
  1620. options.top = size.y - options.height - 10;
  1621. options.left = size.x - options.width - 10;
  1622. options.fromTop = size.y - 10;
  1623. options.fromLeft = size.x - 10;
  1624. break;
  1625. default:
  1626. delete options.top;
  1627. delete options.left;
  1628. delete options.fromTop;
  1629. delete options.fromLeft;
  1630. }
  1631. var _work = this;
  1632. options.onPostLoad = function () {
  1633. debugger;
  1634. var dialog = this;
  1635. dialog.node.setStyle("display", "block");
  1636. var nodeSize = div.getSize();
  1637. dialog.content.setStyles({
  1638. //"width" : nodeSize.x,
  1639. "height": nodeSize.y
  1640. });
  1641. dialog.setContentSize();
  1642. if ((options.promptCloseTime || _work.json.promptCloseTime) != 0) {
  1643. var t = options.promptCloseTime || _work.json.promptCloseTime || 2;
  1644. t = t.toInt() * 1000;
  1645. if (options.isCountDown) {
  1646. timerNode.set("text", _work.app.lp.closePageCountDownText.replace("{second}", Math.ceil(t / 1000).toString()));
  1647. t = t - 1000;
  1648. var countDown = function () {
  1649. if (t > 0) {
  1650. timerNode.set("text", _work.app.lp.closePageCountDownText.replace("{second}", Math.ceil(t / 1000).toString()));
  1651. t = t - 1000;
  1652. window.setTimeout(countDown, 1000);
  1653. } else {
  1654. dlg.close();
  1655. if (_work.json.afterProcessAction=="redirect" && _work.json.afterProcessRedirectScript && _work.json.afterProcessRedirectScript.code){
  1656. var url = _work.Macro.exec(_work.json.afterProcessRedirectScript.code, _work);
  1657. (new URI(url)).go();
  1658. }else{
  1659. _work.app.close();
  1660. }
  1661. }
  1662. };
  1663. window.setTimeout(countDown, 1000);
  1664. } else {
  1665. window.setTimeout(function () {
  1666. if (_work.json.afterProcessAction=="redirect" && _work.json.afterProcessRedirectScript && _work.json.afterProcessRedirectScript.code){
  1667. var url = _work.Macro.exec(_work.json.afterProcessRedirectScript.code, _work);
  1668. (new URI(url)).go();
  1669. }else{
  1670. _work.app.close();
  1671. }
  1672. }, t);
  1673. }
  1674. }
  1675. };
  1676. var dlg = o2.DL.open(options);
  1677. },
  1678. startDraftProcess: function () {
  1679. if (!this.formCustomValidation("", "")) {
  1680. this.app.content.unmask();
  1681. // if (callback) callback();
  1682. return false;
  1683. }
  1684. if (!this.formValidation("", "")) {
  1685. this.app.content.unmask();
  1686. // if (callback) callback();
  1687. return false;
  1688. }
  1689. this.saveFormData(function () {
  1690. this.workAction.startDraft(this.businessData.work.id, function (json) {
  1691. this.app.options.workId = json.data[0].work;
  1692. if (layout.mobile) {
  1693. if(layout.notice) {
  1694. layout.notice(MWF.xApplication.process.Xform.LP.processStartedMessage + "“[" + json.data[0].processName + "]" + (this.businessData.data.title || this.businessData.data.subject));
  1695. }
  1696. }else {
  1697. var msg = {
  1698. "subject": MWF.xApplication.process.Xform.LP.processStarted,
  1699. "content": "<div>" + MWF.xApplication.process.Xform.LP.processStartedMessage + "“[" + json.data[0].processName + "]" + (this.businessData.data.title || this.businessData.data.subject) + "”</div>"
  1700. };
  1701. var tooltip = layout.desktop.message.addTooltip(msg);
  1702. var item = layout.desktop.message.addMessage(msg);
  1703. }
  1704. this.app.reload();
  1705. //this.app.notice(MWF.xApplication.process.Xform.LP.dataSaved, "success");
  1706. //草稿模式暂时不能上传附件,不能直接流转文件
  1707. // o2.Actions.invokeAsync([
  1708. // {"action": this.workAction, "name": "loadWork"},
  1709. // {"action": this.workAction, "name": "getWorkControl"},
  1710. // {"action": this.workAction, "name": "getWorkLog"},
  1711. // {"action": this.workAction, "name": "getRecordLog"},
  1712. // {"action": this.workAction, "name": "listAttachments"}
  1713. // ], {"success": function(json_work, json_control, json_log, json_record, json_att){
  1714. // if (json_work && json_control && json_log && json_att){
  1715. // this.app.parseData(json_work.data, json_control.data, null, json_log.data, json_record.data, json_att.data);
  1716. // var workData = json_work.data;
  1717. // this.businessData.activity = workData.activity;
  1718. // this.businessData.originalData = Object.clone( this.businessData.data );
  1719. // this.businessData.taskList = workData.taskList;
  1720. // this.businessData.task = this.getCurrentTaskData(workData);
  1721. // this.businessData.taskList = workData.taskList;
  1722. // this.businessData.readList = workData.readList;
  1723. // this.businessData.work = workData.work;
  1724. // this.businessData.workCompleted = (workData.work.completedTime) ? workData.work : null;
  1725. //
  1726. // this.businessData.workLogList = json_log.data;
  1727. // this.businessData.recordList = json_record.data;
  1728. // this.businessData.attachmentList = json_att.data;
  1729. // this.businessData.control = json_control.data;
  1730. //
  1731. // if (this.businessData.task){
  1732. // this.processWork();
  1733. // }else{
  1734. // this.app.options.workId = json.data[0].work;
  1735. // this.app.reload();
  1736. // }
  1737. // }
  1738. // }.bind(this), "failure": function(){}}, json.data[0].work);
  1739. }.bind(this));
  1740. }.bind(this), null, false, null, false)
  1741. },
  1742. getCurrentTaskData: function (data) {
  1743. if ((data.currentTaskIndex || data.currentTaskIndex === 0) && data.currentTaskIndex != -1) {
  1744. this.app.options.taskId = this.businessData.taskList[data.currentTaskIndex].id;
  1745. return this.businessData.taskList[data.currentTaskIndex];
  1746. }
  1747. return null;
  1748. },
  1749. processWork: function () {
  1750. var _self = this;
  1751. debugger;
  1752. if (!this.businessData.work.startTime) {
  1753. this.startDraftProcess();
  1754. } else if( this.json.submitFormType === "select" ){
  1755. this.processWork_custom();
  1756. } else if( this.json.submitFormType === "script" ){
  1757. this.processWork_custom();
  1758. } else {
  1759. if (this.json.mode == "Mobile") {
  1760. setTimeout(function () {
  1761. this.processWork_mobile();
  1762. }.bind(this), 100);
  1763. } else {
  1764. this.processWork_pc();
  1765. }
  1766. }
  1767. },
  1768. processWork_custom : function(){
  1769. this.fireEvent("beforeProcessWork");
  1770. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  1771. if (!this.formCustomValidation("", "")) {
  1772. this.app.content.unmask();
  1773. // if (callback) callback();
  1774. return false;
  1775. }
  1776. if (!this.formValidation("", "")) {
  1777. this.app.content.unmask();
  1778. // if (callback) callback();
  1779. return false;
  1780. }
  1781. debugger;
  1782. if( !this.submitFormModule ){
  1783. if (!MWF["APPSubmitform"]) {
  1784. MWF.xDesktop.requireApp("process.Xform", "Subform", null, false);
  1785. }
  1786. var submitFormContainer = new Element("div").inject( layout.mobile ? $(document.body) : this.app.content );
  1787. this.submitFormModule = new MWF["APPSubmitform"]( submitFormContainer , this.json, this);
  1788. this.submitFormModule.addEvent("afterModulesLoad", function () {
  1789. this.submitFormModule.show();
  1790. }.bind(this))
  1791. this.submitFormModule.load();
  1792. }else{
  1793. this.submitFormModule.show();
  1794. }
  1795. },
  1796. processWork_pc: function(){
  1797. var _self = this;
  1798. this.fireEvent("beforeProcessWork");
  1799. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  1800. if (!this.formCustomValidation("", "")) {
  1801. this.app.content.unmask();
  1802. // if (callback) callback();
  1803. return false;
  1804. }
  1805. // MWF.require("MWF.widget.Mask", function() {
  1806. // this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1807. // this.mask.loadNode(this.app.content);
  1808. if (!this.formValidation("", "")) {
  1809. this.app.content.unmask();
  1810. // if (callback) callback();
  1811. return false;
  1812. }
  1813. var setSize = function (notRecenter) {
  1814. debugger;
  1815. var dlg = this;
  1816. if (!dlg || !dlg.node) return;
  1817. dlg.node.setStyle("display", "block");
  1818. var size = processNode.getSize();
  1819. dlg.content.setStyles({
  1820. "height": size.y,
  1821. "width": size.x
  1822. });
  1823. debugger;
  1824. var s = dlg.setContentSize();
  1825. // if ( dlg.content.getStyle("overflow-y") === "auto" && dlg.content.getStyle("overflow-x") !== "auto" ) {
  1826. // var paddingRight = (dlg.content.getStyle("padding-right").toInt() || 0 );
  1827. // if( paddingRight < 20 ){
  1828. // dlg.node.setStyle("width", dlg.node.getStyle("width").toInt() + 20 + "px");
  1829. // dlg.content.setStyle("width", dlg.content.getStyle("width").toInt() + 20 + "px");
  1830. // }
  1831. // }
  1832. if (!notRecenter) dlg.reCenter();
  1833. }
  1834. //var node = new Element("div", {"styles": this.css.rollbackAreaNode});
  1835. var processNode = new Element("div", { "styles": this.app.css.processNode_Area }).inject(this.node);
  1836. this.setProcessNode(processNode, "process", function ( processor ){
  1837. this.processDlg = o2.DL.open({
  1838. "title": this.app.lp.process,
  1839. "style": this.json.dialogStyle || "user",
  1840. "isResize": false,
  1841. "content": processNode,
  1842. "maskNode": this.app.content,
  1843. "positionHeight": 800,
  1844. "maxHeight": 800,
  1845. "maxHeightPercent": "98%",
  1846. "minTop": 5,
  1847. "width": "auto", //processNode.retrieve("width") || 1000, //600,
  1848. "height": "auto", //processNode.retrieve("height") || 401,
  1849. "buttonList": [
  1850. {
  1851. "type": "ok",
  1852. "text": MWF.LP.process.button.ok,
  1853. "action": function (d, e) {
  1854. if (this.processor) this.processor.okButton.click();
  1855. }.bind(this)
  1856. },
  1857. {
  1858. "type": "cancel",
  1859. "text": MWF.LP.process.button.cancel,
  1860. "action": function () {
  1861. this.processDlg.close();
  1862. if (this.processor) this.processor.destroy();
  1863. }.bind(this)
  1864. }
  1865. ],
  1866. "onPostLoad": function () {
  1867. processor.options.mediaNode = this.content;
  1868. setSize.call(this)
  1869. }
  1870. });
  1871. }.bind(this), function () {
  1872. if (this.processDlg) setSize.call(this.processDlg, true)
  1873. }.bind(this));
  1874. },
  1875. processWork_mobile: function () {
  1876. if (this.app.inBrowser) {
  1877. this.app.content.setStyle("height", document.body.getSize().y);
  1878. }
  1879. this.fireEvent("beforeProcessWork");
  1880. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  1881. var position = this.app.content.getPosition(this.app.content.getOffsetParent());
  1882. if (this.json.mode != "Mobile") {
  1883. this.app.content.mask({
  1884. "destroyOnHide": true,
  1885. "style": this.app.css.maskNode,
  1886. "useIframeShim": true,
  1887. "iframeShimOptions": { "browsers": true },
  1888. "onShow": function () {
  1889. this.shim.shim.setStyles({
  1890. "opacity": 0,
  1891. "top": "" + position.y + "px",
  1892. "left": "" + position.x + "px"
  1893. });
  1894. }
  1895. });
  1896. }
  1897. if (!this.formCustomValidation("", "")) {
  1898. this.app.content.unmask();
  1899. // if (callback) callback();
  1900. return false;
  1901. }
  1902. // MWF.require("MWF.widget.Mask", function() {
  1903. // this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1904. // this.mask.loadNode(this.app.content);
  1905. if (!this.formValidation("", "")) {
  1906. this.app.content.unmask();
  1907. // if (callback) callback();
  1908. return false;
  1909. }
  1910. var processNode = this.createProcessNode();
  1911. //this.setProcessNode(processNode);
  1912. this.setProcessNode(processNode);
  1913. this.showProcessNode(processNode);
  1914. processNode.setStyle("overflow", "auto");
  1915. //}.bind(this));
  1916. },
  1917. createProcessNode: function () {
  1918. var fromCss = this.app.css.processNode_from;
  1919. var css = this.app.css.processNode;
  1920. if (layout.mobile) {
  1921. fromCss = this.app.css.processNodeMobile_from;
  1922. css = this.app.css.processNodeMobile;
  1923. // var contentSize = this.app.content.getSize();
  1924. fromCss.width = "100%";
  1925. css.width = "100%";
  1926. fromCss.height = "100%";
  1927. css.height = "100%";
  1928. }
  1929. if (this.json.mode == "Mobile") {
  1930. var processNode = new Element("div", { "styles": fromCss }).inject(document.body);
  1931. } else {
  1932. var processNode = new Element("div", { "styles": fromCss }).inject(this.app.content);
  1933. }
  1934. processNode.position({
  1935. relativeTo: this.app.content,
  1936. position: "topcenter",
  1937. edge: "topcenter"
  1938. });
  1939. return processNode;
  1940. },
  1941. getOpinion: function () {
  1942. var opinion = "";
  1943. var medias = [];
  1944. Object.each(this.forms, function (m, id) {
  1945. if (m.json.type === "Opinion") if (this.businessData.data[id]) opinion += " " + m._getBusinessSectionDataByPerson();
  1946. if (m.handwritingFile) if (m.handwritingFile[layout.session.user.distinguishedName]) medias.push(m.handwritingFile[layout.session.user.distinguishedName]);
  1947. if (m.soundFile) if (m.soundFile[layout.session.user.distinguishedName]) medias.push(m.soundFile[layout.session.user.distinguishedName]);
  1948. if (m.videoFile) if (m.videoFile[layout.session.user.distinguishedName]) medias.push(m.videoFile[layout.session.user.distinguishedName]);
  1949. }.bind(this));
  1950. return { "opinion": opinion.trim(), "medias": medias };
  1951. },
  1952. setProcessNode: function (processNode, style, postLoadFun, resizeFun) {
  1953. var _self = this;
  1954. MWF.xDesktop.requireApp("process.Work", "Processor", function () {
  1955. var op = this.getOpinion();
  1956. var mds = op.medias;
  1957. var innerNode;
  1958. if (layout.mobile) {
  1959. innerNode = new Element("div").inject(processNode);
  1960. }
  1961. this.processor = new MWF.xApplication.process.Work.Processor(innerNode || processNode, this.businessData.task, {
  1962. "style": (layout.mobile) ? "mobile" : (style || "default"),
  1963. "opinion": op.opinion,
  1964. "tabletWidth": this.json.tabletWidth || 0,
  1965. "tabletHeight": this.json.tabletHeight || 0,
  1966. "onPostLoad": function () {
  1967. if (postLoadFun) postLoadFun( this );
  1968. },
  1969. "onResize": function () {
  1970. if (resizeFun) resizeFun();
  1971. },
  1972. "onCancel": function () {
  1973. processNode.destroy();
  1974. _self.app.content.unmask();
  1975. delete this;
  1976. },
  1977. "onSubmit": function (routeName, opinion, medias, appendTaskIdentityList, processorOrgList, callbackBeforeSave) {
  1978. if (!medias || !medias.length) {
  1979. medias = mds;
  1980. } else {
  1981. medias = medias.concat(mds)
  1982. }
  1983. _self.submitWork(routeName, opinion, medias, function () {
  1984. this.destroy();
  1985. processNode.destroy();
  1986. if (_self.processDlg) _self.processDlg.close();
  1987. delete this;
  1988. }.bind(this), this, null, appendTaskIdentityList, processorOrgList, callbackBeforeSave);
  1989. }
  1990. }, this);
  1991. }.bind(this));
  1992. },
  1993. showProcessNode: function (processNode) {
  1994. if (layout.mobile) {
  1995. processNode.setStyles(this.app.css.processNodeMobile)
  1996. } else {
  1997. var size = this.app.content.getSize();
  1998. var nodeSize = processNode.getSize();
  1999. var top = size.y / 2 - nodeSize.y / 2 - 20;
  2000. var left = size.x / 2 - nodeSize.x / 2;
  2001. if (top < 0) top = 0;
  2002. this.app.css.processNode.top = "" + top + "px";
  2003. this.app.css.processNode.left = "" + left + "px";
  2004. var morph = new Fx.Morph(processNode, {
  2005. "duration": 300,
  2006. "transition": Fx.Transitions.Expo.easeOut
  2007. });
  2008. morph.start(this.app.css.processNode);
  2009. }
  2010. },
  2011. confirm: function (type, e, title, text, width, height, ok, cancel, callback, mask, style) {
  2012. MWF.require("MWF.xDesktop.Dialog", function () {
  2013. var size = this.container.getSize();
  2014. var x = 0;
  2015. var y = 0;
  2016. if (typeOf(e) === "element") {
  2017. var position = e.getPosition(this.app.content);
  2018. x = position.x;
  2019. y = position.y;
  2020. } else {
  2021. if (Browser.name == "firefox") {
  2022. x = parseFloat(e.event.clientX || e.event.x);
  2023. y = parseFloat(e.event.clientY || e.event.y);
  2024. } else {
  2025. x = parseFloat(e.event.x);
  2026. y = parseFloat(e.event.y);
  2027. }
  2028. if (e.target) {
  2029. var position = e.target.getPosition(this.app.content);
  2030. //var position = e.target.getPosition();
  2031. x = position.x;
  2032. y = position.y;
  2033. }
  2034. }
  2035. // if (Browser.Platform.ios){
  2036. // $("textdiv").set("text", "$(document.body).getScroll().y: "+$(document.body).getScroll().y);
  2037. // y = y-$(document.body).getScroll().y;
  2038. // }
  2039. if (x + parseFloat(width) > size.x) {
  2040. x = x - parseFloat(width);
  2041. }
  2042. if (x < 0) x = 10;
  2043. if (y + parseFloat(height) > size.y) {
  2044. y = y - parseFloat(height);
  2045. }
  2046. if (y < 0) y = 10;
  2047. //var x = parseFloat((Browser.name==="firefox") ? e.event.clientX : e.event.x);
  2048. //var y = parseFloat((Browser.name==="firefox") ? e.event.clientY : e.event.y);
  2049. // if (x+parseFloat(width)>size.x){
  2050. // x = x-parseFloat(width);
  2051. // }
  2052. if (x < 0) x = 20;
  2053. var dlg = new MWF.xDesktop.Dialog({
  2054. "title": title,
  2055. "style": style || "o2",
  2056. "top": y,
  2057. "left": x - 20,
  2058. "fromTop": e.event.y,
  2059. "fromLeft": (Browser.name === "firefox") ? e.event.clientX - 20 : e.event.x - 20,
  2060. "width": width,
  2061. "height": height,
  2062. "text": text,
  2063. "container": this.app.content,
  2064. "maskNode": mask || this.app.content,
  2065. "buttonList": [
  2066. {
  2067. "type": "ok",
  2068. "text": MWF.LP.process.button.ok,
  2069. "action": ok
  2070. },
  2071. {
  2072. "type": "cancel",
  2073. "text": MWF.LP.process.button.cancel,
  2074. "action": cancel
  2075. }
  2076. ]
  2077. });
  2078. switch (type.toLowerCase()) {
  2079. case "success":
  2080. if (this.json.confirmIcon && this.json.confirmIcon.success) {
  2081. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.success + ")");
  2082. } else {
  2083. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  2084. }
  2085. break;
  2086. case "error":
  2087. if (this.json.confirmIcon && this.json.confirmIcon.error) {
  2088. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.error + ")");
  2089. } else {
  2090. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  2091. }
  2092. break;
  2093. case "info":
  2094. if (this.json.confirmIcon && this.json.confirmIcon.info) {
  2095. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.info + ")");
  2096. } else {
  2097. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  2098. }
  2099. break;
  2100. case "warn":
  2101. if (this.json.confirmIcon && this.json.confirmIcon.warn) {
  2102. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.warn + ")");
  2103. } else {
  2104. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  2105. }
  2106. break;
  2107. default:
  2108. if (this.json.confirmIcon && this.json.confirmIcon.warn) {
  2109. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.warn + ")");
  2110. }
  2111. break;
  2112. }
  2113. dlg.show();
  2114. }.bind(this));
  2115. },
  2116. alert: function (type, title, text, width, height) {
  2117. this.app.alert(type, "center", title, text, width, height);
  2118. },
  2119. notice: function (content, type, target, where, offset, option) {
  2120. if (!where) where = { "x": "right", "y": "top" };
  2121. //if (!target) target = this.node;
  2122. if (!type) type = "ok";
  2123. var noticeTarget = target || this.app.window.content;
  2124. var off = offset;
  2125. if (!off) {
  2126. off = {
  2127. x: 10,
  2128. y: where.y.toString().toLowerCase() == "bottom" ? 10 : 10
  2129. };
  2130. }
  2131. var options = {
  2132. type: type,
  2133. position: where,
  2134. move: false,
  2135. target: noticeTarget,
  2136. delayClose: (type === "error") ? 10000 : 5000,
  2137. //delayClose: 20000000,
  2138. offset: off,
  2139. content: content
  2140. }
  2141. if (this.json.noticeStyle) {
  2142. options = Object.merge(options, this.json.noticeStyle);
  2143. }
  2144. if (this.json["notice" + type.capitalize() + "Style"]) {
  2145. options = Object.merge(options, this.json["notice" + type.capitalize() + "Style"]);
  2146. }
  2147. if (option && typeOf(option) === "object") {
  2148. options = Object.merge(options, option);
  2149. }
  2150. new mBox.Notice(options);
  2151. },
  2152. addSplit: function () {
  2153. if (!this.businessData.control["allowAddSplit"]) {
  2154. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  2155. return false;
  2156. }
  2157. MWF.require("MWF.xDesktop.Dialog", function () {
  2158. var width = 600;
  2159. var height = 230;
  2160. var p = MWF.getCenterPosition(this.app.content, width, height);
  2161. var _self = this;
  2162. var dlg = new MWF.xDesktop.Dialog({
  2163. "title": this.app.lp.addSplit,
  2164. //"style": "work","
  2165. "style": this.json.dialogStyle || "user",
  2166. "top": p.y - 100,
  2167. "left": p.x,
  2168. "fromTop": p.y - 100,
  2169. "fromLeft": p.x,
  2170. "width": width,
  2171. "height": height,
  2172. "url": this.app.path + "split.html",
  2173. "container": this.app.content,
  2174. "isClose": true,
  2175. "buttonList": [
  2176. {
  2177. "type": "ok",
  2178. "text": MWF.LP.process.button.ok,
  2179. "action": function (d, e) {
  2180. //this.doResetWork(dlg);
  2181. var input = dlg.content.getElement("input");
  2182. var checks = dlg.content.getElements(".o2_addSplit_radio");
  2183. var value = input.get("value");
  2184. var trimExist = true;
  2185. if (checks[1].checked) trimExist = false;
  2186. _self.doAddSplit(dlg, value, trimExist);
  2187. }.bind(this)
  2188. },
  2189. {
  2190. "type": "cancel",
  2191. "text": MWF.LP.process.button.cancel,
  2192. "action": function () { dlg.close(); }
  2193. }
  2194. ],
  2195. "onPostShow": function () {
  2196. //var okButton = dlg.content.getElement(".o2_addSplit_okButton");
  2197. //var cancelButton = dlg.content.getElement(".o2_addSplit_cancelButton");
  2198. var selectButton = dlg.content.getElement(".o2_addSplit_selector");
  2199. var input = dlg.content.getElement("input");
  2200. var checks = dlg.content.getElements(".o2_addSplit_radio");
  2201. //okButton.addEvent("click", function(){
  2202. // var value = input.get("value");
  2203. // var trimExist = true;
  2204. // if (checks[1].checked) trimExist = false;
  2205. // _self.doAddSplit(this, value, trimExist);
  2206. //}.bind(this));
  2207. //cancelButton.addEvent("click", function(){
  2208. // this.close();
  2209. //}.bind(this));
  2210. selectButton.addEvent("click", function () {
  2211. var value = input.get("value");
  2212. MWF.xDesktop.requireApp("Selector", "package", function () {
  2213. new o2.O2Selector(_self.app.content, {
  2214. "type": "",
  2215. "count": 0,
  2216. "values": (value) ? value.split(o2.splitStr) : [],
  2217. "types": ["unit", "identity", "group", "role"],
  2218. "onComplete": function (items) {
  2219. var v = [];
  2220. items.each(function (item) {
  2221. v.push(item.data.distinguishedName);
  2222. });
  2223. input.set("value", v.join(", "));
  2224. }
  2225. });
  2226. }.bind(this));
  2227. //_self.selectSplitUnit(this);
  2228. }.bind(this));
  2229. }
  2230. });
  2231. dlg.show();
  2232. }.bind(this));
  2233. },
  2234. doAddSplit: function (dlg, splitValues, trimExist) {
  2235. if (!splitValues) {
  2236. this.app.notice(MWF.xApplication.process.Xform.LP.inputSplitValue, "error", dlg.node);
  2237. return false;
  2238. }
  2239. MWF.require("MWF.widget.Mask", function () {
  2240. var splitValue = splitValues.split(o2.splitStr);
  2241. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2242. this.mask.loadNode(this.app.content);
  2243. this.fireEvent("beforeAddSplit");
  2244. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeAddSplit");
  2245. this.addSplitWork(splitValue, trimExist, function (json) {
  2246. this.fireEvent("afterAddSplit");
  2247. if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddSplit");
  2248. this.addAddSplitMessage(json.data);
  2249. // this.workAction.loadWork(function(workJson){
  2250. // this.fireEvent("afterAddSplit");
  2251. // if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddSplit");
  2252. // this.addAddSplitMessage(workJson.data);
  2253. // }.bind(this), null, this.businessData.work.id);
  2254. dlg.close();
  2255. if (this.mask) { this.mask.hide(); this.mask = null; }
  2256. }.bind(this), function (xhr, text, error) {
  2257. var errorText = error + ":" + text;
  2258. if (xhr) errorText = xhr.responseText;
  2259. this.app.notice("request json error: " + errorText, "error", dlg.node);
  2260. if (this.mask) { this.mask.hide(); this.mask = null; }
  2261. }.bind(this));
  2262. }.bind(this));
  2263. },
  2264. addSplitWork: function (splitValue, trimExist, success, failure) {
  2265. var data = { "splitValueList": splitValue, "trimExist": trimExist };
  2266. if (this.options.readonly) {
  2267. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2AddSplit(this.businessData.work.id, data,function (json) {
  2268. if (success) success(json);
  2269. }.bind(this),
  2270. function (xhr, text, error) {
  2271. if (failure) failure(xhr, text, error);
  2272. });
  2273. // this.workAction.addSplit(
  2274. // function (json) {
  2275. // if (success) success(json);
  2276. // }.bind(this),
  2277. // function (xhr, text, error) {
  2278. // if (failure) failure(xhr, text, error);
  2279. // },
  2280. // this.businessData.work.id, data
  2281. // );
  2282. } else {
  2283. this.saveFormData(
  2284. function (json) {
  2285. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2AddSplit(this.businessData.work.id, data,function (json) {
  2286. if (success) success(json);
  2287. }.bind(this),
  2288. function (xhr, text, error) {
  2289. if (failure) failure(xhr, text, error);
  2290. });
  2291. // this.workAction.addSplit(
  2292. // function (json) {
  2293. // if (success) success(json);
  2294. // }.bind(this),
  2295. // function (xhr, text, error) {
  2296. // if (failure) failure(xhr, text, error);
  2297. // },
  2298. // this.businessData.work.id, data
  2299. // );
  2300. }.bind(this),
  2301. function (xhr, text, error) {
  2302. if (failure) failure(xhr, text, error);
  2303. }, true, null, true
  2304. );
  2305. }
  2306. },
  2307. setRollBackChecked: function (item) {
  2308. item.store("isSelected", true);
  2309. item.setStyles(this.css.rollbackItemNode_current);
  2310. item.getFirst().setStyles(this.css.rollbackItemIconNode_current);
  2311. var node = item.getLast().getFirst();
  2312. node.getFirst().setStyles(this.css.rollbackItemActivityNode_current);
  2313. node.getLast().setStyles(this.css.rollbackItemTimeNode_current);
  2314. node = item.getLast().getLast();
  2315. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode_current);
  2316. node.getLast().setStyles(this.css.rollbackItemTaskNode_current);
  2317. var checkeds = item.getElements("input");
  2318. if (checkeds) checkeds.set("checked", true);
  2319. },
  2320. setRollBackUnchecked: function (item) {
  2321. item.store("isSelected", false);
  2322. item.setStyles(this.css.rollbackItemNode);
  2323. item.getFirst().setStyles(this.css.rollbackItemIconNode);
  2324. var node = item.getLast().getFirst();
  2325. node.getFirst().setStyles(this.css.rollbackItemActivityNode);
  2326. node.getLast().setStyles(this.css.rollbackItemTimeNode);
  2327. node = item.getLast().getLast();
  2328. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode);
  2329. node.getLast().setStyles(this.css.rollbackItemTaskNode);
  2330. var checkeds = item.getElements("input");
  2331. if (checkeds) checkeds.set("checked", false);
  2332. },
  2333. getRollbackLogs: function (rollbackItemNode) {
  2334. var _self = this;
  2335. o2.Actions.load("x_processplatform_assemble_surface").WorkLogAction.listRollbackWithWorkOrWorkCompleted(this.businessData.work.id, function (json) {
  2336. json.data.each(function (log) {
  2337. //if (!log.splitting && log.connected && (log.taskCompletedList.length || log.readList.length || log.readCompletedList.length)) {
  2338. if (!log.splitting && log.connected) {
  2339. var node = new Element("div", { "styles": this.css.rollbackItemNode }).inject(rollbackItemNode);
  2340. node.store("log", log);
  2341. var iconNode = new Element("div", { "styles": this.css.rollbackItemIconNode }).inject(node);
  2342. var contentNode = new Element("div", { "styles": this.css.rollbackItemContentNode }).inject(node);
  2343. var div = new Element("div", { "styles": { "overflow": "hidden" } }).inject(contentNode);
  2344. var activityNode = new Element("div", { "styles": this.css.rollbackItemActivityNode, "text": log.fromActivityName }).inject(div);
  2345. var timeNode = new Element("div", { "styles": this.css.rollbackItemTimeNode, "text": log.arrivedTime }).inject(div);
  2346. div = new Element("div", { "styles": { "overflow": "hidden" } }).inject(contentNode);
  2347. var taskTitleNode = new Element("div", { "styles": this.css.rollbackItemTaskTitleNode, "text": this.app.lp.taskCompletedPerson + ": " }).inject(div);
  2348. if (log.taskCompletedList.length) {
  2349. log.taskCompletedList.each(function (o) {
  2350. var text = o2.name.cn(o.person) + "(" + o.completedTime + ")";
  2351. var check = new Element("input", {
  2352. "value": o.identity,
  2353. "type": "checkbox",
  2354. "styles": this.css.rollbackItemTaskCheckNode
  2355. }).inject(div);
  2356. check.addEvent("click", function (e) {
  2357. e.stopPropagation();
  2358. });
  2359. var taskNode = new Element("div", { "styles": this.css.rollbackItemTaskNode, "text": text }).inject(div);
  2360. }.bind(this));
  2361. } else {
  2362. var text = this.app.lp.systemFlow;
  2363. var taskNode = new Element("div", { "styles": this.css.rollbackItemTaskNode, "text": text }).inject(div);
  2364. }
  2365. node.addEvents({
  2366. "mouseover": function () {
  2367. var isSelected = this.retrieve("isSelected");
  2368. if (!isSelected) this.setStyles(_self.css.rollbackItemNode_over);
  2369. },
  2370. "mouseout": function () {
  2371. var isSelected = this.retrieve("isSelected");
  2372. if (!isSelected) this.setStyles(_self.css.rollbackItemNode)
  2373. },
  2374. "click": function () {
  2375. var isSelected = this.retrieve("isSelected");
  2376. if (isSelected) {
  2377. _self.setRollBackUnchecked(this);
  2378. } else {
  2379. var items = rollbackItemNode.getChildren();
  2380. items.each(function (item) {
  2381. _self.setRollBackUnchecked(item);
  2382. });
  2383. _self.setRollBackChecked(this);
  2384. }
  2385. }
  2386. });
  2387. }
  2388. }.bind(this));
  2389. }.bind(this), null, false);
  2390. },
  2391. rollback: function () {
  2392. if (!this.businessData.control["allowRollback"]) {
  2393. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  2394. return false;
  2395. }
  2396. var node = new Element("div", { "styles": this.css.rollbackAreaNode });
  2397. var html = "<div style=\"line-height: 30px; height: 30px; color: #333333; overflow: hidden;float:left;\">请选择文件要回溯到的位置:</div>";
  2398. html += "<div style=\"line-height: 30px; height: 30px; color: #333333; overflow: hidden;float:right;\"><input class='rollback_flowOption' checked type='checkbox' />并尝试继续流转</div>";
  2399. html += "<div style=\"clear:both; max-height: 300px; margin-bottom:10px; margin-top:10px; overflow-y:auto;\"></div>";
  2400. node.set("html", html);
  2401. var rollbackItemNode = node.getLast();
  2402. this.getRollbackLogs(rollbackItemNode);
  2403. node.inject(this.app.content);
  2404. var dlg = o2.DL.open({
  2405. "title": this.app.lp.rollback,
  2406. "style": this.json.dialogStyle || "user",
  2407. "isResize": false,
  2408. "content": node,
  2409. "width": 600,
  2410. "buttonList": [
  2411. {
  2412. "type": "ok",
  2413. "text": MWF.LP.process.button.ok,
  2414. "action": function (d, e) {
  2415. this.doRollback(node, e, dlg);
  2416. }.bind(this)
  2417. },
  2418. {
  2419. "type": "cancel",
  2420. "text": MWF.LP.process.button.cancel,
  2421. "action": function () { dlg.close(); }
  2422. }
  2423. ]
  2424. });
  2425. },
  2426. doRollback: function (node, e, dlg) {
  2427. var rollbackItemNode = node.getLast();
  2428. var items = rollbackItemNode.getChildren();
  2429. var flowOption = (node.getElement(".rollback_flowOption").checked);
  2430. var _self = this;
  2431. for (var i = 0; i < items.length; i++) {
  2432. if (items[i].retrieve("isSelected")) {
  2433. var text = this.app.lp.rollbackConfirmContent;
  2434. var log = items[i].retrieve("log");
  2435. var checks = items[i].getElements("input:checked");
  2436. var idList = [];
  2437. checks.each(function (check) {
  2438. var id = check.get("value");
  2439. if (idList.indexOf(id) == -1) idList.push(id);
  2440. });
  2441. text = text.replace("{log}", log.fromActivityName + "(" + log.arrivedTime + ")");
  2442. this.app.confirm("infor", e, this.app.lp.rollbackConfirmTitle, text, 450, 120, function () {
  2443. _self.doRollbackAction(log.id, flowOption, dlg, idList);
  2444. dlg.close();
  2445. this.close();
  2446. }, function () {
  2447. this.close();
  2448. }, null, null, this.json.confirmStyle);
  2449. break;
  2450. }
  2451. }
  2452. },
  2453. doRollbackAction: function (log, flowOption, dlg, idList) {
  2454. MWF.require("MWF.widget.Mask", function () {
  2455. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2456. this.mask.loadNode(this.app.content);
  2457. this.fireEvent("beforeRollback");
  2458. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeRollback");
  2459. this.doRollbackActionInvoke(log, flowOption, idList, function (json) {
  2460. if (json.data.properties) {
  2461. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRollback");
  2462. this.addRollbackMessage(json.data);
  2463. } else {
  2464. var id = json.data.id;
  2465. this.workAction.listTaskByWork(function (workJson) {
  2466. this.fireEvent("afterRollback");
  2467. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRollback");
  2468. this.addRollbackMessage_old(workJson.data);
  2469. //this.app.notice(MWF.xApplication.process.Xform.LP.rollbackOk+": "+MWF.name.cns(names).join(", "), "success");
  2470. //if (!this.app.inBrowser) this.app.close();
  2471. }.bind(this), null, id);
  2472. }
  2473. if (!this.app.inBrowser) this.app.close();
  2474. if (this.mask) { this.mask.hide(); this.mask = null; }
  2475. }.bind(this), function (xhr, text, error) {
  2476. var errorText = error + ":" + text;
  2477. if (xhr) errorText = xhr.responseText;
  2478. this.app.notice("request json error: " + errorText, "error");
  2479. if (this.mask) { this.mask.hide(); this.mask = null; }
  2480. }.bind(this));
  2481. }.bind(this));
  2482. },
  2483. doRollbackActionInvoke: function (id, flowOption, idList, success, failure) {
  2484. if (this.businessData.work.completedTime) {
  2485. var method = "rollbackWorkcompleted";
  2486. o2.Actions.get("x_processplatform_assemble_surface")[method](this.businessData.work.id, { "workLog": id }, function (json) {
  2487. if (success) success(json);
  2488. }.bind(this), function (xhr, text, error) {
  2489. if (failure) failure(xhr, text, error)
  2490. }.bind(this));
  2491. } else {
  2492. var body = {
  2493. "workLog": id,
  2494. "taskCompletedIdentityList": idList,
  2495. "processing": !!flowOption
  2496. }
  2497. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Rollback(this.businessData.work.id, body, function (json) {
  2498. //o2.Actions.get("x_processplatform_assemble_surface")[method](this.businessData.work.id, { "workLog": id }, function (json) {
  2499. if (success) success(json);
  2500. }.bind(this), function (xhr, text, error) {
  2501. if (failure) failure(xhr, text, error)
  2502. }.bind(this));
  2503. }
  2504. },
  2505. inBrowserDkg: function (content) {
  2506. if (this.mask) this.mask.hide();
  2507. if (this.json.submitedDlgUseNotice) {
  2508. MWF.xDesktop.notice("success", { x: "right", y: "top" }, content);
  2509. if (this.json.isPrompt !== false) {
  2510. if (this.json.promptCloseTime != 0) {
  2511. var t = this.json.promptCloseTime || 2;
  2512. t = t.toInt() * 1000;
  2513. var _work = this;
  2514. window.setTimeout(function () { _work.app.close(); }, t);
  2515. }
  2516. } else {
  2517. this.app.close();
  2518. }
  2519. } else {
  2520. var div = new Element("div", { "styles": { "margin": "10px 10px 0px 10px", "padding": "5px", "overflow": "hidden" } }).inject(this.app.content);
  2521. div.set("html", content);
  2522. if (this.json.isPrompt !== false) {
  2523. var options = {
  2524. "content": div,
  2525. "isTitle": false,
  2526. "width": 350,
  2527. "height": 180,
  2528. "buttonList": [
  2529. {
  2530. "text": MWF.xApplication.process.Xform.LP.ok,
  2531. "action": function () { dlg.close(); this.app.close(); }.bind(this)
  2532. }
  2533. ]
  2534. }
  2535. var size = this.app.content.getSize();
  2536. switch (this.json.promptPosition || "righttop") {
  2537. case "lefttop":
  2538. options.top = 10;
  2539. options.left = 10;
  2540. options.fromTop = 10;
  2541. options.fromLeft = 10;
  2542. break;
  2543. case "righttop":
  2544. options.top = 10;
  2545. options.left = size.x - 360;
  2546. options.fromTop = 10;
  2547. options.fromLeft = size.x - 10;
  2548. break;
  2549. case "leftbottom":
  2550. options.top = size.y - 190;
  2551. options.left = 10;
  2552. options.fromTop = size.y - 10;
  2553. options.fromLeft = 10;
  2554. break;
  2555. case "rightbottom":
  2556. options.top = size.y - 190;
  2557. options.left = size.x - 360;
  2558. options.fromTop = size.y - 10;
  2559. options.fromLeft = size.x - 10;
  2560. break;
  2561. default:
  2562. delete options.top;
  2563. delete options.left;
  2564. delete options.fromTop;
  2565. delete options.fromLeft;
  2566. }
  2567. var dlg = o2.DL.open(options);
  2568. if (this.json.promptCloseTime != 0) {
  2569. var t = this.json.promptCloseTime || 2;
  2570. t = t.toInt() * 1000;
  2571. var _work = this;
  2572. window.setTimeout(function () { dlg.close(); _work.app.close(); }, t);
  2573. }
  2574. } else {
  2575. this.app.close();
  2576. }
  2577. }
  2578. },
  2579. addRollbackMessage_old: function (data) {
  2580. var users = [];
  2581. data.each(function (task) {
  2582. users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  2583. }.bind(this));
  2584. var content = "<div><b>" + MWF.xApplication.process.Xform.LP.currentActivity + "<font style=\"color: #ea621f\">" + data[0].activityName + "</font>, " + MWF.xApplication.process.Xform.LP.nextUser + "<font style=\"color: #ea621f\">" + users.join(", ") + "</font></b></div>";
  2585. if (layout.desktop.message) {
  2586. var msg = {
  2587. "subject": MWF.xApplication.process.Xform.LP.workRollback,
  2588. "content": "<div>" + MWF.xApplication.process.Xform.LP.rollbackWorkInfor + "“" + this.businessData.work.title + "”</div>" + content
  2589. };
  2590. layout.desktop.message.addTooltip(msg);
  2591. return layout.desktop.message.addMessage(msg);
  2592. } else {
  2593. if (this.app.inBrowser) {
  2594. this.inBrowserDkg("<div>" + MWF.xApplication.process.Xform.LP.rollbackWorkInfor + "“" + this.businessData.work.title + "”</div>" + content);
  2595. }
  2596. }
  2597. },
  2598. addRollbackMessage: function (data) {
  2599. if (layout.desktop.message) {
  2600. var msg = {
  2601. "subject": MWF.xApplication.process.Xform.LP.workRollback,
  2602. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.rollbackWorkInfor)
  2603. };
  2604. layout.desktop.message.addTooltip(msg);
  2605. return layout.desktop.message.addMessage(msg);
  2606. } else {
  2607. if (this.app.inBrowser) {
  2608. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.rollbackWorkInfor));
  2609. }
  2610. }
  2611. },
  2612. pressWork: function (e) {
  2613. if (e && e.setDisable) e.setDisable(true);
  2614. o2.Actions.get("x_processplatform_assemble_surface").press(this.businessData.work.id, function (json) {
  2615. var users = o2.name.cns(json.data.valueList).join(", ");
  2616. this.app.notice("已经向待办人:" + users + ", 发送了提醒", "success");
  2617. if (e && e.setDisable) e.setDisable(false);
  2618. }.bind(this), function (xhr, text, error) {
  2619. //e.setDisable(false);
  2620. if (xhr.status != 0) {
  2621. var errorText = error;
  2622. if (xhr) {
  2623. var json = JSON.decode(xhr.responseText);
  2624. if (json) {
  2625. errorText = json.message.trim() || "request json error";
  2626. } else {
  2627. errorText = "request json error: " + xhr.responseText;
  2628. }
  2629. }
  2630. MWF.xDesktop.notice("error", { x: "right", y: "top" }, errorText);
  2631. }
  2632. });
  2633. },
  2634. downloadAll: function () {
  2635. var htmlFormId = "";
  2636. o2.Actions.load("x_processplatform_assemble_surface").AttachmentAction.uploadWorkInfo(this.businessData.work.id, "pdf", {
  2637. "workHtml": this.app.content.get("html"),
  2638. "pageWidth" : 1000
  2639. }, function (json) {
  2640. htmlFormId = json.data.id;
  2641. }.bind(this), null, false);
  2642. htmlFormId = htmlFormId.replace("#", "%23");
  2643. var url = "/x_processplatform_assemble_surface/jaxrs/attachment/batch/download/work/" + this.businessData.work.id + "/site/(0)/stream";
  2644. url = o2.filterUrl(o2.Actions.getHost("x_processplatform_assemble_surface") + url);
  2645. window.open( o2.filterUrl(url + "?fileName=&flag=" + htmlFormId));
  2646. },
  2647. resetWork: function () {
  2648. if (!this.businessData.control["allowReset"]) {
  2649. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  2650. return false;
  2651. }
  2652. MWF.require("MWF.xDesktop.Dialog", function () {
  2653. var width = 680;
  2654. var height = 300;
  2655. var p = MWF.getCenterPosition(this.app.content, width, height);
  2656. var _self = this;
  2657. var dlg = new MWF.xDesktop.Dialog({
  2658. "title": this.app.lp.reset,
  2659. "style": this.json.dialogStyle || "user", //|| "work",
  2660. "top": p.y - 100,
  2661. "left": p.x,
  2662. "fromTop": p.y - 100,
  2663. "fromLeft": p.x,
  2664. "width": width,
  2665. "height": height,
  2666. "url": this.app.path + "reset.html",
  2667. "container": this.app.content,
  2668. "isClose": true,
  2669. "buttonList": [
  2670. {
  2671. "type": "ok",
  2672. "text": MWF.LP.process.button.ok,
  2673. "action": function (d, e) {
  2674. this.doResetWork(dlg);
  2675. }.bind(this)
  2676. },
  2677. {
  2678. "type": "cancel",
  2679. "text": MWF.LP.process.button.cancel,
  2680. "action": function () { dlg.close(); }
  2681. }
  2682. ],
  2683. "onPostShow": function () {
  2684. //$("resetWork_okButton").addEvent("click", function(){
  2685. // _self.doResetWork(this);
  2686. //}.bind(this));
  2687. //$("resetWork_cancelButton").addEvent("click", function(){
  2688. // this.close();
  2689. //}.bind(this));
  2690. $("resetWork_selPeopleButton").addEvent("click", function () {
  2691. _self.selectPeople(this);
  2692. }.bind(this));
  2693. }
  2694. });
  2695. dlg.show();
  2696. }.bind(this));
  2697. },
  2698. selectPeople: function (dlg) {
  2699. var range = this.businessData.activity.resetRange || "department";
  2700. var count = this.businessData.activity.resetCount || 0;
  2701. switch (range) {
  2702. case "unit":
  2703. this.selectPeopleUnit(dlg, this.businessData.task.unit, count);
  2704. // this.personActions.getDepartmentByIdentity(function(json){
  2705. // this.selectPeopleDepartment(dlg, json.data, count);
  2706. // }.bind(this), null, this.businessData.task.identity);
  2707. break;
  2708. case "topUnit":
  2709. MWF.require("MWF.xScript.Actions.UnitActions", function () {
  2710. orgActions = new MWF.xScript.Actions.UnitActions();
  2711. var data = { "unitList": [this.businessData.task.unit] };
  2712. orgActions.listUnitSupNested(data, function (json) {
  2713. v = json.data[0];
  2714. this.selectPeopleUnit(dlg, v, count);
  2715. }.bind(this));
  2716. }.bind(this));
  2717. // this.personActions.getCompanyByIdentity(function(json){
  2718. // this.selectPeopleCompany(dlg, json.data, count)
  2719. // }.bind(this), null, this.businessData.task.identity);
  2720. break;
  2721. case "script" :
  2722. o2.Actions.load("x_processplatform_assemble_surface").ProcessAction.getActivity( this.businessData.work.activity,"manual",function (activityJson) {
  2723. var scriptText = activityJson.data.activity.resetRangeScriptText;
  2724. if( !scriptText )return;
  2725. var resetRange = this.Macro.exec(activityJson.data.activity.resetRangeScriptText, this);
  2726. this.selectPeopleUnit(dlg, "", count, resetRange);
  2727. }.bind(this))
  2728. break;
  2729. default:
  2730. this.selectPeopleAll(dlg, count);
  2731. }
  2732. },
  2733. selectPeopleUnit: function (dlg, unit, count, include) {
  2734. var names = dlg.identityList || [];
  2735. var areaNode = $("resetWork_selPeopleArea");
  2736. var options = {
  2737. "values": names,
  2738. "type": "identity",
  2739. "count": count,
  2740. "units": (unit) ? [unit] : [],
  2741. "title": this.app.lp.reset,
  2742. "onComplete": function (items) {
  2743. areaNode.empty();
  2744. var identityList = [];
  2745. items.each(function (item) {
  2746. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  2747. identityList.push(item.data.distinguishedName);
  2748. }.bind(this));
  2749. dlg.identityList = identityList;
  2750. }.bind(this)
  2751. };
  2752. if( include ){
  2753. options.noUnit = true;
  2754. options.include = typeOf(include)==="array" ? include : [include];
  2755. }
  2756. MWF.xDesktop.requireApp("Selector", "package", function () {
  2757. var selector = new MWF.O2Selector(this.app.content, options);
  2758. }.bind(this));
  2759. },
  2760. selectPeopleAll: function (dlg, count) {
  2761. var names = dlg.identityList || [];
  2762. var areaNode = $("resetWork_selPeopleArea");
  2763. var options = {
  2764. "values": names,
  2765. "type": "identity",
  2766. "count": count,
  2767. "title": this.app.lp.reset,
  2768. "onComplete": function (items) {
  2769. areaNode.empty();
  2770. var identityList = [];
  2771. items.each(function (item) {
  2772. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  2773. identityList.push(item.data.distinguishedName);
  2774. }.bind(this));
  2775. dlg.identityList = identityList;
  2776. }.bind(this)
  2777. };
  2778. MWF.xDesktop.requireApp("Selector", "package", function () {
  2779. var selector = new MWF.O2Selector(this.app.content, options);
  2780. }.bind(this));
  2781. },
  2782. doResetWork: function (dlg) {
  2783. var names = dlg.identityList || [];
  2784. if (!names.length) {
  2785. this.app.notice(MWF.xApplication.process.Xform.LP.inputResetPeople, "error", dlg.node);
  2786. return false;
  2787. }
  2788. var opinion = $("resetWork_opinion").get("value");
  2789. var checkbox = dlg.content.getElement(".resetWork_keepOption");
  2790. var keep = (checkbox.checked);
  2791. var nameText = [];
  2792. names.each(function (n) { nameText.push(MWF.name.cn(n)); });
  2793. if (!opinion) {
  2794. opinion = MWF.xApplication.process.Xform.LP.resetTo + ": " + nameText.join(", ");
  2795. }
  2796. MWF.require("MWF.widget.Mask", function () {
  2797. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2798. this.mask.loadNode(this.app.content);
  2799. this.fireEvent("beforeReset");
  2800. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeReset");
  2801. this.resetWorkToPeson(names, opinion, keep, function (workJson) {
  2802. //this.workAction.loadWork(function (workJson) {
  2803. this.fireEvent("afterReset");
  2804. if (this.app && this.app.fireEvent) this.app.fireEvent("afterReset");
  2805. this.addResetMessage(workJson.data);
  2806. //this.app.notice(MWF.xApplication.process.Xform.LP.resetOk + ": " + MWF.name.cns(names).join(", "), "success");
  2807. if (!this.app.inBrowser) this.app.close();
  2808. //}.bind(this), null, this.businessData.work.id);
  2809. dlg.close();
  2810. if (this.mask) { this.mask.hide(); this.mask = null; }
  2811. }.bind(this), function (xhr, text, error) {
  2812. var errorText = error + ":" + text;
  2813. if (xhr) errorText = xhr.responseText;
  2814. this.app.notice("request json error: " + errorText, "error", dlg.node);
  2815. if (this.mask) { this.mask.hide(); this.mask = null; }
  2816. }.bind(this));
  2817. }.bind(this));
  2818. //var data = {
  2819. // "opinion": opinion,
  2820. // "routeName": MWF.xApplication.process.Xform.LP.reset,
  2821. // "identityList": names
  2822. //}
  2823. //
  2824. //this.workAction.resetWork(function(json){
  2825. //
  2826. //}.bind(this), null, this.businessData.task.id, data);
  2827. },
  2828. resetWorkToPeson: function (identityList, opinion, keep, success, failure) {
  2829. var data = {
  2830. "opinion": opinion,
  2831. "routeName": MWF.xApplication.process.Xform.LP.reset,
  2832. "identityList": identityList,
  2833. "keep": !!keep
  2834. };
  2835. this.saveFormData(
  2836. function (json) {
  2837. o2.Actions.load("x_processplatform_assemble_surface").TaskAction.V2Reset(
  2838. //this.workAction.resetWork(
  2839. function (json) {
  2840. if (success) success(json);
  2841. }.bind(this),
  2842. function (xhr, text, error) {
  2843. if (failure) failure(xhr, text, error);
  2844. },
  2845. this.businessData.task.id, data
  2846. );
  2847. }.bind(this),
  2848. function (xhr, text, error) {
  2849. if (failure) failure(xhr, text, error);
  2850. }, true, null, true
  2851. );
  2852. },
  2853. addAddSplitMessage: function (data) {
  2854. // var content = "";
  2855. // if (data && data.length) {
  2856. // data.each(function (work) {
  2857. // var users = [];
  2858. // work.taskList.each(function (task) {
  2859. // users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  2860. // }.bind(this));
  2861. // content += "<div><b>" + MWF.xApplication.process.Xform.LP.nextActivity + "<font style=\"color: #ea621f\">" + work.activityName + "</font>, " + MWF.xApplication.process.Xform.LP.nextUser + "<font style=\"color: #ea621f\">" + users.join(", ") + "</font></b></div>";
  2862. // }.bind(this));
  2863. // } else {
  2864. // content += MWF.xApplication.process.Xform.LP.workCompleted;
  2865. // }
  2866. if (layout.desktop.message) {
  2867. //var content = "<div><b>"+MWF.xApplication.process.Xform.LP.currentActivity+"<font style=\"color: #ea621f\">"+data.work.activityName+"</font>, "+MWF.xApplication.process.Xform.LP.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b></div>";
  2868. var msg = {
  2869. "subject": MWF.xApplication.process.Xform.LP.addSplitWork,
  2870. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.addSplitWorkInfor)
  2871. };
  2872. layout.desktop.message.addTooltip(msg);
  2873. return layout.desktop.message.addMessage(msg);
  2874. } else {
  2875. if (this.app.inBrowser) {
  2876. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.addSplitWorkInfor));
  2877. }
  2878. }
  2879. },
  2880. addResetMessage: function (data) {
  2881. // var content = "";
  2882. // if (data.completed){
  2883. // content += MWF.xApplication.process.Xform.LP.workCompleted;
  2884. // }else{
  2885. // if (data.properties.nextManualList && data.properties.nextManualList.length){
  2886. // var activityUsers = [];
  2887. // data.properties.nextManualList.each(function(a){
  2888. // var ids = [];
  2889. // a.taskIdentityList.each(function(i){
  2890. // ids.push(o2.name.cn(i))
  2891. // });
  2892. // var t = "<b>"+MWF.xApplication.process.Xform.LP.nextActivity + "</b><span style='color: #ea621f'>"+a.activityName+"</span>;<b>"+ MWF.xApplication.process.Xform.LP.nextUser+ "</b><span style='color: #ea621f'>"+ids.join(",")+"</span>";
  2893. // activityUsers.push(t);
  2894. // });
  2895. // content += activityUsers.join("<br>");
  2896. // }else{
  2897. // content += MWF.xApplication.process.Xform.LP.taskCompleted;
  2898. // }
  2899. // }
  2900. if (layout.desktop.message) {
  2901. var msg = {
  2902. "subject": MWF.xApplication.process.Xform.LP.workReset,
  2903. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.resetWorkInfor)
  2904. };
  2905. layout.desktop.message.addTooltip(msg);
  2906. return layout.desktop.message.addMessage(msg);
  2907. } else {
  2908. if (this.app.inBrowser) {
  2909. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.resetWorkInfor));
  2910. }
  2911. }
  2912. },
  2913. retractWork: function (e, ev) {
  2914. var _self = this;
  2915. if (this.json.mode == "Mobile") {
  2916. //window.confirm 在ios移动端不可用 ??
  2917. // if (window.confirm(MWF.xApplication.process.Xform.LP.retractText)) {
  2918. var p = MWF.getCenterPosition(document.body, 300, 150);
  2919. console.log("position x:" + p.x + " , y:" + p.y);
  2920. var x = p.x;
  2921. if (p.x < 20) {
  2922. x = 20;
  2923. } else {
  2924. x = p.x;
  2925. }
  2926. var event = {
  2927. "event": {
  2928. "x": x,
  2929. "y": p.y - 200,
  2930. "clientX": x,
  2931. "clientY": p.y - 200
  2932. }
  2933. };
  2934. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.retractTitle, MWF.xApplication.process.Xform.LP.retractText, 300, 120, function () {
  2935. _self.app.content.mask({
  2936. "style": {
  2937. "background-color": "#999",
  2938. "opacity": 0.6
  2939. }
  2940. });
  2941. MWF.require("MWF.widget.Mask", function () {
  2942. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2943. _self.mask.loadNode(_self.app.content);
  2944. _self.fireEvent("beforeRetract");
  2945. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeRetract");
  2946. _self.doRetractWork(function () {
  2947. //_self.workAction.getJobByWork(function(workJson){
  2948. _self.fireEvent("afterRetract");
  2949. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterRetract");
  2950. _self.app.notice(MWF.xApplication.process.Xform.LP.workRetract, "success");
  2951. _self.app.content.unmask();
  2952. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2953. _self.finishOnMobile()
  2954. }.bind(this), function (xhr, text, error) {
  2955. _self.app.content.unmask();
  2956. var errorText = error + ":" + text;
  2957. if (xhr) errorText = xhr.responseText;
  2958. _self.app.notice("request json error: " + errorText, "error");
  2959. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2960. });
  2961. }.bind(this));
  2962. }, function () {
  2963. this.close();
  2964. }, null, null, this.json.confirmStyle);
  2965. } else {
  2966. var p = MWF.getCenterPosition(this.app.content, 300, 150);
  2967. var event = {
  2968. "event": {
  2969. "x": p.x,
  2970. "y": p.y - 200,
  2971. "clientX": p.x,
  2972. "clientY": p.y - 200
  2973. }
  2974. };
  2975. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.retractTitle, MWF.xApplication.process.Xform.LP.retractText, 300, 120, function () {
  2976. _self.app.content.mask({
  2977. "style": {
  2978. "background-color": "#999",
  2979. "opacity": 0.6
  2980. }
  2981. });
  2982. MWF.require("MWF.widget.Mask", function () {
  2983. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2984. _self.mask.loadNode(_self.app.content);
  2985. _self.fireEvent("beforeRetract");
  2986. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeRetract");
  2987. _self.doRetractWork(function (json) {
  2988. //_self.workAction.getJobByWork(function(workJson){
  2989. _self.fireEvent("afterRetract");
  2990. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterRetract");
  2991. //_self.addRetractMessage(json.data);
  2992. _self.app.notice(MWF.xApplication.process.Xform.LP.workRetract, "success");
  2993. _self.app.content.unmask();
  2994. _self.app.reload();
  2995. //}, null, _self.businessData.work.id);
  2996. this.close();
  2997. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2998. }.bind(this), function (xhr, text, error) {
  2999. _self.app.content.unmask();
  3000. var errorText = error + ":" + text;
  3001. if (xhr) errorText = xhr.responseText;
  3002. _self.app.notice("request json error: " + errorText, "error");
  3003. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  3004. });
  3005. }.bind(this));
  3006. //this.close();
  3007. }, function () {
  3008. this.close();
  3009. }, null, null, this.json.confirmStyle);
  3010. }
  3011. },
  3012. doRetractWork: function (success, failure) {
  3013. if (this.businessData.control["allowRetract"]) {
  3014. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Retract(this.businessData.work.id, null, function (json) {
  3015. if (success) success(json);
  3016. }.bind(this), function (xhr, text, error) {
  3017. if (failure) failure(xhr, text, error);
  3018. });
  3019. // this.workAction.retractWork(function (json) {
  3020. // if (success) success();
  3021. // }.bind(this), function (xhr, text, error) {
  3022. // if (failure) failure(xhr, text, error);
  3023. // }, this.businessData.work.id);
  3024. } else {
  3025. if (failure) failure(null, "Permission Denied", "");
  3026. }
  3027. },
  3028. addRetractMessage: function (data) {
  3029. // var users = [];
  3030. // data.taskList.each(function (task) {
  3031. // users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  3032. // }.bind(this));
  3033. // var content = "<div><b>" + MWF.xApplication.process.Xform.LP.currentActivity + "<font style=\"color: #ea621f\">" + data.work.activityName + "</font>, " + MWF.xApplication.process.Xform.LP.nextUser + "<font style=\"color: #ea621f\">" + users.join(", ") + "</font></b></div>";
  3034. if (layout.desktop.message) {
  3035. var msg = {
  3036. "subject": MWF.xApplication.process.Xform.LP.workRetract,
  3037. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.retractWorkInfor)
  3038. };
  3039. layout.desktop.message.addTooltip(msg);
  3040. return layout.desktop.message.addMessage(msg);
  3041. } else {
  3042. if (this.app.inBrowser) {
  3043. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.retractWorkInfor));
  3044. }
  3045. }
  3046. },
  3047. rerouteWork: function (e, ev) {
  3048. if (!this.businessData.control["allowReroute"]) {
  3049. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  3050. return false;
  3051. }
  3052. MWF.require("MWF.xDesktop.Dialog", function () {
  3053. var width = 560;
  3054. var height = 260;
  3055. var p = MWF.getCenterPosition(this.app.content, width, height);
  3056. var _self = this;
  3057. var dlg = new MWF.xDesktop.Dialog({
  3058. "title": this.app.lp.reroute,
  3059. "style": this.json.dialogStyle || "user", //|| "work",
  3060. "top": p.y - 100,
  3061. "left": p.x,
  3062. "fromTop": p.y - 100,
  3063. "fromLeft": p.x,
  3064. "width": width,
  3065. "height": height,
  3066. "url": this.app.path + "reroute.html",
  3067. "container": this.app.content,
  3068. "isClose": true,
  3069. "buttonList": [
  3070. {
  3071. "type": "ok",
  3072. "text": MWF.LP.process.button.ok,
  3073. "action": function (d, e) {
  3074. _self.doRerouteWork(dlg);
  3075. }.bind(this)
  3076. },
  3077. {
  3078. "type": "cancel",
  3079. "text": MWF.LP.process.button.cancel,
  3080. "action": function () { dlg.close(); }
  3081. }
  3082. ],
  3083. "onPostShow": function () {
  3084. //$("rerouteWork_okButton").addEvent("click", function(){
  3085. // _self.doRerouteWork(this);
  3086. //}.bind(this));
  3087. //$("rerouteWork_cancelButton").addEvent("click", function(){
  3088. // this.close();
  3089. //}.bind(this));
  3090. var select = $("rerouteWork_selectActivity");
  3091. _self.workAction.getRerouteTo(_self.businessData.work.process, function (json) {
  3092. json.data.agentList.each(function (activity) {
  3093. new Element("option", {
  3094. "value": activity.id + "#agent",
  3095. "text": activity.name
  3096. }).inject(select);
  3097. }.bind(_self));
  3098. json.data.cancelList.each(function (activity) {
  3099. new Element("option", {
  3100. "value": activity.id + "#cancel",
  3101. "text": activity.name
  3102. }).inject(select);
  3103. }.bind(_self));
  3104. json.data.choiceList.each(function (activity) {
  3105. new Element("option", {
  3106. "value": activity.id + "#choice",
  3107. "text": activity.name
  3108. }).inject(select);
  3109. }.bind(_self));
  3110. // json.data.controllerList.each(function(activity){
  3111. // new Element("option", {
  3112. // "value": activity.id+"#condition",
  3113. // "text": activity.name
  3114. // }).inject(select);
  3115. // }.bind(_self));
  3116. json.data.delayList.each(function (activity) {
  3117. new Element("option", {
  3118. "value": activity.id + "#delay",
  3119. "text": activity.name
  3120. }).inject(select);
  3121. }.bind(_self));
  3122. json.data.embedList.each(function (activity) {
  3123. new Element("option", {
  3124. "value": activity.id + "#embed",
  3125. "text": activity.name
  3126. }).inject(select);
  3127. }.bind(_self));
  3128. json.data.endList.each(function (activity) {
  3129. new Element("option", {
  3130. "value": activity.id + "#end",
  3131. "text": activity.name
  3132. }).inject(select);
  3133. }.bind(_self));
  3134. json.data.invokeList.each(function (activity) {
  3135. new Element("option", {
  3136. "value": activity.id + "#invoke",
  3137. "text": activity.name
  3138. }).inject(select);
  3139. }.bind(_self));
  3140. json.data.manualList.each(function (activity) {
  3141. new Element("option", {
  3142. "value": activity.id + "#manual",
  3143. "text": activity.name
  3144. }).inject(select);
  3145. }.bind(_self));
  3146. json.data.mergeList.each(function (activity) {
  3147. new Element("option", {
  3148. "value": activity.id + "#merge",
  3149. "text": activity.name
  3150. }).inject(select);
  3151. }.bind(_self));
  3152. json.data.messageList.each(function (activity) {
  3153. new Element("option", {
  3154. "value": activity.id + "#message",
  3155. "text": activity.name
  3156. }).inject(select);
  3157. }.bind(_self));
  3158. json.data.parallelList.each(function (activity) {
  3159. new Element("option", {
  3160. "value": activity.id + "#parallel",
  3161. "text": activity.name
  3162. }).inject(select);
  3163. }.bind(_self));
  3164. json.data.serviceList.each(function (activity) {
  3165. new Element("option", {
  3166. "value": activity.id + "#service",
  3167. "text": activity.name
  3168. }).inject(select);
  3169. }.bind(_self));
  3170. json.data.splitList.each(function (activity) {
  3171. new Element("option", {
  3172. "value": activity.id + "#split",
  3173. "text": activity.name
  3174. }).inject(select);
  3175. }.bind(_self));
  3176. }.bind(_self));
  3177. var selPeopleButton = this.content.getElement(".rerouteWork_selPeopleButton");
  3178. selPeopleButton.addEvent("click", function () {
  3179. _self.selectReroutePeople(this);
  3180. }.bind(this));
  3181. }
  3182. });
  3183. dlg.show();
  3184. }.bind(this));
  3185. },
  3186. selectReroutePeople: function (dlg) {
  3187. var names = dlg.identityList || [];
  3188. var areaNode = dlg.content.getElement(".rerouteWork_selPeopleArea");
  3189. var options = {
  3190. "values": names,
  3191. "type": "identity",
  3192. "count": 0,
  3193. "title": this.app.lp.reroute,
  3194. "onComplete": function (items) {
  3195. areaNode.empty();
  3196. var identityList = [];
  3197. items.each(function (item) {
  3198. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  3199. identityList.push(item.data.distinguishedName);
  3200. }.bind(this));
  3201. dlg.identityList = identityList;
  3202. }.bind(this)
  3203. };
  3204. MWF.xDesktop.requireApp("Selector", "package", function () {
  3205. var selector = new MWF.O2Selector(this.app.content, options);
  3206. }.bind(this));
  3207. },
  3208. doRerouteWork: function (dlg) {
  3209. var opinion = $("rerouteWork_opinion").get("value");
  3210. var select = $("rerouteWork_selectActivity");
  3211. var activity = select.options[select.selectedIndex].get("value");
  3212. var activityName = select.options[select.selectedIndex].get("text");
  3213. var tmp = activity.split("#");
  3214. activity = tmp[0];
  3215. var type = tmp[1];
  3216. var nameArr = [];
  3217. var names = dlg.identityList || [];
  3218. names.each(function (n) { nameArr.push(n); });
  3219. //var nameText = nameArr.join(", ");
  3220. // if (!opinion) {
  3221. // opinion = MWF.xApplication.process.Xform.LP.resetTo + ": " + nameText.join(", ");
  3222. // }
  3223. MWF.require("MWF.widget.Mask", function () {
  3224. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  3225. this.mask.loadNode(this.app.content);
  3226. this.fireEvent("beforeReroute");
  3227. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRetract");
  3228. this.rerouteWorkToActivity(activity, type, opinion, nameArr, function (workJson) {
  3229. //this.workAction.loadWork(function (workJson) {
  3230. this.fireEvent("afterReroute");
  3231. if (this.app && this.app.fireEvent) this.app.fireEvent("afterReroute");
  3232. this.addRerouteMessage(workJson.data);
  3233. this.app.notice(MWF.xApplication.process.Xform.LP.rerouteOk + ": " + activityName, "success");
  3234. if (!this.app.inBrowser) this.app.close();
  3235. //}.bind(this), null, this.businessData.work.id);
  3236. dlg.close();
  3237. if (this.mask) { this.mask.hide(); this.mask = null; }
  3238. }.bind(this), function (xhr, text, error) {
  3239. var errorText = error + ":" + text;
  3240. if (xhr) errorText = xhr.responseText;
  3241. this.app.notice("request json error: " + errorText, "error", dlg.node);
  3242. if (this.mask) { this.mask.hide(); this.mask = null; }
  3243. }.bind(this));
  3244. }.bind(this));
  3245. },
  3246. rerouteWorkToActivity: function (activity, type, opinion, nameArr, success, failure) {
  3247. var body = {
  3248. "activity": activity,
  3249. "activityType": type,
  3250. "mergeWork": false,
  3251. "manualForceTaskIdentityList": nameArr
  3252. };
  3253. if (this.businessData.task) {
  3254. this.saveFormData(function (json) {
  3255. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Reroute(this.businessData.work.id, body, function (json) {
  3256. if (success) success(json);
  3257. }.bind(this), function (xhr, text, error) {
  3258. if (failure) failure(xhr, text, error);
  3259. });
  3260. // this.workAction.rerouteWork(function (json) {
  3261. // if (success) success();
  3262. // }.bind(this), function (xhr, text, error) {
  3263. // if (failure) failure(xhr, text, error);
  3264. // }, this.businessData.work.id, activity, type);
  3265. }.bind(this), function (xhr, text, error) {
  3266. if (failure) failure(xhr, text, error);
  3267. }, true, null, true);
  3268. } else {
  3269. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Reroute(this.businessData.work.id, body, function (json) {
  3270. if (success) success(json);
  3271. }.bind(this), function (xhr, text, error) {
  3272. if (failure) failure(xhr, text, error);
  3273. });
  3274. // this.workAction.rerouteWork(function (json) {
  3275. // if (success) success();
  3276. // }.bind(this), function (xhr, text, error) {
  3277. // if (failure) failure(xhr, text, error);
  3278. // }, this.businessData.work.id, activity, type);
  3279. }
  3280. },
  3281. addRerouteMessage: function (data) {
  3282. if (layout.desktop.message) {
  3283. var msg = {
  3284. "subject": MWF.xApplication.process.Xform.LP.workReroute,
  3285. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.rerouteWorkInfor)
  3286. };
  3287. layout.desktop.message.addTooltip(msg);
  3288. return layout.desktop.message.addMessage(msg);
  3289. } else {
  3290. if (this.app.inBrowser) {
  3291. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.rerouteWorkInfor));
  3292. }
  3293. }
  3294. },
  3295. deleteDraftWork: function () {
  3296. var _self = this;
  3297. if (this.json.mode === "Mobile") {
  3298. var p = MWF.getCenterPosition(document.body, 300, 150);
  3299. console.log("position x:" + p.x + " , y:" + p.y);
  3300. var x = p.x;
  3301. if (p.x < 20) {
  3302. x = 20;
  3303. } else {
  3304. x = p.x;
  3305. }
  3306. var event = {
  3307. "event": {
  3308. "x": x,
  3309. "y": p.y - 200,
  3310. "clientX": x,
  3311. "clientY": p.y - 200
  3312. }
  3313. };
  3314. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText.text, 300, 120, function () {
  3315. _self.app.content.mask({
  3316. "style": {
  3317. "background-color": "#999",
  3318. "opacity": 0.6
  3319. }
  3320. });
  3321. // if (window.confirm(MWF.xApplication.process.Xform.LP.deleteWorkText.text)) {
  3322. MWF.require("MWF.widget.Mask", function () {
  3323. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  3324. _self.mask.loadNode(_self.app.content);
  3325. _self.doDeleteWork(function () {
  3326. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  3327. if (_self.mask) {
  3328. _self.mask.hide();
  3329. _self.mask = null;
  3330. }
  3331. _self.finishOnMobile()
  3332. }.bind(this), function (xhr, text, error) {
  3333. var errorText = error + ":" + text;
  3334. if (xhr) errorText = xhr.responseText;
  3335. _self.app.notice("request json error: " + errorText, "error");
  3336. if (_self.mask) {
  3337. _self.mask.hide();
  3338. _self.mask = null;
  3339. }
  3340. }.bind(this));
  3341. }.bind(this));
  3342. }, function () {
  3343. this.close();
  3344. }, null, null, this.json.confirmStyle);
  3345. } else {
  3346. var p = MWF.getCenterPosition(this.app.content, 380, 150);
  3347. var event = {
  3348. "event": {
  3349. "x": p.x,
  3350. "y": p.y - 200,
  3351. "clientX": p.x,
  3352. "clientY": p.y - 200
  3353. }
  3354. };
  3355. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText, 380, 120, function () {
  3356. MWF.require("MWF.widget.Mask", function () {
  3357. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  3358. _self.mask.loadNode(_self.app.content);
  3359. _self.doDeleteWork(function () {
  3360. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  3361. _self.app.close();
  3362. this.close();
  3363. if (_self.mask) {
  3364. _self.mask.hide();
  3365. _self.mask = null;
  3366. }
  3367. }.bind(this), function (xhr, text, error) {
  3368. var errorText = error + ":" + text;
  3369. if (xhr) errorText = xhr.responseText;
  3370. _self.app.notice("request json error: " + errorText, "error");
  3371. if (_self.mask) {
  3372. _self.mask.hide();
  3373. _self.mask = null;
  3374. }
  3375. }.bind(this));
  3376. }.bind(this));
  3377. }, function () {
  3378. this.close();
  3379. }, null, this.app.content, this.json.confirmStyle);
  3380. }
  3381. },
  3382. deleteWork: function () {
  3383. if (!this.businessData.work.startTime) {
  3384. this.deleteDraftWork();
  3385. } else {
  3386. var _self = this;
  3387. if (this.json.mode === "Mobile") {
  3388. var p = MWF.getCenterPosition(document.body, 300, 150);
  3389. console.log("position x:" + p.x + " , y:" + p.y);
  3390. var x = p.x;
  3391. if (p.x < 20) {
  3392. x = 20;
  3393. } else {
  3394. x = p.x;
  3395. }
  3396. var event = {
  3397. "event": {
  3398. "x": x,
  3399. "y": p.y - 200,
  3400. "clientX": x,
  3401. "clientY": p.y - 200
  3402. }
  3403. };
  3404. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText.text, 300, 120, function () {
  3405. _self.app.content.mask({
  3406. "style": {
  3407. "background-color": "#999",
  3408. "opacity": 0.6
  3409. }
  3410. });
  3411. // if (window.confirm(MWF.xApplication.process.Xform.LP.deleteWorkText.text)) {
  3412. MWF.require("MWF.widget.Mask", function () {
  3413. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  3414. _self.mask.loadNode(_self.app.content);
  3415. _self.fireEvent("beforeDelete");
  3416. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeDelete");
  3417. _self.doDeleteWork(function () {
  3418. _self.fireEvent("afterDelete");
  3419. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterDelete");
  3420. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  3421. if (_self.mask) {
  3422. _self.mask.hide();
  3423. _self.mask = null;
  3424. }
  3425. _self.finishOnMobile()
  3426. }.bind(this), function (xhr, text, error) {
  3427. var errorText = error + ":" + text;
  3428. if (xhr) errorText = xhr.responseText;
  3429. _self.app.notice("request json error: " + errorText, "error", dlg.node);
  3430. if (_self.mask) {
  3431. _self.mask.hide();
  3432. _self.mask = null;
  3433. }
  3434. }.bind(this));
  3435. }.bind(this));
  3436. }, function () {
  3437. this.close();
  3438. }, null, this.app.content, this.json.confirmStyle);
  3439. } else {
  3440. var p = MWF.getCenterPosition(this.app.content, 380, 150);
  3441. var event = {
  3442. "event": {
  3443. "x": p.x,
  3444. "y": p.y - 200,
  3445. "clientX": p.x,
  3446. "clientY": p.y - 200
  3447. }
  3448. };
  3449. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText, 380, 120, function () {
  3450. // _self.app.content.mask({
  3451. // "style": {
  3452. // "background-color": "#999",
  3453. // "opacity": 0.6
  3454. // }
  3455. // });
  3456. MWF.require("MWF.widget.Mask", function () {
  3457. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  3458. _self.mask.loadNode(_self.app.content);
  3459. _self.fireEvent("beforeDelete");
  3460. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeDelete");
  3461. _self.doDeleteWork(function () {
  3462. _self.fireEvent("afterDelete");
  3463. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterDelete");
  3464. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  3465. _self.app.close();
  3466. this.close();
  3467. if (_self.mask) {
  3468. _self.mask.hide();
  3469. _self.mask = null;
  3470. }
  3471. }.bind(this), function (xhr, text, error) {
  3472. var errorText = error + ":" + text;
  3473. if (xhr) errorText = xhr.responseText;
  3474. _self.app.notice("request json error: " + errorText, "error", dlg.node);
  3475. if (_self.mask) {
  3476. _self.mask.hide();
  3477. _self.mask = null;
  3478. }
  3479. }.bind(this));
  3480. }.bind(this));
  3481. //_self.workAction.deleteWork(function(json){
  3482. // _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete+": “"+_self.businessData.work.title+"”", "success");
  3483. // _self.app.close();
  3484. // this.close();
  3485. //}.bind(this), null, _self.businessData.work.id);
  3486. //this.close();
  3487. }, function () {
  3488. this.close();
  3489. }, null, this.app.content, this.json.confirmStyle);
  3490. }
  3491. }
  3492. },
  3493. doDeleteDraftWork: function (success, failure) {
  3494. this.workAction.deleteDraftWork(function (json) {
  3495. if (success) success(json);
  3496. }.bind(this), function (xhr, text, error) {
  3497. if (failure) failure(xhr, text, error);
  3498. }, this.businessData.work.id);
  3499. },
  3500. doDeleteWork: function (success, failure) {
  3501. if (!this.businessData.work.startTime) {
  3502. this.doDeleteDraftWork(success, failure);
  3503. } else {
  3504. if (this.businessData.control["allowDelete"]) {
  3505. this.workAction.deleteWork(function (json) {
  3506. if (success) success(json);
  3507. }.bind(this), function (xhr, text, error) {
  3508. if (failure) failure(xhr, text, error);
  3509. }, this.businessData.work.id);
  3510. } else {
  3511. if (failure) failure(null, "Permission Denied", "");
  3512. }
  3513. }
  3514. },
  3515. //printWork: function(){
  3516. // var form = this.json.id;
  3517. // if (this.json.printForm){
  3518. // form = this.json.printForm;
  3519. // }
  3520. // window.open("../x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form);
  3521. //},
  3522. printWork: function (app, form) {
  3523. var application = app || (this.businessData.work) ? this.businessData.work.application : this.businessData.workCompleted.application;
  3524. var form = form;
  3525. if (!form) {
  3526. form = this.json.id;
  3527. if (this.json.printForm) form = this.json.printForm;
  3528. }
  3529. if (this.businessData.workCompleted) {
  3530. var application = app || this.businessData.workCompleted.application;
  3531. window.open(o2.filterUrl("../x_desktop/printWork.html?workCompletedId=" + this.businessData.workCompleted.id + "&app=" + application + "&form=" + form));
  3532. } else {
  3533. var application = app || this.businessData.work.application;
  3534. window.open(o2.filterUrl("../x_desktop/printWork.html?workid=" + this.businessData.work.id + "&app=" + application + "&form=" + form));
  3535. }
  3536. },
  3537. readedWork: function (e) {
  3538. this.fireEvent("beforeReaded");
  3539. var _self = this;
  3540. var title = this.businessData.work.title;
  3541. if (title.length > 75) {
  3542. title = title.substr(0, 74) + "..."
  3543. }
  3544. var text = "您确定要将“" + title + "”标记为已阅吗?";
  3545. this.app.confirm("infor", e, "标记已阅确认", text, 300, 120, function () {
  3546. var read = null;
  3547. for (var i = 0; i < _self.businessData.readList.length; i++) {
  3548. if (_self.businessData.readList[i].person === layout.session.user.distinguishedName) {
  3549. read = _self.businessData.readList[i];
  3550. break;
  3551. }
  3552. }
  3553. if (read) {
  3554. _self.app.action.setReaded(function () {
  3555. this.fireEvent("afterReaded");
  3556. _self.app.reload();
  3557. }.bind(_self), null, read.id, read);
  3558. } else {
  3559. _self.app.reload();
  3560. }
  3561. if (layout.mobile) {
  3562. //移动端页面关闭
  3563. _self.finishOnMobile()
  3564. } else {
  3565. this.close();
  3566. }
  3567. }, function () {
  3568. this.close();
  3569. }, null, this.app.content, this.json.confirmStyle);
  3570. },
  3571. openWindow: function (form, app) {
  3572. //var application = app || (this.businessData.work) ? this.businessData.work.application : this.businessData.workCompleted.application;
  3573. var form = form;
  3574. if (!form) {
  3575. form = this.json.id;
  3576. //if (this.json.printForm) form = this.json.printForm;
  3577. }
  3578. if (this.businessData.workCompleted) {
  3579. var application = app || this.businessData.workCompleted.application;
  3580. window.open(o2.filterUrl("../x_desktop/printWork.html?workCompletedId=" + this.businessData.workCompleted.id + "&app=" + application + "&form=" + form));
  3581. } else {
  3582. var application = app || this.businessData.work.application;
  3583. window.open(o2.filterUrl("../x_desktop/printWork.html?workid=" + this.businessData.work.id + "&app=" + application + "&form=" + form));
  3584. }
  3585. //window.open("../x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form);
  3586. },
  3587. uploadedAttachment: function (site, id) {
  3588. this.workAction.getAttachment(id, this.businessData.work.id, function (json) {
  3589. var att = this.all[site];
  3590. if (att) {
  3591. if (json.data) att.attachmentController.addAttachment(json.data);
  3592. att.attachmentController.checkActions();
  3593. att.fireEvent("upload", [json.data]);
  3594. }
  3595. }.bind(this));
  3596. },
  3597. replacedAttachment: function (site, id) {
  3598. this.workAction.getAttachment(id, this.businessData.work.id, function (json) {
  3599. var att = this.all[site];
  3600. if (att) {
  3601. var attachmentController = att.attachmentController;
  3602. var attachment = null;
  3603. for (var i = 0; i < attachmentController.attachments.length; i++) {
  3604. if (attachmentController.attachments[i].data.id === id) {
  3605. attachment = attachmentController.attachments[i];
  3606. break;
  3607. }
  3608. }
  3609. attachment.data = json.data;
  3610. attachment.reload();
  3611. attachmentController.checkActions();
  3612. }
  3613. }.bind(this))
  3614. },
  3615. //移动端页面 工作处理完成后
  3616. finishOnMobile: function () {
  3617. var _self = this;
  3618. //新建检查
  3619. this.workAction.checkDraft(this.businessData.work.id, function (json) {
  3620. var str = JSON.stringify(json);
  3621. // console.log("===========success==============");
  3622. _self.finishOnMobileReal();
  3623. }.bind(this), function () {
  3624. console.log("===========fail..==============");
  3625. _self.finishOnMobileReal();
  3626. }, false);
  3627. },
  3628. finishOnMobileReal: function () {
  3629. if (window.o2android && window.o2android.closeWork) {
  3630. window.o2android.closeWork("");
  3631. } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.closeWork) {
  3632. window.webkit.messageHandlers.closeWork.postMessage("");
  3633. } else {
  3634. var len = window.history.length;
  3635. if (len > 1) {
  3636. history.back();
  3637. } else {
  3638. var uri = new URI(window.location.href);
  3639. var redirectlink = uri.getData("redirectlink");
  3640. if (redirectlink) {
  3641. history.replaceState(null, "work", redirectlink);
  3642. redirectlink.toURI().go();
  3643. } else {
  3644. window.location = o2.filterUrl("../x_desktop/appMobile.html?app=process.TaskCenter");
  3645. history.replaceState(null, "work", o2.filterUrl("../x_desktop/appMobile.html?app=process.TaskCenter"));
  3646. o2.filterUrl("../x_desktop/appMobile.html?app=process.TaskCenter").toURI().go();
  3647. }
  3648. }
  3649. }
  3650. }
  3651. });