Form.js 109 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355
  1. MWF.require(["MWF.widget.Common", "MWF.widget.Identity"], null, false);
  2. MWF.xApplication.process = MWF.xApplication.process || {};
  3. MWF.xApplication.process.Xform = MWF.xApplication.process.Xform || {};
  4. MWF.xDesktop.requireApp("process.Xform", "Package", null, false);
  5. MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class({
  6. Implements: [Options, Events],
  7. Extends: MWF.widget.Common,
  8. options: {
  9. "style": "default",
  10. "readonly": false,
  11. "cssPath": "",
  12. "macro": "FormContext",
  13. "parameters": null,
  14. "moduleEvents": ["queryLoad",
  15. "beforeLoad",
  16. "postLoad",
  17. "afterLoad",
  18. "beforeSave",
  19. "afterSave",
  20. "beforeClose",
  21. "beforeProcess",
  22. "beforeProcessWork",
  23. "afterProcess",
  24. "beforeReset",
  25. "afterReset",
  26. "beforeRetract",
  27. "afterRetract",
  28. "beforeReroute",
  29. "afterReroute",
  30. "beforeDelete",
  31. "afterDelete",
  32. "beforeModulesLoad",
  33. "resize",
  34. "afterModulesLoad"]
  35. },
  36. initialize: function(node, data, options){
  37. this.setOptions(options);
  38. this.container = $(node);
  39. this.container.setStyle("-webkit-user-select", "text");
  40. this.data = data;
  41. this.json = data.json;
  42. this.html = data.html;
  43. this.path = "/x_component_process_Xform/$Form/";
  44. this.cssPath = this.options.cssPath || "/x_component_process_Xform/$Form/"+this.options.style+"/css.wcss";
  45. this._loadCss();
  46. this.modules = [];
  47. this.all = {};
  48. this.forms = {};
  49. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  50. },
  51. parseCSS: function(css){
  52. var rex = /(url\(.*\))/g;
  53. var match;
  54. while ((match = rex.exec(css)) !== null) {
  55. var pic = match[0];
  56. var len = pic.length;
  57. var s = pic.substring(pic.length-2, pic.length-1);
  58. var n0 = (s==="'" || s==="\"") ? 5 : 4;
  59. var n1 = (s==="'" || s==="\"") ? 2 : 1;
  60. pic = pic.substring(n0, pic.length-n1);
  61. if ((pic.indexOf("x_processplatform_assemble_surface")!=-1 || pic.indexOf("x_portal_assemble_surface")!=-1)){
  62. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  63. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  64. if (pic.indexOf("/x_processplatform_assemble_surface")!==-1){
  65. pic = pic.replace("/x_processplatform_assemble_surface", pic+"/x_processplatform_assemble_surface");
  66. }else if (pic.indexOf("x_processplatform_assemble_surface")!==-1){
  67. pic = pic.replace("x_processplatform_assemble_surface", pic+"/x_processplatform_assemble_surface");
  68. }
  69. if (pic.indexOf("/x_portal_assemble_surface")!==-1){
  70. pic = pic.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  71. }else if (pic.indexOf("x_portal_assemble_surface")!==-1){
  72. pic = pic.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  73. }
  74. }
  75. pic = "url('"+pic+"')";
  76. var len2 = pic.length;
  77. css = css.substring(0, match.index) + pic + css.substring(rex.lastIndex, css.length);
  78. rex.lastIndex = rex.lastIndex + (len2-len);
  79. }
  80. return css;
  81. },
  82. loadCss: function(){
  83. debugger;
  84. cssText = this.json.css.code;
  85. //var head = (document.head || document.getElementsByTagName("head")[0] || document.documentElement);
  86. var styleNode = $("style"+this.json.id);
  87. if (styleNode) styleNode.destroy();
  88. if (cssText){
  89. cssText = this.parseCSS(cssText);
  90. var rex = new RegExp("(.+)(?=\\{)", "g");
  91. var match;
  92. var id = this.json.id.replace(/\-/g, "");
  93. var prefix = ".css" + id + " ";
  94. while ((match = rex.exec(cssText)) !== null) {
  95. var rule = prefix + match[0];
  96. cssText = cssText.substring(0, match.index) + rule + cssText.substring(rex.lastIndex, cssText.length);
  97. rex.lastIndex = rex.lastIndex + prefix.length;
  98. }
  99. var styleNode = document.createElement("style");
  100. styleNode.setAttribute("type", "text/css");
  101. styleNode.id="style"+this.json.id;
  102. styleNode.inject(this.container, "before");
  103. if(styleNode.styleSheet){
  104. var setFunc = function(){
  105. styleNode.styleSheet.cssText = cssText;
  106. };
  107. if(styleNode.styleSheet.disabled){
  108. setTimeout(setFunc, 10);
  109. }else{
  110. setFunc();
  111. }
  112. }else{
  113. var cssTextNode = document.createTextNode(cssText);
  114. styleNode.appendChild(cssTextNode);
  115. }
  116. return "css" + id;
  117. }
  118. return "";
  119. },
  120. load: function(){
  121. if (this.app){
  122. if (this.app.formNode) this.app.formNode.setStyles(this.json.styles);
  123. if (this.app.addEvent){
  124. this.app.addEvent("resize", function(){
  125. this.fireEvent("resize");
  126. }.bind(this));
  127. this.app.addEvent("queryClose", function(){
  128. this.beforeCloseWork();
  129. }.bind(this))
  130. }
  131. }
  132. if (!this.businessData.control.allowSave) this.setOptions({"readonly": true});
  133. var cssClass = "";
  134. if (this.json.css && this.json.css.code) cssClass = this.loadCss();
  135. this.loadMacro(function(){
  136. this.container.set("html", this.html);
  137. this.node = this.container.getFirst();
  138. if (cssClass) this.node.addClass(cssClass);
  139. this._loadEvents();
  140. if (this.fireEvent("queryLoad")){
  141. if (this.app) if (this.app.fireEvent) this.app.fireEvent("queryLoad");
  142. MWF.xDesktop.requireApp("process.Xform", "lp."+MWF.language, null, false);
  143. this._loadBusinessData();
  144. this.fireEvent("beforeLoad");
  145. if (this.app) if (this.app.fireEvent) this.app.fireEvent("beforeLoad");
  146. this.loadContent();
  147. }
  148. }.bind(this));
  149. },
  150. loadMacro: function(callback){
  151. //if (!MWF.Macro[this.options.macro || "FormContext"]){
  152. MWF.require("MWF.xScript.Macro", function(){
  153. this.Macro = new MWF.Macro[this.options.macro || "FormContext"](this);
  154. if (callback) callback();
  155. }.bind(this));
  156. // }else{
  157. // this.Macro = new MWF.Macro[this.options.macro || "FormContext"](this);
  158. // if (callback) callback();
  159. // }
  160. },
  161. loadContent: function(){
  162. this._loadHtml();
  163. this._loadForm();
  164. this.fireEvent("beforeModulesLoad");
  165. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeModulesLoad");
  166. this._loadModules(this.node);
  167. if (this.json.mode === "Mobile"){
  168. var node = document.body.getElement(".o2_form_mobile_actions");
  169. if (node) this._loadMobileActions(node);
  170. }
  171. this.fireEvent("afterModulesLoad");
  172. this.fireEvent("postLoad");
  173. this.fireEvent("afterLoad");
  174. if (this.app && this.app.fireEvent){
  175. this.app.fireEvent("afterModulesLoad");
  176. this.app.fireEvent("postLoad");
  177. this.app.fireEvent("afterLoad");
  178. }
  179. },
  180. _loadMobileDefaultTools: function(callback){
  181. if (this.json.defaultTools){
  182. if (callback) callback();
  183. }else{
  184. this.json.defaultTools = o2.JSON.get("/x_component_process_FormDesigner/Module/Form/toolbars.json", function(json){
  185. this.json.defaultTools = json;
  186. if (callback) callback();
  187. }.bind(this));
  188. }
  189. },
  190. _loadMobileActions: function(node){
  191. var tools = [];
  192. this._loadMobileDefaultTools(function(){
  193. if (this.json.defaultTools){
  194. this.json.defaultTools.each(function(tool){
  195. var flag = this._checkDefaultMobileActionItem(tool, this.options.readonly);
  196. if (flag) tools.push(tool);
  197. }.bind(this));
  198. }
  199. if (this.json.tools){
  200. this.json.tools.each(function(tool){
  201. var flag = this._checkCustomMobileActionItem(tool, this.options.readonly);
  202. if (flag) tools.push(tool);
  203. }.bind(this));
  204. }
  205. if (tools.length) this._createMobileActions(node, tools);
  206. }.bind(this));
  207. },
  208. _createMobileActions:function(node, tools){
  209. node.show();
  210. var count = tools.length;
  211. if (count<=2){
  212. this.css.html5ActionButton.width = "100%"
  213. if (count==2) this.css.html5ActionButton.width = "49%"
  214. tools.each(function(tool){
  215. var action = new Element("div", {"styles": this.css.html5ActionButton, "text": tool.text}).inject(node);
  216. action.store("tool", tool);
  217. action.addEvent("click", function(e){
  218. var t = e.target.retrieve("tool");
  219. e.setDisable = function(){}
  220. if (t.actionScript){
  221. this._runCustomAction(t.actionScript);
  222. }else{
  223. if (this[t.action]) this[t.action](e);
  224. }
  225. }.bind(this));
  226. this._setMobileBottonStyle(action);
  227. }.bind(this));
  228. if (count==2) new Element("div", {"styles": this.css.html5ActionButtonSplit}).inject(node.getLast(), "before");
  229. }else{
  230. this.css.html5ActionButton.width = "38%"
  231. for (var i=0; i<2; i++){
  232. tool = tools[i];
  233. var action = new Element("div", {"styles": this.css.html5ActionButton, "text": tool.text}).inject(node);
  234. action.store("tool", tool);
  235. action.addEvent("click", function(e){
  236. var t = e.target.retrieve("tool");
  237. e.setDisable = function(){}
  238. if (t.actionScript){
  239. this._runCustomAction(t.actionScript);
  240. }else{
  241. if (this[t.action]) this[t.action](e);
  242. }
  243. }.bind(this));
  244. this._setMobileBottonStyle(action);
  245. }
  246. new Element("div", {"styles": this.css.html5ActionButtonSplit}).inject(node.getLast(), "before");
  247. new Element("div", {"styles": this.css.html5ActionButtonSplit}).inject(node);
  248. this.css.html5ActionButton.width = "23%"
  249. var action = new Element("div", {"styles": this.css.html5ActionButton, "text": "…"}).inject(node);
  250. action.addEvent("click", function(e){
  251. this._loadMoreMobileActions(tools, 2, node);
  252. }.bind(this));
  253. this._setMobileBottonStyle(action);
  254. }
  255. },
  256. _loadMoreMobileActions: function(tools, n, node){
  257. document.body.mask({
  258. "style": {
  259. "background-color": "#cccccc",
  260. "opacity": 0.6
  261. },
  262. "hideOnClick": true,
  263. "onHide": function(){
  264. this.actionMoreArea.setStyle("display", "none");
  265. }.bind(this)
  266. });
  267. if (this.actionMoreArea){
  268. this.actionMoreArea.setStyle("display", "block");
  269. }else{
  270. var size = document.body.getSize();
  271. this.actionMoreArea = new Element("div", {"styles": this.css.html5ActionOtherArea}).inject(document.body);
  272. var pl = this.actionMoreArea.getStyle("padding-left").toInt();
  273. var pr = this.actionMoreArea.getStyle("padding-right").toInt();
  274. var w = size.x-pl-pr;
  275. this.actionMoreArea.setStyle("width", ""+w+"px");
  276. for (var i=n; i<tools.length; i++){
  277. tool = tools[i];
  278. var action = new Element("div", {"styles": this.css.html5ActionOtherButton, "text": tool.text}).inject(this.actionMoreArea);
  279. action.store("tool", tool);
  280. action.addEvent("click", function(e){
  281. var t = e.target.retrieve("tool");
  282. e.setDisable = function(){}
  283. if (t.actionScript){
  284. this._runCustomAction(t.actionScript);
  285. }else{
  286. if (this[t.action]) this[t.action](e);
  287. }
  288. }.bind(this));
  289. this._setMobileBottonStyle(action);
  290. }
  291. }
  292. // actionArea.position({
  293. // relativeTo: node,
  294. // position: 'topCenter',
  295. // edge: 'bottomCenter'
  296. // });
  297. },
  298. _setMobileBottonStyle:function(action){
  299. var _self = this;
  300. action.addEvents({
  301. "mouseover": function(e){ this.setStyles(_self.css.html5ActionButton_over)},
  302. "mouseout": function(e){this.setStyles(_self.css.html5ActionButton_up)},
  303. "mousedown": function(e){this.setStyles(_self.css.html5ActionButton_over)},
  304. "mouseup": function(e){this.setStyles(_self.css.html5ActionButton_up)},
  305. "touchstart": function(e){this.setStyles(_self.css.html5ActionButton_over)},
  306. "touchcancel": function(e){this.setStyles(_self.css.html5ActionButton_up)},
  307. "touchend": function(e){this.setStyles(_self.css.html5ActionButton_up)},
  308. "touchmove": function(e){this.setStyles(_self.css.html5ActionButton_over)},
  309. });
  310. },
  311. _runCustomAction: function(actionScript){
  312. //var script = bt.node.retrieve("script");
  313. this.Macro.exec(actionScript, this);
  314. },
  315. _checkCustomMobileActionItem: function(tool,readonly){
  316. var flag = true;
  317. if (readonly){
  318. flag = tool.readShow;
  319. }else{
  320. flag = tool.editShow;
  321. }
  322. if (flag){
  323. flag = true;
  324. if (tool.control){
  325. flag = this.form.businessData.control[tool.control]
  326. }
  327. if (tool.condition){
  328. var hideFlag = this.form.Macro.exec(tool.condition, this);
  329. flag = !hideFlag;
  330. }
  331. }
  332. return flag;
  333. },
  334. _checkDefaultMobileActionItem: function(tool, readonly, noCondition){
  335. var flag = true;
  336. if (tool.control){
  337. flag = this.businessData.control[tool.control]
  338. }
  339. if (!noCondition) if (tool.condition){
  340. var hideFlag = this.Macro.exec(tool.condition, this);
  341. flag = flag && (!hideFlag);
  342. }
  343. if (tool.id == "action_processWork"){
  344. if (!this.businessData.task){
  345. flag = false;
  346. }
  347. }
  348. if (tool.id == "action_rollback") tool.read = true;
  349. if (readonly) if (!tool.read) flag = false;
  350. return flag;
  351. },
  352. _loadBusinessData: function(){
  353. if (!this.businessData){
  354. this.businessData = {};
  355. // this.businessData = {
  356. // "data": {
  357. // "select": "222",
  358. // "radio": "bbb",
  359. // "checkbox": ["check1", "check3"],
  360. // "orderData": [
  361. // {
  362. // "orderName": {"namefield": "电脑"},
  363. // "orderCount": {"countField": "3"},
  364. // "priceCount": {"priceField": "9000"}
  365. // },
  366. // {
  367. // "orderName": {"namefield": "路由器"},
  368. // "orderCount": {"countField": "2"},
  369. // "priceCount": {"priceField": "1000"}
  370. // },
  371. // {
  372. // "orderName": {"namefield": "网线"},
  373. // "orderCount": {"countField": "10"},
  374. // "priceCount": {"priceField": "200"}
  375. // }
  376. // ]
  377. //
  378. // }
  379. // };
  380. }
  381. },
  382. _loadHtml: function(){
  383. // this.container.set("html", this.html);
  384. // this.node = this.container.getFirst();
  385. //this.node.setStyle("overflow", "hidden");
  386. this.node.addEvent("selectstart", function(e){
  387. var select = "text";
  388. if (e.target.getStyle("-webkit-user-select")){
  389. select = e.target.getStyle("-webkit-user-select").toString().toLowerCase();
  390. }
  391. if (select!=="text" && select!=="auto") e.preventDefault();
  392. });
  393. },
  394. _loadForm: function(){
  395. this._loadStyles();
  396. this._loadCssLinks();
  397. this._loadScriptSrc();
  398. this._loadJsheader();
  399. //this._loadEvents();
  400. },
  401. _loadStyles: function(){
  402. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  403. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  404. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  405. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  406. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  407. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  408. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  409. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  410. }
  411. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  412. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  413. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  414. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  415. }
  416. }
  417. this.node.setStyle(key, value);
  418. }.bind(this));
  419. //this.node.setStyles(this.json.styles);
  420. },
  421. _loadCssLinks: function(){
  422. var urls = this.json.cssLinks;
  423. urls.each(function(url){
  424. new Element("link", {
  425. "rel": "stylesheet",
  426. "type": "text/css",
  427. "href": url
  428. }).inject($(document.head));
  429. });
  430. },
  431. _loadScriptSrc: function(){
  432. var urls = this.json.scriptSrc;
  433. urls.each(function(url){
  434. new Element("script", {
  435. "src": url
  436. }).inject($(document.head));
  437. });
  438. },
  439. _loadJsheader: function(){
  440. var code = this.json.jsheader.code;
  441. if (code) Browser.exec(code);
  442. },
  443. _loadEvents: function(){
  444. Object.each(this.json.events, function(e, key){
  445. if (e.code){
  446. if (this.options.moduleEvents.indexOf(key)!==-1){
  447. this.addEvent(key, function(event){
  448. return this.Macro.fire(e.code, this, event);
  449. }.bind(this));
  450. }else{
  451. if (key==="load"){
  452. this.addEvent("postLoad", function(){
  453. return this.Macro.fire(e.code, this);
  454. }.bind(this));
  455. }else if (key==="submit"){
  456. this.addEvent("beforeProcess", function(){
  457. return this.Macro.fire(e.code, this);
  458. }.bind(this));
  459. }else{
  460. this.node.addEvent(key, function(event){
  461. return this.Macro.fire(e.code, this, event);
  462. }.bind(this));
  463. }
  464. }
  465. }
  466. }.bind(this));
  467. },
  468. _getDomjson: function(dom){
  469. var mwfType = dom.get("MWFtype") || dom.get("mwftype");
  470. switch (mwfType) {
  471. case "form":
  472. return this.json;
  473. case "":
  474. return null;
  475. default:
  476. var id = dom.get("id");
  477. if (!id) id = dom.get("MWFId");
  478. if (id){
  479. return this.json.moduleList[id];
  480. }else{
  481. return null;
  482. }
  483. }
  484. },
  485. _getModuleNodes: function(dom){
  486. var moduleNodes = [];
  487. var subDom = dom.getFirst();
  488. while (subDom){
  489. var mwftype = subDom.get("MWFtype") || subDom.get("mwftype");
  490. if (mwftype){
  491. var type = mwftype;
  492. if (type.indexOf("$")===-1){
  493. moduleNodes.push(subDom);
  494. }
  495. // && mwftype !== "tab$Content"
  496. if (mwftype !== "datagrid" && mwftype !== "subSource" && mwftype !== "tab$Content"){
  497. moduleNodes = moduleNodes.concat(this._getModuleNodes(subDom));
  498. }
  499. }else{
  500. moduleNodes = moduleNodes.concat(this._getModuleNodes(subDom));
  501. }
  502. subDom = subDom.getNext();
  503. }
  504. return moduleNodes;
  505. },
  506. _loadModules: function(dom){
  507. //var subDom = this.node.getFirst();
  508. //while (subDom){
  509. // if (subDom.get("MWFtype")){
  510. // var json = this._getDomjson(subDom);
  511. // var module = this._loadModule(json, subDom);
  512. // this.modules.push(module);
  513. // }
  514. // subDom = subDom.getNext();
  515. //}
  516. var moduleNodes = this._getModuleNodes(dom);
  517. //alert(moduleNodes.length);
  518. moduleNodes.each(function(node){
  519. var json = this._getDomjson(node);
  520. var module = this._loadModule(json, node);
  521. this.modules.push(module);
  522. }.bind(this));
  523. },
  524. _loadModule: function(json, node, beforeLoad){
  525. if (!MWF["APP"+json.type]){
  526. MWF.xDesktop.requireApp("process.Xform", json.type, null, false);
  527. }
  528. var module = new MWF["APP"+json.type](node, json, this);
  529. if (beforeLoad) beforeLoad.apply(module);
  530. if (!this.all[json.id]) this.all[json.id] = module;
  531. if (module.field){
  532. if (!this.forms[json.id]) this.forms[json.id] = module;
  533. }
  534. module.readonly = this.options.readonly;
  535. module.load();
  536. return module;
  537. },
  538. saveOpinion: function(module){
  539. var op = module._getBusinessSectionDataByPerson();
  540. MWF.UD.getDataJson("userOpinion", function(json){
  541. if (!json) json = [];
  542. var idx = json.indexOf(op);
  543. if (idx==-1){
  544. if (json.length>=50) json.shift();
  545. }else{
  546. json.splice(idx, 1);
  547. }
  548. json.push(op);
  549. MWF.UD.putData("userOpinion", json);
  550. }.bind(this), false);
  551. },
  552. getData: function(issubmit){
  553. var data= Object.clone(this.businessData.data);
  554. Object.each(this.forms, function(module, id){
  555. if (module.json.type==="Opinion"){
  556. if (issubmit){
  557. this.saveOpinion(module);
  558. delete data[id];
  559. }else{
  560. var v = module.getData();
  561. data[id] = this.getSectionDataByPerson(v, data[id]);
  562. }
  563. }else{
  564. if (module.json.section==="yes"){
  565. data[id] = this.getSectionData(module, data[id]);
  566. }else{
  567. data[id] = module.getData();
  568. }
  569. }
  570. }.bind(this));
  571. this.businessData.data = data;
  572. this.Macro.environment.setData(this.businessData.data);
  573. return data;
  574. },
  575. getSectionData: function(module, obj){
  576. var v = module.getData();
  577. switch (module.json.sectionBy){
  578. case "person":
  579. return this.getSectionDataByPerson(v, obj);
  580. break;
  581. case "unit":
  582. return this.getSectionDataByUnit(v, obj);
  583. break;
  584. case "activity":
  585. return this.getSectionDataByPActivity(v, obj);
  586. break;
  587. case "script":
  588. return this.getSectionDataByScript(module.json.sectionByScript.code, v, obj);
  589. break;
  590. default:
  591. return v;
  592. }
  593. },
  594. getSectionDataByPerson: function(v, obj) {
  595. var key = layout.desktop.session.user.id;
  596. if (!obj || (typeOf(obj)!=="object")) obj={};
  597. obj[key] = v;
  598. return obj;
  599. },
  600. getSectionDataByUnit: function(v, obj) {
  601. var key = (this.businessData.task) ? this.businessData.task.unit : "";
  602. if (!obj || (typeOf(obj)!=="object")) obj={};
  603. if (key) obj[key] = v;
  604. return obj;
  605. },
  606. getSectionDataByPActivity: function(v, obj) {
  607. var key = (this.businessData.work) ? this.businessData.work.activity : "";
  608. if (!obj || (typeOf(obj)!=="object")) obj={};
  609. if (key) obj[key] = v;
  610. return obj;
  611. },
  612. getSectionDataByScript: function(code, v, obj) {
  613. var key = this.form.Macro.exec(code, this);
  614. if (!obj || (typeOf(obj)!=="object")) obj={};
  615. if (key) obj[key] = v;
  616. return obj;
  617. },
  618. saveWork: function(callback){
  619. if (this.businessData.control["allowSave"]){
  620. this.fireEvent("beforeSave");
  621. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeSave");
  622. this.saveFormData(function(json){
  623. if (this.app) this.app.notice(MWF.xApplication.process.Xform.LP.dataSaved, "success");
  624. if (callback) callback();
  625. this.fireEvent("afterSave");
  626. if (this.app && this.app.fireEvent) this.app.fireEvent("afterSave");
  627. }.bind(this));
  628. }else{
  629. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "Permission Denied");
  630. //if (failure) failure(null, "Permission Denied", "");
  631. }
  632. },
  633. saveFormData: function(callback, failure, history ,data, issubmit){
  634. if (this.officeList){
  635. this.officeList.each(function(module){
  636. module.save(history);
  637. });
  638. }
  639. this.workAction.saveData(callback, failure, this.businessData.work.id, data || this.getData(issubmit));
  640. },
  641. beforeCloseWork: function(){
  642. this.fireEvent("beforeClose");
  643. if (this.app && this.app.fireEvent){
  644. this.app.fireEvent("beforeClose");
  645. // this.fireEvent("afterClose");
  646. }
  647. if (!this.options.readonly){
  648. if (this.businessData.work) this.workAction.checkDraft(this.businessData.work.id, function(){
  649. if (layout.desktop.apps){
  650. if (layout.desktop.apps["TaskCenter"]){
  651. layout.desktop.apps["TaskCenter"].content.unmask();
  652. layout.desktop.apps["TaskCenter"].refreshAll();
  653. }
  654. }
  655. }.bind(this), null, false);
  656. }else{
  657. this.app.refreshTaskCenter();
  658. }
  659. },
  660. closeWork: function(){
  661. // this.fireEvent("beforeClose");
  662. // if (this.app && this.app.fireEvent){
  663. // this.app.fireEvent("beforeClose");
  664. // // this.fireEvent("afterClose");
  665. // }
  666. // debugger;
  667. // if (!this.options.readonly)
  668. // if (this.businessData.work) this.workAction.checkDraft(this.businessData.work.id);
  669. this.app.close();
  670. },
  671. getMessageContent: function(data){
  672. var content = "";
  673. if (data.length){
  674. data.each(function(work){
  675. var users = [];
  676. work.taskList.each(function(task){
  677. users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  678. }.bind(this));
  679. content += "<div><b>"+MWF.xApplication.process.Xform.LP.nextActivity+"<font style=\"color: #ea621f\">"+work.fromActivityName+"</font>, "+MWF.xApplication.process.Xform.LP.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b></div>";
  680. }.bind(this));
  681. }else{
  682. content += MWF.xApplication.process.Xform.LP.workCompleted;
  683. }
  684. return "<div>"+MWF.xApplication.process.Xform.LP.taskProcessedMessage+"“"+this.businessData.work.title+"”</div>"+content;
  685. },
  686. addMessage: function(data){
  687. // var content = "";
  688. // if (data.length){
  689. // data.each(function(work){
  690. // var users = [];
  691. // work.taskList.each(function(task){
  692. // users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  693. // }.bind(this));
  694. //
  695. // content += "<div><b>"+MWF.xApplication.process.Xform.LP.nextActivity+"<font style=\"color: #ea621f\">"+work.fromActivityName+"</font>, "+MWF.xApplication.process.Xform.LP.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b></div>";
  696. // }.bind(this));
  697. // }else{
  698. // content += MWF.xApplication.process.Xform.LP.workCompleted;
  699. // }
  700. //data.workList.each(function(list){
  701. // content += "<div><b>"+MWF.xApplication.process.Xform.LP.nextActivity+"<font style=\"color: #ea621f\">"+list.activityName+"</font>, "+MWF.xApplication.process.Xform.LP.nextUser+"<font style=\"color: #ea621f\">"+list.personList.join(", ")+"</font></b></div>"
  702. //}.bind(this));
  703. var msg = {
  704. "subject": MWF.xApplication.process.Xform.LP.taskProcessed,
  705. "content": this.getMessageContent(data)
  706. };
  707. layout.desktop.message.addTooltip(msg);
  708. return layout.desktop.message.addMessage(msg);
  709. },
  710. formValidation: function(routeName, opinion, medias){
  711. if (this.options.readonly) return true;
  712. this.Macro.environment.form.currentRouteName = routeName;
  713. this.Macro.environment.form.opinion = opinion;
  714. this.Macro.environment.form.medias = medias;
  715. var flag = true;
  716. //flag = this.validation();
  717. Object.each(this.forms, function(field, key){
  718. field.validationMode();
  719. if (!field.validation(routeName, opinion, medias)) flag = false;
  720. }.bind(this));
  721. return flag;
  722. },
  723. validation: function(routeName, opinion, processor, medias){
  724. this.Macro.environment.form.currentRouteName = routeName;
  725. this.Macro.environment.form.opinion = opinion;
  726. this.Macro.environment.form.medias = medias;
  727. var routeFlag = this.validationRoute(processor);
  728. var opinionFlag = this.validationOpinion(processor);
  729. return routeFlag && opinionFlag;
  730. },
  731. validationRoute: function(processor){
  732. if (!this.json.validationRoute) return true;
  733. if (!this.json.validationRoute.code) return true;
  734. var flag = this.Macro.exec(this.json.validationRoute.code, this);
  735. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  736. if (flag.toString()!="true"){
  737. this.notValidationRouteMode(flag, processor);
  738. return false;
  739. }
  740. return true;
  741. },
  742. validationOpinion: function(processor){
  743. if (!this.json.validationOpinion) return true;
  744. if (!this.json.validationOpinion.code) return true;
  745. var flag = this.Macro.exec(this.json.validationOpinion.code, this);
  746. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  747. if (flag.toString()!="true"){
  748. this.notValidationOpinionMode(flag, processor);
  749. return false;
  750. }
  751. return true;
  752. },
  753. formCustomValidation: function(){
  754. if (!this.json.validationFormCustom) return true;
  755. if (!this.json.validationFormCustom.code) return true;
  756. var flag = this.Macro.exec(this.json.validationFormCustom.code, this);
  757. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  758. if (flag.toString()!="true"){
  759. this.notValidationOpinionMode(flag);
  760. return false;
  761. }
  762. return true;
  763. },
  764. notValidationRouteMode: function(flag, processor){
  765. processor.routeSelectorArea.setStyle("background-color", "#ffe9e9");
  766. new mBox.Notice({
  767. type: "error",
  768. position: {"x": "center", "y": "top"},
  769. move: false,
  770. target: processor.routeSelectorArea,
  771. delayClose: 6000,
  772. content: flag
  773. });
  774. },
  775. notValidationOpinionMode: function(flag, processor){
  776. if (processor) processor.inputTextarea.setStyle("background-color", "#ffe9e9");
  777. new mBox.Notice({
  778. type: "error",
  779. position: (processor) ? {"x": "center", "y": "top"} : {"x": "right", "y": "top"},
  780. move: false,
  781. target: (processor) ? processor.inputTextarea : this.app.content,
  782. delayClose: 6000,
  783. content: flag
  784. });
  785. },
  786. //fireRtEvent: function(type, args, delay){
  787. // type = removeOn(type);
  788. // var events = this.$events[type];
  789. // if (!events) return this;
  790. // if (!events.length) return this;
  791. // var event = events[events.length-1];
  792. // args = Array.from(args);
  793. // if (delay) fn.delay(delay, this, args);
  794. // else return fn.apply(this, args);
  795. // return this;
  796. //},
  797. submitWork: function(routeName, opinion, medias, callback, processor, data){
  798. if (!this.businessData.control["allowProcessing"]){
  799. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "Permission Denied");
  800. this.app.content.unmask();
  801. processor.node.unmask();
  802. return false;
  803. }
  804. if (!this.formValidation(routeName, opinion, medias)){
  805. this.app.content.unmask();
  806. //this.app.notice("", "error", target, where, offset);
  807. if (callback) callback();
  808. return false;
  809. }
  810. if (!this.validation(routeName, opinion, processor, medias)){
  811. //this.app.content.unmask();
  812. processor.node.unmask();
  813. //if (callback) callback();
  814. return false;
  815. }
  816. if (!opinion){
  817. var idx = this.businessData.task.routeNameList.indexOf(routeName);
  818. if (this.businessData.task.routeOpinionList[idx]){
  819. opinion = this.businessData.task.routeOpinionList[idx];
  820. }else{
  821. opinion = routeName;
  822. }
  823. }
  824. this.fireEvent("beforeProcess");
  825. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcess");
  826. MWF.require("MWF.widget.Mask", function(){
  827. this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  828. this.mask.loadNode(this.app.content);
  829. this.fireEvent("beforeSave");
  830. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeSave");
  831. this.saveFormData(function(json){
  832. this.businessData.task.routeName = routeName;
  833. this.businessData.task.opinion = opinion;
  834. var mediaIds = [];
  835. if (medias && medias.length){
  836. medias.each(function(file){
  837. var formData = new FormData();
  838. formData.append("file", file);
  839. formData.append("site", "$mediaOpinion");
  840. this.workAction.uploadAttachment(this.businessData.work.id, formData, file, function(json){
  841. mediaIds.push(json.data.id);
  842. }.bind(this), null, false);
  843. }.bind(this));
  844. }
  845. if (mediaIds.length) this.businessData.task.mediaOpinion = mediaIds.join(",");
  846. this.fireEvent("afterSave");
  847. if (this.app && this.app.fireEvent) this.app.fireEvent("afterSave");
  848. this.workAction.processTask(function(json){
  849. //if (processor) processor.destroy();
  850. //if (processNode) processNode.destroy();
  851. if (callback) callback(json);
  852. this.taskList = json.data;
  853. this.fireEvent("afterProcess");
  854. if (this.app && this.app.fireEvent) this.app.fireEvent("afterProcess");
  855. // this.notice(MWF.xApplication.process.Xform.LP.taskProcessed, "success");
  856. this.addMessage(json.data);
  857. if (this.app.taskObject) this.app.taskObject.destroy();
  858. if (layout.mobile){
  859. var uri = new URI(window.location.href);
  860. var redirectlink = uri.getData("redirectlink");
  861. if( redirectlink ){
  862. window.location = decodeURIComponent(redirectlink);
  863. }else{
  864. window.location = "appMobile.html?app=process.TaskCenter";
  865. }
  866. }else{
  867. if (this.app.inBrowser){
  868. if (this.mask) this.mask.hide();
  869. var content = this.getMessageContent(json.data);
  870. var div = new Element("div", {"styles": {"margin": "10px 10px 0px 10px", "padding": "5px", "overflow": "hidden"}}).inject(this.app.content);
  871. div.set("html", content);
  872. debugger;
  873. if (this.json.isPrompt!=="false"){
  874. var options ={
  875. "content": div,
  876. "isTitle": false,
  877. "width": 350,
  878. "height": 180,
  879. "buttonList": [
  880. {
  881. "text": MWF.xApplication.process.Xform.LP.ok,
  882. "action": function(){dlg.close(); this.app.close();}.bind(this)
  883. }
  884. ]
  885. }
  886. var size = this.app.content.getSize();
  887. switch (this.json.promptPosition || "righttop"){
  888. case "lefttop":
  889. options.top = 10;
  890. options.left = 10;
  891. options.fromTop = 10;
  892. options.fromLeft = 10;
  893. break;
  894. case "righttop":
  895. options.top = 10;
  896. options.left = size.x-360;
  897. options.fromTop = 10;
  898. options.fromLeft = size.x-10;
  899. break;
  900. case "leftbottom":
  901. options.top = size.y-190;
  902. options.left = 10;
  903. options.fromTop = size.y-10;
  904. options.fromLeft = 10;
  905. break;
  906. case "rightbottom":
  907. options.top = size.y-190;
  908. options.left = size.x-360;
  909. options.fromTop = size.y-10;
  910. options.fromLeft = size.x-10;
  911. break;
  912. default:
  913. delete options.top;
  914. delete options.left;
  915. delete options.fromTop;
  916. delete options.fromLeft;
  917. }
  918. var dlg = o2.DL.open(options);
  919. if (this.json.promptCloseTime!=0){
  920. var t = this.json.promptCloseTime || 2;
  921. t = t.toInt()*1000;
  922. var _work = this;
  923. window.setTimeout(function(){dlg.close(); _work.app.close();}, t);
  924. }
  925. }else{
  926. this.app.close();
  927. }
  928. }else{
  929. this.app.close();
  930. }
  931. }
  932. //window.setTimeout(function(){this.app.close();}.bind(this), 2000);
  933. }.bind(this), null, this.businessData.task.id, this.businessData.task);
  934. }.bind(this), null, true, data, true);
  935. }.bind(this));
  936. },
  937. processWork: function(){
  938. if (this.app.inBrowser){
  939. this.app.content.setStyle("height", document.body.getSize().y);
  940. }
  941. this.fireEvent("beforeProcessWork");
  942. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  943. var position = this.app.content.getPosition(this.app.content.getOffsetParent());
  944. this.app.content.mask({
  945. "destroyOnHide": true,
  946. "style": this.app.css.maskNode,
  947. "useIframeShim": true,
  948. "iframeShimOptions": {"browsers": true},
  949. "onShow": function(){
  950. this.shim.shim.setStyles({
  951. "opacity": 0,
  952. "top": ""+position.y+"px",
  953. "left": ""+position.x+"px"
  954. });
  955. }
  956. });
  957. if (!this.formCustomValidation("", "")){
  958. this.app.content.unmask();
  959. // if (callback) callback();
  960. return false;
  961. }
  962. // MWF.require("MWF.widget.Mask", function() {
  963. // this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  964. // this.mask.loadNode(this.app.content);
  965. if (!this.formValidation("", "")){
  966. this.app.content.unmask();
  967. // if (callback) callback();
  968. return false;
  969. }
  970. var processNode = this.createProcessNode();
  971. this.setProcessNode(processNode);
  972. this.showProcessNode(processNode);
  973. //}.bind(this));
  974. },
  975. createProcessNode: function(){
  976. var fromCss = this.app.css.processNode_from;
  977. var css = this.app.css.processNode;
  978. if (layout.mobile){
  979. fromCss = this.app.css.processNodeMobile_from;
  980. css = this.app.css.processNodeMobile;
  981. var contentSize = this.app.content.getSize();
  982. fromCss.width = "100%";
  983. css.width = "100%";
  984. fromCss.height = contentSize.y+"px";
  985. css.height = contentSize.y+"px";
  986. }
  987. var processNode = new Element("div", {"styles": fromCss}).inject(this.app.content);
  988. processNode.position({
  989. relativeTo: this.app.content,
  990. position: "topcenter",
  991. edge: "topcenter"
  992. });
  993. return processNode;
  994. },
  995. getOpinion: function(){
  996. var opinion = "";
  997. var medias = [];
  998. Object.each(this.forms, function(m, id){
  999. if (m.json.type==="Opinion") if (this.businessData.data[id]) opinion += " "+m._getBusinessSectionDataByPerson();
  1000. if (m.handwritingFile) if (m.handwritingFile[layout.session.user.distinguishedName]) medias.push(m.handwritingFile[layout.session.user.distinguishedName]);
  1001. if (m.soundFile) if (m.soundFile[layout.session.user.distinguishedName]) medias.push(m.soundFile[layout.session.user.distinguishedName]);
  1002. if (m.videoFile) if (m.videoFile[layout.session.user.distinguishedName]) medias.push(m.videoFile[layout.session.user.distinguishedName]);
  1003. }.bind(this));
  1004. return {"opinion": opinion.trim(), "medias": medias};
  1005. },
  1006. setProcessNode: function(processNode){
  1007. var _self = this;
  1008. MWF.xDesktop.requireApp("process.Work", "Processor", function(){
  1009. var op = this.getOpinion();
  1010. var mds = op.medias;
  1011. new MWF.xApplication.process.Work.Processor(processNode, this.businessData.task, {
  1012. "style": (layout.mobile) ? "mobile" : "default",
  1013. "opinion": op.opinion,
  1014. "onCancel": function(){
  1015. processNode.destroy();
  1016. _self.app.content.unmask();
  1017. delete this;
  1018. },
  1019. "onSubmit": function(routeName, opinion, medias){
  1020. if (!medias || !medias.length) medias = mds;
  1021. _self.submitWork(routeName, opinion, medias, function(){
  1022. this.destroy();
  1023. processNode.destroy();
  1024. delete this;
  1025. }.bind(this), this);
  1026. }
  1027. });
  1028. }.bind(this));
  1029. },
  1030. showProcessNode: function(processNode){
  1031. if (layout.mobile){
  1032. processNode.setStyles(this.app.css.processNodeMobile)
  1033. }else{
  1034. var size = this.app.content.getSize();
  1035. var nodeSize = processNode.getSize();
  1036. var top = size.y/2-nodeSize.y/2-20;
  1037. var left = size.x/2-nodeSize.x/2;
  1038. if (top<0) top = 0;
  1039. this.app.css.processNode.top = ""+top+"px";
  1040. this.app.css.processNode.left = ""+left+"px";
  1041. var morph = new Fx.Morph(processNode, {
  1042. "duration": 300,
  1043. "transition": Fx.Transitions.Expo.easeOut
  1044. });
  1045. morph.start(this.app.css.processNode);
  1046. }
  1047. },
  1048. confirm: function(type, e, title, text, width, height, ok, cancel, callback, mask, style){
  1049. MWF.require("MWF.xDesktop.Dialog", function(){
  1050. var size = this.container.getSize();
  1051. var x = 0;
  1052. var y = 0;
  1053. if (typeOf(e)==="element"){
  1054. var position = e.getPosition(this.app.content);
  1055. x = position.x;
  1056. y = position.y;
  1057. }else{
  1058. if (Browser.name=="firefox"){
  1059. x = parseFloat(e.event.clientX || e.event.x);
  1060. y = parseFloat(e.event.clientY || e.event.y);
  1061. }else{
  1062. x = parseFloat(e.event.x);
  1063. y = parseFloat(e.event.y);
  1064. }
  1065. if (e.target){
  1066. var position = e.target.getPosition(this.app.content);
  1067. //var position = e.target.getPosition();
  1068. x = position.x;
  1069. y = position.y;
  1070. }
  1071. }
  1072. // if (Browser.Platform.ios){
  1073. // $("textdiv").set("text", "$(document.body).getScroll().y: "+$(document.body).getScroll().y);
  1074. // y = y-$(document.body).getScroll().y;
  1075. // }
  1076. if (x+parseFloat(width)>size.x){
  1077. x = x-parseFloat(width);
  1078. }
  1079. if (x<0) x = 10;
  1080. if (y+parseFloat(height)>size.y){
  1081. y = y-parseFloat(height);
  1082. }
  1083. if (y<0) y = 10;
  1084. //var x = parseFloat((Browser.name==="firefox") ? e.event.clientX : e.event.x);
  1085. //var y = parseFloat((Browser.name==="firefox") ? e.event.clientY : e.event.y);
  1086. // if (x+parseFloat(width)>size.x){
  1087. // x = x-parseFloat(width);
  1088. // }
  1089. if (x<0) x = 20;
  1090. var dlg = new MWF.xDesktop.Dialog({
  1091. "title": title,
  1092. "style": style || "o2",
  1093. "top": y,
  1094. "left": x-20,
  1095. "fromTop":e.event.y,
  1096. "fromLeft": (Browser.name==="firefox") ? e.event.clientX-20 : e.event.x-20,
  1097. "width": width,
  1098. "height": height,
  1099. "text": text,
  1100. "container": this.app.content,
  1101. "maskNode": mask || this.app.content,
  1102. "buttonList": [
  1103. {
  1104. "text": MWF.LP.process.button.ok,
  1105. "action": ok
  1106. },
  1107. {
  1108. "text": MWF.LP.process.button.cancel,
  1109. "action": cancel
  1110. }
  1111. ]
  1112. });
  1113. switch (type.toLowerCase()){
  1114. case "success":
  1115. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  1116. break;
  1117. case "error":
  1118. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  1119. break;
  1120. case "info":
  1121. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  1122. break;
  1123. case "warn":
  1124. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  1125. break;
  1126. default:
  1127. }
  1128. dlg.show();
  1129. }.bind(this));
  1130. },
  1131. notice: function(content, type, target, where){
  1132. if (!where) where = {"x": "right", "y": "top"};
  1133. if (!target) target = this.node;
  1134. if (!type) type = "ok";
  1135. var noticeTarget = target || layout.layout.contentNode;
  1136. new mBox.Notice({
  1137. type: type,
  1138. position: where,
  1139. move: false,
  1140. target: noticeTarget,
  1141. delayClose: (type==="error") ? 5000 : 1000,
  1142. offset: {
  1143. x: 10,
  1144. y: where.y.toString().toLowerCase()==="bottom" ? 10 : 10
  1145. },
  1146. content: content
  1147. });
  1148. },
  1149. addSplit: function(){
  1150. if (!this.businessData.control["allowAddSplit"]){
  1151. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "Permission Denied");
  1152. return false;
  1153. }
  1154. MWF.require("MWF.xDesktop.Dialog", function(){
  1155. var width = 600;
  1156. var height = 230;
  1157. var p = MWF.getCenterPosition(this.app.content, width, height);
  1158. var _self = this;
  1159. var dlg = new MWF.xDesktop.Dialog({
  1160. "title": this.app.lp.addSplit,
  1161. "style": "work",
  1162. "top": p.y-100,
  1163. "left": p.x,
  1164. "fromTop": p.y-100,
  1165. "fromLeft": p.x,
  1166. "width": width,
  1167. "height": height,
  1168. "url": this.app.path+"split.html",
  1169. "container": this.app.content,
  1170. "isClose": true,
  1171. "onPostShow": function(){
  1172. debugger;
  1173. var okButton = dlg.content.getElement(".o2_addSplit_okButton");
  1174. var cancelButton = dlg.content.getElement(".o2_addSplit_cancelButton");
  1175. var selectButton = dlg.content.getElement(".o2_addSplit_selector");
  1176. var input = dlg.content.getElement("input");
  1177. var checks = dlg.content.getElements(".o2_addSplit_radio")
  1178. okButton.addEvent("click", function(){
  1179. var value = input.get("value");
  1180. var trimExist = true;
  1181. if (checks[1].checked) trimExist = false;
  1182. _self.doAddSplit(this, value, trimExist);
  1183. }.bind(this));
  1184. cancelButton.addEvent("click", function(){
  1185. this.close();
  1186. }.bind(this));
  1187. selectButton.addEvent("click", function(){
  1188. var value = input.get("value");
  1189. MWF.xDesktop.requireApp("Selector", "package", function(){
  1190. new o2.O2Selector(_self.app.content, {
  1191. "type": "",
  1192. "count": 0,
  1193. "values": (value) ? value.split(o2.splitStr): [],
  1194. "types": ["unit", "identity", "group", "role"],
  1195. "onComplete": function(items){
  1196. var v = [];
  1197. items.each(function(item){
  1198. v.push(item.data.distinguishedName);
  1199. });
  1200. input.set("value", v.join(", "));
  1201. }
  1202. });
  1203. }.bind(this));
  1204. //_self.selectSplitUnit(this);
  1205. }.bind(this));
  1206. }
  1207. });
  1208. dlg.show();
  1209. }.bind(this));
  1210. },
  1211. doAddSplit: function(dlg, splitValues, trimExist){
  1212. debugger;
  1213. if (!splitValues){
  1214. this.app.notice(MWF.xApplication.process.Xform.LP.inputSplitValue, "error", dlg.node);
  1215. return false;
  1216. }
  1217. MWF.require("MWF.widget.Mask", function(){
  1218. var splitValue = splitValues.split(o2.splitStr);
  1219. this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1220. this.mask.loadNode(this.app.content);
  1221. this.fireEvent("beforeAddSplit");
  1222. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeAddSplit");
  1223. this.addSplitWork(splitValue, trimExist, function(json){
  1224. this.fireEvent("afterAddSplit");
  1225. if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddSplit");
  1226. this.addAddSplitMessage(json.data);
  1227. // this.workAction.loadWork(function(workJson){
  1228. // this.fireEvent("afterAddSplit");
  1229. // if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddSplit");
  1230. // this.addAddSplitMessage(workJson.data);
  1231. // }.bind(this), null, this.businessData.work.id);
  1232. dlg.close();
  1233. if (this.mask) {this.mask.hide(); this.mask = null;}
  1234. }.bind(this), function(xhr, text, error){
  1235. var errorText = error+":"+text;
  1236. if (xhr) errorText = xhr.responseText;
  1237. this.app.notice("request json error: "+errorText, "error", dlg.node);
  1238. if (this.mask) {this.mask.hide(); this.mask = null;}
  1239. }.bind(this));
  1240. }.bind(this));
  1241. },
  1242. addSplitWork: function(splitValue, trimExist, success, failure){
  1243. var data = {"splitValueList": splitValue, "trimExist": trimExist};
  1244. if (this.options.readonly){
  1245. this.workAction.addSplit(
  1246. function(json){
  1247. if (success) success(json);
  1248. }.bind(this),
  1249. function(xhr, text, error){
  1250. if (failure) failure(xhr, text, error);
  1251. },
  1252. this.businessData.work.id, data
  1253. );
  1254. }else{
  1255. this.saveFormData(
  1256. function(json){
  1257. this.workAction.addSplit(
  1258. function(json){
  1259. if (success) success(json);
  1260. }.bind(this),
  1261. function(xhr, text, error){
  1262. if (failure) failure(xhr, text, error);
  1263. },
  1264. this.businessData.work.id, data
  1265. );
  1266. }.bind(this),
  1267. function(xhr, text, error){
  1268. if (failure) failure(xhr, text, error);
  1269. }, true, null, true
  1270. );
  1271. }
  1272. },
  1273. setRollBackChecked: function(item){
  1274. item.store("isSelected", true);
  1275. item.setStyles(this.css.rollbackItemNode_current);
  1276. item.getFirst().setStyles(this.css.rollbackItemIconNode_current);
  1277. var node = item.getLast().getFirst();
  1278. node.getFirst().setStyles(this.css.rollbackItemActivityNode_current);
  1279. node.getLast().setStyles(this.css.rollbackItemTimeNode_current);
  1280. node = item.getLast().getLast();
  1281. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode_current);
  1282. node.getLast().setStyles(this.css.rollbackItemTaskNode_current);
  1283. },
  1284. setRollBackUnchecked: function(item){
  1285. item.store("isSelected", false);
  1286. item.setStyles(this.css.rollbackItemNode);
  1287. item.getFirst().setStyles(this.css.rollbackItemIconNode);
  1288. var node = item.getLast().getFirst();
  1289. node.getFirst().setStyles(this.css.rollbackItemActivityNode);
  1290. node.getLast().setStyles(this.css.rollbackItemTimeNode);
  1291. node = item.getLast().getLast();
  1292. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode);
  1293. node.getLast().setStyles(this.css.rollbackItemTaskNode);
  1294. },
  1295. getRollbackLogs: function(rollbackItemNode){
  1296. var _self = this;
  1297. this.businessData.workLogList.each(function(log){
  1298. if (!log.splitting && log.connected && (log.taskCompletedList.length || log.readList.length || log.readCompletedList.length)){
  1299. var node = new Element("div", {"styles": this.css.rollbackItemNode}).inject(rollbackItemNode);
  1300. node.store("log", log);
  1301. var iconNode = new Element("div", {"styles": this.css.rollbackItemIconNode}).inject(node);
  1302. var contentNode = new Element("div", {"styles": this.css.rollbackItemContentNode}).inject(node);
  1303. var div = new Element("div", {"styles": {"overflow": "hidden"}}).inject(contentNode);
  1304. var activityNode = new Element("div", {"styles": this.css.rollbackItemActivityNode, "text": log.fromActivityName}).inject(div);
  1305. var timeNode = new Element("div", {"styles": this.css.rollbackItemTimeNode, "text": log.arrivedTime}).inject(div);
  1306. div = new Element("div", {"styles": {"overflow": "hidden"}}).inject(contentNode);
  1307. var taskTitleNode = new Element("div", {"styles": this.css.rollbackItemTaskTitleNode, "text": this.app.lp.taskCompletedPerson+": "}).inject(div);
  1308. log.taskCompletedList.each(function(o){
  1309. var text = o2.name.cn(o.person)+"("+o.completedTime+")";
  1310. var taskNode = new Element("div", {"styles": this.css.rollbackItemTaskNode, "text": text}).inject(div);
  1311. }.bind(this));
  1312. node.addEvents({
  1313. "mouseover": function(){
  1314. var isSelected = this.retrieve("isSelected");
  1315. if (!isSelected) this.setStyles(_self.css.rollbackItemNode_over);
  1316. },
  1317. "mouseout": function(){
  1318. var isSelected = this.retrieve("isSelected");
  1319. if (!isSelected) this.setStyles(_self.css.rollbackItemNode)
  1320. },
  1321. "click": function(){
  1322. var isSelected = this.retrieve("isSelected");
  1323. if (isSelected){
  1324. _self.setRollBackUnchecked(this);
  1325. }else{
  1326. var items = rollbackItemNode.getChildren();
  1327. items.each(function(item){
  1328. _self.setRollBackUnchecked(item);
  1329. });
  1330. _self.setRollBackChecked(this);
  1331. }
  1332. }
  1333. });
  1334. }
  1335. }.bind(this));
  1336. },
  1337. rollback: function(){
  1338. if (!this.businessData.control["allowRollback"]){
  1339. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "Permission Denied");
  1340. return false;
  1341. }
  1342. var node = new Element("div", {"styles": this.css.rollbackAreaNode});
  1343. var html = "<div style=\"line-height: 30px; height: 30px; color: #333333; overflow: hidden\">请选择文件要回溯到的位置:</div>";
  1344. html += "<div style=\"max-height: 300px; margin-bottom:10px; margin-top:10px; overflow-y:auto;\"></div>";
  1345. node.set("html", html);
  1346. var rollbackItemNode = node.getLast();
  1347. this.getRollbackLogs(rollbackItemNode);
  1348. node.inject(this.app.content);
  1349. var dlg = o2.DL.open({
  1350. "title": this.app.lp.rollback,
  1351. //"style": "work",
  1352. "isResize": false,
  1353. "content": node,
  1354. "width": 600,
  1355. "buttonList": [
  1356. {
  1357. "text": MWF.LP.process.button.ok,
  1358. "action": function(d, e){
  1359. debugger;
  1360. this.doRollback(node, e, dlg);
  1361. }.bind(this)
  1362. },
  1363. {
  1364. "text": MWF.LP.process.button.cancel,
  1365. "action": function(){dlg.close();}
  1366. }
  1367. ]
  1368. });
  1369. },
  1370. doRollback: function(node, e, dlg){
  1371. var rollbackItemNode = node.getLast();
  1372. var items = rollbackItemNode.getChildren();
  1373. var _self = this;
  1374. for (var i=0; i<items.length; i++){
  1375. if (items[i].retrieve("isSelected")){
  1376. var text = this.app.lp.rollbackConfirmContent;
  1377. var log = items[i].retrieve("log");
  1378. text = text.replace("{log}", log.fromActivityName+"("+log.arrivedTime+")");
  1379. this.app.confirm("infor", e, this.app.lp.rollbackConfirmTitle, text, 450, 120, function(){
  1380. _self.doRollbackAction(log.id, dlg);
  1381. dlg.close();
  1382. this.close();
  1383. }, function(){
  1384. this.close();
  1385. });
  1386. break;
  1387. }
  1388. }
  1389. },
  1390. doRollbackAction: function(log){
  1391. MWF.require("MWF.widget.Mask", function(){
  1392. this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1393. this.mask.loadNode(this.app.content);
  1394. this.fireEvent("beforeRollback");
  1395. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeRollback");
  1396. this.doRollbackActionInvoke(log, function(json){
  1397. var id = json.data.id;
  1398. this.workAction.listTaskByWork(function(workJson){
  1399. this.fireEvent("afterReset");
  1400. if (this.app && this.app.fireEvent) this.app.fireEvent("afterReset");
  1401. this.addRollbackMessage(workJson.data);
  1402. //this.app.notice(MWF.xApplication.process.Xform.LP.rollbackOk+": "+MWF.name.cns(names).join(", "), "success");
  1403. this.app.close();
  1404. }.bind(this), null, id);
  1405. if (this.mask) {this.mask.hide(); this.mask = null;}
  1406. }.bind(this), function(xhr, text, error){
  1407. var errorText = error+":"+text;
  1408. if (xhr) errorText = xhr.responseText;
  1409. this.app.notice("request json error: "+errorText, "error");
  1410. if (this.mask) {this.mask.hide(); this.mask = null;}
  1411. }.bind(this));
  1412. }.bind(this));
  1413. },
  1414. doRollbackActionInvoke: function(id, success, failure){
  1415. var method = (this.businessData.work.completedTime) ? "rollbackWorkcompleted" : "rollback";
  1416. o2.Actions.get("x_processplatform_assemble_surface")[method](this.businessData.work.id, {"workLog":id}, function(json){
  1417. if (success) success(json);
  1418. }.bind(this), function(xhr, text, error){
  1419. if (failure) failure(xhr, text, error)
  1420. }.bind(this));
  1421. },
  1422. addRollbackMessage: function(data){
  1423. var users = [];
  1424. data.each(function(task){
  1425. users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  1426. }.bind(this));
  1427. 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>";
  1428. var msg = {
  1429. "subject": MWF.xApplication.process.Xform.LP.workRollback,
  1430. "content": "<div>"+MWF.xApplication.process.Xform.LP.rollbackWorkInfor+"“"+this.businessData.work.title+"”</div>"+content
  1431. };
  1432. layout.desktop.message.addTooltip(msg);
  1433. return layout.desktop.message.addMessage(msg);
  1434. },
  1435. pressWork: function(e){
  1436. e.setDisable(true);
  1437. debugger;
  1438. o2.Actions.get("x_processplatform_assemble_surface").press(this.businessData.work.id, function(json){
  1439. var users = o2.name.cns(json.data.valueList).join(", ");
  1440. this.app.notice("已经向待办人:"+users+", 发送了提醒", "success");
  1441. e.setDisable(false);
  1442. }.bind(this), function(xhr, text, error){
  1443. //e.setDisable(false);
  1444. if (xhr.status!=0){
  1445. var errorText = error;
  1446. if (xhr){
  1447. var json = JSON.decode(xhr.responseText);
  1448. if (json){
  1449. errorText = json.message.trim() || "request json error";
  1450. }else{
  1451. errorText = "request json error: "+xhr.responseText;
  1452. }
  1453. }
  1454. MWF.xDesktop.notice("error", {x: "right", y:"top"}, errorText);
  1455. }
  1456. });
  1457. },
  1458. resetWork: function(){
  1459. if (!this.businessData.control["allowReset"]){
  1460. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "Permission Denied");
  1461. return false;
  1462. }
  1463. MWF.require("MWF.xDesktop.Dialog", function(){
  1464. var width = 680;
  1465. var height = 300;
  1466. var p = MWF.getCenterPosition(this.app.content, width, height);
  1467. var _self = this;
  1468. var dlg = new MWF.xDesktop.Dialog({
  1469. "title": this.app.lp.reset,
  1470. "style": "work",
  1471. "top": p.y-100,
  1472. "left": p.x,
  1473. "fromTop": p.y-100,
  1474. "fromLeft": p.x,
  1475. "width": width,
  1476. "height": height,
  1477. "url": this.app.path+"reset.html",
  1478. "container": this.app.content,
  1479. "isClose": true,
  1480. "onPostShow": function(){
  1481. $("resetWork_okButton").addEvent("click", function(){
  1482. _self.doResetWork(this);
  1483. }.bind(this));
  1484. $("resetWork_cancelButton").addEvent("click", function(){
  1485. this.close();
  1486. }.bind(this));
  1487. $("resetWork_selPeopleButton").addEvent("click", function(){
  1488. _self.selectPeople(this);
  1489. }.bind(this));
  1490. }
  1491. });
  1492. dlg.show();
  1493. }.bind(this));
  1494. },
  1495. selectPeople: function(dlg){
  1496. var range = this.businessData.activity.resetRange || "department";
  1497. var count = this.businessData.activity.resetCount || 0;
  1498. switch (range){
  1499. case "unit":
  1500. this.selectPeopleUnit(dlg, this.businessData.task.unit, count);
  1501. // this.personActions.getDepartmentByIdentity(function(json){
  1502. // this.selectPeopleDepartment(dlg, json.data, count);
  1503. // }.bind(this), null, this.businessData.task.identity);
  1504. break;
  1505. case "topUnit":
  1506. MWF.require("MWF.xScript.Actions.UnitActions", function(){
  1507. orgActions = new MWF.xScript.Actions.UnitActions();
  1508. var data = {"unitList": [this.businessData.task.unit]};
  1509. orgActions.listUnitSupNested(data, function(json){
  1510. v = json.data[0];
  1511. this.selectPeopleUnit(dlg, v, count);
  1512. }.bind(this));
  1513. }.bind(this));
  1514. // this.personActions.getCompanyByIdentity(function(json){
  1515. // this.selectPeopleCompany(dlg, json.data, count)
  1516. // }.bind(this), null, this.businessData.task.identity);
  1517. break;
  1518. default:
  1519. this.selectPeopleAll(dlg, count);
  1520. }
  1521. },
  1522. selectPeopleUnit: function(dlg, unit, count){
  1523. var names = dlg.identityList || [];
  1524. var areaNode = $("resetWork_selPeopleArea");
  1525. var options = {
  1526. "values": names,
  1527. "type": "identity",
  1528. "count": count,
  1529. "units": (unit) ? [unit]: [],
  1530. "title": this.app.lp.reset,
  1531. "onComplete": function (items) {
  1532. areaNode.empty();
  1533. var identityList = [];
  1534. items.each(function(item){
  1535. new MWF.widget.O2Identity(item.data, areaNode, {"style": "reset"});
  1536. identityList.push(item.data.distinguishedName);
  1537. }.bind(this));
  1538. dlg.identityList = identityList;
  1539. }.bind(this)
  1540. };
  1541. MWF.xDesktop.requireApp("Selector", "package", function(){
  1542. var selector = new MWF.O2Selector(this.app.content, options);
  1543. }.bind(this));
  1544. },
  1545. // selectPeopleDepartment: function(dlg, department, count){
  1546. // var names = dlg.identityList || [];
  1547. // var areaNode = $("resetWork_selPeopleArea");
  1548. // var options = {
  1549. // "names": names,
  1550. // "type": "identity",
  1551. // "count": count,
  1552. // "departments": (department) ? [department.name]: [],
  1553. // "title": this.app.lp.reset,
  1554. // "onComplete": function (items) {
  1555. // areaNode.empty();
  1556. // var identityList = [];
  1557. // items.each(function(item){
  1558. // var explorer = {
  1559. // "actions": this.personActions,
  1560. // "app": {"lp": this.app.lp}
  1561. // };
  1562. // new MWF.widget.Identity(item.data, areaNode, explorer, false, null, {"style": "reset"});
  1563. // identityList.push(item.data.name);
  1564. // }.bind(this));
  1565. // dlg.identityList = identityList;
  1566. // }.bind(this)
  1567. // };
  1568. //
  1569. // var selector = new MWF.OrgSelector(this.app.content, options);
  1570. // },
  1571. // selectPeopleCompany: function(dlg, company, count){
  1572. // var names = dlg.identityList || [];
  1573. // var areaNode = $("resetWork_selPeopleArea");
  1574. // var options = {
  1575. // "names": names,
  1576. // "type": "identity",
  1577. // "count": count,
  1578. // "companys": [company.name],
  1579. // "title": this.app.lp.reset,
  1580. // "onComplete": function (items) {
  1581. // areaNode.empty();
  1582. // var identityList = [];
  1583. // items.each(function(item){
  1584. // var explorer = {
  1585. // "actions": this.personActions,
  1586. // "app": {"lp": this.app.lp}
  1587. // };
  1588. // new MWF.widget.Identity(item.data, areaNode, explorer, false, null, {"style": "reset"});
  1589. // identityList.push(item.data.name);
  1590. // }.bind(this));
  1591. // dlg.identityList = identityList;
  1592. // }.bind(this)
  1593. // };
  1594. //
  1595. // var selector = new MWF.Selector(this.app.content, options);
  1596. // },
  1597. selectPeopleAll: function(dlg, count){
  1598. var names = dlg.identityList || [];
  1599. var areaNode = $("resetWork_selPeopleArea");
  1600. var options = {
  1601. "values": names,
  1602. "type": "identity",
  1603. "count": count,
  1604. "title": this.app.lp.reset,
  1605. "onComplete": function (items) {
  1606. areaNode.empty();
  1607. var identityList = [];
  1608. items.each(function(item){
  1609. new MWF.widget.O2Identity(item.data, areaNode, {"style": "reset"});
  1610. identityList.push(item.data.distinguishedName);
  1611. }.bind(this));
  1612. dlg.identityList = identityList;
  1613. }.bind(this)
  1614. };
  1615. MWF.xDesktop.requireApp("Selector", "package", function(){
  1616. var selector = new MWF.O2Selector(this.app.content, options);
  1617. }.bind(this));
  1618. },
  1619. doResetWork: function(dlg){
  1620. var names = dlg.identityList || [];
  1621. if (!names.length){
  1622. this.app.notice(MWF.xApplication.process.Xform.LP.inputResetPeople, "error", dlg.node);
  1623. return false;
  1624. }
  1625. var opinion = $("resetWork_opinion").get("value");
  1626. var nameText = [];
  1627. names.each(function(n){ nameText.push(MWF.name.cn(n)); });
  1628. if (!opinion){
  1629. opinion = MWF.xApplication.process.Xform.LP.resetTo+": "+nameText.join(", ");
  1630. }
  1631. MWF.require("MWF.widget.Mask", function(){
  1632. this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1633. this.mask.loadNode(this.app.content);
  1634. this.fireEvent("beforeReset");
  1635. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeReset");
  1636. this.resetWorkToPeson(names, opinion, function(){
  1637. this.workAction.loadWork(function(workJson){
  1638. this.fireEvent("afterReset");
  1639. if (this.app && this.app.fireEvent) this.app.fireEvent("afterReset");
  1640. this.addResetMessage(workJson.data);
  1641. this.app.notice(MWF.xApplication.process.Xform.LP.resetOk+": "+MWF.name.cns(names).join(", "), "success");
  1642. this.app.close();
  1643. }.bind(this), null, this.businessData.work.id);
  1644. dlg.close();
  1645. if (this.mask) {this.mask.hide(); this.mask = null;}
  1646. }.bind(this), function(xhr, text, error){
  1647. var errorText = error+":"+text;
  1648. if (xhr) errorText = xhr.responseText;
  1649. this.app.notice("request json error: "+errorText, "error", dlg.node);
  1650. if (this.mask) {this.mask.hide(); this.mask = null;}
  1651. }.bind(this));
  1652. }.bind(this));
  1653. //var data = {
  1654. // "opinion": opinion,
  1655. // "routeName": MWF.xApplication.process.Xform.LP.reset,
  1656. // "identityList": names
  1657. //}
  1658. //
  1659. //this.workAction.resetWork(function(json){
  1660. //
  1661. //}.bind(this), null, this.businessData.task.id, data);
  1662. },
  1663. resetWorkToPeson: function(identityList, opinion, success, failure){
  1664. var data = {
  1665. "opinion": opinion,
  1666. "routeName": MWF.xApplication.process.Xform.LP.reset,
  1667. "identityList": identityList
  1668. };
  1669. this.saveFormData(
  1670. function(json){
  1671. this.workAction.resetWork(
  1672. function(json){
  1673. if (success) success(json);
  1674. }.bind(this),
  1675. function(xhr, text, error){
  1676. if (failure) failure(xhr, text, error);
  1677. },
  1678. this.businessData.task.id, data
  1679. );
  1680. }.bind(this),
  1681. function(xhr, text, error){
  1682. if (failure) failure(xhr, text, error);
  1683. }, true, null, true
  1684. );
  1685. },
  1686. addAddSplitMessage: function(data){
  1687. var content = "";
  1688. if (data && data.length){
  1689. data.each(function(work){
  1690. var users = [];
  1691. work.taskList.each(function(task){
  1692. users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  1693. }.bind(this));
  1694. 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>";
  1695. }.bind(this));
  1696. }else{
  1697. content += MWF.xApplication.process.Xform.LP.workCompleted;
  1698. }
  1699. //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>";
  1700. var msg = {
  1701. "subject": MWF.xApplication.process.Xform.LP.addSplitWork,
  1702. "content": "<div>"+MWF.xApplication.process.Xform.LP.addSplitWorkInfor+"“"+this.businessData.work.title+"”</div>"+content
  1703. };
  1704. layout.desktop.message.addTooltip(msg);
  1705. return layout.desktop.message.addMessage(msg);
  1706. },
  1707. addResetMessage: function(data){
  1708. var users = [];
  1709. data.taskList.each(function(task){
  1710. users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  1711. }.bind(this));
  1712. 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>";
  1713. var msg = {
  1714. "subject": MWF.xApplication.process.Xform.LP.workReset,
  1715. "content": "<div>"+MWF.xApplication.process.Xform.LP.resetWorkInfor+"“"+this.businessData.work.title+"”</div>"+content
  1716. };
  1717. layout.desktop.message.addTooltip(msg);
  1718. return layout.desktop.message.addMessage(msg);
  1719. },
  1720. retractWork: function(e, ev){
  1721. var _self = this;
  1722. if (this.json.mode=="Mobile"){
  1723. if (window.confirm(MWF.xApplication.process.Xform.LP.retractText)){
  1724. _self.app.content.mask({
  1725. "style": {
  1726. "background-color": "#999",
  1727. "opacity": 0.6
  1728. }
  1729. });
  1730. MWF.require("MWF.widget.Mask", function(){
  1731. _self.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1732. _self.mask.loadNode(_self.app.content);
  1733. _self.fireEvent("beforeRetract");
  1734. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeRetract");
  1735. _self.doRetractWork(function(){
  1736. //_self.workAction.getJobByWork(function(workJson){
  1737. _self.fireEvent("afterRetract");
  1738. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterRetract");
  1739. _self.app.notice(MWF.xApplication.process.Xform.LP.workRetract, "success");
  1740. _self.app.content.unmask();
  1741. _self.app.reload();
  1742. //}, null, _self.businessData.work.id);
  1743. // var uri = new URI(window.location.href);
  1744. // var redirectlink = uri.getData("redirectlink");
  1745. // if( redirectlink ){
  1746. // window.location = decodeURIComponent(redirectlink);
  1747. // }else{
  1748. // window.location = "appMobile.html?app=process.TaskCenter";
  1749. // }
  1750. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  1751. }.bind(this), function(xhr, text, error){
  1752. _self.app.content.unmask();
  1753. var errorText = error+":"+text;
  1754. if (xhr) errorText = xhr.responseText;
  1755. _self.app.notice("request json error: "+errorText, "error");
  1756. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  1757. });
  1758. }.bind(this));
  1759. }
  1760. }else{
  1761. var p = MWF.getCenterPosition(this.app.content, 300, 150);
  1762. var event = {
  1763. "event":{
  1764. "x": p.x,
  1765. "y": p.y-200,
  1766. "clientX": p.x,
  1767. "clientY": p.y-200
  1768. }
  1769. };
  1770. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.retractTitle, MWF.xApplication.process.Xform.LP.retractText, 300, 120, function(){
  1771. _self.app.content.mask({
  1772. "style": {
  1773. "background-color": "#999",
  1774. "opacity": 0.6
  1775. }
  1776. });
  1777. MWF.require("MWF.widget.Mask", function(){
  1778. _self.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1779. _self.mask.loadNode(_self.app.content);
  1780. _self.fireEvent("beforeRetract");
  1781. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeRetract");
  1782. _self.doRetractWork(function(){
  1783. //_self.workAction.getJobByWork(function(workJson){
  1784. _self.fireEvent("afterRetract");
  1785. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterRetract");
  1786. _self.app.notice(MWF.xApplication.process.Xform.LP.workRetract, "success");
  1787. _self.app.content.unmask();
  1788. _self.app.reload();
  1789. //}, null, _self.businessData.work.id);
  1790. this.close();
  1791. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  1792. }.bind(this), function(xhr, text, error){
  1793. _self.app.content.unmask();
  1794. var errorText = error+":"+text;
  1795. if (xhr) errorText = xhr.responseText;
  1796. _self.app.notice("request json error: "+errorText, "error");
  1797. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  1798. });
  1799. }.bind(this));
  1800. //this.close();
  1801. }, function(){
  1802. this.close();
  1803. });
  1804. }
  1805. },
  1806. doRetractWork: function(success, failure){
  1807. if (this.businessData.control["allowRetract"]){
  1808. this.workAction.retractWork(function(json){
  1809. if (success) success();
  1810. }.bind(this), function(xhr, text, error){
  1811. if (failure) failure(xhr, text, error);
  1812. }, this.businessData.work.id);
  1813. }else{
  1814. if (failure) failure(null, "Permission Denied", "");
  1815. }
  1816. },
  1817. addRetractMessage: function(data){
  1818. var users = [];
  1819. data.taskList.each(function(task){
  1820. users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  1821. }.bind(this));
  1822. 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>";
  1823. var msg = {
  1824. "subject": MWF.xApplication.process.Xform.LP.workRetract,
  1825. "content": "<div>"+MWF.xApplication.process.Xform.LP.retractWorkInfor+"“"+this.businessData.work.title+"”</div>"+content
  1826. };
  1827. layout.desktop.message.addTooltip(msg);
  1828. return layout.desktop.message.addMessage(msg);
  1829. },
  1830. rerouteWork: function(e, ev){
  1831. if (!this.businessData.control["allowReroute"]){
  1832. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "Permission Denied");
  1833. return false;
  1834. }
  1835. MWF.require("MWF.xDesktop.Dialog", function(){
  1836. var width = 480;
  1837. var height = 160;
  1838. var p = MWF.getCenterPosition(this.app.content, width, height);
  1839. var _self = this;
  1840. var dlg = new MWF.xDesktop.Dialog({
  1841. "title": this.app.lp.reroute,
  1842. "style": "work",
  1843. "top": p.y-100,
  1844. "left": p.x,
  1845. "fromTop": p.y-100,
  1846. "fromLeft": p.x,
  1847. "width": width,
  1848. "height": height,
  1849. "url": this.app.path+"reroute.html",
  1850. "container": this.app.content,
  1851. "isClose": true,
  1852. "onPostShow": function(){
  1853. $("rerouteWork_okButton").addEvent("click", function(){
  1854. _self.doRerouteWork(this);
  1855. }.bind(this));
  1856. $("rerouteWork_cancelButton").addEvent("click", function(){
  1857. this.close();
  1858. }.bind(this));
  1859. var select = $("rerouteWork_selectActivity");
  1860. _self.workAction.getRerouteTo(_self.businessData.work.process, function(json){
  1861. json.data.agentList.each(function(activity){
  1862. new Element("option", {
  1863. "value": activity.id+"#agent",
  1864. "text": activity.name
  1865. }).inject(select);
  1866. }.bind(_self));
  1867. json.data.cancelList.each(function(activity){
  1868. new Element("option", {
  1869. "value": activity.id+"#cancel",
  1870. "text": activity.name
  1871. }).inject(select);
  1872. }.bind(_self));
  1873. json.data.choiceList.each(function(activity){
  1874. new Element("option", {
  1875. "value": activity.id+"#choice",
  1876. "text": activity.name
  1877. }).inject(select);
  1878. }.bind(_self));
  1879. // json.data.controllerList.each(function(activity){
  1880. // new Element("option", {
  1881. // "value": activity.id+"#condition",
  1882. // "text": activity.name
  1883. // }).inject(select);
  1884. // }.bind(_self));
  1885. json.data.delayList.each(function(activity){
  1886. new Element("option", {
  1887. "value": activity.id+"#delay",
  1888. "text": activity.name
  1889. }).inject(select);
  1890. }.bind(_self));
  1891. json.data.embedList.each(function(activity){
  1892. new Element("option", {
  1893. "value": activity.id+"#embed",
  1894. "text": activity.name
  1895. }).inject(select);
  1896. }.bind(_self));
  1897. json.data.endList.each(function(activity){
  1898. new Element("option", {
  1899. "value": activity.id+"#end",
  1900. "text": activity.name
  1901. }).inject(select);
  1902. }.bind(_self));
  1903. json.data.invokeList.each(function(activity){
  1904. new Element("option", {
  1905. "value": activity.id+"#invoke",
  1906. "text": activity.name
  1907. }).inject(select);
  1908. }.bind(_self));
  1909. json.data.manualList.each(function(activity){
  1910. new Element("option", {
  1911. "value": activity.id+"#manual",
  1912. "text": activity.name
  1913. }).inject(select);
  1914. }.bind(_self));
  1915. json.data.mergeList.each(function(activity){
  1916. new Element("option", {
  1917. "value": activity.id+"#merge",
  1918. "text": activity.name
  1919. }).inject(select);
  1920. }.bind(_self));
  1921. json.data.messageList.each(function(activity){
  1922. new Element("option", {
  1923. "value": activity.id+"#message",
  1924. "text": activity.name
  1925. }).inject(select);
  1926. }.bind(_self));
  1927. json.data.parallelList.each(function(activity){
  1928. new Element("option", {
  1929. "value": activity.id+"#parallel",
  1930. "text": activity.name
  1931. }).inject(select);
  1932. }.bind(_self));
  1933. json.data.serviceList.each(function(activity){
  1934. new Element("option", {
  1935. "value": activity.id+"#service",
  1936. "text": activity.name
  1937. }).inject(select);
  1938. }.bind(_self));
  1939. json.data.splitList.each(function(activity){
  1940. new Element("option", {
  1941. "value": activity.id+"#split",
  1942. "text": activity.name
  1943. }).inject(select);
  1944. }.bind(_self));
  1945. }.bind(_self));
  1946. }
  1947. });
  1948. dlg.show();
  1949. }.bind(this));
  1950. },
  1951. doRerouteWork: function(dlg){
  1952. var opinion = $("rerouteWork_opinion").get("value");
  1953. var select = $("rerouteWork_selectActivity");
  1954. var activity = select.options[select.selectedIndex].get("value");
  1955. var activityName = select.options[select.selectedIndex].get("text");
  1956. var tmp = activity.split("#");
  1957. activity = tmp[0];
  1958. var type = tmp[1];
  1959. MWF.require("MWF.widget.Mask", function(){
  1960. this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1961. this.mask.loadNode(this.app.content);
  1962. this.fireEvent("beforeReroute");
  1963. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRetract");
  1964. this.rerouteWorkToActivity(activity, type, opinion, function(){
  1965. this.workAction.loadWork(function(workJson){
  1966. this.fireEvent("afterReroute");
  1967. if (this.app && this.app.fireEvent) this.app.fireEvent("afterReroute");
  1968. this.addRerouteMessage(workJson.data);
  1969. this.app.notice(MWF.xApplication.process.Xform.LP.rerouteOk+": "+activityName, "success");
  1970. this.app.close();
  1971. }.bind(this), null, this.businessData.work.id);
  1972. dlg.close();
  1973. if (this.mask) {this.mask.hide(); this.mask = null;}
  1974. }.bind(this), function(xhr, text, error){
  1975. var errorText = error+":"+text;
  1976. if (xhr) errorText = xhr.responseText;
  1977. this.app.notice("request json error: "+errorText, "error", dlg.node);
  1978. if (this.mask) {this.mask.hide(); this.mask = null;}
  1979. }.bind(this));
  1980. }.bind(this));
  1981. },
  1982. rerouteWorkToActivity: function(activity, type, opinion, success, failure){
  1983. if (this.businessData.task){
  1984. this.saveFormData(function(json){
  1985. this.workAction.rerouteWork(function(json){
  1986. if (success) success();
  1987. }.bind(this), function(xhr, text, error){
  1988. if (failure) failure(xhr, text, error);
  1989. }, this.businessData.work.id, activity, type);
  1990. }.bind(this), function(xhr, text, error){
  1991. if (failure) failure(xhr, text, error);
  1992. }, true, null, true);
  1993. }else{
  1994. this.workAction.rerouteWork(function(json){
  1995. if (success) success();
  1996. }.bind(this), function(xhr, text, error){
  1997. if (failure) failure(xhr, text, error);
  1998. }, this.businessData.work.id, activity, type);
  1999. }
  2000. },
  2001. addRerouteMessage: function(data){
  2002. var users = [];
  2003. data.taskList.each(function(task){
  2004. users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  2005. }.bind(this));
  2006. 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>";
  2007. var msg = {
  2008. "subject": MWF.xApplication.process.Xform.LP.workReroute,
  2009. "content": "<div>"+MWF.xApplication.process.Xform.LP.rerouteWorkInfor+"“"+this.businessData.work.title+"”</div>"+content
  2010. };
  2011. layout.desktop.message.addTooltip(msg);
  2012. return layout.desktop.message.addMessage(msg);
  2013. },
  2014. deleteWork: function(){
  2015. var _self = this;
  2016. if (this.json.mode === "Mobile"){
  2017. if (window.confirm(MWF.xApplication.process.Xform.LP.deleteWorkText.text)){
  2018. MWF.require("MWF.widget.Mask", function(){
  2019. _self.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  2020. _self.mask.loadNode(_self.app.content);
  2021. _self.fireEvent("beforeDelete");
  2022. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeDelete");
  2023. _self.doDeleteWork(function(){
  2024. _self.fireEvent("s");
  2025. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterDelete");
  2026. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete+": “"+_self.businessData.work.title+"”", "success");
  2027. _self.app.close();
  2028. //if (layout.mobile){
  2029. var uri = new URI(window.location.href);
  2030. var redirectlink = uri.getData("redirectlink");
  2031. if( redirectlink ){
  2032. window.location = decodeURIComponent(redirectlink);
  2033. }else{
  2034. window.location = "appMobile.html?app=process.TaskCenter";
  2035. }
  2036. //}
  2037. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  2038. }.bind(this),function(xhr, text, error){
  2039. var errorText = error+":"+text;
  2040. if (xhr) errorText = xhr.responseText;
  2041. _self.app.notice("request json error: "+errorText, "error", dlg.node);
  2042. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  2043. }.bind(this));
  2044. }.bind(this));
  2045. }
  2046. }else{
  2047. var p = MWF.getCenterPosition(this.app.content, 380, 150);
  2048. var event = {
  2049. "event":{
  2050. "x": p.x,
  2051. "y": p.y-200,
  2052. "clientX": p.x,
  2053. "clientY": p.y-200
  2054. }
  2055. };
  2056. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText, 380, 120, function(){
  2057. // _self.app.content.mask({
  2058. // "style": {
  2059. // "background-color": "#999",
  2060. // "opacity": 0.6
  2061. // }
  2062. // });
  2063. MWF.require("MWF.widget.Mask", function(){
  2064. _self.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  2065. _self.mask.loadNode(_self.app.content);
  2066. _self.fireEvent("beforeDelete");
  2067. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeDelete");
  2068. _self.doDeleteWork(function(){
  2069. _self.fireEvent("s");
  2070. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterDelete");
  2071. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete+": “"+_self.businessData.work.title+"”", "success");
  2072. _self.app.close();
  2073. this.close();
  2074. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  2075. }.bind(this),function(xhr, text, error){
  2076. var errorText = error+":"+text;
  2077. if (xhr) errorText = xhr.responseText;
  2078. _self.app.notice("request json error: "+errorText, "error", dlg.node);
  2079. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  2080. }.bind(this));
  2081. }.bind(this));
  2082. //_self.workAction.deleteWork(function(json){
  2083. // _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete+": “"+_self.businessData.work.title+"”", "success");
  2084. // _self.app.close();
  2085. // this.close();
  2086. //}.bind(this), null, _self.businessData.work.id);
  2087. //this.close();
  2088. }, function(){
  2089. this.close();
  2090. }, null, this.app.content);
  2091. }
  2092. },
  2093. doDeleteWork: function(success, failure){
  2094. if (this.businessData.control["allowDelete"]){
  2095. this.workAction.deleteWork(function(json){
  2096. if (success) success(json);
  2097. }.bind(this), function(xhr, text, error){
  2098. if (failure) failure(xhr, text, error);
  2099. }, this.businessData.work.id);
  2100. }else{
  2101. if (failure) failure(null, "Permission Denied", "");
  2102. }
  2103. },
  2104. //printWork: function(){
  2105. // var form = this.json.id;
  2106. // if (this.json.printForm){
  2107. // form = this.json.printForm;
  2108. // }
  2109. // window.open("/x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form);
  2110. //},
  2111. printWork: function(app, form){
  2112. var application = app || (this.businessData.work) ? this.businessData.work.application : this.businessData.workCompleted.application;
  2113. var form = form;
  2114. if (!form){
  2115. form = this.json.id;
  2116. if (this.json.printForm) form = this.json.printForm;
  2117. }
  2118. if (this.businessData.workCompleted){
  2119. var application = app || this.businessData.workCompleted.application;
  2120. window.open("/x_desktop/printWork.html?workCompletedId="+this.businessData.workCompleted.id+"&app="+application+"&form="+form);
  2121. }else{
  2122. var application = app || this.businessData.work.application;
  2123. window.open("/x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+application+"&form="+form);
  2124. }
  2125. },
  2126. readedWork: function(e){
  2127. var _self = this;
  2128. var text = "您确定要将“"+this.businessData.work.title+"”标记为已阅吗?"
  2129. this.app.confirm("infor", e, "标记已阅确认", text, 350, 150, function(){
  2130. var read = null;
  2131. for (var i=0; i<_self.businessData.readList.length; i++){
  2132. if (_self.businessData.readList[i].person === layout.session.user.distinguishedName){
  2133. read = _self.businessData.readList[i];
  2134. break;
  2135. }
  2136. }
  2137. if (read){
  2138. _self.app.action.setReaded(function(){
  2139. _self.app.reload();
  2140. }.bind(_self), null, read.id, read);
  2141. }else{
  2142. _self.app.reload();
  2143. }
  2144. this.close();
  2145. }, function(){
  2146. this.close();
  2147. }, null, this.app.content);
  2148. },
  2149. openWindow: function(form, app){
  2150. //var application = app || (this.businessData.work) ? this.businessData.work.application : this.businessData.workCompleted.application;
  2151. var form = form;
  2152. if (!form){
  2153. form = this.json.id;
  2154. //if (this.json.printForm) form = this.json.printForm;
  2155. }
  2156. if (this.businessData.workCompleted){
  2157. var application = app || this.businessData.workCompleted.application;
  2158. window.open("/x_desktop/printWork.html?workCompletedId="+this.businessData.workCompleted.id+"&app="+application+"&form="+form);
  2159. }else{
  2160. var application = app || this.businessData.work.application;
  2161. window.open("/x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+application+"&form="+form);
  2162. }
  2163. //window.open("/x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form);
  2164. },
  2165. uploadedAttachment: function(site, id){
  2166. this.workAction.getAttachment(id, this.businessData.work.id, function(json){
  2167. var att = this.all[site];
  2168. if (att){
  2169. if (json.data) att.attachmentController.addAttachment(json.data);
  2170. att.attachmentController.checkActions();
  2171. att.fireEvent("upload", [json.data]);
  2172. }
  2173. }.bind(this));
  2174. },
  2175. replacedAttachment: function(site, id){
  2176. this.workAction.getAttachment(id, this.businessData.work.id, function(json){
  2177. var att = this.all[site];
  2178. if (att){
  2179. var attachmentController = att.attachmentController;
  2180. var attachment = null;
  2181. for (var i=0; i<attachmentController.attachments.length; i++){
  2182. if (attachmentController.attachments[i].data.id===id){
  2183. attachment = attachmentController.attachments[i];
  2184. break;
  2185. }
  2186. }
  2187. attachment.data = json.data;
  2188. attachment.reload();
  2189. attachmentController.checkActions();
  2190. }
  2191. }.bind(this))
  2192. }
  2193. });