Form.js 155 KB

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