Form.js 189 KB

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