Form.js 177 KB

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