Form.js 175 KB

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