Form.js 183 KB

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