Form.js 168 KB

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