Form.js 173 KB

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