Form.js 175 KB

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