Form.js 173 KB

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