Form.js 183 KB

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