Form.js 169 KB

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