Form.js 174 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784
  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" && data[id][key] ){
  864. delete data[id][key]
  865. }
  866. // delete data[id];
  867. } else {
  868. var v = module.getData();
  869. // var d = this.loadPathData(id);
  870. // if (d) data[id] = d;
  871. data[id] = this.getSectionDataByPerson(v, data[id]);
  872. }
  873. } else {
  874. if (module.json.section === "yes") {
  875. // var d = this.loadPathData(id);
  876. // if (d) data[id] = d;
  877. data[id] = this.getSectionData(module, data[id]);
  878. } else {
  879. data[id] = module.getData();
  880. }
  881. }
  882. }.bind(this));
  883. this.businessData.data = data;
  884. this.Macro.environment.setData(this.businessData.data);
  885. return data;
  886. },
  887. getSectionData: function (module, obj) {
  888. var v = module.getData();
  889. switch (module.json.sectionBy) {
  890. case "person":
  891. return this.getSectionDataByPerson(v, obj);
  892. case "unit":
  893. return this.getSectionDataByUnit(v, obj);
  894. case "activity":
  895. return this.getSectionDataByPActivity(v, obj);
  896. case "splitValue":
  897. return this.getSectionDataBySplitValue(v, obj);
  898. case "script":
  899. return this.getSectionDataByScript(module.json.sectionByScript.code, v, obj);
  900. default:
  901. return v;
  902. }
  903. },
  904. getSectionDataByPerson: function (v, obj) {
  905. var key = layout.desktop.session.user.id;
  906. if (!obj || (typeOf(obj) !== "object")) obj = {};
  907. obj[key] = v;
  908. return obj;
  909. },
  910. getSectionDataByUnit: function (v, obj) {
  911. var key = (this.businessData.task) ? this.businessData.task.unit : "";
  912. if (!obj || (typeOf(obj) !== "object")) obj = {};
  913. if (key) obj[key] = v;
  914. return obj;
  915. },
  916. getSectionDataByPActivity: function (v, obj) {
  917. var key = (this.businessData.work) ? this.businessData.work.activity : "";
  918. if (!obj || (typeOf(obj) !== "object")) obj = {};
  919. if (key) obj[key] = v;
  920. return obj;
  921. },
  922. getSectionDataBySplitValue: function (v, obj) {
  923. var key = (this.businessData.work) ? this.businessData.work.splitValue : "";
  924. if (!obj || (typeOf(obj) !== "object")) obj = {};
  925. if (key) obj[key] = v;
  926. return obj;
  927. },
  928. getSectionDataByScript: function (code, v, obj) {
  929. var key = this.Macro.exec(code, this);
  930. if (!obj || (typeOf(obj) !== "object")) obj = {};
  931. if (key) obj[key] = v;
  932. return obj;
  933. },
  934. setSection: function (json, data) {
  935. var obj = data[json.name];
  936. switch (json.sectionBy) {
  937. case "person":
  938. return this.setSectionByPerson(obj, json.name);
  939. case "unit":
  940. return this.setSectionByUnit(obj, json.name);
  941. case "activity":
  942. return this.setSectionByPActivity(obj, json.name);
  943. case "splitValue":
  944. return this.setSectionBySplitValue(obj, json.name);
  945. case "script":
  946. return this.setSectionByScript(json.sectionByScript.code, obj, json.name);
  947. default:
  948. return v;
  949. }
  950. },
  951. setSectionByPerson: function (obj, name) {
  952. var key = layout.desktop.session.user.id;
  953. if (!obj || (typeOf(obj) !== "object")) obj = {};
  954. //obj[key] = v;
  955. this.sectionListObj[name] = key;
  956. return obj;
  957. },
  958. setSectionByUnit: function (obj, name) {
  959. var key = (this.businessData.task) ? this.businessData.task.unit : "";
  960. if (!obj || (typeOf(obj) !== "object")) obj = {};
  961. this.sectionListObj[name] = key || "";
  962. //if (key) obj[key] = v;
  963. return obj;
  964. },
  965. setSectionByPActivity: function (obj, name) {
  966. var key = (this.businessData.work) ? this.businessData.work.activity : "";
  967. if (!obj || (typeOf(obj) !== "object")) obj = {};
  968. this.sectionListObj[name] = key || "";
  969. //if (key) obj[key] = v;
  970. return obj;
  971. },
  972. setSectionBySplitValue: function (obj, name) {
  973. var key = (this.businessData.work) ? this.businessData.work.splitValue : "";
  974. if (!obj || (typeOf(obj) !== "object")) obj = {};
  975. this.sectionListObj[name] = key || "";
  976. //if (key) obj[key] = v;
  977. return obj;
  978. },
  979. setSectionByScript: function (code, obj, name) {
  980. var key = this.Macro.exec(code, this);
  981. if (!obj || (typeOf(obj) !== "object")) obj = {};
  982. this.sectionListObj[name] = key || "";
  983. //if (key) obj[key] = v;
  984. return obj;
  985. },
  986. saveWork: function (callback, silent) {
  987. debugger;
  988. if (this.businessData.control["allowSave"]) {
  989. this.fireEvent("beforeSave");
  990. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeSave");
  991. this.saveFormData(function (json) {
  992. if (this.app && !silent) this.app.notice(MWF.xApplication.process.Xform.LP.dataSaved, "success");
  993. if (callback && typeOf(callback) === "function") callback();
  994. this.fireEvent("afterSave");
  995. if (this.app && this.app.fireEvent) this.app.fireEvent("afterSave");
  996. }.bind(this));
  997. } else {
  998. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  999. //if (failure) failure(null, "Permission Denied", "");
  1000. }
  1001. },
  1002. getSectionList: function () {
  1003. return Object.keys(this.sectionListObj).map(function (p) {
  1004. var o = { "path": p };
  1005. if (this.sectionListObj[p]) o.key = this.sectionListObj[p];
  1006. return o;
  1007. }.bind(this));
  1008. },
  1009. setModifedDataByPathList: function (data, pathList) {
  1010. var d = this.modifedData;
  1011. for (var i = 0; i < pathList.length; i++) {
  1012. if (i === pathList.length - 1) {
  1013. d[pathList[i]] = data;
  1014. } else {
  1015. if (typeOf(d[pathList[i]]) === "object" || typeOf(d[pathList[i]]) === "array") {
  1016. d = d[pathList[i]]
  1017. } else if (typeOf(pathList[i]) === "number") {
  1018. d = d[pathList[i]] = [];
  1019. } else {
  1020. d = d[pathList[i]] = {};
  1021. }
  1022. }
  1023. }
  1024. },
  1025. getOrigianlPathData: function (pathList) {
  1026. var d = this.businessData.originalData;
  1027. for (var i = 0; i < pathList.length; i++) {
  1028. if (i === pathList.length - 1) {
  1029. d = d[pathList[i]];
  1030. } else {
  1031. if (typeOf(d[pathList[i]]) === "object" || typeOf(d[pathList[i]]) === "array") {
  1032. d = d[pathList[i]];
  1033. } else {
  1034. return null;
  1035. }
  1036. }
  1037. }
  1038. return d;
  1039. },
  1040. setModifedData: function (data, pathList) {
  1041. pathList = pathList || [];
  1042. if (typeOf(data) === "object") {
  1043. for (var key in data) {
  1044. var pList = Array.clone(pathList);
  1045. pList.push(key);
  1046. this.setModifedData(data[key], pList);
  1047. }
  1048. } else if (typeOf(data) === "array") {
  1049. var od = this.getOrigianlPathData(pathList);
  1050. if (typeOf(od) !== "array" || od.length !== data.length || JSON.stringify(od) !== JSON.stringify(data)) {
  1051. this.setModifedDataByPathList(data, pathList);
  1052. }
  1053. //}else{
  1054. // for( var i=0; i<data.length; i++ ){
  1055. // this.setModifedData(data[i], pathList.push(i));
  1056. // }
  1057. //}
  1058. } else if (typeOf(data) !== "null") { //后台对null是忽略处理的,认为值没有变化
  1059. var od = this.getOrigianlPathData(pathList);
  1060. if (typeOf(data) !== typeOf(od) || data !== od) {
  1061. this.setModifedDataByPathList(data, pathList);
  1062. }
  1063. }
  1064. },
  1065. saveFormData: function (callback, failure, history, data, issubmit) {
  1066. if (this.businessData.work.startTime) {
  1067. this.saveFormDataInstance(callback, failure, history, data, issubmit);
  1068. } else {
  1069. this.saveFormDataDraft(callback, failure, history, data, issubmit);
  1070. }
  1071. },
  1072. saveFormDataInstance: function (callback, failure, history, data, issubmit) {
  1073. if (this.officeList) {
  1074. this.officeList.each(function (module) {
  1075. module.save(history);
  1076. });
  1077. }
  1078. var data = data || this.getData(issubmit);
  1079. this.modifedData = {};
  1080. this.setModifedData(data);
  1081. this.workAction.saveData(callback || function () { }, failure, this.businessData.work.id, this.modifedData);
  1082. this.businessData.originalData = null;
  1083. this.businessData.originalData = Object.clone(data);
  1084. },
  1085. saveFormDataDraft: function (callback, failure, history, data, issubmit) {
  1086. if (this.officeList) {
  1087. this.officeList.each(function (module) {
  1088. module.save(history);
  1089. });
  1090. }
  1091. var data = data || this.getData(issubmit);
  1092. var draft = {
  1093. "data": data,
  1094. "work": this.businessData.work,
  1095. "identity": this.businessData.work.creatorIdentityDn
  1096. }
  1097. this.workAction.saveDraft(draft, function (json) {
  1098. this.workAction.getDraft(json.data.id, function (json) {
  1099. this.businessData.work = json.data.work;
  1100. this.app.options.draftId = json.data.work.id;
  1101. this.app.options.desktopReload = true;
  1102. this.app.appId = "process.Work" + json.data.work.id;
  1103. if(layout.desktop.apps) {
  1104. delete layout.desktop.apps[this.app.options.appId];
  1105. }else {
  1106. layout.desktop.apps = {};
  1107. }
  1108. layout.desktop.apps[this.app.appId] = this.app;
  1109. if (callback) callback();
  1110. }.bind(this));
  1111. }.bind(this), failure);
  1112. this.businessData.originalData = null;
  1113. this.businessData.originalData = Object.clone(data);
  1114. },
  1115. setProcessorSectionOrgList: function (data) {
  1116. if (!this.routeDataList) this.getRouteDataList();
  1117. var routeList = this.routeDataList;
  1118. //var processorSectionOrg = [];
  1119. for (var i = 0; i < routeList.length; i++) {
  1120. (routeList[i].selectConfigList || []).each(function (config, j) {
  1121. if (config.section == "yes") {
  1122. this.setSection(config, data);
  1123. }
  1124. }.bind(this))
  1125. }
  1126. },
  1127. getRouteDataList: function () {
  1128. if (!this.routeDataList) {
  1129. o2.Actions.get("x_processplatform_assemble_surface").listRoute({ "valueList": this.businessData.task.routeList }, function (json) {
  1130. json.data.each(function (d) {
  1131. d.selectConfigList = JSON.parse(d.selectConfig || "[]");
  1132. }.bind(this));
  1133. this.routeDataList = json.data;
  1134. }.bind(this), null, false);
  1135. }
  1136. return this.routeDataList;
  1137. },
  1138. beforeCloseWork: function () {
  1139. this.fireEvent("beforeClose");
  1140. if (this.app && this.app.fireEvent) {
  1141. this.app.fireEvent("beforeClose");
  1142. // this.fireEvent("afterClose");
  1143. }
  1144. if (!this.options.readonly) {
  1145. if (this.businessData.work && this.businessData.work.id) {
  1146. if (this.app.inBrowser && navigator.sendBeacon) {
  1147. debugger;
  1148. var obj = this.workAction.action.actions["checkDraft"];
  1149. var url = this.workAction.action.address + obj.uri;
  1150. url = url.replace("{id}", this.businessData.work.id);
  1151. navigator.sendBeacon(url);
  1152. } else {
  1153. this.workAction.checkDraft(this.businessData.work.id, function () {
  1154. if (layout.desktop.apps) {
  1155. if (layout.desktop.apps["TaskCenter"] && layout.desktop.apps["TaskCenter"].window) {
  1156. layout.desktop.apps["TaskCenter"].content.unmask();
  1157. layout.desktop.apps["TaskCenter"].refreshAll();
  1158. }
  1159. }
  1160. }.bind(this), null, false);
  1161. }
  1162. }
  1163. } else {
  1164. this.app.refreshTaskCenter();
  1165. }
  1166. },
  1167. closeWork: function () {
  1168. // this.fireEvent("beforeClose");
  1169. // if (this.app && this.app.fireEvent){
  1170. // this.app.fireEvent("beforeClose");
  1171. // // this.fireEvent("afterClose");
  1172. // }
  1173. // debugger;
  1174. // if (!this.options.readonly)
  1175. // if (this.businessData.work) this.workAction.checkDraft(this.businessData.work.id);
  1176. this.app.close();
  1177. },
  1178. getMessageContent: function (data, maxLength, titlelp) {
  1179. var content = "";
  1180. if (data.completed) {
  1181. content += MWF.xApplication.process.Xform.LP.workCompleted;
  1182. } else {
  1183. if (data.properties.nextManualList && data.properties.nextManualList.length) {
  1184. var activityUsers = [];
  1185. data.properties.nextManualList.each(function (a) {
  1186. var ids = [];
  1187. a.taskIdentityList.each(function (i) {
  1188. ids.push(o2.name.cn(i))
  1189. });
  1190. 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>";
  1191. activityUsers.push(t);
  1192. });
  1193. content += activityUsers.join("<br>");
  1194. } else {
  1195. if (data.arrivedActivityName) {
  1196. content += MWF.xApplication.process.Xform.LP.arrivedActivity + data.arrivedActivityName;
  1197. } else {
  1198. content += MWF.xApplication.process.Xform.LP.taskCompleted;
  1199. }
  1200. }
  1201. }
  1202. var title = this.businessData.data.title || this.businessData.data.subject || this.businessData.work.title
  1203. if (maxLength && title.length > maxLength) {
  1204. title = title.substr(0, maxLength) + "..."
  1205. }
  1206. return "<div>" + (titlelp || MWF.xApplication.process.Xform.LP.taskProcessedMessage) + "“" + title + "”</div>" + content;
  1207. },
  1208. addMessage: function (data, notShowBrowserDkg) {
  1209. if (layout.desktop.message) {
  1210. var msg = {
  1211. "subject": MWF.xApplication.process.Xform.LP.taskProcessed,
  1212. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.taskProcessedMessage)
  1213. };
  1214. layout.desktop.message.addTooltip(msg);
  1215. return layout.desktop.message.addMessage(msg);
  1216. } else {
  1217. if (this.app.inBrowser && !notShowBrowserDkg) {
  1218. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.taskProcessedMessage));
  1219. }
  1220. }
  1221. },
  1222. formValidation: function (routeName, opinion, medias) {
  1223. if (this.options.readonly) return true;
  1224. this.Macro.environment.form.currentRouteName = routeName;
  1225. this.Macro.environment.form.opinion = opinion;
  1226. this.Macro.environment.form.medias = medias;
  1227. var flag = true;
  1228. //flag = this.validation();
  1229. Object.each(this.forms, function (field, key) {
  1230. field.validationMode();
  1231. if (!field.validation(routeName, opinion, medias)) flag = false;
  1232. }.bind(this));
  1233. return flag;
  1234. },
  1235. validation: function (routeName, opinion, processor, medias) {
  1236. this.Macro.environment.form.currentRouteName = routeName;
  1237. this.Macro.environment.form.opinion = opinion;
  1238. this.Macro.environment.form.medias = medias;
  1239. var routeFlag = this.validationRoute(processor);
  1240. var opinionFlag = this.validationOpinion(processor);
  1241. return routeFlag && opinionFlag;
  1242. },
  1243. validationRoute: function (processor) {
  1244. if (!this.json.validationRoute) return true;
  1245. if (!this.json.validationRoute.code) return true;
  1246. var flag = this.Macro.exec(this.json.validationRoute.code, this);
  1247. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1248. if (flag.toString() != "true") {
  1249. this.notValidationRouteMode(flag, processor);
  1250. return false;
  1251. }
  1252. return true;
  1253. },
  1254. validationOpinion: function (processor) {
  1255. if (!this.json.validationOpinion) return true;
  1256. if (!this.json.validationOpinion.code) return true;
  1257. var flag = this.Macro.exec(this.json.validationOpinion.code, this);
  1258. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1259. if (flag.toString() != "true") {
  1260. this.notValidationOpinionMode(flag, processor);
  1261. return false;
  1262. }
  1263. return true;
  1264. },
  1265. formCustomValidation: function () {
  1266. if (!this.json.validationFormCustom) return true;
  1267. if (!this.json.validationFormCustom.code) return true;
  1268. var flag = this.Macro.exec(this.json.validationFormCustom.code, this);
  1269. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1270. if (flag.toString() != "true") {
  1271. this.notValidationOpinionMode(flag);
  1272. return false;
  1273. }
  1274. return true;
  1275. },
  1276. notValidationRouteMode: function (flag, processor) {
  1277. if (processor) processor.routeSelectorArea.setStyle("background-color", "#ffe9e9");
  1278. MWF.xDesktop.notice(
  1279. "error",
  1280. { "x": "center", "y": "top" },
  1281. flag,
  1282. (processor) ? processor.routeSelectorArea : this.app.content,
  1283. null, //{"x": 0, "y": 30}
  1284. { "closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000 }
  1285. );
  1286. //new mBox.Notice({
  1287. // type: "error",
  1288. // position: {"x": "center", "y": "top"},
  1289. // move: false,
  1290. // target: (processor) ? processor.routeSelectorArea : this.app.content,
  1291. // delayClose: 6000,
  1292. // content: flag
  1293. //});
  1294. },
  1295. notValidationOpinionMode: function (flag, processor) {
  1296. if (processor) processor.inputTextarea.setStyle("background-color", "#ffe9e9");
  1297. MWF.xDesktop.notice(
  1298. "error",
  1299. (processor) ? { "x": "center", "y": "top" } : { "x": "right", "y": "top" },
  1300. flag,
  1301. (processor) ? processor.inputTextarea : this.app.content,
  1302. null, //{"x": 0, "y": 30}
  1303. { "closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000 }
  1304. );
  1305. //new mBox.Notice({
  1306. // type: "error",
  1307. // position: (processor) ? {"x": "center", "y": "top"} : {"x": "right", "y": "top"},
  1308. // move: false,
  1309. // target: (processor) ? processor.inputTextarea : this.app.content,
  1310. // delayClose: 6000,
  1311. // content: flag
  1312. //});
  1313. },
  1314. //fireRtEvent: function(type, args, delay){
  1315. // type = removeOn(type);
  1316. // var events = this.$events[type];
  1317. // if (!events) return this;
  1318. // if (!events.length) return this;
  1319. // var event = events[events.length-1];
  1320. // args = Array.from(args);
  1321. // if (delay) fn.delay(delay, this, args);
  1322. // else return fn.apply(this, args);
  1323. // return this;
  1324. //},
  1325. getIgnoreImpowerIdentity: function (processorOrgList) {
  1326. debugger;
  1327. var list = [];
  1328. var check = function (org, isProcessOrg) {
  1329. var moduleData = isProcessOrg ? org.getValue() : org.getData();
  1330. var flag = false;
  1331. if (typeOf(moduleData) === "array" && moduleData.length) {
  1332. moduleData.each(function (d) {
  1333. if (d.ignoreEmpower) {
  1334. list.push(d.distinguishedName || d.unique || d.id);
  1335. d.ignoredEmpower = true;
  1336. delete d.ignoreEmpower;
  1337. flag = true;
  1338. }
  1339. })
  1340. }
  1341. if (flag) org.setData(moduleData);
  1342. }
  1343. var modules = this.modules;
  1344. for (var i = 0; i < modules.length; i++) {
  1345. var module = modules[i];
  1346. var moduleName = module.json.moduleName;
  1347. if (!moduleName) moduleName = typeOf(module.json.type) === "string" ? module.json.type.toLowerCase() : "";
  1348. if (moduleName === "org") {
  1349. check(module)
  1350. }
  1351. }
  1352. if (processorOrgList && processorOrgList.length > 0) {
  1353. for (var i = 0; i < processorOrgList.length; i++) {
  1354. check(processorOrgList[i], true)
  1355. }
  1356. }
  1357. return list;
  1358. },
  1359. //saveDocumentEditor
  1360. submitWork: function (routeName, opinion, medias, callback, processor, data, appendTaskIdentityList, processorOrgList, callbackBeforeSave) {
  1361. if (!this.businessData.control["allowProcessing"]) {
  1362. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  1363. this.app.content.unmask();
  1364. if (processor && processor.node) processor.node.unmask();
  1365. return false;
  1366. }
  1367. debugger;
  1368. if (!this.formValidation(routeName, opinion, medias)) {
  1369. this.app.content.unmask();
  1370. //this.app.notice("", "error", target, where, offset);
  1371. if (callback) callback();
  1372. return false;
  1373. }
  1374. if (!this.validation(routeName, opinion, processor, medias)) {
  1375. //this.app.content.unmask();
  1376. if (processor && processor.node) processor.node.unmask();
  1377. //if (callback) callback();
  1378. return false;
  1379. }
  1380. if (!opinion) {
  1381. var idx = this.businessData.task.routeNameList.indexOf(routeName);
  1382. if (this.businessData.task.routeOpinionList[idx]) {
  1383. opinion = this.businessData.task.routeOpinionList[idx];
  1384. }
  1385. // else{
  1386. // opinion = routeName;
  1387. // }
  1388. }
  1389. this.fireEvent("beforeProcess");
  1390. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcess");
  1391. // if (this.documenteditorList) {
  1392. // this.documenteditorList.each(function (module) {
  1393. // module.save(history);
  1394. // });
  1395. // }
  1396. //处理忽略授权
  1397. var ignoreEmpowerIdentityList = this.getIgnoreImpowerIdentity(processorOrgList);
  1398. var _self = this;
  1399. MWF.require("MWF.widget.Mask", function () {
  1400. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  1401. this.mask.loadNode(this.app.content);
  1402. if (callbackBeforeSave) callbackBeforeSave();
  1403. this.fireEvent("beforeSave");
  1404. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeSave");
  1405. this.saveFormData(function (json) {
  1406. this.businessData.task.routeName = routeName;
  1407. this.businessData.task.opinion = opinion || "";
  1408. var mediaIds = [];
  1409. if (medias && medias.length) {
  1410. medias.each(function (file) {
  1411. var formData = new FormData();
  1412. formData.append("file", file);
  1413. formData.append("site", "$mediaOpinion");
  1414. this.workAction.uploadAttachment(this.businessData.work.id, formData, file, function (json) {
  1415. mediaIds.push(json.data.id);
  1416. }.bind(this), null, false);
  1417. }.bind(this));
  1418. }
  1419. if (mediaIds.length) this.businessData.task.mediaOpinion = mediaIds.join(",");
  1420. if (appendTaskIdentityList && appendTaskIdentityList.length) {
  1421. var list = [];
  1422. appendTaskIdentityList.each(function (identity) {
  1423. if (typeOf(identity) === "object") {
  1424. list.push(identity.distinguishedName || identity.unique || identity.id)
  1425. } else {
  1426. list.push(identity);
  1427. }
  1428. }.bind(this));
  1429. this.businessData.task.appendTaskIdentityList = list;
  1430. }
  1431. this.businessData.task.ignoreEmpowerIdentityList = ignoreEmpowerIdentityList;
  1432. this.fireEvent("afterSave");
  1433. if (this.app && this.app.fireEvent) this.app.fireEvent("afterSave");
  1434. this.workAction.processTask(function (json) {
  1435. //if (processor) processor.destroy();
  1436. //if (processNode) processNode.destroy();
  1437. if (callback) callback(json);
  1438. this.taskList = json.data;
  1439. this.fireEvent("afterProcess");
  1440. if (this.app && this.app.fireEvent) this.app.fireEvent("afterProcess");
  1441. // this.notice(MWF.xApplication.process.Xform.LP.taskProcessed, "success");
  1442. this.addMessage(json.data, true);
  1443. if (this.app.taskObject) this.app.taskObject.destroy();
  1444. if (this.closeImmediatelyOnProcess) {
  1445. this.app.close();
  1446. } else if (typeOf(this.showCustomSubmitedDialog) === "function") {
  1447. this.showCustomSubmitedDialog(json.data);
  1448. } else if (layout.mobile) {
  1449. //移动端页面关闭
  1450. _self.finishOnMobile()
  1451. } else {
  1452. if (this.app.inBrowser) {
  1453. if (this.mask) this.mask.hide();
  1454. if (this.json.isPrompt !== false) {
  1455. this.showSubmitedDialog(json.data);
  1456. } else {
  1457. if (this.json.afterProcessAction=="redirect" && this.json.afterProcessRedirectScript && this.json.afterProcessRedirectScript.code){
  1458. var url = this.Macro.exec(this.json.afterProcessRedirectScript.code, this);
  1459. (new URI(url)).go();
  1460. }else{
  1461. this.app.close();
  1462. }
  1463. }
  1464. //}
  1465. } else {
  1466. this.app.close();
  1467. }
  1468. }
  1469. //window.setTimeout(function(){this.app.close();}.bind(this), 2000);
  1470. }.bind(this), null, this.businessData.task.id, this.businessData.task);
  1471. }.bind(this), null, true, data, true);
  1472. }.bind(this));
  1473. },
  1474. showSubmitedDialog: function (data) {
  1475. var content = this.getMessageContent(data, this.json.submitedDlgStyle ? this.json.submitedDlgStyle.maxTitleLength : 60);
  1476. //if( this.json.submitedDlgUseNotice ){
  1477. // MWF.xDesktop.notice("success", {x: "right", y:"top"}, content);
  1478. // if (this.json.isPrompt!==false){
  1479. // if (this.json.promptCloseTime!=0){
  1480. // var t = this.json.promptCloseTime || 2;
  1481. // t = t.toInt()*1000;
  1482. // var _work = this;
  1483. // window.setTimeout(function(){ _work.app.close();}, t);
  1484. // }
  1485. // }else{
  1486. // this.app.close();
  1487. // }
  1488. //}else{
  1489. var div = new Element("div", { "styles": { "margin": "10px 10px 0px 10px", "padding": "5px", "overflow": "hidden", "width": "270px" } }).inject(this.app.content);
  1490. div.set("html", content);
  1491. var timerNode = new Element("div", { "styles": { "margin-top": "5px" } }).inject(div);
  1492. var options = {
  1493. "content": div,
  1494. "isTitle": false,
  1495. "width": 350,
  1496. "height": 180,
  1497. "buttonList": [
  1498. {
  1499. "text": this.app.lp.closePage,
  1500. "action": function () { dlg.close(); this.app.close(); }.bind(this)
  1501. }
  1502. ]
  1503. };
  1504. if (this.json.submitedDlgStyle) {
  1505. options = Object.merge(options, this.json.submitedDlgStyle);
  1506. if (this.json.submitedDlgStyle.contentStyle) {
  1507. div.setStyles(this.json.submitedDlgStyle.contentStyle);
  1508. delete options.contentStyle;
  1509. }
  1510. }
  1511. var size = this.app.content.getSize();
  1512. switch (options.promptPosition || this.json.promptPosition || "righttop") {
  1513. case "lefttop":
  1514. options.top = 10;
  1515. options.left = 10;
  1516. options.fromTop = 10;
  1517. options.fromLeft = 10;
  1518. break;
  1519. case "righttop":
  1520. options.top = 10;
  1521. options.left = size.x - options.width - 10;
  1522. options.fromTop = 10;
  1523. options.fromLeft = size.x - 10;
  1524. break;
  1525. case "leftbottom":
  1526. options.top = size.y - options.height - 10;
  1527. options.left = 10;
  1528. options.fromTop = size.y - 10;
  1529. options.fromLeft = 10;
  1530. break;
  1531. case "rightbottom":
  1532. options.top = size.y - options.height - 10;
  1533. options.left = size.x - options.width - 10;
  1534. options.fromTop = size.y - 10;
  1535. options.fromLeft = size.x - 10;
  1536. break;
  1537. default:
  1538. delete options.top;
  1539. delete options.left;
  1540. delete options.fromTop;
  1541. delete options.fromLeft;
  1542. }
  1543. var _work = this;
  1544. options.onPostLoad = function () {
  1545. debugger;
  1546. var dialog = this;
  1547. dialog.node.setStyle("display", "block");
  1548. var nodeSize = div.getSize();
  1549. dialog.content.setStyles({
  1550. //"width" : nodeSize.x,
  1551. "height": nodeSize.y
  1552. });
  1553. dialog.setContentSize();
  1554. if ((options.promptCloseTime || _work.json.promptCloseTime) != 0) {
  1555. var t = options.promptCloseTime || _work.json.promptCloseTime || 2;
  1556. t = t.toInt() * 1000;
  1557. if (options.isCountDown) {
  1558. timerNode.set("text", _work.app.lp.closePageCountDownText.replace("{second}", Math.ceil(t / 1000).toString()));
  1559. t = t - 1000;
  1560. var countDown = function () {
  1561. if (t > 0) {
  1562. timerNode.set("text", _work.app.lp.closePageCountDownText.replace("{second}", Math.ceil(t / 1000).toString()));
  1563. t = t - 1000;
  1564. window.setTimeout(countDown, 1000);
  1565. } else {
  1566. dlg.close();
  1567. if (_work.json.afterProcessAction=="redirect" && _work.json.afterProcessRedirectScript && _work.json.afterProcessRedirectScript.code){
  1568. var url = _work.Macro.exec(_work.json.afterProcessRedirectScript.code, _work);
  1569. (new URI(url)).go();
  1570. }else{
  1571. _work.app.close();
  1572. }
  1573. }
  1574. };
  1575. window.setTimeout(countDown, 1000);
  1576. } else {
  1577. window.setTimeout(function () {
  1578. if (_work.json.afterProcessAction=="redirect" && _work.json.afterProcessRedirectScript && _work.json.afterProcessRedirectScript.code){
  1579. var url = _work.Macro.exec(_work.json.afterProcessRedirectScript.code, _work);
  1580. (new URI(url)).go();
  1581. }else{
  1582. _work.app.close();
  1583. }
  1584. }, t);
  1585. }
  1586. }
  1587. };
  1588. var dlg = o2.DL.open(options);
  1589. },
  1590. startDraftProcess: function () {
  1591. if (!this.formCustomValidation("", "")) {
  1592. this.app.content.unmask();
  1593. // if (callback) callback();
  1594. return false;
  1595. }
  1596. if (!this.formValidation("", "")) {
  1597. this.app.content.unmask();
  1598. // if (callback) callback();
  1599. return false;
  1600. }
  1601. this.saveFormData(function () {
  1602. this.workAction.startDraft(this.businessData.work.id, function (json) {
  1603. this.app.options.workId = json.data[0].work;
  1604. if (layout.mobile) {
  1605. if(layout.notice) {
  1606. layout.notice(MWF.xApplication.process.Xform.LP.processStartedMessage + "“[" + json.data[0].processName + "]" + (this.businessData.data.title || this.businessData.data.subject));
  1607. }
  1608. }else {
  1609. var msg = {
  1610. "subject": MWF.xApplication.process.Xform.LP.processStarted,
  1611. "content": "<div>" + MWF.xApplication.process.Xform.LP.processStartedMessage + "“[" + json.data[0].processName + "]" + (this.businessData.data.title || this.businessData.data.subject) + "”</div>"
  1612. };
  1613. var tooltip = layout.desktop.message.addTooltip(msg);
  1614. var item = layout.desktop.message.addMessage(msg);
  1615. }
  1616. this.app.reload();
  1617. //this.app.notice(MWF.xApplication.process.Xform.LP.dataSaved, "success");
  1618. //草稿模式暂时不能上传附件,不能直接流转文件
  1619. // o2.Actions.invokeAsync([
  1620. // {"action": this.workAction, "name": "loadWork"},
  1621. // {"action": this.workAction, "name": "getWorkControl"},
  1622. // {"action": this.workAction, "name": "getWorkLog"},
  1623. // {"action": this.workAction, "name": "getRecordLog"},
  1624. // {"action": this.workAction, "name": "listAttachments"}
  1625. // ], {"success": function(json_work, json_control, json_log, json_record, json_att){
  1626. // if (json_work && json_control && json_log && json_att){
  1627. // this.app.parseData(json_work.data, json_control.data, null, json_log.data, json_record.data, json_att.data);
  1628. // var workData = json_work.data;
  1629. // this.businessData.activity = workData.activity;
  1630. // this.businessData.originalData = Object.clone( this.businessData.data );
  1631. // this.businessData.taskList = workData.taskList;
  1632. // this.businessData.task = this.getCurrentTaskData(workData);
  1633. // this.businessData.taskList = workData.taskList;
  1634. // this.businessData.readList = workData.readList;
  1635. // this.businessData.work = workData.work;
  1636. // this.businessData.workCompleted = (workData.work.completedTime) ? workData.work : null;
  1637. //
  1638. // this.businessData.workLogList = json_log.data;
  1639. // this.businessData.recordList = json_record.data;
  1640. // this.businessData.attachmentList = json_att.data;
  1641. // this.businessData.control = json_control.data;
  1642. //
  1643. // if (this.businessData.task){
  1644. // this.processWork();
  1645. // }else{
  1646. // this.app.options.workId = json.data[0].work;
  1647. // this.app.reload();
  1648. // }
  1649. // }
  1650. // }.bind(this), "failure": function(){}}, json.data[0].work);
  1651. }.bind(this));
  1652. }.bind(this), null, false, null, false)
  1653. },
  1654. getCurrentTaskData: function (data) {
  1655. if ((data.currentTaskIndex || data.currentTaskIndex === 0) && data.currentTaskIndex != -1) {
  1656. this.app.options.taskId = this.businessData.taskList[data.currentTaskIndex].id;
  1657. return this.businessData.taskList[data.currentTaskIndex];
  1658. }
  1659. return null;
  1660. },
  1661. processWork: function () {
  1662. var _self = this;
  1663. debugger;
  1664. if (!this.businessData.work.startTime) {
  1665. this.startDraftProcess();
  1666. } else if( this.json.submitFormType === "select" ){
  1667. this.processWork_custom();
  1668. } else if( this.json.submitFormType === "script" ){
  1669. this.processWork_custom();
  1670. } else {
  1671. if (this.json.mode == "Mobile") {
  1672. setTimeout(function () {
  1673. this.processWork_mobile();
  1674. }.bind(this), 100);
  1675. } else {
  1676. this.processWork_pc();
  1677. }
  1678. }
  1679. },
  1680. processWork_custom : function(){
  1681. this.fireEvent("beforeProcessWork");
  1682. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  1683. if (!this.formCustomValidation("", "")) {
  1684. this.app.content.unmask();
  1685. // if (callback) callback();
  1686. return false;
  1687. }
  1688. if (!this.formValidation("", "")) {
  1689. this.app.content.unmask();
  1690. // if (callback) callback();
  1691. return false;
  1692. }
  1693. debugger;
  1694. if( !this.submitFormModule ){
  1695. if (!MWF["APPSubmitform"]) {
  1696. MWF.xDesktop.requireApp("process.Xform", "Subform", null, false);
  1697. }
  1698. var submitFormContainer = new Element("div").inject( layout.mobile ? $(document.body) : this.app.content );
  1699. this.submitFormModule = new MWF["APPSubmitform"]( submitFormContainer , this.json, this);
  1700. this.submitFormModule.addEvent("afterModulesLoad", function () {
  1701. this.submitFormModule.show();
  1702. }.bind(this))
  1703. this.submitFormModule.load();
  1704. }else{
  1705. this.submitFormModule.show();
  1706. }
  1707. },
  1708. processWork_pc: function(){
  1709. var _self = this;
  1710. this.fireEvent("beforeProcessWork");
  1711. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  1712. if (!this.formCustomValidation("", "")) {
  1713. this.app.content.unmask();
  1714. // if (callback) callback();
  1715. return false;
  1716. }
  1717. // MWF.require("MWF.widget.Mask", function() {
  1718. // this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1719. // this.mask.loadNode(this.app.content);
  1720. if (!this.formValidation("", "")) {
  1721. this.app.content.unmask();
  1722. // if (callback) callback();
  1723. return false;
  1724. }
  1725. var setSize = function (notRecenter) {
  1726. debugger;
  1727. var dlg = this;
  1728. if (!dlg || !dlg.node) return;
  1729. dlg.node.setStyle("display", "block");
  1730. var size = processNode.getSize();
  1731. dlg.content.setStyles({
  1732. "height": size.y,
  1733. "width": size.x
  1734. });
  1735. debugger;
  1736. var s = dlg.setContentSize();
  1737. // if ( dlg.content.getStyle("overflow-y") === "auto" && dlg.content.getStyle("overflow-x") !== "auto" ) {
  1738. // var paddingRight = (dlg.content.getStyle("padding-right").toInt() || 0 );
  1739. // if( paddingRight < 20 ){
  1740. // dlg.node.setStyle("width", dlg.node.getStyle("width").toInt() + 20 + "px");
  1741. // dlg.content.setStyle("width", dlg.content.getStyle("width").toInt() + 20 + "px");
  1742. // }
  1743. // }
  1744. if (!notRecenter) dlg.reCenter();
  1745. }
  1746. //var node = new Element("div", {"styles": this.css.rollbackAreaNode});
  1747. var processNode = new Element("div", { "styles": this.app.css.processNode_Area }).inject(this.node);
  1748. this.setProcessNode(processNode, "process", function ( processor ){
  1749. this.processDlg = o2.DL.open({
  1750. "title": this.app.lp.process,
  1751. "style": this.json.dialogStyle || "user",
  1752. "isResize": false,
  1753. "content": processNode,
  1754. "maskNode": this.app.content,
  1755. "positionHeight": 800,
  1756. "maxHeight": 800,
  1757. "maxHeightPercent": "98%",
  1758. "minTop": 5,
  1759. "width": "auto", //processNode.retrieve("width") || 1000, //600,
  1760. "height": "auto", //processNode.retrieve("height") || 401,
  1761. "buttonList": [
  1762. {
  1763. "type": "ok",
  1764. "text": MWF.LP.process.button.ok,
  1765. "action": function (d, e) {
  1766. if (this.processor) this.processor.okButton.click();
  1767. }.bind(this)
  1768. },
  1769. {
  1770. "type": "cancel",
  1771. "text": MWF.LP.process.button.cancel,
  1772. "action": function () {
  1773. this.processDlg.close();
  1774. if (this.processor) this.processor.destroy();
  1775. }.bind(this)
  1776. }
  1777. ],
  1778. "onPostLoad": function () {
  1779. processor.options.mediaNode = this.content;
  1780. setSize.call(this)
  1781. }
  1782. });
  1783. }.bind(this), function () {
  1784. if (this.processDlg) setSize.call(this.processDlg, true)
  1785. }.bind(this));
  1786. },
  1787. processWork_mobile: function () {
  1788. if (this.app.inBrowser) {
  1789. this.app.content.setStyle("height", document.body.getSize().y);
  1790. }
  1791. this.fireEvent("beforeProcessWork");
  1792. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  1793. var position = this.app.content.getPosition(this.app.content.getOffsetParent());
  1794. if (this.json.mode != "Mobile") {
  1795. this.app.content.mask({
  1796. "destroyOnHide": true,
  1797. "style": this.app.css.maskNode,
  1798. "useIframeShim": true,
  1799. "iframeShimOptions": { "browsers": true },
  1800. "onShow": function () {
  1801. this.shim.shim.setStyles({
  1802. "opacity": 0,
  1803. "top": "" + position.y + "px",
  1804. "left": "" + position.x + "px"
  1805. });
  1806. }
  1807. });
  1808. }
  1809. if (!this.formCustomValidation("", "")) {
  1810. this.app.content.unmask();
  1811. // if (callback) callback();
  1812. return false;
  1813. }
  1814. // MWF.require("MWF.widget.Mask", function() {
  1815. // this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1816. // this.mask.loadNode(this.app.content);
  1817. if (!this.formValidation("", "")) {
  1818. this.app.content.unmask();
  1819. // if (callback) callback();
  1820. return false;
  1821. }
  1822. var processNode = this.createProcessNode();
  1823. //this.setProcessNode(processNode);
  1824. this.setProcessNode(processNode);
  1825. this.showProcessNode(processNode);
  1826. processNode.setStyle("overflow", "auto");
  1827. //}.bind(this));
  1828. },
  1829. createProcessNode: function () {
  1830. var fromCss = this.app.css.processNode_from;
  1831. var css = this.app.css.processNode;
  1832. if (layout.mobile) {
  1833. fromCss = this.app.css.processNodeMobile_from;
  1834. css = this.app.css.processNodeMobile;
  1835. // var contentSize = this.app.content.getSize();
  1836. fromCss.width = "100%";
  1837. css.width = "100%";
  1838. fromCss.height = "100%";
  1839. css.height = "100%";
  1840. }
  1841. if (this.json.mode == "Mobile") {
  1842. var processNode = new Element("div", { "styles": fromCss }).inject(document.body);
  1843. } else {
  1844. var processNode = new Element("div", { "styles": fromCss }).inject(this.app.content);
  1845. }
  1846. processNode.position({
  1847. relativeTo: this.app.content,
  1848. position: "topcenter",
  1849. edge: "topcenter"
  1850. });
  1851. return processNode;
  1852. },
  1853. getOpinion: function () {
  1854. var opinion = "";
  1855. var medias = [];
  1856. Object.each(this.forms, function (m, id) {
  1857. if (m.json.type === "Opinion") if (this.businessData.data[id]) opinion += " " + m._getBusinessSectionDataByPerson();
  1858. if (m.handwritingFile) if (m.handwritingFile[layout.session.user.distinguishedName]) medias.push(m.handwritingFile[layout.session.user.distinguishedName]);
  1859. if (m.soundFile) if (m.soundFile[layout.session.user.distinguishedName]) medias.push(m.soundFile[layout.session.user.distinguishedName]);
  1860. if (m.videoFile) if (m.videoFile[layout.session.user.distinguishedName]) medias.push(m.videoFile[layout.session.user.distinguishedName]);
  1861. }.bind(this));
  1862. return { "opinion": opinion.trim(), "medias": medias };
  1863. },
  1864. setProcessNode: function (processNode, style, postLoadFun, resizeFun) {
  1865. var _self = this;
  1866. MWF.xDesktop.requireApp("process.Work", "Processor", function () {
  1867. var op = this.getOpinion();
  1868. var mds = op.medias;
  1869. var innerNode;
  1870. if (layout.mobile) {
  1871. innerNode = new Element("div").inject(processNode);
  1872. }
  1873. this.processor = new MWF.xApplication.process.Work.Processor(innerNode || processNode, this.businessData.task, {
  1874. "style": (layout.mobile) ? "mobile" : (style || "default"),
  1875. "opinion": op.opinion,
  1876. "tabletWidth": this.json.tabletWidth || 0,
  1877. "tabletHeight": this.json.tabletHeight || 0,
  1878. "onPostLoad": function () {
  1879. if (postLoadFun) postLoadFun( this );
  1880. },
  1881. "onResize": function () {
  1882. if (resizeFun) resizeFun();
  1883. },
  1884. "onCancel": function () {
  1885. processNode.destroy();
  1886. _self.app.content.unmask();
  1887. delete this;
  1888. },
  1889. "onSubmit": function (routeName, opinion, medias, appendTaskIdentityList, processorOrgList, callbackBeforeSave) {
  1890. if (!medias || !medias.length) {
  1891. medias = mds;
  1892. } else {
  1893. medias = medias.concat(mds)
  1894. }
  1895. _self.submitWork(routeName, opinion, medias, function () {
  1896. this.destroy();
  1897. processNode.destroy();
  1898. if (_self.processDlg) _self.processDlg.close();
  1899. delete this;
  1900. }.bind(this), this, null, appendTaskIdentityList, processorOrgList, callbackBeforeSave);
  1901. }
  1902. }, this);
  1903. }.bind(this));
  1904. },
  1905. showProcessNode: function (processNode) {
  1906. if (layout.mobile) {
  1907. processNode.setStyles(this.app.css.processNodeMobile)
  1908. } else {
  1909. var size = this.app.content.getSize();
  1910. var nodeSize = processNode.getSize();
  1911. var top = size.y / 2 - nodeSize.y / 2 - 20;
  1912. var left = size.x / 2 - nodeSize.x / 2;
  1913. if (top < 0) top = 0;
  1914. this.app.css.processNode.top = "" + top + "px";
  1915. this.app.css.processNode.left = "" + left + "px";
  1916. var morph = new Fx.Morph(processNode, {
  1917. "duration": 300,
  1918. "transition": Fx.Transitions.Expo.easeOut
  1919. });
  1920. morph.start(this.app.css.processNode);
  1921. }
  1922. },
  1923. confirm: function (type, e, title, text, width, height, ok, cancel, callback, mask, style) {
  1924. MWF.require("MWF.xDesktop.Dialog", function () {
  1925. var size = this.container.getSize();
  1926. var x = 0;
  1927. var y = 0;
  1928. if (typeOf(e) === "element") {
  1929. var position = e.getPosition(this.app.content);
  1930. x = position.x;
  1931. y = position.y;
  1932. } else {
  1933. if (Browser.name == "firefox") {
  1934. x = parseFloat(e.event.clientX || e.event.x);
  1935. y = parseFloat(e.event.clientY || e.event.y);
  1936. } else {
  1937. x = parseFloat(e.event.x);
  1938. y = parseFloat(e.event.y);
  1939. }
  1940. if (e.target) {
  1941. var position = e.target.getPosition(this.app.content);
  1942. //var position = e.target.getPosition();
  1943. x = position.x;
  1944. y = position.y;
  1945. }
  1946. }
  1947. // if (Browser.Platform.ios){
  1948. // $("textdiv").set("text", "$(document.body).getScroll().y: "+$(document.body).getScroll().y);
  1949. // y = y-$(document.body).getScroll().y;
  1950. // }
  1951. if (x + parseFloat(width) > size.x) {
  1952. x = x - parseFloat(width);
  1953. }
  1954. if (x < 0) x = 10;
  1955. if (y + parseFloat(height) > size.y) {
  1956. y = y - parseFloat(height);
  1957. }
  1958. if (y < 0) y = 10;
  1959. //var x = parseFloat((Browser.name==="firefox") ? e.event.clientX : e.event.x);
  1960. //var y = parseFloat((Browser.name==="firefox") ? e.event.clientY : e.event.y);
  1961. // if (x+parseFloat(width)>size.x){
  1962. // x = x-parseFloat(width);
  1963. // }
  1964. if (x < 0) x = 20;
  1965. var dlg = new MWF.xDesktop.Dialog({
  1966. "title": title,
  1967. "style": style || "o2",
  1968. "top": y,
  1969. "left": x - 20,
  1970. "fromTop": e.event.y,
  1971. "fromLeft": (Browser.name === "firefox") ? e.event.clientX - 20 : e.event.x - 20,
  1972. "width": width,
  1973. "height": height,
  1974. "text": text,
  1975. "container": this.app.content,
  1976. "maskNode": mask || this.app.content,
  1977. "buttonList": [
  1978. {
  1979. "type": "ok",
  1980. "text": MWF.LP.process.button.ok,
  1981. "action": ok
  1982. },
  1983. {
  1984. "type": "cancel",
  1985. "text": MWF.LP.process.button.cancel,
  1986. "action": cancel
  1987. }
  1988. ]
  1989. });
  1990. switch (type.toLowerCase()) {
  1991. case "success":
  1992. if (this.json.confirmIcon && this.json.confirmIcon.success) {
  1993. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.success + ")");
  1994. } else {
  1995. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  1996. }
  1997. break;
  1998. case "error":
  1999. if (this.json.confirmIcon && this.json.confirmIcon.error) {
  2000. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.error + ")");
  2001. } else {
  2002. dlg.content.setStyle("background-image", "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABsVJREFUeNqkWFtsFGUU/nZn2r21IqX3llp6AQmkWDVGAgIlGI0EeMAHffAFa998MCQaE8JDxZCgSHzQKIm3qPHFGC7GW0xqkIgIKhhEwFJaKSDQUtplu73s7vidmX/q32F2uw2TnOzMv2fO+f5z/8fci7yvWAZYRXo4CCwLAM1cq+HvXRYwQrrM/7rTwB+TwC/dwKG3uU75mVxCO7T7wExgKHiBATzJ2411wMoy3pSQ5gg6UiFpgpQgDZNukK6TLgBHuf7lAPD5q8DfXMpQl5U3mA4P4ztAO3+2tADLCQSV+VsR/5L+If0G/EqgH78EvKtwT1lqr0en6SfoLaCe1niB7nj+CQIuV+uZWYApV8RNPPAVcP/rQMtF4I03gbNcpjdvt5KxQXs4SKKflxBI54PAs20EElNvZTQJucjLFyUtpZwioJVurFtMD/4MXBXWDUqnL5jHHYt0PgQ8da/4UFMwThpTz0HF7wfEj0/kSKwVAwsZU5U1wKkTwOBBj7GD08xE17QSSJPanVCKlCSNkM5s2mT/JtV6epZ8InclsH4R9TjYRKWPZQixnch2POJsZNpOb5HOb9yIi5s3I5XJIHb2rL2LoBZL+fBZKhOZaS3LgPgh4HcnYZ34scFI+goQxsj8iA+QHipItrejrKwMiaVLMZJIIEpFAaUkH76AFrEVfLxEzzEej/0FXFOGc8CQ8bmFTOE6DciEUnCBCsapoLGxETU1NYhGo7i+YAHiSlFauWMmvqAGKOzcVzDlh2mdo2o/loCJkeEVRnldSMsGUdCrKaiqqkJxcTEikQgKCgpsRbJzk4oukm8iB1+CfEUKkLtZub/CZOsFvht0Qi1lrAfW0WwvN3gyI7J1K+7ZswfNzc0oLS1FKBRCMBiEaZoIh8OOovp6jI6NYXLLFjQ1NdlAxCKGYaCwsBAlJSWoJ08lwQZTKaSPHJmSL9YZZWZx438eZ8yLMwwWtWeYaqvv9oBJ8UWDyovWrUMgEPi/ZPPeBWT/rlhhx0h1dbUNRABPpSrvBVhixw4kd+26rRyMOq3jCl31kzya0vSiKgW91/DOnbZJ53V22iAsy5pSIopra2vtNflP3KIDcTcwuH074pQT8JEvelkMF4kjpBuY0n1Dbjj7XDcpSCCU+gCKxWK+77hABghkOAsQuUIOivmq3xrSm2qMLJZxrwEKlGJQ5QGUC8gVBSSYQ67hoCidAiPzSCCHZSxVlXopeHhiAk30v8RBtivFQO3etg1Du3fbbihQKe0L3MmqmGrYwaAMRuPKMl6aVCkeJ11jRvSuWYO+vj4kk0lf4bIu/wuf8MfV+5NZ5I87RhhVuAKmTGhsbHPCWSwiwoYoOMQ60tDQgPLycjvNfWOA6/J/Op3GefJzsMLcAwfs6PSz0JhTXAfcBDNlVCS0xaYHSEql3jCBRLSC5k3faV1XZZnwySWABmUqJKCo8oUOaNTZbL9SlzE4Niwh8lURLf/TyoQzAZFgdcmvDklhjKsKXKAqsF5rZEztAboOAz+KA4xHmeo0+tNFqky7VMkKfJ+nAnuV2rtn1pS0td32n16B67kpRjZuqQrs6pB5mW37s5OswoLNaOTUdRfQRjPWGhrqOF80aYVSTwXWgfQQSL8URiqa6wGkV+B+ZuAlTwUWF/VxyPoUeD/uTH5x4xhjiNapoHXWhj3l+ubhw0hTkbtz3SXdBNJHIJgFn+Vx0Tlg37eOi+RAkTTk+MDueY1WWc64qQ5oZpSXhpSiedrOz1HBBVWZZ8Pn0phzcjj9DfBBvz1r4aYkrz3PvEhZq9lIyfgY3RXwzrY3lKKytWtxhgp6fHaaL5+AoU8stulPvgB+UFZJuPOMPaF/D5wgoGq6q9XMosianER3FiD58iWcDNr/GvCegwtDbjeywShAGQ5Y3aYzZC00PELsDkxFmOGokosv6cy/XV8DHyr3XFfL1rSBnL/WNqKUcw3rQWWhD6A7oaSTPV1dwEecX07CmX1v6W3Re4iz5IAl5xqCiTIMW0zJ5DsAkXKOLxbHy/1iEQ3IiHdYmAbGdZccsBhDXXKcoMAyWqjCynJwywVCqjgbz2kJVokR5RoXyKRkctYTpQ5Iepica+Q4QesMU0GUoCozPjGS0QZ5t9uzJ51ioO6T9FVZc1XFiLgm5X6ROJjvJ5EOZ4iXwaeIs2Elz1WreExtlVFRJjQZjGQekTFAuq80PRazbp6JTtOyxy87FX9EkYCY8H6v6fDMNzNdagayQYXVZ5mIei7UmrHrnQlFSZXJY9qnECuXIjMPMJZ2lHIPj6aaGg0FNOD5CJHWjtl5f0n5T4ABAFHaXG6UVjGNAAAAAElFTkSuQmCC)");
  2003. }
  2004. break;
  2005. case "info":
  2006. if (this.json.confirmIcon && this.json.confirmIcon.info) {
  2007. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.info + ")");
  2008. } else {
  2009. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  2010. }
  2011. break;
  2012. case "warn":
  2013. if (this.json.confirmIcon && this.json.confirmIcon.warn) {
  2014. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.warn + ")");
  2015. } else {
  2016. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  2017. }
  2018. break;
  2019. default:
  2020. if (this.json.confirmIcon && this.json.confirmIcon.warn) {
  2021. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.warn + ")");
  2022. }
  2023. break;
  2024. }
  2025. dlg.show();
  2026. }.bind(this));
  2027. },
  2028. alert: function (type, title, text, width, height) {
  2029. this.app.alert(type, "center", title, text, width, height);
  2030. },
  2031. notice: function (content, type, target, where, offset, option) {
  2032. if (!where) where = { "x": "right", "y": "top" };
  2033. //if (!target) target = this.node;
  2034. if (!type) type = "ok";
  2035. var noticeTarget = target || this.app.window.content;
  2036. var off = offset;
  2037. if (!off) {
  2038. off = {
  2039. x: 10,
  2040. y: where.y.toString().toLowerCase() == "bottom" ? 10 : 10
  2041. };
  2042. }
  2043. var options = {
  2044. type: type,
  2045. position: where,
  2046. move: false,
  2047. target: noticeTarget,
  2048. delayClose: (type === "error") ? 10000 : 5000,
  2049. //delayClose: 20000000,
  2050. offset: off,
  2051. content: content
  2052. }
  2053. if (this.json.noticeStyle) {
  2054. options = Object.merge(options, this.json.noticeStyle);
  2055. }
  2056. if (this.json["notice" + type.capitalize() + "Style"]) {
  2057. options = Object.merge(options, this.json["notice" + type.capitalize() + "Style"]);
  2058. }
  2059. if (option && typeOf(option) === "object") {
  2060. options = Object.merge(options, option);
  2061. }
  2062. new mBox.Notice(options);
  2063. },
  2064. addSplit: function () {
  2065. if (!this.businessData.control["allowAddSplit"]) {
  2066. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  2067. return false;
  2068. }
  2069. MWF.require("MWF.xDesktop.Dialog", function () {
  2070. var width = 600;
  2071. var height = 230;
  2072. var p = MWF.getCenterPosition(this.app.content, width, height);
  2073. var _self = this;
  2074. var dlg = new MWF.xDesktop.Dialog({
  2075. "title": this.app.lp.addSplit,
  2076. //"style": "work","
  2077. "style": this.json.dialogStyle || "user",
  2078. "top": p.y - 100,
  2079. "left": p.x,
  2080. "fromTop": p.y - 100,
  2081. "fromLeft": p.x,
  2082. "width": width,
  2083. "height": height,
  2084. "url": this.app.path + "split.html",
  2085. "container": this.app.content,
  2086. "isClose": true,
  2087. "buttonList": [
  2088. {
  2089. "type": "ok",
  2090. "text": MWF.LP.process.button.ok,
  2091. "action": function (d, e) {
  2092. //this.doResetWork(dlg);
  2093. var input = dlg.content.getElement("input");
  2094. var checks = dlg.content.getElements(".o2_addSplit_radio");
  2095. var value = input.get("value");
  2096. var trimExist = true;
  2097. if (checks[1].checked) trimExist = false;
  2098. _self.doAddSplit(dlg, value, trimExist);
  2099. }.bind(this)
  2100. },
  2101. {
  2102. "type": "cancel",
  2103. "text": MWF.LP.process.button.cancel,
  2104. "action": function () { dlg.close(); }
  2105. }
  2106. ],
  2107. "onPostShow": function () {
  2108. //var okButton = dlg.content.getElement(".o2_addSplit_okButton");
  2109. //var cancelButton = dlg.content.getElement(".o2_addSplit_cancelButton");
  2110. var selectButton = dlg.content.getElement(".o2_addSplit_selector");
  2111. var input = dlg.content.getElement("input");
  2112. var checks = dlg.content.getElements(".o2_addSplit_radio");
  2113. //okButton.addEvent("click", function(){
  2114. // var value = input.get("value");
  2115. // var trimExist = true;
  2116. // if (checks[1].checked) trimExist = false;
  2117. // _self.doAddSplit(this, value, trimExist);
  2118. //}.bind(this));
  2119. //cancelButton.addEvent("click", function(){
  2120. // this.close();
  2121. //}.bind(this));
  2122. selectButton.addEvent("click", function () {
  2123. var value = input.get("value");
  2124. MWF.xDesktop.requireApp("Selector", "package", function () {
  2125. new o2.O2Selector(_self.app.content, {
  2126. "type": "",
  2127. "count": 0,
  2128. "values": (value) ? value.split(o2.splitStr) : [],
  2129. "types": ["unit", "identity", "group", "role"],
  2130. "onComplete": function (items) {
  2131. var v = [];
  2132. items.each(function (item) {
  2133. v.push(item.data.distinguishedName);
  2134. });
  2135. input.set("value", v.join(", "));
  2136. }
  2137. });
  2138. }.bind(this));
  2139. //_self.selectSplitUnit(this);
  2140. }.bind(this));
  2141. }
  2142. });
  2143. dlg.show();
  2144. }.bind(this));
  2145. },
  2146. doAddSplit: function (dlg, splitValues, trimExist) {
  2147. if (!splitValues) {
  2148. this.app.notice(MWF.xApplication.process.Xform.LP.inputSplitValue, "error", dlg.node);
  2149. return false;
  2150. }
  2151. MWF.require("MWF.widget.Mask", function () {
  2152. var splitValue = splitValues.split(o2.splitStr);
  2153. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2154. this.mask.loadNode(this.app.content);
  2155. this.fireEvent("beforeAddSplit");
  2156. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeAddSplit");
  2157. this.addSplitWork(splitValue, trimExist, function (json) {
  2158. this.fireEvent("afterAddSplit");
  2159. if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddSplit");
  2160. this.addAddSplitMessage(json.data);
  2161. // this.workAction.loadWork(function(workJson){
  2162. // this.fireEvent("afterAddSplit");
  2163. // if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddSplit");
  2164. // this.addAddSplitMessage(workJson.data);
  2165. // }.bind(this), null, this.businessData.work.id);
  2166. dlg.close();
  2167. if (this.mask) { this.mask.hide(); this.mask = null; }
  2168. }.bind(this), function (xhr, text, error) {
  2169. var errorText = error + ":" + text;
  2170. if (xhr) errorText = xhr.responseText;
  2171. this.app.notice("request json error: " + errorText, "error", dlg.node);
  2172. if (this.mask) { this.mask.hide(); this.mask = null; }
  2173. }.bind(this));
  2174. }.bind(this));
  2175. },
  2176. addSplitWork: function (splitValue, trimExist, success, failure) {
  2177. var data = { "splitValueList": splitValue, "trimExist": trimExist };
  2178. if (this.options.readonly) {
  2179. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2AddSplit(this.businessData.work.id, data,function (json) {
  2180. if (success) success(json);
  2181. }.bind(this),
  2182. function (xhr, text, error) {
  2183. if (failure) failure(xhr, text, error);
  2184. });
  2185. // this.workAction.addSplit(
  2186. // function (json) {
  2187. // if (success) success(json);
  2188. // }.bind(this),
  2189. // function (xhr, text, error) {
  2190. // if (failure) failure(xhr, text, error);
  2191. // },
  2192. // this.businessData.work.id, data
  2193. // );
  2194. } else {
  2195. this.saveFormData(
  2196. function (json) {
  2197. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2AddSplit(this.businessData.work.id, data,function (json) {
  2198. if (success) success(json);
  2199. }.bind(this),
  2200. function (xhr, text, error) {
  2201. if (failure) failure(xhr, text, error);
  2202. });
  2203. // this.workAction.addSplit(
  2204. // function (json) {
  2205. // if (success) success(json);
  2206. // }.bind(this),
  2207. // function (xhr, text, error) {
  2208. // if (failure) failure(xhr, text, error);
  2209. // },
  2210. // this.businessData.work.id, data
  2211. // );
  2212. }.bind(this),
  2213. function (xhr, text, error) {
  2214. if (failure) failure(xhr, text, error);
  2215. }, true, null, true
  2216. );
  2217. }
  2218. },
  2219. setRollBackChecked: function (item) {
  2220. item.store("isSelected", true);
  2221. item.setStyles(this.css.rollbackItemNode_current);
  2222. item.getFirst().setStyles(this.css.rollbackItemIconNode_current);
  2223. var node = item.getLast().getFirst();
  2224. node.getFirst().setStyles(this.css.rollbackItemActivityNode_current);
  2225. node.getLast().setStyles(this.css.rollbackItemTimeNode_current);
  2226. node = item.getLast().getLast();
  2227. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode_current);
  2228. node.getLast().setStyles(this.css.rollbackItemTaskNode_current);
  2229. var checkeds = item.getElements("input");
  2230. if (checkeds) checkeds.set("checked", true);
  2231. },
  2232. setRollBackUnchecked: function (item) {
  2233. item.store("isSelected", false);
  2234. item.setStyles(this.css.rollbackItemNode);
  2235. item.getFirst().setStyles(this.css.rollbackItemIconNode);
  2236. var node = item.getLast().getFirst();
  2237. node.getFirst().setStyles(this.css.rollbackItemActivityNode);
  2238. node.getLast().setStyles(this.css.rollbackItemTimeNode);
  2239. node = item.getLast().getLast();
  2240. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode);
  2241. node.getLast().setStyles(this.css.rollbackItemTaskNode);
  2242. var checkeds = item.getElements("input");
  2243. if (checkeds) checkeds.set("checked", false);
  2244. },
  2245. getRollbackLogs: function (rollbackItemNode) {
  2246. var _self = this;
  2247. o2.Actions.load("x_processplatform_assemble_surface").WorkLogAction.listRollbackWithWorkOrWorkCompleted(this.businessData.work.id, function (json) {
  2248. json.data.each(function (log) {
  2249. //if (!log.splitting && log.connected && (log.taskCompletedList.length || log.readList.length || log.readCompletedList.length)) {
  2250. if (!log.splitting && log.connected) {
  2251. var node = new Element("div", { "styles": this.css.rollbackItemNode }).inject(rollbackItemNode);
  2252. node.store("log", log);
  2253. var iconNode = new Element("div", { "styles": this.css.rollbackItemIconNode }).inject(node);
  2254. var contentNode = new Element("div", { "styles": this.css.rollbackItemContentNode }).inject(node);
  2255. var div = new Element("div", { "styles": { "overflow": "hidden" } }).inject(contentNode);
  2256. var activityNode = new Element("div", { "styles": this.css.rollbackItemActivityNode, "text": log.fromActivityName }).inject(div);
  2257. var timeNode = new Element("div", { "styles": this.css.rollbackItemTimeNode, "text": log.arrivedTime }).inject(div);
  2258. div = new Element("div", { "styles": { "overflow": "hidden" } }).inject(contentNode);
  2259. var taskTitleNode = new Element("div", { "styles": this.css.rollbackItemTaskTitleNode, "text": this.app.lp.taskCompletedPerson + ": " }).inject(div);
  2260. if (log.taskCompletedList.length) {
  2261. log.taskCompletedList.each(function (o) {
  2262. var text = o2.name.cn(o.person) + "(" + o.completedTime + ")";
  2263. var check = new Element("input", {
  2264. "value": o.identity,
  2265. "type": "checkbox",
  2266. "styles": this.css.rollbackItemTaskCheckNode
  2267. }).inject(div);
  2268. check.addEvent("click", function (e) {
  2269. e.stopPropagation();
  2270. });
  2271. var taskNode = new Element("div", { "styles": this.css.rollbackItemTaskNode, "text": text }).inject(div);
  2272. }.bind(this));
  2273. } else {
  2274. var text = this.app.lp.systemFlow;
  2275. var taskNode = new Element("div", { "styles": this.css.rollbackItemTaskNode, "text": text }).inject(div);
  2276. }
  2277. node.addEvents({
  2278. "mouseover": function () {
  2279. var isSelected = this.retrieve("isSelected");
  2280. if (!isSelected) this.setStyles(_self.css.rollbackItemNode_over);
  2281. },
  2282. "mouseout": function () {
  2283. var isSelected = this.retrieve("isSelected");
  2284. if (!isSelected) this.setStyles(_self.css.rollbackItemNode)
  2285. },
  2286. "click": function () {
  2287. var isSelected = this.retrieve("isSelected");
  2288. if (isSelected) {
  2289. _self.setRollBackUnchecked(this);
  2290. } else {
  2291. var items = rollbackItemNode.getChildren();
  2292. items.each(function (item) {
  2293. _self.setRollBackUnchecked(item);
  2294. });
  2295. _self.setRollBackChecked(this);
  2296. }
  2297. }
  2298. });
  2299. }
  2300. }.bind(this));
  2301. }.bind(this), null, false);
  2302. },
  2303. rollback: function () {
  2304. if (!this.businessData.control["allowRollback"]) {
  2305. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  2306. return false;
  2307. }
  2308. var node = new Element("div", { "styles": this.css.rollbackAreaNode });
  2309. var html = "<div style=\"line-height: 30px; height: 30px; color: #333333; overflow: hidden;float:left;\">请选择文件要回溯到的位置:</div>";
  2310. html += "<div style=\"line-height: 30px; height: 30px; color: #333333; overflow: hidden;float:right;\"><input class='rollback_flowOption' checked type='checkbox' />并尝试继续流转</div>";
  2311. html += "<div style=\"clear:both; max-height: 300px; margin-bottom:10px; margin-top:10px; overflow-y:auto;\"></div>";
  2312. node.set("html", html);
  2313. var rollbackItemNode = node.getLast();
  2314. this.getRollbackLogs(rollbackItemNode);
  2315. node.inject(this.app.content);
  2316. var dlg = o2.DL.open({
  2317. "title": this.app.lp.rollback,
  2318. "style": this.json.dialogStyle || "user",
  2319. "isResize": false,
  2320. "content": node,
  2321. "width": 600,
  2322. "buttonList": [
  2323. {
  2324. "type": "ok",
  2325. "text": MWF.LP.process.button.ok,
  2326. "action": function (d, e) {
  2327. this.doRollback(node, e, dlg);
  2328. }.bind(this)
  2329. },
  2330. {
  2331. "type": "cancel",
  2332. "text": MWF.LP.process.button.cancel,
  2333. "action": function () { dlg.close(); }
  2334. }
  2335. ]
  2336. });
  2337. },
  2338. doRollback: function (node, e, dlg) {
  2339. var rollbackItemNode = node.getLast();
  2340. var items = rollbackItemNode.getChildren();
  2341. var flowOption = (node.getElement(".rollback_flowOption").checked);
  2342. var _self = this;
  2343. for (var i = 0; i < items.length; i++) {
  2344. if (items[i].retrieve("isSelected")) {
  2345. var text = this.app.lp.rollbackConfirmContent;
  2346. var log = items[i].retrieve("log");
  2347. var checks = items[i].getElements("input:checked");
  2348. var idList = [];
  2349. checks.each(function (check) {
  2350. var id = check.get("value");
  2351. if (idList.indexOf(id) == -1) idList.push(id);
  2352. });
  2353. text = text.replace("{log}", log.fromActivityName + "(" + log.arrivedTime + ")");
  2354. this.app.confirm("infor", e, this.app.lp.rollbackConfirmTitle, text, 450, 120, function () {
  2355. _self.doRollbackAction(log.id, flowOption, dlg, idList);
  2356. dlg.close();
  2357. this.close();
  2358. }, function () {
  2359. this.close();
  2360. }, null, null, this.json.confirmStyle);
  2361. break;
  2362. }
  2363. }
  2364. },
  2365. doRollbackAction: function (log, flowOption, dlg, idList) {
  2366. MWF.require("MWF.widget.Mask", function () {
  2367. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2368. this.mask.loadNode(this.app.content);
  2369. this.fireEvent("beforeRollback");
  2370. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeRollback");
  2371. this.doRollbackActionInvoke(log, flowOption, idList, function (json) {
  2372. if (json.data.properties) {
  2373. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRollback");
  2374. this.addRollbackMessage(json.data);
  2375. } else {
  2376. var id = json.data.id;
  2377. this.workAction.listTaskByWork(function (workJson) {
  2378. this.fireEvent("afterRollback");
  2379. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRollback");
  2380. this.addRollbackMessage_old(workJson.data);
  2381. //this.app.notice(MWF.xApplication.process.Xform.LP.rollbackOk+": "+MWF.name.cns(names).join(", "), "success");
  2382. //if (!this.app.inBrowser) this.app.close();
  2383. }.bind(this), null, id);
  2384. }
  2385. if (!this.app.inBrowser) this.app.close();
  2386. if (this.mask) { this.mask.hide(); this.mask = null; }
  2387. }.bind(this), function (xhr, text, error) {
  2388. var errorText = error + ":" + text;
  2389. if (xhr) errorText = xhr.responseText;
  2390. this.app.notice("request json error: " + errorText, "error");
  2391. if (this.mask) { this.mask.hide(); this.mask = null; }
  2392. }.bind(this));
  2393. }.bind(this));
  2394. },
  2395. doRollbackActionInvoke: function (id, flowOption, idList, success, failure) {
  2396. if (this.businessData.work.completedTime) {
  2397. var method = "rollbackWorkcompleted";
  2398. o2.Actions.get("x_processplatform_assemble_surface")[method](this.businessData.work.id, { "workLog": id }, function (json) {
  2399. if (success) success(json);
  2400. }.bind(this), function (xhr, text, error) {
  2401. if (failure) failure(xhr, text, error)
  2402. }.bind(this));
  2403. } else {
  2404. var body = {
  2405. "workLog": id,
  2406. "taskCompletedIdentityList": idList,
  2407. "processing": !!flowOption
  2408. }
  2409. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Rollback(this.businessData.work.id, body, function (json) {
  2410. //o2.Actions.get("x_processplatform_assemble_surface")[method](this.businessData.work.id, { "workLog": id }, function (json) {
  2411. if (success) success(json);
  2412. }.bind(this), function (xhr, text, error) {
  2413. if (failure) failure(xhr, text, error)
  2414. }.bind(this));
  2415. }
  2416. },
  2417. inBrowserDkg: function (content) {
  2418. if (this.mask) this.mask.hide();
  2419. if (this.json.submitedDlgUseNotice) {
  2420. MWF.xDesktop.notice("success", { x: "right", y: "top" }, content);
  2421. if (this.json.isPrompt !== false) {
  2422. if (this.json.promptCloseTime != 0) {
  2423. var t = this.json.promptCloseTime || 2;
  2424. t = t.toInt() * 1000;
  2425. var _work = this;
  2426. window.setTimeout(function () { _work.app.close(); }, t);
  2427. }
  2428. } else {
  2429. this.app.close();
  2430. }
  2431. } else {
  2432. var div = new Element("div", { "styles": { "margin": "10px 10px 0px 10px", "padding": "5px", "overflow": "hidden" } }).inject(this.app.content);
  2433. div.set("html", content);
  2434. if (this.json.isPrompt !== false) {
  2435. var options = {
  2436. "content": div,
  2437. "isTitle": false,
  2438. "width": 350,
  2439. "height": 180,
  2440. "buttonList": [
  2441. {
  2442. "text": MWF.xApplication.process.Xform.LP.ok,
  2443. "action": function () { dlg.close(); this.app.close(); }.bind(this)
  2444. }
  2445. ]
  2446. }
  2447. var size = this.app.content.getSize();
  2448. switch (this.json.promptPosition || "righttop") {
  2449. case "lefttop":
  2450. options.top = 10;
  2451. options.left = 10;
  2452. options.fromTop = 10;
  2453. options.fromLeft = 10;
  2454. break;
  2455. case "righttop":
  2456. options.top = 10;
  2457. options.left = size.x - 360;
  2458. options.fromTop = 10;
  2459. options.fromLeft = size.x - 10;
  2460. break;
  2461. case "leftbottom":
  2462. options.top = size.y - 190;
  2463. options.left = 10;
  2464. options.fromTop = size.y - 10;
  2465. options.fromLeft = 10;
  2466. break;
  2467. case "rightbottom":
  2468. options.top = size.y - 190;
  2469. options.left = size.x - 360;
  2470. options.fromTop = size.y - 10;
  2471. options.fromLeft = size.x - 10;
  2472. break;
  2473. default:
  2474. delete options.top;
  2475. delete options.left;
  2476. delete options.fromTop;
  2477. delete options.fromLeft;
  2478. }
  2479. var dlg = o2.DL.open(options);
  2480. if (this.json.promptCloseTime != 0) {
  2481. var t = this.json.promptCloseTime || 2;
  2482. t = t.toInt() * 1000;
  2483. var _work = this;
  2484. window.setTimeout(function () { dlg.close(); _work.app.close(); }, t);
  2485. }
  2486. } else {
  2487. this.app.close();
  2488. }
  2489. }
  2490. },
  2491. addRollbackMessage_old: function (data) {
  2492. var users = [];
  2493. data.each(function (task) {
  2494. users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  2495. }.bind(this));
  2496. 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>";
  2497. if (layout.desktop.message) {
  2498. var msg = {
  2499. "subject": MWF.xApplication.process.Xform.LP.workRollback,
  2500. "content": "<div>" + MWF.xApplication.process.Xform.LP.rollbackWorkInfor + "“" + this.businessData.work.title + "”</div>" + content
  2501. };
  2502. layout.desktop.message.addTooltip(msg);
  2503. return layout.desktop.message.addMessage(msg);
  2504. } else {
  2505. if (this.app.inBrowser) {
  2506. this.inBrowserDkg("<div>" + MWF.xApplication.process.Xform.LP.rollbackWorkInfor + "“" + this.businessData.work.title + "”</div>" + content);
  2507. }
  2508. }
  2509. },
  2510. addRollbackMessage: function (data) {
  2511. if (layout.desktop.message) {
  2512. var msg = {
  2513. "subject": MWF.xApplication.process.Xform.LP.workRollback,
  2514. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.rollbackWorkInfor)
  2515. };
  2516. layout.desktop.message.addTooltip(msg);
  2517. return layout.desktop.message.addMessage(msg);
  2518. } else {
  2519. if (this.app.inBrowser) {
  2520. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.rollbackWorkInfor));
  2521. }
  2522. }
  2523. },
  2524. pressWork: function (e) {
  2525. if (e && e.setDisable) e.setDisable(true);
  2526. o2.Actions.get("x_processplatform_assemble_surface").press(this.businessData.work.id, function (json) {
  2527. var users = o2.name.cns(json.data.valueList).join(", ");
  2528. this.app.notice("已经向待办人:" + users + ", 发送了提醒", "success");
  2529. if (e && e.setDisable) e.setDisable(false);
  2530. }.bind(this), function (xhr, text, error) {
  2531. //e.setDisable(false);
  2532. if (xhr.status != 0) {
  2533. var errorText = error;
  2534. if (xhr) {
  2535. var json = JSON.decode(xhr.responseText);
  2536. if (json) {
  2537. errorText = json.message.trim() || "request json error";
  2538. } else {
  2539. errorText = "request json error: " + xhr.responseText;
  2540. }
  2541. }
  2542. MWF.xDesktop.notice("error", { x: "right", y: "top" }, errorText);
  2543. }
  2544. });
  2545. },
  2546. downloadAll: function () {
  2547. var htmlFormId = "";
  2548. o2.Actions.load("x_processplatform_assemble_surface").AttachmentAction.uploadWorkInfo(this.businessData.work.id, "pdf", {
  2549. "workHtml": this.app.content.get("html")
  2550. }, function (json) {
  2551. htmlFormId = json.data.id;
  2552. }.bind(this), null, false);
  2553. htmlFormId = htmlFormId.replace("#", "%23");
  2554. var url = "/x_processplatform_assemble_surface/jaxrs/attachment/batch/download/work/" + this.businessData.work.id + "/site/(0)/stream";
  2555. url = o2.filterUrl(o2.Actions.getHost("x_processplatform_assemble_surface") + url);
  2556. window.open( o2.filterUrl(url + "?fileName=&flag=" + htmlFormId));
  2557. },
  2558. resetWork: function () {
  2559. if (!this.businessData.control["allowReset"]) {
  2560. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  2561. return false;
  2562. }
  2563. MWF.require("MWF.xDesktop.Dialog", function () {
  2564. var width = 680;
  2565. var height = 300;
  2566. var p = MWF.getCenterPosition(this.app.content, width, height);
  2567. var _self = this;
  2568. var dlg = new MWF.xDesktop.Dialog({
  2569. "title": this.app.lp.reset,
  2570. "style": this.json.dialogStyle || "user", //|| "work",
  2571. "top": p.y - 100,
  2572. "left": p.x,
  2573. "fromTop": p.y - 100,
  2574. "fromLeft": p.x,
  2575. "width": width,
  2576. "height": height,
  2577. "url": this.app.path + "reset.html",
  2578. "container": this.app.content,
  2579. "isClose": true,
  2580. "buttonList": [
  2581. {
  2582. "type": "ok",
  2583. "text": MWF.LP.process.button.ok,
  2584. "action": function (d, e) {
  2585. this.doResetWork(dlg);
  2586. }.bind(this)
  2587. },
  2588. {
  2589. "type": "cancel",
  2590. "text": MWF.LP.process.button.cancel,
  2591. "action": function () { dlg.close(); }
  2592. }
  2593. ],
  2594. "onPostShow": function () {
  2595. //$("resetWork_okButton").addEvent("click", function(){
  2596. // _self.doResetWork(this);
  2597. //}.bind(this));
  2598. //$("resetWork_cancelButton").addEvent("click", function(){
  2599. // this.close();
  2600. //}.bind(this));
  2601. $("resetWork_selPeopleButton").addEvent("click", function () {
  2602. _self.selectPeople(this);
  2603. }.bind(this));
  2604. }
  2605. });
  2606. dlg.show();
  2607. }.bind(this));
  2608. },
  2609. selectPeople: function (dlg) {
  2610. var range = this.businessData.activity.resetRange || "department";
  2611. var count = this.businessData.activity.resetCount || 0;
  2612. switch (range) {
  2613. case "unit":
  2614. this.selectPeopleUnit(dlg, this.businessData.task.unit, count);
  2615. // this.personActions.getDepartmentByIdentity(function(json){
  2616. // this.selectPeopleDepartment(dlg, json.data, count);
  2617. // }.bind(this), null, this.businessData.task.identity);
  2618. break;
  2619. case "topUnit":
  2620. MWF.require("MWF.xScript.Actions.UnitActions", function () {
  2621. orgActions = new MWF.xScript.Actions.UnitActions();
  2622. var data = { "unitList": [this.businessData.task.unit] };
  2623. orgActions.listUnitSupNested(data, function (json) {
  2624. v = json.data[0];
  2625. this.selectPeopleUnit(dlg, v, count);
  2626. }.bind(this));
  2627. }.bind(this));
  2628. // this.personActions.getCompanyByIdentity(function(json){
  2629. // this.selectPeopleCompany(dlg, json.data, count)
  2630. // }.bind(this), null, this.businessData.task.identity);
  2631. break;
  2632. default:
  2633. this.selectPeopleAll(dlg, count);
  2634. }
  2635. },
  2636. selectPeopleUnit: function (dlg, unit, count) {
  2637. var names = dlg.identityList || [];
  2638. var areaNode = $("resetWork_selPeopleArea");
  2639. var options = {
  2640. "values": names,
  2641. "type": "identity",
  2642. "count": count,
  2643. "units": (unit) ? [unit] : [],
  2644. "title": this.app.lp.reset,
  2645. "onComplete": function (items) {
  2646. areaNode.empty();
  2647. var identityList = [];
  2648. items.each(function (item) {
  2649. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  2650. identityList.push(item.data.distinguishedName);
  2651. }.bind(this));
  2652. dlg.identityList = identityList;
  2653. }.bind(this)
  2654. };
  2655. MWF.xDesktop.requireApp("Selector", "package", function () {
  2656. var selector = new MWF.O2Selector(this.app.content, options);
  2657. }.bind(this));
  2658. },
  2659. selectPeopleAll: function (dlg, count) {
  2660. var names = dlg.identityList || [];
  2661. var areaNode = $("resetWork_selPeopleArea");
  2662. var options = {
  2663. "values": names,
  2664. "type": "identity",
  2665. "count": count,
  2666. "title": this.app.lp.reset,
  2667. "onComplete": function (items) {
  2668. areaNode.empty();
  2669. var identityList = [];
  2670. items.each(function (item) {
  2671. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  2672. identityList.push(item.data.distinguishedName);
  2673. }.bind(this));
  2674. dlg.identityList = identityList;
  2675. }.bind(this)
  2676. };
  2677. MWF.xDesktop.requireApp("Selector", "package", function () {
  2678. var selector = new MWF.O2Selector(this.app.content, options);
  2679. }.bind(this));
  2680. },
  2681. doResetWork: function (dlg) {
  2682. var names = dlg.identityList || [];
  2683. if (!names.length) {
  2684. this.app.notice(MWF.xApplication.process.Xform.LP.inputResetPeople, "error", dlg.node);
  2685. return false;
  2686. }
  2687. var opinion = $("resetWork_opinion").get("value");
  2688. var checkbox = dlg.content.getElement(".resetWork_keepOption");
  2689. var keep = (checkbox.checked);
  2690. var nameText = [];
  2691. names.each(function (n) { nameText.push(MWF.name.cn(n)); });
  2692. if (!opinion) {
  2693. opinion = MWF.xApplication.process.Xform.LP.resetTo + ": " + nameText.join(", ");
  2694. }
  2695. MWF.require("MWF.widget.Mask", function () {
  2696. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2697. this.mask.loadNode(this.app.content);
  2698. this.fireEvent("beforeReset");
  2699. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeReset");
  2700. this.resetWorkToPeson(names, opinion, keep, function (workJson) {
  2701. //this.workAction.loadWork(function (workJson) {
  2702. this.fireEvent("afterReset");
  2703. if (this.app && this.app.fireEvent) this.app.fireEvent("afterReset");
  2704. this.addResetMessage(workJson.data);
  2705. //this.app.notice(MWF.xApplication.process.Xform.LP.resetOk + ": " + MWF.name.cns(names).join(", "), "success");
  2706. if (!this.app.inBrowser) this.app.close();
  2707. //}.bind(this), null, this.businessData.work.id);
  2708. dlg.close();
  2709. if (this.mask) { this.mask.hide(); this.mask = null; }
  2710. }.bind(this), function (xhr, text, error) {
  2711. var errorText = error + ":" + text;
  2712. if (xhr) errorText = xhr.responseText;
  2713. this.app.notice("request json error: " + errorText, "error", dlg.node);
  2714. if (this.mask) { this.mask.hide(); this.mask = null; }
  2715. }.bind(this));
  2716. }.bind(this));
  2717. //var data = {
  2718. // "opinion": opinion,
  2719. // "routeName": MWF.xApplication.process.Xform.LP.reset,
  2720. // "identityList": names
  2721. //}
  2722. //
  2723. //this.workAction.resetWork(function(json){
  2724. //
  2725. //}.bind(this), null, this.businessData.task.id, data);
  2726. },
  2727. resetWorkToPeson: function (identityList, opinion, keep, success, failure) {
  2728. var data = {
  2729. "opinion": opinion,
  2730. "routeName": MWF.xApplication.process.Xform.LP.reset,
  2731. "identityList": identityList,
  2732. "keep": !!keep
  2733. };
  2734. this.saveFormData(
  2735. function (json) {
  2736. o2.Actions.load("x_processplatform_assemble_surface").TaskAction.V2Reset(
  2737. //this.workAction.resetWork(
  2738. function (json) {
  2739. if (success) success(json);
  2740. }.bind(this),
  2741. function (xhr, text, error) {
  2742. if (failure) failure(xhr, text, error);
  2743. },
  2744. this.businessData.task.id, data
  2745. );
  2746. }.bind(this),
  2747. function (xhr, text, error) {
  2748. if (failure) failure(xhr, text, error);
  2749. }, true, null, true
  2750. );
  2751. },
  2752. addAddSplitMessage: function (data) {
  2753. // var content = "";
  2754. // if (data && data.length) {
  2755. // data.each(function (work) {
  2756. // var users = [];
  2757. // work.taskList.each(function (task) {
  2758. // users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  2759. // }.bind(this));
  2760. // 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>";
  2761. // }.bind(this));
  2762. // } else {
  2763. // content += MWF.xApplication.process.Xform.LP.workCompleted;
  2764. // }
  2765. if (layout.desktop.message) {
  2766. //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>";
  2767. var msg = {
  2768. "subject": MWF.xApplication.process.Xform.LP.addSplitWork,
  2769. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.addSplitWorkInfor)
  2770. };
  2771. layout.desktop.message.addTooltip(msg);
  2772. return layout.desktop.message.addMessage(msg);
  2773. } else {
  2774. if (this.app.inBrowser) {
  2775. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.addSplitWorkInfor));
  2776. }
  2777. }
  2778. },
  2779. addResetMessage: function (data) {
  2780. // var content = "";
  2781. // if (data.completed){
  2782. // content += MWF.xApplication.process.Xform.LP.workCompleted;
  2783. // }else{
  2784. // if (data.properties.nextManualList && data.properties.nextManualList.length){
  2785. // var activityUsers = [];
  2786. // data.properties.nextManualList.each(function(a){
  2787. // var ids = [];
  2788. // a.taskIdentityList.each(function(i){
  2789. // ids.push(o2.name.cn(i))
  2790. // });
  2791. // 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>";
  2792. // activityUsers.push(t);
  2793. // });
  2794. // content += activityUsers.join("<br>");
  2795. // }else{
  2796. // content += MWF.xApplication.process.Xform.LP.taskCompleted;
  2797. // }
  2798. // }
  2799. if (layout.desktop.message) {
  2800. var msg = {
  2801. "subject": MWF.xApplication.process.Xform.LP.workReset,
  2802. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.resetWorkInfor)
  2803. };
  2804. layout.desktop.message.addTooltip(msg);
  2805. return layout.desktop.message.addMessage(msg);
  2806. } else {
  2807. if (this.app.inBrowser) {
  2808. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.resetWorkInfor));
  2809. }
  2810. }
  2811. },
  2812. retractWork: function (e, ev) {
  2813. var _self = this;
  2814. if (this.json.mode == "Mobile") {
  2815. //window.confirm 在ios移动端不可用 ??
  2816. // if (window.confirm(MWF.xApplication.process.Xform.LP.retractText)) {
  2817. var p = MWF.getCenterPosition(document.body, 300, 150);
  2818. console.log("position x:" + p.x + " , y:" + p.y);
  2819. var x = p.x;
  2820. if (p.x < 20) {
  2821. x = 20;
  2822. } else {
  2823. x = p.x;
  2824. }
  2825. var event = {
  2826. "event": {
  2827. "x": x,
  2828. "y": p.y - 200,
  2829. "clientX": x,
  2830. "clientY": p.y - 200
  2831. }
  2832. };
  2833. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.retractTitle, MWF.xApplication.process.Xform.LP.retractText, 300, 120, function () {
  2834. _self.app.content.mask({
  2835. "style": {
  2836. "background-color": "#999",
  2837. "opacity": 0.6
  2838. }
  2839. });
  2840. MWF.require("MWF.widget.Mask", function () {
  2841. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2842. _self.mask.loadNode(_self.app.content);
  2843. _self.fireEvent("beforeRetract");
  2844. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeRetract");
  2845. _self.doRetractWork(function () {
  2846. //_self.workAction.getJobByWork(function(workJson){
  2847. _self.fireEvent("afterRetract");
  2848. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterRetract");
  2849. _self.app.notice(MWF.xApplication.process.Xform.LP.workRetract, "success");
  2850. _self.app.content.unmask();
  2851. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2852. _self.finishOnMobile()
  2853. }.bind(this), function (xhr, text, error) {
  2854. _self.app.content.unmask();
  2855. var errorText = error + ":" + text;
  2856. if (xhr) errorText = xhr.responseText;
  2857. _self.app.notice("request json error: " + errorText, "error");
  2858. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2859. });
  2860. }.bind(this));
  2861. }, function () {
  2862. this.close();
  2863. }, null, null, this.json.confirmStyle);
  2864. } else {
  2865. var p = MWF.getCenterPosition(this.app.content, 300, 150);
  2866. var event = {
  2867. "event": {
  2868. "x": p.x,
  2869. "y": p.y - 200,
  2870. "clientX": p.x,
  2871. "clientY": p.y - 200
  2872. }
  2873. };
  2874. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.retractTitle, MWF.xApplication.process.Xform.LP.retractText, 300, 120, function () {
  2875. _self.app.content.mask({
  2876. "style": {
  2877. "background-color": "#999",
  2878. "opacity": 0.6
  2879. }
  2880. });
  2881. MWF.require("MWF.widget.Mask", function () {
  2882. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2883. _self.mask.loadNode(_self.app.content);
  2884. _self.fireEvent("beforeRetract");
  2885. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeRetract");
  2886. _self.doRetractWork(function (json) {
  2887. //_self.workAction.getJobByWork(function(workJson){
  2888. _self.fireEvent("afterRetract");
  2889. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterRetract");
  2890. //_self.addRetractMessage(json.data);
  2891. _self.app.notice(MWF.xApplication.process.Xform.LP.workRetract, "success");
  2892. _self.app.content.unmask();
  2893. _self.app.reload();
  2894. //}, null, _self.businessData.work.id);
  2895. this.close();
  2896. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2897. }.bind(this), function (xhr, text, error) {
  2898. _self.app.content.unmask();
  2899. var errorText = error + ":" + text;
  2900. if (xhr) errorText = xhr.responseText;
  2901. _self.app.notice("request json error: " + errorText, "error");
  2902. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2903. });
  2904. }.bind(this));
  2905. //this.close();
  2906. }, function () {
  2907. this.close();
  2908. }, null, null, this.json.confirmStyle);
  2909. }
  2910. },
  2911. doRetractWork: function (success, failure) {
  2912. if (this.businessData.control["allowRetract"]) {
  2913. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Retract(this.businessData.work.id, null, function (json) {
  2914. if (success) success(json);
  2915. }.bind(this), function (xhr, text, error) {
  2916. if (failure) failure(xhr, text, error);
  2917. });
  2918. // this.workAction.retractWork(function (json) {
  2919. // if (success) success();
  2920. // }.bind(this), function (xhr, text, error) {
  2921. // if (failure) failure(xhr, text, error);
  2922. // }, this.businessData.work.id);
  2923. } else {
  2924. if (failure) failure(null, "Permission Denied", "");
  2925. }
  2926. },
  2927. addRetractMessage: function (data) {
  2928. // var users = [];
  2929. // data.taskList.each(function (task) {
  2930. // users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  2931. // }.bind(this));
  2932. // 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>";
  2933. if (layout.desktop.message) {
  2934. var msg = {
  2935. "subject": MWF.xApplication.process.Xform.LP.workRetract,
  2936. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.retractWorkInfor)
  2937. };
  2938. layout.desktop.message.addTooltip(msg);
  2939. return layout.desktop.message.addMessage(msg);
  2940. } else {
  2941. if (this.app.inBrowser) {
  2942. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.retractWorkInfor));
  2943. }
  2944. }
  2945. },
  2946. rerouteWork: function (e, ev) {
  2947. if (!this.businessData.control["allowReroute"]) {
  2948. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  2949. return false;
  2950. }
  2951. MWF.require("MWF.xDesktop.Dialog", function () {
  2952. var width = 560;
  2953. var height = 260;
  2954. var p = MWF.getCenterPosition(this.app.content, width, height);
  2955. var _self = this;
  2956. var dlg = new MWF.xDesktop.Dialog({
  2957. "title": this.app.lp.reroute,
  2958. "style": this.json.dialogStyle || "user", //|| "work",
  2959. "top": p.y - 100,
  2960. "left": p.x,
  2961. "fromTop": p.y - 100,
  2962. "fromLeft": p.x,
  2963. "width": width,
  2964. "height": height,
  2965. "url": this.app.path + "reroute.html",
  2966. "container": this.app.content,
  2967. "isClose": true,
  2968. "buttonList": [
  2969. {
  2970. "type": "ok",
  2971. "text": MWF.LP.process.button.ok,
  2972. "action": function (d, e) {
  2973. _self.doRerouteWork(dlg);
  2974. }.bind(this)
  2975. },
  2976. {
  2977. "type": "cancel",
  2978. "text": MWF.LP.process.button.cancel,
  2979. "action": function () { dlg.close(); }
  2980. }
  2981. ],
  2982. "onPostShow": function () {
  2983. //$("rerouteWork_okButton").addEvent("click", function(){
  2984. // _self.doRerouteWork(this);
  2985. //}.bind(this));
  2986. //$("rerouteWork_cancelButton").addEvent("click", function(){
  2987. // this.close();
  2988. //}.bind(this));
  2989. var select = $("rerouteWork_selectActivity");
  2990. _self.workAction.getRerouteTo(_self.businessData.work.process, function (json) {
  2991. json.data.agentList.each(function (activity) {
  2992. new Element("option", {
  2993. "value": activity.id + "#agent",
  2994. "text": activity.name
  2995. }).inject(select);
  2996. }.bind(_self));
  2997. json.data.cancelList.each(function (activity) {
  2998. new Element("option", {
  2999. "value": activity.id + "#cancel",
  3000. "text": activity.name
  3001. }).inject(select);
  3002. }.bind(_self));
  3003. json.data.choiceList.each(function (activity) {
  3004. new Element("option", {
  3005. "value": activity.id + "#choice",
  3006. "text": activity.name
  3007. }).inject(select);
  3008. }.bind(_self));
  3009. // json.data.controllerList.each(function(activity){
  3010. // new Element("option", {
  3011. // "value": activity.id+"#condition",
  3012. // "text": activity.name
  3013. // }).inject(select);
  3014. // }.bind(_self));
  3015. json.data.delayList.each(function (activity) {
  3016. new Element("option", {
  3017. "value": activity.id + "#delay",
  3018. "text": activity.name
  3019. }).inject(select);
  3020. }.bind(_self));
  3021. json.data.embedList.each(function (activity) {
  3022. new Element("option", {
  3023. "value": activity.id + "#embed",
  3024. "text": activity.name
  3025. }).inject(select);
  3026. }.bind(_self));
  3027. json.data.endList.each(function (activity) {
  3028. new Element("option", {
  3029. "value": activity.id + "#end",
  3030. "text": activity.name
  3031. }).inject(select);
  3032. }.bind(_self));
  3033. json.data.invokeList.each(function (activity) {
  3034. new Element("option", {
  3035. "value": activity.id + "#invoke",
  3036. "text": activity.name
  3037. }).inject(select);
  3038. }.bind(_self));
  3039. json.data.manualList.each(function (activity) {
  3040. new Element("option", {
  3041. "value": activity.id + "#manual",
  3042. "text": activity.name
  3043. }).inject(select);
  3044. }.bind(_self));
  3045. json.data.mergeList.each(function (activity) {
  3046. new Element("option", {
  3047. "value": activity.id + "#merge",
  3048. "text": activity.name
  3049. }).inject(select);
  3050. }.bind(_self));
  3051. json.data.messageList.each(function (activity) {
  3052. new Element("option", {
  3053. "value": activity.id + "#message",
  3054. "text": activity.name
  3055. }).inject(select);
  3056. }.bind(_self));
  3057. json.data.parallelList.each(function (activity) {
  3058. new Element("option", {
  3059. "value": activity.id + "#parallel",
  3060. "text": activity.name
  3061. }).inject(select);
  3062. }.bind(_self));
  3063. json.data.serviceList.each(function (activity) {
  3064. new Element("option", {
  3065. "value": activity.id + "#service",
  3066. "text": activity.name
  3067. }).inject(select);
  3068. }.bind(_self));
  3069. json.data.splitList.each(function (activity) {
  3070. new Element("option", {
  3071. "value": activity.id + "#split",
  3072. "text": activity.name
  3073. }).inject(select);
  3074. }.bind(_self));
  3075. }.bind(_self));
  3076. var selPeopleButton = this.content.getElement(".rerouteWork_selPeopleButton");
  3077. selPeopleButton.addEvent("click", function () {
  3078. _self.selectReroutePeople(this);
  3079. }.bind(this));
  3080. }
  3081. });
  3082. dlg.show();
  3083. }.bind(this));
  3084. },
  3085. selectReroutePeople: function (dlg) {
  3086. var names = dlg.identityList || [];
  3087. var areaNode = dlg.content.getElement(".rerouteWork_selPeopleArea");
  3088. var options = {
  3089. "values": names,
  3090. "type": "identity",
  3091. "count": 0,
  3092. "title": this.app.lp.reroute,
  3093. "onComplete": function (items) {
  3094. areaNode.empty();
  3095. var identityList = [];
  3096. items.each(function (item) {
  3097. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  3098. identityList.push(item.data.distinguishedName);
  3099. }.bind(this));
  3100. dlg.identityList = identityList;
  3101. }.bind(this)
  3102. };
  3103. MWF.xDesktop.requireApp("Selector", "package", function () {
  3104. var selector = new MWF.O2Selector(this.app.content, options);
  3105. }.bind(this));
  3106. },
  3107. doRerouteWork: function (dlg) {
  3108. var opinion = $("rerouteWork_opinion").get("value");
  3109. var select = $("rerouteWork_selectActivity");
  3110. var activity = select.options[select.selectedIndex].get("value");
  3111. var activityName = select.options[select.selectedIndex].get("text");
  3112. var tmp = activity.split("#");
  3113. activity = tmp[0];
  3114. var type = tmp[1];
  3115. var nameArr = [];
  3116. var names = dlg.identityList || [];
  3117. names.each(function (n) { nameArr.push(n); });
  3118. //var nameText = nameArr.join(", ");
  3119. // if (!opinion) {
  3120. // opinion = MWF.xApplication.process.Xform.LP.resetTo + ": " + nameText.join(", ");
  3121. // }
  3122. MWF.require("MWF.widget.Mask", function () {
  3123. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  3124. this.mask.loadNode(this.app.content);
  3125. this.fireEvent("beforeReroute");
  3126. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRetract");
  3127. this.rerouteWorkToActivity(activity, type, opinion, nameArr, function (workJson) {
  3128. //this.workAction.loadWork(function (workJson) {
  3129. this.fireEvent("afterReroute");
  3130. if (this.app && this.app.fireEvent) this.app.fireEvent("afterReroute");
  3131. this.addRerouteMessage(workJson.data);
  3132. this.app.notice(MWF.xApplication.process.Xform.LP.rerouteOk + ": " + activityName, "success");
  3133. if (!this.app.inBrowser) this.app.close();
  3134. //}.bind(this), null, this.businessData.work.id);
  3135. dlg.close();
  3136. if (this.mask) { this.mask.hide(); this.mask = null; }
  3137. }.bind(this), function (xhr, text, error) {
  3138. var errorText = error + ":" + text;
  3139. if (xhr) errorText = xhr.responseText;
  3140. this.app.notice("request json error: " + errorText, "error", dlg.node);
  3141. if (this.mask) { this.mask.hide(); this.mask = null; }
  3142. }.bind(this));
  3143. }.bind(this));
  3144. },
  3145. rerouteWorkToActivity: function (activity, type, opinion, nameArr, success, failure) {
  3146. var body = {
  3147. "activity": activity,
  3148. "activityType": type,
  3149. "mergeWork": false,
  3150. "manualForceTaskIdentityList": nameArr
  3151. };
  3152. if (this.businessData.task) {
  3153. this.saveFormData(function (json) {
  3154. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Reroute(this.businessData.work.id, body, function (json) {
  3155. if (success) success(json);
  3156. }.bind(this), function (xhr, text, error) {
  3157. if (failure) failure(xhr, text, error);
  3158. });
  3159. // this.workAction.rerouteWork(function (json) {
  3160. // if (success) success();
  3161. // }.bind(this), function (xhr, text, error) {
  3162. // if (failure) failure(xhr, text, error);
  3163. // }, this.businessData.work.id, activity, type);
  3164. }.bind(this), function (xhr, text, error) {
  3165. if (failure) failure(xhr, text, error);
  3166. }, true, null, true);
  3167. } else {
  3168. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Reroute(this.businessData.work.id, body, function (json) {
  3169. if (success) success(json);
  3170. }.bind(this), function (xhr, text, error) {
  3171. if (failure) failure(xhr, text, error);
  3172. });
  3173. // this.workAction.rerouteWork(function (json) {
  3174. // if (success) success();
  3175. // }.bind(this), function (xhr, text, error) {
  3176. // if (failure) failure(xhr, text, error);
  3177. // }, this.businessData.work.id, activity, type);
  3178. }
  3179. },
  3180. addRerouteMessage: function (data) {
  3181. if (layout.desktop.message) {
  3182. var msg = {
  3183. "subject": MWF.xApplication.process.Xform.LP.workReroute,
  3184. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.rerouteWorkInfor)
  3185. };
  3186. layout.desktop.message.addTooltip(msg);
  3187. return layout.desktop.message.addMessage(msg);
  3188. } else {
  3189. if (this.app.inBrowser) {
  3190. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.rerouteWorkInfor));
  3191. }
  3192. }
  3193. },
  3194. deleteDraftWork: function () {
  3195. var _self = this;
  3196. if (this.json.mode === "Mobile") {
  3197. var p = MWF.getCenterPosition(document.body, 300, 150);
  3198. console.log("position x:" + p.x + " , y:" + p.y);
  3199. var x = p.x;
  3200. if (p.x < 20) {
  3201. x = 20;
  3202. } else {
  3203. x = p.x;
  3204. }
  3205. var event = {
  3206. "event": {
  3207. "x": x,
  3208. "y": p.y - 200,
  3209. "clientX": x,
  3210. "clientY": p.y - 200
  3211. }
  3212. };
  3213. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText.text, 300, 120, function () {
  3214. _self.app.content.mask({
  3215. "style": {
  3216. "background-color": "#999",
  3217. "opacity": 0.6
  3218. }
  3219. });
  3220. // if (window.confirm(MWF.xApplication.process.Xform.LP.deleteWorkText.text)) {
  3221. MWF.require("MWF.widget.Mask", function () {
  3222. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  3223. _self.mask.loadNode(_self.app.content);
  3224. _self.doDeleteWork(function () {
  3225. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  3226. if (_self.mask) {
  3227. _self.mask.hide();
  3228. _self.mask = null;
  3229. }
  3230. _self.finishOnMobile()
  3231. }.bind(this), function (xhr, text, error) {
  3232. var errorText = error + ":" + text;
  3233. if (xhr) errorText = xhr.responseText;
  3234. _self.app.notice("request json error: " + errorText, "error", dlg.node);
  3235. if (_self.mask) {
  3236. _self.mask.hide();
  3237. _self.mask = null;
  3238. }
  3239. }.bind(this));
  3240. }.bind(this));
  3241. }, function () {
  3242. this.close();
  3243. }, null, null, this.json.confirmStyle);
  3244. } else {
  3245. var p = MWF.getCenterPosition(this.app.content, 380, 150);
  3246. var event = {
  3247. "event": {
  3248. "x": p.x,
  3249. "y": p.y - 200,
  3250. "clientX": p.x,
  3251. "clientY": p.y - 200
  3252. }
  3253. };
  3254. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText, 380, 120, function () {
  3255. MWF.require("MWF.widget.Mask", function () {
  3256. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  3257. _self.mask.loadNode(_self.app.content);
  3258. _self.doDeleteWork(function () {
  3259. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  3260. _self.app.close();
  3261. this.close();
  3262. if (_self.mask) {
  3263. _self.mask.hide();
  3264. _self.mask = null;
  3265. }
  3266. }.bind(this), function (xhr, text, error) {
  3267. var errorText = error + ":" + text;
  3268. if (xhr) errorText = xhr.responseText;
  3269. _self.app.notice("request json error: " + errorText, "error", dlg.node);
  3270. if (_self.mask) {
  3271. _self.mask.hide();
  3272. _self.mask = null;
  3273. }
  3274. }.bind(this));
  3275. }.bind(this));
  3276. }, function () {
  3277. this.close();
  3278. }, null, this.app.content, this.json.confirmStyle);
  3279. }
  3280. },
  3281. deleteWork: function () {
  3282. if (!this.businessData.work.startTime) {
  3283. this.deleteDraftWork();
  3284. } else {
  3285. var _self = this;
  3286. if (this.json.mode === "Mobile") {
  3287. var p = MWF.getCenterPosition(document.body, 300, 150);
  3288. console.log("position x:" + p.x + " , y:" + p.y);
  3289. var x = p.x;
  3290. if (p.x < 20) {
  3291. x = 20;
  3292. } else {
  3293. x = p.x;
  3294. }
  3295. var event = {
  3296. "event": {
  3297. "x": x,
  3298. "y": p.y - 200,
  3299. "clientX": x,
  3300. "clientY": p.y - 200
  3301. }
  3302. };
  3303. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText.text, 300, 120, function () {
  3304. _self.app.content.mask({
  3305. "style": {
  3306. "background-color": "#999",
  3307. "opacity": 0.6
  3308. }
  3309. });
  3310. // if (window.confirm(MWF.xApplication.process.Xform.LP.deleteWorkText.text)) {
  3311. MWF.require("MWF.widget.Mask", function () {
  3312. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  3313. _self.mask.loadNode(_self.app.content);
  3314. _self.fireEvent("beforeDelete");
  3315. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeDelete");
  3316. _self.doDeleteWork(function () {
  3317. _self.fireEvent("afterDelete");
  3318. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterDelete");
  3319. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  3320. if (_self.mask) {
  3321. _self.mask.hide();
  3322. _self.mask = null;
  3323. }
  3324. _self.finishOnMobile()
  3325. }.bind(this), function (xhr, text, error) {
  3326. var errorText = error + ":" + text;
  3327. if (xhr) errorText = xhr.responseText;
  3328. _self.app.notice("request json error: " + errorText, "error", dlg.node);
  3329. if (_self.mask) {
  3330. _self.mask.hide();
  3331. _self.mask = null;
  3332. }
  3333. }.bind(this));
  3334. }.bind(this));
  3335. }, function () {
  3336. this.close();
  3337. }, null, this.app.content, this.json.confirmStyle);
  3338. } else {
  3339. var p = MWF.getCenterPosition(this.app.content, 380, 150);
  3340. var event = {
  3341. "event": {
  3342. "x": p.x,
  3343. "y": p.y - 200,
  3344. "clientX": p.x,
  3345. "clientY": p.y - 200
  3346. }
  3347. };
  3348. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText, 380, 120, function () {
  3349. // _self.app.content.mask({
  3350. // "style": {
  3351. // "background-color": "#999",
  3352. // "opacity": 0.6
  3353. // }
  3354. // });
  3355. MWF.require("MWF.widget.Mask", function () {
  3356. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  3357. _self.mask.loadNode(_self.app.content);
  3358. _self.fireEvent("beforeDelete");
  3359. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeDelete");
  3360. _self.doDeleteWork(function () {
  3361. _self.fireEvent("afterDelete");
  3362. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterDelete");
  3363. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  3364. _self.app.close();
  3365. this.close();
  3366. if (_self.mask) {
  3367. _self.mask.hide();
  3368. _self.mask = null;
  3369. }
  3370. }.bind(this), function (xhr, text, error) {
  3371. var errorText = error + ":" + text;
  3372. if (xhr) errorText = xhr.responseText;
  3373. _self.app.notice("request json error: " + errorText, "error", dlg.node);
  3374. if (_self.mask) {
  3375. _self.mask.hide();
  3376. _self.mask = null;
  3377. }
  3378. }.bind(this));
  3379. }.bind(this));
  3380. //_self.workAction.deleteWork(function(json){
  3381. // _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete+": “"+_self.businessData.work.title+"”", "success");
  3382. // _self.app.close();
  3383. // this.close();
  3384. //}.bind(this), null, _self.businessData.work.id);
  3385. //this.close();
  3386. }, function () {
  3387. this.close();
  3388. }, null, this.app.content, this.json.confirmStyle);
  3389. }
  3390. }
  3391. },
  3392. doDeleteDraftWork: function (success, failure) {
  3393. this.workAction.deleteDraftWork(function (json) {
  3394. if (success) success(json);
  3395. }.bind(this), function (xhr, text, error) {
  3396. if (failure) failure(xhr, text, error);
  3397. }, this.businessData.work.id);
  3398. },
  3399. doDeleteWork: function (success, failure) {
  3400. if (!this.businessData.work.startTime) {
  3401. this.doDeleteDraftWork(success, failure);
  3402. } else {
  3403. if (this.businessData.control["allowDelete"]) {
  3404. this.workAction.deleteWork(function (json) {
  3405. if (success) success(json);
  3406. }.bind(this), function (xhr, text, error) {
  3407. if (failure) failure(xhr, text, error);
  3408. }, this.businessData.work.id);
  3409. } else {
  3410. if (failure) failure(null, "Permission Denied", "");
  3411. }
  3412. }
  3413. },
  3414. //printWork: function(){
  3415. // var form = this.json.id;
  3416. // if (this.json.printForm){
  3417. // form = this.json.printForm;
  3418. // }
  3419. // window.open("../x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form);
  3420. //},
  3421. printWork: function (app, form) {
  3422. var application = app || (this.businessData.work) ? this.businessData.work.application : this.businessData.workCompleted.application;
  3423. var form = form;
  3424. if (!form) {
  3425. form = this.json.id;
  3426. if (this.json.printForm) form = this.json.printForm;
  3427. }
  3428. if (this.businessData.workCompleted) {
  3429. var application = app || this.businessData.workCompleted.application;
  3430. window.open(o2.filterUrl("../x_desktop/printWork.html?workCompletedId=" + this.businessData.workCompleted.id + "&app=" + application + "&form=" + form));
  3431. } else {
  3432. var application = app || this.businessData.work.application;
  3433. window.open(o2.filterUrl("../x_desktop/printWork.html?workid=" + this.businessData.work.id + "&app=" + application + "&form=" + form));
  3434. }
  3435. },
  3436. readedWork: function (e) {
  3437. this.fireEvent("beforeReaded");
  3438. var _self = this;
  3439. var title = this.businessData.work.title;
  3440. if (title.length > 75) {
  3441. title = title.substr(0, 74) + "..."
  3442. }
  3443. var text = "您确定要将“" + title + "”标记为已阅吗?";
  3444. this.app.confirm("infor", e, "标记已阅确认", text, 300, 120, function () {
  3445. var read = null;
  3446. for (var i = 0; i < _self.businessData.readList.length; i++) {
  3447. if (_self.businessData.readList[i].person === layout.session.user.distinguishedName) {
  3448. read = _self.businessData.readList[i];
  3449. break;
  3450. }
  3451. }
  3452. if (read) {
  3453. _self.app.action.setReaded(function () {
  3454. this.fireEvent("afterReaded");
  3455. _self.app.reload();
  3456. }.bind(_self), null, read.id, read);
  3457. } else {
  3458. _self.app.reload();
  3459. }
  3460. if (layout.mobile) {
  3461. //移动端页面关闭
  3462. _self.finishOnMobile()
  3463. } else {
  3464. this.close();
  3465. }
  3466. }, function () {
  3467. this.close();
  3468. }, null, this.app.content, this.json.confirmStyle);
  3469. },
  3470. openWindow: function (form, app) {
  3471. //var application = app || (this.businessData.work) ? this.businessData.work.application : this.businessData.workCompleted.application;
  3472. var form = form;
  3473. if (!form) {
  3474. form = this.json.id;
  3475. //if (this.json.printForm) form = this.json.printForm;
  3476. }
  3477. if (this.businessData.workCompleted) {
  3478. var application = app || this.businessData.workCompleted.application;
  3479. window.open(o2.filterUrl("../x_desktop/printWork.html?workCompletedId=" + this.businessData.workCompleted.id + "&app=" + application + "&form=" + form));
  3480. } else {
  3481. var application = app || this.businessData.work.application;
  3482. window.open(o2.filterUrl("../x_desktop/printWork.html?workid=" + this.businessData.work.id + "&app=" + application + "&form=" + form));
  3483. }
  3484. //window.open("../x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form);
  3485. },
  3486. uploadedAttachment: function (site, id) {
  3487. this.workAction.getAttachment(id, this.businessData.work.id, function (json) {
  3488. var att = this.all[site];
  3489. if (att) {
  3490. if (json.data) att.attachmentController.addAttachment(json.data);
  3491. att.attachmentController.checkActions();
  3492. att.fireEvent("upload", [json.data]);
  3493. }
  3494. }.bind(this));
  3495. },
  3496. replacedAttachment: function (site, id) {
  3497. this.workAction.getAttachment(id, this.businessData.work.id, function (json) {
  3498. var att = this.all[site];
  3499. if (att) {
  3500. var attachmentController = att.attachmentController;
  3501. var attachment = null;
  3502. for (var i = 0; i < attachmentController.attachments.length; i++) {
  3503. if (attachmentController.attachments[i].data.id === id) {
  3504. attachment = attachmentController.attachments[i];
  3505. break;
  3506. }
  3507. }
  3508. attachment.data = json.data;
  3509. attachment.reload();
  3510. attachmentController.checkActions();
  3511. }
  3512. }.bind(this))
  3513. },
  3514. //移动端页面 工作处理完成后
  3515. finishOnMobile: function () {
  3516. var _self = this;
  3517. //新建检查
  3518. this.workAction.checkDraft(this.businessData.work.id, function (json) {
  3519. var str = JSON.stringify(json);
  3520. // console.log("===========success==============");
  3521. _self.finishOnMobileReal();
  3522. }.bind(this), function () {
  3523. console.log("===========fail..==============");
  3524. _self.finishOnMobileReal();
  3525. }, false);
  3526. },
  3527. finishOnMobileReal: function () {
  3528. if (window.o2android && window.o2android.closeWork) {
  3529. window.o2android.closeWork("");
  3530. } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.closeWork) {
  3531. window.webkit.messageHandlers.closeWork.postMessage("");
  3532. } else {
  3533. var len = window.history.length;
  3534. if (len > 1) {
  3535. history.back();
  3536. } else {
  3537. var uri = new URI(window.location.href);
  3538. var redirectlink = uri.getData("redirectlink");
  3539. if (redirectlink) {
  3540. history.replaceState(null, "work", redirectlink);
  3541. redirectlink.toURI().go();
  3542. } else {
  3543. window.location = o2.filterUrl("../x_desktop/appMobile.html?app=process.TaskCenter");
  3544. history.replaceState(null, "work", o2.filterUrl("../x_desktop/appMobile.html?app=process.TaskCenter"));
  3545. o2.filterUrl("../x_desktop/appMobile.html?app=process.TaskCenter").toURI().go();
  3546. }
  3547. }
  3548. }
  3549. }
  3550. });