Form.js 155 KB

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