Form.js 166 KB

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