Form.js 185 KB

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