Form.js 187 KB

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