Main.js 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840
  1. MWF.xApplication.process.workcenter.options.multitask = false;
  2. MWF.xApplication.process.workcenter.Main = new Class({
  3. Extends: MWF.xApplication.Common.Main,
  4. Implements: [Options, Events],
  5. options: {
  6. "style1": "default",
  7. "style": "default",
  8. "name": "process.workcenter",
  9. "mvcStyle": "style.css",
  10. "icon": "icon.png",
  11. "title": MWF.xApplication.process.workcenter.LP.title
  12. },
  13. onQueryLoad: function(){
  14. this.lp = MWF.xApplication.process.workcenter.LP;
  15. this.action = o2.Actions.load("x_processplatform_assemble_surface");
  16. },
  17. loadApplication: function(callback){
  18. var url = this.path+this.options.style+"/view/view.html";
  19. this.content.loadHtml(url, {"bind": {"lp": this.lp}, "module": this}, function(){
  20. this.setLayout();
  21. this.loadCount();
  22. var list = (this.status) ? (this.status.navi || "task") : "task";
  23. this.loadList(list, null, callback);
  24. // if (callback) callback();
  25. }.bind(this));
  26. },
  27. setLayout: function(){
  28. var items = this.content.getElements(".menuItem");
  29. items.addEvents({
  30. "mouseover": function(){this.addClass("menuItem_over")},
  31. "mouseout": function(){this.removeClass("menuItem_over")},
  32. "click": function(){}
  33. });
  34. },
  35. createCountData: function(){
  36. var _self = this;
  37. if (!this.countData){
  38. this.countData = {"data": {}};
  39. var createDefineObject = function(p){
  40. return {
  41. "get": function(){return this.data[p]},
  42. "set": function(v){
  43. this.data[p] = v;
  44. _self[p+"CountNode"].set("text", v);
  45. }
  46. }
  47. };
  48. var o = {
  49. "task": createDefineObject("task"),
  50. "taskCompleted": createDefineObject("taskCompleted"),
  51. "read": createDefineObject("read"),
  52. "readCompleted": createDefineObject("readCompleted"),
  53. "draft": createDefineObject("draft"),
  54. "review": createDefineObject("review"),
  55. "myCreated": createDefineObject("myCreated"),
  56. };
  57. MWF.defineProperties(this.countData, o);
  58. }
  59. },
  60. loadCount: function(){
  61. this.createCountData();
  62. this.action.WorkAction.countWithPerson(layout.session.user.id).then(function(json){
  63. this.countData.task = json.data.task;
  64. this.countData.taskCompleted = json.data.taskCompleted;
  65. this.countData.read = json.data.read;
  66. this.countData.readCompleted = json.data.readCompleted;
  67. this.countData.review = json.data.review;
  68. // this.pageData = Object.assign(this.pageData, json.data);
  69. // this.taskCountNode.set("text", json.data.task);
  70. // this.taskCompletedCountNode.set("text", json.data.taskCompleted);
  71. // this.readCountNode.set("text", json.data.read);
  72. // this.readCompletedCountNode.set("text", json.data.readCompleted);
  73. }.bind(this));
  74. this.action.DraftAction.listMyPaging(1,1, {}).then(function(json){
  75. this.countData.draft = json.count;
  76. // this.pageData = Object.assign(this.pageData, {"draft": json.size});
  77. // this.draftCountNode.set("text", json.size);
  78. }.bind(this));
  79. this.action.ReviewAction.countWithPerson(layout.session.user.id, {
  80. creatorPersonList: [layout.session.user.id]
  81. }).then(function(json){
  82. this.countData.myCreated = json.data.count;
  83. }.bind(this));
  84. },
  85. loadList: function(type, e, callback){
  86. if (this.currentMenu) this.setMenuItemStyleDefault(this.currentMenu);
  87. this.setMenuItemStyleCurrent(this[type+"MenuNode"]);
  88. this.currentMenu = this[type+"MenuNode"];
  89. if (this.currentList) this.currentList.hide();
  90. this.showSkeleton();
  91. this._loadListContent(type, callback);
  92. this.loadCount();
  93. //if (this.currentList) this.currentList.loadPage();
  94. },
  95. showSkeleton: function(){
  96. if (this.skeletonNode) this.skeletonNode.inject(this.listContentNode);
  97. },
  98. hideSkeleton: function(){
  99. if (this.skeletonNode) this.skeletonNode.dispose();
  100. },
  101. _loadListContent: function(type, callback){
  102. var list = this[(type+"-list").camelCase()];
  103. if (!list){
  104. list = new MWF.xApplication.process.workcenter[type.capitalize()+"List"](this, { "onLoadData": this.hideSkeleton.bind(this) });
  105. this[(type+"-list").camelCase()] = list;
  106. }
  107. list.init();
  108. list.load(callback);
  109. this.currentList = list;
  110. },
  111. setMenuItemStyleDefault: function(node){
  112. node.removeClass("mainColor_bg_opacity");
  113. node.getFirst().removeClass("mainColor_color");
  114. node.getLast().removeClass("mainColor_color");
  115. },
  116. setMenuItemStyleCurrent: function(node){
  117. node.addClass("mainColor_bg_opacity");
  118. node.getFirst().addClass("mainColor_color");
  119. node.getLast().addClass("mainColor_color");
  120. },
  121. getApplicationIcon: function(application){
  122. var icon = (this.appIcons) ? this.appIcons[application] : null;
  123. if (!icon) {
  124. return this.action.ApplicationAction.getIcon(application).then(function(json){
  125. if (json.data){
  126. if (!this.appIcons) this.appIcons = {};
  127. this.appIcons[application] = json.data;
  128. return json.data;
  129. }
  130. return this.getDefaultIcon();
  131. }.bind(this), function(){
  132. return this.getDefaultIcon();
  133. });
  134. }else{
  135. return icon;
  136. }
  137. },
  138. getDefaultIcon: function(){
  139. return {
  140. "icon": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAEgElEQVR4Xu1aPXMTSRB9vUaGQqs6iCgi4Bfgq7I2lqWrSwgQMQHyPzAJIeguvOT4BxbBxYjgkquTrFiiCvkXYCKKCFMSFEjs9tWsrEKWvTtfuyvXrTbd6ZnuN69fz842IecP5Tx+rAFYMyDnCKxTYBUE4MrWta9UuLu49hWeHlJveJy1P6kzQAT7eWPzPgN1MFeI6FpckMx8DKIeAe2iP3mVNiipADALuvAIQAOgLbtd5SGAVtGfvkgDjMQB+Fz1ngXgPdlO64IimOGAnhe7/d90bePGJwbAuOY9AqMJwu0kHTwzF+MIhKbb6b9IYh1rAATdxxub+yRyPMOHgbbrT3Zt08IKgHGlvIUN7NvnuSlyPISPXbc3EDph9BgDMPplu4KAXiad67pRhFXD4Qelf1/3dG3FeCMARPDEzoHJgmnZMAU7JiBoAyBozw4OVr3zy0AKJlCAHd100ALgpL4frC7nZfzhYdGf7ugIoxYAo5r3Mmu1l4V8hglAu9TpP1C1UwZgXC03QLSvOvFKxzHvut1BS8UHDQC8t6kfclQ8VhnDOHK7/TsqQ5UAGFW9JhGeqUy4PIZu3AR/eG9iChtbcPDY7b5+LltYCkB40nMKb01U/9Kv93D5yVN8++N3fP/nb5kvp97b2IqJRFVwg+kdmSBKARhXt/dAzp9a3gOYBzC30wHBxvaUnwoskANQK7/RLXvLAeiAYGN7dpN46HYGP8dtXiwAJ5cZH3V2X+Tt1b/akSZxTIgKfj7Zl4d1bT0p+pPrcWkQC4Bp6ZMFch4IJjZKGyMpibEAjGpem4D7SgstDdIJSGesri8MvCp1+pGf6vEAVMsfTdR/7qRKYGKsqBRRj454njeHqAal7uB61PzxKVDzWBfx5fEyEOLmtw1+Prfb6UfGGfnCRACjgjEBIanghU9GACT9za8DQpLBh4eimLuCSAYkDYBwRAWEpINfA3BRGKCy+zonRh1xNkqB3IugQHic5zIoABjVyscE+kmHbotjZbQXgpf6QQj8qdQZRP6QXR+F43Y39x9DJkL4v/ocDoWw6g1BONXNIdMEm0sNG9szfjEO3W4/tj9BfiOU9yux2e/vwpFJNbC52LSxDY+/4E+uP71tfSkalsM8X4vP82pc9URnxi1Z/l+I94x3brev1Kki1YAfAOT819jsZGh+R5gVM2R3gMt+KDMgFBbR/uZs9nTLYlbBg3FYDCYVmfAt+qMFQHguEA0SG+iZVIU0gRCqTz4qqTZIzANI47bIFpzMWmQWQQBTe9VMEDsP4rpJf5CIRTsFFncqbJNzqLUyTWAcIuCGLu2tNGCZqieNki3TP0im1Bdq7/qTho7gnbeWFQNOsUG00IBEq2y6hyXGO4Cbqi0wMoATA+DHgWl7j4maSWtDqPIsApd3fciCTjQFzltsdl641ACchrU+iDxH0CoG31u2dE81BaJQn4FRqDNRXRylZMwIVR3UI+Z2MZi20wg6dQaoUDDsNV54TMuYylpxYxLXAFuHsrZfA5A14hdtvTUDLtqOZO1P7hnwH8CljF98DV13AAAAAElFTkSuQmCC",
  141. "iconHue": "#4e82bd"
  142. };
  143. },
  144. firstPage: function(){
  145. if (this.currentList) this.currentList.firstPage();
  146. },
  147. lastPage: function(){
  148. if (this.currentList) this.currentList.lastPage();
  149. },
  150. prevPage: function(){
  151. if (this.currentList) this.currentList.prevPage();
  152. },
  153. nextPage: function(){
  154. if (this.currentList) this.currentList.nextPage();
  155. },
  156. getFilterData: function(){
  157. var type = this.currentList.options.type.capitalize();
  158. switch (type) {
  159. case "MyCreated":
  160. return this.action.ReviewAction.filterCreateEntry().then(function(json){return json.data});
  161. case "Review":
  162. return this.action.ReviewAction.filterEntry().then(function(json){return json.data});
  163. default:
  164. var action = type+"Action";
  165. return this.action[action].filterAttribute().then(function(json){return json.data});
  166. }
  167. },
  168. showFilter: function(e){
  169. //console.log(this.filterDlg);
  170. if (this.filterDlg) return;
  171. var node = e.target;
  172. var p = node.getPosition(this.content);
  173. var size = node.getSize();
  174. var y = p.y+size.y+10;
  175. var x = p.x-600+size.x;
  176. var fx = p.x+size.x;
  177. var filterContent = new Element("div");
  178. var url = this.path+this.options.style+"/view/dlg/filter.html";
  179. this.getFilterData().then(function(data){
  180. if (data.completedList) {
  181. data.completedList.forEach(function (item) {
  182. item.name = (item.name === "completed") ? this.lp.completed : this.lp.processing;
  183. }.bind(this));
  184. }
  185. this.currentList.filterAttribute = data;
  186. var filterCategoryList = ['review','myCreated'].contains(this.currentList.options.type) ? this.lp.filterCategoryListReview : this.lp.filterCategoryList;
  187. filterContent.loadHtml(url, {"bind": {"lp": this.lp, "type": this.options.type, "data": data, filter: this.currentList.filterList, filterCategoryList: filterCategoryList}, "module": this})
  188. }.bind(this));
  189. var _self = this;
  190. var closeFilterDlg = function(){
  191. _self.filterDlg.close();
  192. }
  193. this.filterDlg = o2.DL.open({
  194. "container": this.content,
  195. "mask": false,
  196. "title": "",
  197. "style": "user",
  198. "isMove": false,
  199. "isResize": false,
  200. "isTitle": false,
  201. "content": filterContent,
  202. "maskNode": this.content,
  203. "top": y,
  204. "left": x,
  205. "fromTop": y,
  206. "fromLeft": fx,
  207. "width": 600,
  208. "height": 550,
  209. "duration": 100,
  210. // "onQueryClose": function(){
  211. // document.body.removeEvent("mousedown", closeFilterDlg);
  212. // },
  213. "onPostClose": function(){
  214. document.body.removeEvent("mousedown", closeFilterDlg);
  215. _self.filterDlg = null;
  216. },
  217. "buttonList": [
  218. {
  219. "type": "ok",
  220. "text": MWF.LP.process.button.ok,
  221. "action": function (d, e) {
  222. _self.doFilter();
  223. }.bind(this)
  224. },
  225. {
  226. "type": "cancel",
  227. "text": MWF.LP.process.button.reset,
  228. "action": function () {
  229. debugger;
  230. _self.resetFilter();
  231. this.filterDlg.close();
  232. }.bind(this)
  233. }
  234. ],
  235. });
  236. this.filterDlg.node.addEvent("mousedown", function(e){
  237. e.stopPropagation();
  238. });
  239. document.body.addEvent("mousedown", closeFilterDlg);
  240. },
  241. selectFilterItem: function(name, value, category, e){
  242. var node = e.target;
  243. // var value = node.dataset.value;
  244. // var category = node.dataset.category;
  245. if (!this.currentList.filterList) this.currentList.filterList = {};
  246. if (!this.currentList.filterList[category]) this.currentList.filterList[category] = [];
  247. if (!this.currentList.filterNameList) this.currentList.filterNameList = {};
  248. if (!this.currentList.filterNameList[category]) this.currentList.filterNameList[category] = [];
  249. var findedIdx = this.currentList.filterList[category].indexOf(value);
  250. if (findedIdx===-1){
  251. node.addClass("mainColor_bg");
  252. this.currentList.filterList[category].push(value);
  253. this.currentList.filterNameList[category].push(name)
  254. }else{
  255. node.removeClass("mainColor_bg");
  256. this.currentList.filterList[category].splice(findedIdx, 1);
  257. this.currentList.filterNameList[category].splice(findedIdx, 1);
  258. }
  259. },
  260. resetFilter: function(){
  261. this.currentList.page = 1;
  262. this.currentList.filterList = {};
  263. this.currentList.filterNameList = {};
  264. this.currentList.refresh();
  265. },
  266. doFilter: function(){
  267. debugger;
  268. var key = this.filterDlg.content.getElement("input").get("value");
  269. if (key) {
  270. if (!this.currentList.filterList) this.currentList.filterList = {};
  271. if (!this.currentList.filterNameList) this.currentList.filterNameList = {};
  272. this.currentList.filterList.key = key;
  273. this.currentList.filterNameList.key = [key];
  274. }
  275. this.currentList.page = 1;
  276. this.currentList.refresh();
  277. this.filterDlg.close();
  278. },
  279. inputFilter: function(e){
  280. if (e.keyCode==13) this.doFilter();
  281. },
  282. getStartData: function(){
  283. // var p1 = this.action.ApplicationAction.listWithPersonComplex().then(function(json){return json.data});
  284. var p1 = o2.Actions.load("x_processplatform_assemble_surface").ApplicationAction.listWithPersonAndTerminal("client").then(function(json){return json.data;});
  285. var p2 = new Promise(function(resolve){
  286. o2.UD.getDataJson("taskCenter_startTop", function(data){
  287. resolve(data);
  288. });
  289. });
  290. var p3 = o2.Actions.load("x_cms_assemble_control").AppInfoAction.listPublishWithProcess().then(function(json){return json.data;});
  291. return Promise.all([p1, p2, p3]);
  292. },
  293. closeStartProcess: function(e){
  294. e.target.getParent(".st_area").destroy();
  295. this.appNode.show();
  296. },
  297. startProcess: function(){
  298. var startContent = new Element("div.st_area");
  299. var url = this.path+this.options.style+"/view/dlg/start.html";
  300. this.getStartData().then(function(data){
  301. var map = {}, mapById = {};
  302. data[0].each(function (d) {
  303. if (d.processList && d.processList.length){
  304. var type = d.applicationCategory || "未分类";
  305. if( !map[type] )map[type] = [];
  306. map[type].push(d);
  307. d.processList.each(function (process) {
  308. mapById[ process.id ] = process;
  309. });
  310. }
  311. });
  312. data[2].each(function (d) {
  313. var type = d.appType || "未分类";
  314. if( !map[type] )map[type] = [];
  315. map[type].push(d);
  316. });
  317. data[1] = (data[1] || []).filter(function (d) {
  318. if( mapById[ d.id ] ){
  319. d.name = mapById[ d.id ].name;
  320. return true;
  321. }else{
  322. return false;
  323. }
  324. });
  325. var array = [];
  326. Object.each(map, function (list, key) {
  327. array.push({ key: key, appList: list })
  328. });
  329. array.sort(function (a1, b1) {
  330. var a = a1.key, b = b1.key;
  331. if( a === "未分类" )return 1;
  332. if( b === "未分类" )return -1;
  333. var n = !isNaN(a - 0), n2 = !isNaN(b - 0);
  334. if (n && n2) {
  335. return a - b;
  336. } else if (n) {
  337. return -1;
  338. } else if (n2) {
  339. return 1;
  340. }
  341. var e = escape(a).indexOf("%u") === 0, e2 = escape(b).indexOf("%u") === 0;
  342. if (e && e2) {
  343. return a.localeCompare(b);
  344. } else if (e) {
  345. return 1;
  346. } else if (e2) {
  347. return -1;
  348. }
  349. return a.localeCompare(b);
  350. });
  351. startContent.loadHtml(url, {"bind": {"lp": this.lp, "data": {"app": data[0], "topApp": data[1], "column": data[2], "appByType":array}}, "module": this});
  352. }.bind(this));
  353. this.appNode.hide();
  354. startContent.inject(this.content);
  355. },
  356. loadStartProcessList: function(e, data){
  357. var node = e.target;
  358. var url = this.path+this.options.style+"/view/dlg/processList.html";
  359. node.loadHtml(url, {"bind": {"lp": this.lp, "data": data}, "module": this});
  360. },
  361. appCategoryExpandOrCollapse: function(e, data){
  362. var node = e.target;
  363. while (node && !node.hasClass("st_appCategoryWrap")){ node = node.getParent();}
  364. if( node ){
  365. var contentNode = node.getElement(".st_appCategoryContent");
  366. if( contentNode ){
  367. if( contentNode.getStyle("display") === "none" ){
  368. contentNode.show();
  369. e.target.addClass("o2icon-triangle_down2").removeClass("o2icon-triangle_right2");
  370. }else{
  371. contentNode.hide();
  372. e.target.addClass("o2icon-triangle_right2").removeClass("o2icon-triangle_down2");
  373. }
  374. }
  375. }
  376. e.stopPropagation();
  377. },
  378. startAppItemOver: function(e, data){
  379. var node = e.target;
  380. while (node && !node.hasClass("st_appListItem")){ node = node.getParent();}
  381. if (node) node.addClass("menuItem_over");
  382. },
  383. startAppItemOut: function(e, data){
  384. var node = e.target;
  385. while (node && !node.hasClass("st_appListItem")){ node = node.getParent();}
  386. if (node) node.removeClass("menuItem_over");
  387. },
  388. startAppItemClick: function(e, data){
  389. var node = e.target;
  390. this.clearStartAppSelected(e);
  391. while (node && !node.hasClass("st_appListItem")){ node = node.getParent();}
  392. node.addClass("mainColor_bg_opacity");
  393. if( node.hasClass("st_tabItem") ){
  394. node.addClass("mainColor_border");
  395. if( node.hasClass("st_all") ){
  396. this.currentTab = "all";
  397. this.byTypeNode.removeClass("mainColor_border");
  398. this.allContentNode.show();
  399. this.byTypeContentNode.hide();
  400. }else{
  401. this.currentTab = "byType";
  402. this.allNode.removeClass("mainColor_border");
  403. this.allContentNode.hide();
  404. this.byTypeContentNode.show();
  405. }
  406. }
  407. var appData;
  408. if(data.appList) {
  409. appData = {
  410. "app": data.appList.filter(function (d) {
  411. return !d.appName
  412. }),
  413. "column": data.appList.filter(function (d) {
  414. return d.appName
  415. }),
  416. };
  417. }else if(data.app){
  418. appData = data;
  419. }else if( data.appName ) {
  420. appData = {"column": [data]}
  421. }else{
  422. appData = {"app": [data]}
  423. }
  424. this.reloadStartProcessList(node, appData);
  425. },
  426. clearStartAppSelected: function(e){
  427. var node = e.target.getParent(".st_menu").getElement(".mainColor_bg_opacity");
  428. if (node) node.removeClass("mainColor_bg_opacity");
  429. },
  430. reloadStartProcessList: function(node, data){
  431. var processListNode = node.getParent(".st_processContent").getElement(".st_processList").empty();
  432. var url = this.path+this.options.style+"/view/dlg/processList.html";
  433. processListNode.loadHtml(url, {"bind": {"lp": this.lp, "data": data}, "module": this});
  434. },
  435. startProcessSearch: function(e, data){
  436. if (e.keyCode===13){
  437. var key = e.target.get("value");
  438. if (key){
  439. var name = this.lp.searchProcessResault.replace("{key}", key);
  440. var processList = [];
  441. data.app.forEach(function(app){
  442. app.processList.forEach(function(process){
  443. if (process.name.indexOf(key)!==-1){
  444. processList.push(process);
  445. }
  446. });
  447. });
  448. var categoryList = [];
  449. data.column.forEach(function(column){
  450. column.wrapOutCategoryList.forEach(function(category){
  451. if (category.categoryName.indexOf(key)!==-1){
  452. categoryList.push(category);
  453. }
  454. });
  455. });
  456. this.clearStartAppSelected(e);
  457. e.target.getParent(".st_search").addClass("mainColor_bg_opacity");
  458. this.reloadStartProcessList(e.target, {
  459. app: [{ name: name, processList: processList }],
  460. column: [{ wrapOutCategoryList: categoryList }]
  461. });
  462. }else{
  463. this.clearStartProcessSearch(e);
  464. }
  465. }
  466. },
  467. loadColumnItemIcon: function(columnId, e, data){
  468. var node = e.currentTarget;
  469. if (data.appIcon){
  470. node.setStyle("background-image", "url(data:image/png;base64,"+data.appIcon+")");
  471. }else{
  472. node.setStyle("background-image", "url("+"../x_component_process_ApplicationExplorer/$Main/default/icon/application.png)");
  473. }
  474. },
  475. startCategoryItemClick: function(e, data){
  476. if( !data.categoryId ){
  477. data.categoryId = data.id;
  478. data.id = data.workflowFlag;
  479. if( !data.name )data.name = data.categoryName;
  480. }
  481. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  482. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(data, this, {
  483. "workData": {
  484. "cmsDocument" : {
  485. "isNewDocument" : true,
  486. "title": this.lp.unnamed,
  487. // "creatorIdentity": data.identity,
  488. // "identity": data.identity,
  489. "appId" : data.appId,
  490. "categoryId" : data.categoryId,
  491. "docStatus" : "draft",
  492. "categoryName" : data.categoryName,
  493. "categoryAlias" : data.categoryAlias,
  494. "createTime": new Date().format("db"),
  495. "attachmentList" : []
  496. }
  497. },
  498. "onBeforeStarted": function(data){
  499. data.data.cmsDocument.creatorIdentity = data.identity;
  500. data.data.cmsDocument.identity = data.identity;
  501. },
  502. "onStarted": function(workdata, title, processName){
  503. this.afterStartProcess(workdata, title, processName, data, true);
  504. this.closeStartProcess(e);
  505. }.bind(this)
  506. });
  507. starter.load();
  508. }.bind(this));
  509. },
  510. clearStartProcessSearch: function(e){
  511. var pnode = e.target.getParent(".st_processContent");
  512. if( this.currentTab === "byType" ){
  513. this.byTypeNode.click();
  514. }else{
  515. this.allNode.click();
  516. }
  517. pnode.getElement("input").set("value", "");
  518. },
  519. loadItemIcon: function(application, e){
  520. var node = e.currentTarget;
  521. Promise.resolve(this.getApplicationIcon(application)).then(function(icon){
  522. if (icon.icon){
  523. node.setStyle("background-image", "url(data:image/png;base64,"+icon.icon+")");
  524. }else{
  525. node.setStyle("background-image", "url("+"../x_component_process_ApplicationExplorer/$Main/default/icon/application.png)");
  526. }
  527. });
  528. },
  529. startProcessItemOver: function(e){
  530. var node = e.target;
  531. while (node && !node.hasClass("st_processItem")){ node = node.getParent();}
  532. if (node){
  533. node.addClass("menuItem_over");
  534. node.removeClass("mainColor_bg");
  535. }
  536. },
  537. startProcessItemOut: function(e){
  538. var node = e.target;
  539. while (node && !node.hasClass("st_processItem")){ node = node.getParent();}
  540. if (node){
  541. node.removeClass("menuItem_over");
  542. node.removeClass("mainColor_bg");
  543. }
  544. },
  545. startProcessItemDown: function(e){
  546. var node = e.target;
  547. while (node && !node.hasClass("st_processItem")){ node = node.getParent();}
  548. if (node){
  549. node.removeClass("menuItem_over");
  550. node.addClass("mainColor_bg");
  551. }
  552. },
  553. startProcessItemUp: function(e){
  554. var node = e.target;
  555. while (node && !node.hasClass("st_processItem")){ node = node.getParent();}
  556. if (node){
  557. node.addClass("menuItem_over");
  558. node.removeClass("mainColor_bg");
  559. }
  560. },
  561. startProcessItemClick: function(e, data){
  562. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  563. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(data, this, {
  564. "onStarted": function(workdata, title, processName){
  565. this.afterStartProcess(workdata, title, processName, data);
  566. this.closeStartProcess(e);
  567. }.bind(this)
  568. });
  569. starter.load();
  570. }.bind(this));
  571. },
  572. recordProcessData: function(data){
  573. debugger;
  574. if( data._ )delete data._ ;
  575. MWF.UD.getDataJson("taskCenter_startTop", function(json){
  576. if (!json || !json.length) json = [];
  577. var recordProcess = null;
  578. data.lastStartTime = new Date();
  579. var earlyProcessIdx = 0;
  580. var flag = true;
  581. for (var i=0; i<json.length; i++){
  582. var process = json[i];
  583. if (process.id === data.id) recordProcess = process;
  584. if (flag){
  585. if (!process.lastStartTime){
  586. earlyProcessIdx = i;
  587. flag = false;
  588. }else{
  589. if (new Date(process.lastStartTime)<new Date(json[earlyProcessIdx].lastStartTime)){
  590. earlyProcessIdx = i;
  591. }
  592. }
  593. }
  594. if( o2.typeOf( process.applicationName ) === "object")process.applicationName = process.applicationName.name || "";
  595. }
  596. if (recordProcess) {
  597. recordProcess.lastStartTime = new Date();
  598. recordProcess.count = (recordProcess.count || 0)+1;
  599. recordProcess.applicationName = data.applicationName || "";
  600. }else{
  601. if (json.length<10){
  602. data.count = 1;
  603. //data.applicationName = this.applicationData.name;
  604. json.push(data);
  605. }else{
  606. json.splice(earlyProcessIdx, 1);
  607. data.count = 1;
  608. //data.applicationName = this.applicationData.name;
  609. json.push(data);
  610. }
  611. }
  612. MWF.UD.putData("taskCenter_startTop", json);
  613. }.bind(this));
  614. },
  615. afterStartProcess: function(data, title, processName, processdata, notRecorded){
  616. if( !notRecorded )this.recordProcessData(processdata);
  617. if (data.work){
  618. this.startProcessDraft(data, title, processName);
  619. }else{
  620. this.startProcessInstance(data, title, processName);
  621. }
  622. },
  623. startProcessDraft: function(data, title, processName){
  624. var work = data.work;
  625. var options = {"draft": work, "appId": "process.Work"+(new o2.widget.UUID).toString(), "desktopReload": false,
  626. "onPostClose": function(){
  627. if (this.currentList.refresh) this.currentList.refresh();
  628. }.bind(this)
  629. };
  630. this.desktop.openApplication(null, "process.Work", options);
  631. },
  632. startProcessInstance: function(data, title, processName){
  633. var workInfors = [];
  634. var currentTask = [];
  635. data.each(function(work){
  636. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  637. workInfors.push(this.getStartWorkInforObj(work));
  638. }.bind(this));
  639. if (currentTask.length===1){
  640. var options = {"workId": currentTask[0], "appId": "process.Work"+currentTask[0],
  641. "onPostClose": function(){
  642. if (this.currentList.refresh) this.currentList.refresh();
  643. }.bind(this)
  644. };
  645. this.desktop.openApplication(null, "process.Work", options);
  646. if (layout.desktop.message) this.createStartWorkResault(workInfors, title, processName, false);
  647. }else{
  648. if (layout.desktop.message) this.createStartWorkResault(workInfors, title, processName, true);
  649. }
  650. },
  651. getStartWorkInforObj: function(work){
  652. var users = [];
  653. var currentTask = "";
  654. work.taskList.each(function(task, idx){
  655. users.push(task.person+"("+task.department + ")");
  656. if (work.currentTaskIndex===idx) currentTask = task.id;
  657. }.bind(this));
  658. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask};
  659. },
  660. createStartWorkResault: function(workInfors, title, processName, isopen){
  661. var content = "";
  662. workInfors.each(function(infor){
  663. var users = [];
  664. infor.users.each(function(uname){
  665. users.push(MWF.name.cn(uname));
  666. });
  667. content += "<div><b>"+this.lp.nextActivity+"<font style=\"color: #ea621f\">"+infor.activity+"</font>, "+this.lp.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b>";
  668. if (infor.currentTask && isopen){
  669. content += "&nbsp;&nbsp;&nbsp;&nbsp;<span value=\""+infor.currentTask+"\">"+this.lp.deal+"</span></div>";
  670. }else{
  671. content += "</div>";
  672. }
  673. }.bind(this));
  674. var msg = {
  675. "subject": this.lp.processStarted,
  676. "content": "<div>"+this.lp.processStartedMessage+"“["+processName+"]"+title+"”</div>"+content
  677. };
  678. var tooltip = layout.desktop.message.addTooltip(msg);
  679. var item = layout.desktop.message.addMessage(msg);
  680. this.setStartWorkResaultAction(tooltip);
  681. this.setStartWorkResaultAction(item);
  682. },
  683. setStartWorkResaultAction: function(item){
  684. var node = item.node.getElements("span.dealStartedWorkAction");
  685. var _self = this;
  686. node.addEvent("click", function(e){
  687. var options = {"taskId": this.get("value"), "appId": this.get("value"),
  688. "onPostClose": function(){
  689. if (_self.currentList.refresh) _self.currentList.refresh();
  690. }
  691. };
  692. _self.app.desktop.openApplication(e, "process.Work", options);
  693. });
  694. },
  695. recordStatus: function(){
  696. return {"navi": this.currentList.options.type};
  697. },
  698. });
  699. MWF.xApplication.process.workcenter.List = new Class({
  700. Implements: [Options, Events],
  701. options: {
  702. "itemHeight": 60,
  703. "view": "list.html",
  704. "type": "task"
  705. },
  706. initialize: function (app, options) {
  707. this.setOptions(options);
  708. this.app = app;
  709. this.content = app.listContentNode;
  710. this.bottomNode = app.listBottomNode;
  711. this.pageNode = app.pageNumberAreaNode;
  712. this.filterNode = app.filterItemArea;
  713. this.lp = this.app.lp;
  714. this.action = o2.Actions.load("x_processplatform_assemble_surface");
  715. this.init();
  716. //this.load();
  717. },
  718. init: function(){
  719. this.listHeight = this.content.getSize().y;
  720. this.size = (this.listHeight/this.options.itemHeight).toInt()
  721. this.page = 1;
  722. this.totalCount = this.app.countData.task;
  723. this.filterList = {};
  724. this.filterNameList = {};
  725. },
  726. startProcess: function(){
  727. this.app.startProcess();
  728. },
  729. setLayout: function(){
  730. },
  731. load: function(callback){
  732. this.total = null;
  733. var _self = this;
  734. this.loadFilterFlag();
  735. this.app.filterActionNode.show();
  736. this.selectedTaskList = [];
  737. this.loadData().then(function(data){
  738. _self.hide();
  739. _self.loadPage();
  740. _self.loadItems(data);
  741. if(callback)callback();
  742. });
  743. },
  744. refresh: function(){
  745. this.hide();
  746. this.load();
  747. // this.loadPage();
  748. this.app.loadCount();
  749. },
  750. loadFilterFlag: function(){
  751. this.filterNode.empty();
  752. var filterItemHtml = "<div class='ft_filterItem'>" +
  753. "<div class='ft_filterItemTitle mainColor_color'>{{$.title}}:</div>" +
  754. "<div class='ft_filterItemName'>{{$.name}}</div>"+
  755. "<icon class='o2icon-clear ft_filterItemDel' data-key='{{$.key}}' data-name='{{$.name}}'/>"+
  756. "</div>";
  757. var _self = this;
  758. this.lp.filterCategoryShortList.forEach(function(list){
  759. if (_self.filterNameList && _self.filterNameList[list.key] && _self.filterNameList[list.key].length){
  760. _self.filterNameList[list.key].forEach(function(i){
  761. var html = o2.bindJson(filterItemHtml, {"title": list.name, "name": i, "key": list.key});
  762. _self.filterNode.appendHTML(html);
  763. });
  764. }
  765. });
  766. this.filterNode.getElements(".ft_filterItemDel").addEvent("click", this.clearFilterItem.bind(this));
  767. },
  768. clearFilterItem: function(e){
  769. debugger;
  770. var node = e.target;
  771. var key = node.dataset.key;
  772. var name = node.dataset.name;
  773. if (this.filterNameList && this.filterNameList[key]){
  774. var findedIdx = this.filterNameList[key].indexOf(name);
  775. this.filterNameList[key].splice(findedIdx, 1);
  776. if (this.filterList && this.filterList[key]){
  777. if (this.filterList[key].splice){
  778. this.filterList[key].splice(findedIdx, 1);
  779. }else{
  780. delete this.filterList[key];
  781. }
  782. }
  783. this.page = 1;
  784. this.refresh();
  785. }
  786. },
  787. hide: function(){
  788. if (this.node) this.node.destroy();
  789. },
  790. loadPage: function(){
  791. var totalCount = this.total || this.app.countData[this.options.type];
  792. var pages = totalCount/this.size;
  793. var pageCount = pages.toInt();
  794. if (pages !== pageCount) pageCount = pageCount+1;
  795. this.pageCount = pageCount;
  796. var size = this.bottomNode.getSize();
  797. var maxPageSize = size.x*0.8;
  798. maxPageSize = maxPageSize - 80*2-24*2-10*3;
  799. var maxPageCount = (maxPageSize/34).toInt();
  800. this.loadPageNode(pageCount, maxPageCount);
  801. },
  802. loadPageNode: function(pageCount, maxPageCount){
  803. var pageStart = 1;
  804. var pageEnd = pageCount;
  805. if (pageCount>maxPageCount){
  806. var halfCount = (maxPageCount/2).toInt();
  807. pageStart = Math.max(this.page-halfCount, 1);
  808. pageEnd = pageStart+maxPageCount-1;
  809. pageEnd = Math.min(pageEnd, pageCount);
  810. pageStart = pageEnd - maxPageCount+1;
  811. }
  812. this.pageNode.empty();
  813. var _self = this;
  814. for (var i=pageStart; i<=pageEnd; i++){
  815. var node = new Element("div.pageItem", {
  816. "text": i,
  817. "events": { "click": function(){_self.gotoPage(this.get("text"));} }
  818. }).inject(this.pageNode);
  819. if (i==this.page) node.addClass("mainColor_bg");
  820. }
  821. },
  822. nextPage: function(){
  823. this.page++;
  824. if (this.page>this.pageCount) this.page = this.pageCount;
  825. this.gotoPage(this.page);
  826. },
  827. prevPage: function(){
  828. this.page--;
  829. if (this.page<1) this.page = 1;
  830. this.gotoPage(this.page);
  831. },
  832. firstPage: function(){
  833. this.gotoPage(1);
  834. },
  835. lastPage: function(){
  836. this.gotoPage(this.pageCount);
  837. },
  838. gotoPage: function(page){
  839. this.page = page;
  840. this.hide();
  841. this.app.showSkeleton();
  842. this.load();
  843. //this.loadPage();
  844. },
  845. loadData: function(){
  846. var _self = this;
  847. return this.action.TaskAction.listMyFilterPaging(this.page, this.size, this.filterList||{}).then(function(json){
  848. _self.fireEvent("loadData");
  849. //if (_self.total!==json.size) _self.countNode.set("text", json.size);
  850. _self.total = json.count;
  851. return json.data;
  852. }.bind(this));
  853. },
  854. loadItems: function(data){
  855. var url = this.app.path+this.app.options.style+"/view/"+this.options.view;
  856. this.content.loadHtml(url, {"bind": {"lp": this.lp, "type": this.options.type, "data": data}, "module": this}, function(){
  857. this.node = this.content.getFirst();
  858. }.bind(this));
  859. },
  860. overTaskItem: function(e){
  861. e.currentTarget.addClass("listItem_over");
  862. },
  863. outTaskItem: function(e){
  864. e.currentTarget.removeClass("listItem_over");
  865. },
  866. openTask: function(e, data){
  867. o2.api.form.openWork(data.work, "", data.title, {
  868. "taskId": data.id,
  869. "onPostClose": function(){
  870. if (this.refresh) this.refresh();
  871. }.bind(this)
  872. });
  873. },
  874. loadItemIcon: function(application, e){
  875. this.app.loadItemIcon(application, e);
  876. },
  877. loadItemFlag: function(e, data){
  878. var node = e.currentTarget;
  879. var iconNode = node.getElement(".listItemFlag");
  880. var expireNode = node.getElement(".listItemExpire");
  881. if (data.completed){
  882. iconNode.setStyle("background-image", "url("+"../x_component_process_workcenter/$Main/default/icons/pic_ok.png)");
  883. return true;
  884. }
  885. var start = new Date().parse(data.startTime);
  886. var now = new Date();
  887. if (now.getTime()-start.getTime()<86400000){
  888. iconNode.setStyle("background-image", "url("+"../x_component_process_workcenter/$Main/default/icons/pic_new.png)");
  889. }
  890. if (data.expireTime){
  891. var d1 = Date.parse(data.expireTime);
  892. var d2 = Date.parse(data.createTime);
  893. var time1 = d2.diff(now, "second");
  894. var time2 = now.diff(d1, "second");
  895. var time3 = d2.diff(d1, "second");
  896. var n = time1/time3;
  897. var img = "";
  898. var text = this.lp.expire1;
  899. text = text.replace(/{time}/g, data.expireTime);
  900. if (n<0.5){
  901. img = "1.png";
  902. }else if (n<0.75){
  903. img = "2.png";
  904. }else if (n<1){
  905. text = this.lp.expire2.replace(/{time}/g, data.expireTime);
  906. img = "3.png";
  907. iconNode.setStyle("background-image", "url("+"../x_component_process_workcenter/$Main/default/icons/pic_jichao.png)");
  908. }else if (n<2){
  909. text = this.lp.expire3.replace(/{time}/g, data.expireTime);
  910. img = "4.png";
  911. iconNode.setStyle("background-image", "url("+"../x_component_process_workcenter/$Main/default/icons/pic_yichao.png)");
  912. }else{
  913. text = this.lp.expire3.replace(/{time}/g, data.expireTime);
  914. img = "5.png";
  915. iconNode.setStyle("background-image", "url("+"../x_component_process_workcenter/$Main/default/icons/pic_yanchao.png)");
  916. }
  917. expireNode.setStyle("background-image", "url(../"+this.app.path+this.app.options.style+"/icons/"+img+")");
  918. expireNode.set("title", text);
  919. }
  920. },
  921. getFormData: function(data){
  922. var action = this.action;
  923. var formPromise = action.FormAction[((layout.mobile) ? "V2LookupWorkOrWorkCompletedMobile" : "V2LookupWorkOrWorkCompleted")](data.work).then(function(json){
  924. var formId = json.data.id;
  925. if (json.data.form){
  926. return json.form;
  927. }else{
  928. return action.FormAction[((layout.mobile) ? "V2GetMobile": "V2Get")](formId).then(function(formJson){
  929. return formJson.data.form;
  930. });
  931. }
  932. }).then(function(form){
  933. var formText = (form) ? MWF.decodeJsonString(form.data) : "";
  934. return (formText) ? JSON.decode(formText): null;
  935. });
  936. var taskPromise = action.TaskAction.get(data.id).then(function(json){
  937. return json.data;
  938. });
  939. return Promise.all([formPromise, taskPromise]);
  940. },
  941. editTask: function(e, data, action){
  942. this.getFormData(data).then(function(dataArr){
  943. var form = dataArr[0];
  944. var task = dataArr[1];
  945. if (form.json.submitFormType === "select") {
  946. this.processWork_custom();
  947. } else if (form.json.submitFormType === "script") {
  948. this.processWork_custom();
  949. } else {
  950. if (form.json.mode == "Mobile") {
  951. setTimeout(function () {
  952. this.processWork_mobile();
  953. }.bind(this), 100);
  954. } else {
  955. this.processWork_pc(task, form, action);
  956. }
  957. }
  958. }.bind(this));
  959. },
  960. processWork_pc: function(task, form, action) {
  961. var _self = this;
  962. var setSize = function (notRecenter) {
  963. var dlg = this;
  964. if (!dlg || !dlg.node) return;
  965. dlg.node.setStyle("display", "block");
  966. var size = processNode.getSize();
  967. dlg.content.setStyles({
  968. "height": size.y,
  969. "width": size.x
  970. });
  971. var s = dlg.setContentSize();
  972. if (!notRecenter) dlg.reCenter();
  973. }
  974. var processNode = new Element("div.processNode").inject(this.content);
  975. this.setProcessNode(task, form, processNode, "process", function (processor) {
  976. this.processDlg = o2.DL.open({
  977. "container": this.app.content,
  978. "title": this.lp.process,
  979. "style": form.json.dialogStyle || "user",
  980. "isResize": false,
  981. //"isClose": false,
  982. "content": processNode,
  983. "maskNode": this.app.content,
  984. "positionHeight": 800,
  985. "maxHeight": 800,
  986. "maxHeightPercent": "98%",
  987. "minTop": 5,
  988. "width": "auto", //processNode.retrieve("width") || 1000, //600,
  989. "height": "auto", //processNode.retrieve("height") || 401,
  990. "buttonList": [
  991. {
  992. "type": "ok",
  993. "text": MWF.LP.process.button.ok,
  994. "action": function (d, e) {
  995. if (this.processor) this.processor.okButton.click();
  996. }.bind(this)
  997. },
  998. {
  999. "type": "cancel",
  1000. "text": MWF.LP.process.button.cancel,
  1001. "action": function () {
  1002. this.processDlg.close();
  1003. if (this.processor) this.processor.destroy();
  1004. _self.app.content.unmask();
  1005. }.bind(this)
  1006. }
  1007. ],
  1008. "onPostLoad": function () {
  1009. processor.options.mediaNode = this.content;
  1010. setSize.call(this)
  1011. }
  1012. });
  1013. }.bind(this), function () {
  1014. if (this.processDlg) setSize.call(this.processDlg, true)
  1015. }.bind(this), "", action);
  1016. },
  1017. setProcessNode: function (task, form, processNode, style, postLoadFun, resizeFun, defaultRoute, action) {
  1018. var _self = this;
  1019. MWF.xDesktop.requireApp("process.Work", "Processor", function () {
  1020. var mds = [];
  1021. var innerNode;
  1022. if (layout.mobile) {
  1023. innerNode = new Element("div").inject(processNode);
  1024. }
  1025. this.processor = new MWF.xApplication.process.Work.Processor(innerNode || processNode, task, {
  1026. "style": (layout.mobile) ? "mobile" : (style || "default"),
  1027. "tabletWidth": form.json.tabletWidth || 0,
  1028. "tabletHeight": form.json.tabletHeight || 0,
  1029. "onPostLoad": function () {
  1030. if (postLoadFun) postLoadFun(this);
  1031. _self.fireEvent("afterLoadProcessor", [this]);
  1032. },
  1033. "onResize": function () {
  1034. if (resizeFun) resizeFun();
  1035. },
  1036. "onCancel": function () {
  1037. processNode.destroy();
  1038. _self.app.content.unmask();
  1039. delete this;
  1040. },
  1041. "onSubmit": function (routeName, opinion, medias, appendTaskIdentityList, processorOrgList, callbackBeforeSave) {
  1042. if (!medias || !medias.length) {
  1043. medias = mds;
  1044. } else {
  1045. medias = medias.concat(mds)
  1046. }
  1047. var method = action || "submitTask";
  1048. _self[method](routeName, opinion, medias, task);
  1049. }
  1050. });
  1051. }.bind(this));
  1052. },
  1053. submitTask: function(routeName, opinion, medias, task){
  1054. if (!opinion) opinion = routeName;
  1055. task.routeName = routeName;
  1056. task.opinion = opinion;
  1057. var mediaIds = [];
  1058. if (medias.length){
  1059. medias.each(function(file){
  1060. var formData = new FormData();
  1061. formData.append("file", file);
  1062. formData.append("site", "$mediaOpinion");
  1063. this.action.AttachmentAction.upload(task.work, formData, file, function(json){
  1064. mediaIds.push(json.data.id);
  1065. }.bind(this), null, false);
  1066. }.bind(this));
  1067. }
  1068. if (mediaIds.length) task.mediaOpinion = mediaIds.join(",");
  1069. this.action.TaskAction.processing(task.id, task, function(json){
  1070. if (this.processor) this.processor.destroy();
  1071. if (this.processDlg) this.processDlg.close();
  1072. this.app.content.unmask();
  1073. this.refresh();
  1074. this.addMessage(json.data, task);
  1075. }.bind(this));
  1076. },
  1077. getMessageContent: function (data, task, maxLength, titlelp) {
  1078. var content = "";
  1079. var lp = this.lp;
  1080. if (data.completed) {
  1081. content += lp.workCompleted;
  1082. } else {
  1083. if (data.occurSignalStack) {
  1084. if (data.signalStack && data.signalStack.length) {
  1085. var activityUsers = [];
  1086. data.signalStack.each(function (stack) {
  1087. var idList = [];
  1088. if (stack.splitExecute) {
  1089. idList = stack.splitExecute.splitValueList || [];
  1090. }
  1091. if (stack.manualExecute) {
  1092. idList = stack.manualExecute.identities || [];
  1093. }
  1094. var count = 0;
  1095. var ids = [];
  1096. idList.each( function(i){
  1097. var cn = o2.name.cn(i);
  1098. if( !ids.contains( cn ) ){
  1099. ids.push(cn)
  1100. }
  1101. });
  1102. if (ids.length > 8) {
  1103. count = ids.length;
  1104. ids = ids.slice(0, 8);
  1105. }
  1106. ids = o2.name.cns(ids);
  1107. var t = "<b>" + lp.nextActivity + "</b><span style='color: #ea621f'>" + stack.name + "</span>;<b>" + lp.nextUser + "</b><span style='color: #ea621f'>" + ids.join(",") + "</span> <b>" + ((count) ? "," + lp.next_etc.replace("{count}", count) : "") + "</b>";
  1108. activityUsers.push(t);
  1109. }.bind(this));
  1110. content += activityUsers.join("<br>");
  1111. } else {
  1112. content += lp.processTaskCompleted;
  1113. }
  1114. } else {
  1115. if (data.properties.nextManualList && data.properties.nextManualList.length) {
  1116. var activityUsers = [];
  1117. data.properties.nextManualList.each(function (a) {
  1118. var ids = [];
  1119. a.taskIdentityList.each(function (i) {
  1120. var cn = o2.name.cn(i);
  1121. if( !ids.contains( cn ) ){
  1122. ids.push(cn)
  1123. }
  1124. });
  1125. var t = "<b>" + lp.nextActivity + "</b><span style='color: #ea621f'>" + a.activityName + "</span>;<b>" + lp.nextUser + "</b><span style='color: #ea621f'>" + ids.join(",") + "</span>";
  1126. activityUsers.push(t);
  1127. });
  1128. content += activityUsers.join("<br>");
  1129. } else {
  1130. if (data.arrivedActivityName) {
  1131. content += lp.arrivedActivity + data.arrivedActivityName;
  1132. } else {
  1133. content += lp.processTaskCompleted;
  1134. }
  1135. }
  1136. }
  1137. }
  1138. var title = task.title;
  1139. if (maxLength && title.length > maxLength) {
  1140. title = title.substr(0, maxLength) + "...";
  1141. }
  1142. return "<div>" + (titlelp || lp.taskProcessedMessage) + "“" + title + "”</div>" + content;
  1143. },
  1144. addMessage: function (data, task, notShowBrowserDkg) {
  1145. if (layout.desktop.message) {
  1146. var msg = {
  1147. "subject": this.lp.taskProcessed,
  1148. "content": this.getMessageContent(data, task, 0, this.lp.taskProcessedMessage)
  1149. };
  1150. layout.desktop.message.addTooltip(msg);
  1151. return layout.desktop.message.addMessage(msg);
  1152. } else {
  1153. // if (this.app.inBrowser && !notShowBrowserDkg) {
  1154. // this.inBrowserDkg(this.getMessageContent(data, 0, this.lp.taskProcessedMessage));
  1155. // }
  1156. }
  1157. },
  1158. selectTask: function(e, data){
  1159. if (e.currentTarget.get("disabled").toString()!="true"){
  1160. var itemNode = e.currentTarget.getParent(".listItem");
  1161. var iconNode = e.currentTarget.getElement(".selectFlagIcon");
  1162. if (itemNode){
  1163. if (itemNode.hasClass("mainColor_bg_opacity")){
  1164. itemNode.removeClass("mainColor_bg_opacity");
  1165. iconNode.removeClass("o2icon-xuanzhong");
  1166. iconNode.removeClass("selectFlagIcon_select");
  1167. iconNode.removeClass("mainColor_color");
  1168. this.unSelectedTask(data);
  1169. this.showBatchAction();
  1170. }else{
  1171. itemNode.addClass("mainColor_bg_opacity");
  1172. iconNode.addClass("o2icon-xuanzhong");
  1173. iconNode.addClass("selectFlagIcon_select");
  1174. iconNode.addClass("mainColor_color");
  1175. this.selectedTask(data);
  1176. this.showBatchAction(itemNode);
  1177. }
  1178. this.checkSelectTask();
  1179. }
  1180. }
  1181. },
  1182. checkSelectTask: function(){
  1183. var _self = this;
  1184. var nodes = this.app.listContentNode.getElements(".selectFlagArea");
  1185. if (this.selectedTaskList && this.selectedTaskList.length){
  1186. var data = this.selectedTaskList[0];
  1187. nodes.each(function(node){
  1188. var t = node.retrieve("task");
  1189. if (t.activity !== data.activity){
  1190. node.set("disabled", true);
  1191. node.set("title", _self.lp.cannotSelectBatch);
  1192. node.addClass("selectFlagArea_disabled");
  1193. }
  1194. });
  1195. }else{
  1196. nodes.set("disabled", false);
  1197. nodes.set("title", this.lp.selectBatch);
  1198. nodes.removeClass("selectFlagArea_disabled");
  1199. }
  1200. },
  1201. showBatchAction: function(itemNode){
  1202. if (this.selectedTaskList && this.selectedTaskList.length){
  1203. if (!itemNode){
  1204. var nodes = this.app.listContentNode.getElements(".listItem.mainColor_bg_opacity");
  1205. if (nodes && nodes.length){
  1206. itemNode = nodes[nodes.length-1];
  1207. }
  1208. }
  1209. if (itemNode){
  1210. this.batchAction.show();
  1211. this.batchAction.position({
  1212. "relativeTo": itemNode,
  1213. "position": "centerBottom",
  1214. "edge": "centerTop",
  1215. "offset": {"y": 10}
  1216. });
  1217. }else{
  1218. this.batchAction.hide();
  1219. }
  1220. }else{
  1221. this.batchAction.hide();
  1222. }
  1223. },
  1224. selectedTask: function(data){
  1225. delete data._;
  1226. if (!this.selectedTaskList) this.selectedTaskList = [];
  1227. var idx = this.selectedTaskList.findIndex(function(t){
  1228. return t.id == data.id;
  1229. });
  1230. if (idx===-1) this.selectedTaskList.push(data);
  1231. },
  1232. unSelectedTask: function(data){
  1233. delete data._;
  1234. if (!this.selectedTaskList) this.selectedTaskList = [];
  1235. var idx = this.selectedTaskList.findIndex(function(t){
  1236. return t.id == data.id;
  1237. });
  1238. if (idx!==-1) this.selectedTaskList.splice(idx, 1);
  1239. },
  1240. bindSelectData: function(e, data){
  1241. delete data._;
  1242. e.currentTarget.store("task", data);
  1243. },
  1244. batchProcess: function(e){
  1245. if(this.options.type === "read"){
  1246. this.batchProcessRead(e);
  1247. }else {
  1248. this.batchProcessTask(e);
  1249. }
  1250. },
  1251. batchProcessTask: function(e){
  1252. if (this.selectedTaskList && this.selectedTaskList.length){
  1253. var data = this.selectedTaskList[0];
  1254. this.editTask(e, data, "batchSubmitTask")
  1255. }
  1256. },
  1257. batchSubmitTask: function(routeName, opinion, medias){
  1258. if (this.selectedTaskList && this.selectedTaskList.length){
  1259. var p = [];
  1260. this.selectedTaskList.forEach(function(task){
  1261. if (!opinion) opinion = routeName;
  1262. task.routeName = routeName;
  1263. task.opinion = opinion;
  1264. var mediaIds = [];
  1265. if (medias.length){
  1266. medias.each(function(file){
  1267. var formData = new FormData();
  1268. formData.append("file", file);
  1269. formData.append("site", "$mediaOpinion");
  1270. this.action.AttachmentAction.upload(task.work, formData, file, function(json){
  1271. mediaIds.push(json.data.id);
  1272. }.bind(this), null, false);
  1273. }.bind(this));
  1274. }
  1275. if (mediaIds.length) task.mediaOpinion = mediaIds.join(",");
  1276. p.push(this.action.TaskAction.processing(task.id, task, function(json){
  1277. if (this.processor) this.processor.destroy();
  1278. if (this.processDlg) this.processDlg.close();
  1279. this.addMessage(json.data, task);
  1280. }.bind(this)));
  1281. }.bind(this));
  1282. Promise.all(p).then(function(){
  1283. this.app.content.unmask();
  1284. this.refresh();
  1285. }.bind(this));
  1286. }
  1287. },
  1288. });
  1289. MWF.xApplication.process.workcenter.TaskList = new Class({
  1290. Extends: MWF.xApplication.process.workcenter.List
  1291. });
  1292. MWF.xApplication.process.workcenter.ReadList = new Class({
  1293. Extends: MWF.xApplication.process.workcenter.List,
  1294. options: {
  1295. "itemHeight": 60,
  1296. "type": "read"
  1297. },
  1298. loadData: function(){
  1299. var _self = this;
  1300. return this.action.ReadAction.listMyFilterPaging(this.page, this.size, this.filterList||{}).then(function(json){
  1301. _self.fireEvent("loadData");
  1302. json.data.each(function (d){
  1303. d.allowRapid = true;
  1304. })
  1305. _self.total = json.count;
  1306. return json.data;
  1307. }.bind(this));
  1308. // var _self = this;
  1309. // return this.action.ReadAction.listMyPaging(this.page, this.size).then(function(json){
  1310. // _self.fireEvent("loadData");
  1311. // _self.total = json.size;
  1312. // return json.data;
  1313. // }.bind(this));
  1314. },
  1315. loadItemFlag: function(e, data){
  1316. var node = e.currentTarget;
  1317. var iconNode = node.getElement(".listItemFlag");
  1318. if (data.completed){
  1319. iconNode.setStyle("background-image", "url("+"../x_component_process_workcenter/$Main/default/icons/pic_ok.png)");
  1320. return true;
  1321. }
  1322. var start = new Date().parse(data.startTime);
  1323. var now = new Date();
  1324. if (now.getTime()-start.getTime()<86400000){
  1325. iconNode.setStyle("background-image", "url("+"../x_component_process_workcenter/$Main/default/icons/pic_new.png)");
  1326. }
  1327. },
  1328. selectTask: function(e, data){
  1329. if (e.currentTarget.get("disabled").toString()!="true"){
  1330. var itemNode = e.currentTarget.getParent(".listItem");
  1331. var iconNode = e.currentTarget.getElement(".selectFlagIcon");
  1332. if (itemNode){
  1333. if (itemNode.hasClass("mainColor_bg_opacity")){
  1334. itemNode.removeClass("mainColor_bg_opacity");
  1335. iconNode.removeClass("o2icon-xuanzhong");
  1336. iconNode.removeClass("selectFlagIcon_select");
  1337. iconNode.removeClass("mainColor_color");
  1338. this.unSelectedTask(data);
  1339. this.showBatchAction();
  1340. }else{
  1341. itemNode.addClass("mainColor_bg_opacity");
  1342. iconNode.addClass("o2icon-xuanzhong");
  1343. iconNode.addClass("selectFlagIcon_select");
  1344. iconNode.addClass("mainColor_color");
  1345. this.selectedTask(data);
  1346. this.showBatchAction(itemNode);
  1347. }
  1348. }
  1349. }
  1350. },
  1351. batchProcessRead: function(e){
  1352. if (this.selectedTaskList && this.selectedTaskList.length){
  1353. var data = this.selectedTaskList[0];
  1354. this.editRead();
  1355. }
  1356. },
  1357. editRead : function(){
  1358. var _self = this;
  1359. var text = this.lp.readConfirm;
  1360. var url = this.app.path+this.app.options.style+"/view/dlg/read.html";
  1361. o2.loadHtml(url, {"bind": {"lp": this.lp, "readedConfirmContent": text}, "module": this}, function(o){
  1362. var html = o2.bindJson(o[0].data, {"lp": this.lp, "readedConfirmContent": text});
  1363. //var p = o2.dlgPosition(null, this.app.content, 550, 260)
  1364. var readDlg = o2.DL.open({
  1365. "title": this.lp.setReadedConfirmTitle,
  1366. "style": "user",
  1367. "isResize": false,
  1368. "height": "260",
  1369. "width": "550",
  1370. "html": html,
  1371. "maskNode": this.app.content,
  1372. "minTop": 5,
  1373. "buttonList": [
  1374. {
  1375. "type": "ok",
  1376. "text": MWF.LP.process.button.ok,
  1377. "action": function () {
  1378. debugger;
  1379. var opinion = this.content.getElement("textarea").get("value");
  1380. _self.batchSubmitRead(opinion);
  1381. this.close();
  1382. }
  1383. },
  1384. {
  1385. "type": "cancel",
  1386. "text": MWF.LP.process.button.cancel,
  1387. "action": function () {
  1388. this.close();
  1389. }
  1390. }
  1391. ]
  1392. });
  1393. }.bind(this));
  1394. },
  1395. batchSubmitRead: function(opinion){
  1396. if (this.selectedTaskList && this.selectedTaskList.length){
  1397. var p = [];
  1398. this.selectedTaskList.forEach(function(task){
  1399. if (!opinion) opinion = routeName;
  1400. p.push(this.action.ReadAction.processing(task.id, {"opinion": opinion}, function(json){
  1401. }.bind(this)));
  1402. }.bind(this));
  1403. Promise.all(p).then(function(){
  1404. this.app.content.unmask();
  1405. this.refresh();
  1406. }.bind(this));
  1407. }
  1408. },
  1409. setReadCompleted: function(e, data){
  1410. if (data.item) data = data.item;
  1411. var _self = this;
  1412. var text = this.lp.setReadedConfirmContent.replace("{title}", data.title );
  1413. var url = this.app.path+this.app.options.style+"/view/dlg/read.html";
  1414. o2.loadHtml(url, {"bind": {"lp": this.lp, "readedConfirmContent": text}, "module": this}, function(o){
  1415. var html = o2.bindJson(o[0].data, {"lp": this.lp, "readedConfirmContent": text});
  1416. var p = o2.dlgPosition(e, this.app.content, 550, 260)
  1417. var readDlg = o2.DL.open({
  1418. "container": this.app.content,
  1419. "title": this.lp.setReadedConfirmTitle,
  1420. "style": "user",
  1421. "isResize": false,
  1422. "height": "260",
  1423. "width": "550",
  1424. "top": p.y,
  1425. "left": p.x,
  1426. "fromTop": p.fromy,
  1427. "fromLeft": p.fromx,
  1428. "html": html,
  1429. "maskNode": this.app.content,
  1430. "minTop": 5,
  1431. "buttonList": [
  1432. {
  1433. "type": "ok",
  1434. "text": MWF.LP.process.button.ok,
  1435. "action": function () {
  1436. debugger;
  1437. var opinion = this.content.getElement("textarea").get("value");
  1438. _self.setReadAction(data, opinion);
  1439. this.close();
  1440. }
  1441. },
  1442. {
  1443. "type": "cancel",
  1444. "text": MWF.LP.process.button.cancel,
  1445. "action": function () {
  1446. this.close();
  1447. }
  1448. }
  1449. ]
  1450. });
  1451. }.bind(this));
  1452. },
  1453. setReadAction: function(data, opinion){
  1454. this.action.ReadAction.processing(data.id, {"opinion": opinion}, function(){
  1455. if (this.infoDlg) this.infoDlg.close();
  1456. this.refresh();
  1457. }.bind(this));
  1458. },
  1459. getReference: function(data){
  1460. return this.action.ReadAction.reference(data.id).then(function(json){
  1461. json.data.item = json.data.read;
  1462. return json.data;
  1463. });
  1464. },
  1465. openWorkInfo: function(e, data){
  1466. // var p = e.target.getPosition(this.app.content);
  1467. var infoContent = new Element("div");
  1468. var url = this.app.path+this.app.options.style+"/view/dlg/processInfo.html";
  1469. var _self = this;
  1470. this.getReference(data).then(function(data){
  1471. //data.workLog = json.data;
  1472. infoContent.loadHtml(url, {"bind": {"lp": _self.lp, "type": _self.options.type, "data": data}, "module": _self});
  1473. });
  1474. this.infoDlg = o2.DL.open({
  1475. // "top": p.y,
  1476. // "left": p.x,
  1477. "container": this.app.content,
  1478. "title": this.lp.processInfo,
  1479. "style": "user",
  1480. "isResize": true,
  1481. "content": infoContent,
  1482. "maskNode": this.app.content,
  1483. "width": 800,
  1484. "height": 720
  1485. });
  1486. },
  1487. attachShowPersonLog: function(e, data){
  1488. var inforNode = new Element("div.pf_workLogInfor");
  1489. var html = "<div>"+o2.name.cn(data.person)+"</div>";
  1490. if (data.completedTime){
  1491. html += "<div>"+this.lp.opinion+": "+o2.txt(data.opinion || data.routeName)+"</div>";
  1492. html += "<div>"+this.lp.time+": "+data.completedTime.substring(0,16)+"</div>";
  1493. }else{
  1494. html += "<div style='color:red'>"+this.lp.processing+"</div>";
  1495. html += "<div>"+this.lp.starttime+": "+data.startTime.substring(0,16)+"</div>";
  1496. }
  1497. inforNode.set("html", html);
  1498. if (!Browser.Platform.ios){
  1499. // new mBox.Tooltip({
  1500. // content: inforNode,
  1501. // setStyles: {content: {padding: 15, lineHeight: 20}},
  1502. // attach: e.target,
  1503. // transition: 'flyin'
  1504. // });
  1505. this.tooltip = new MWF.xApplication.process.workcenter.List.Tooltip(this.app.content, e.target, this.app, {}, {
  1506. axis : "y",
  1507. hiddenDelay : 300,
  1508. displayDelay : 300
  1509. });
  1510. this.tooltip.inforNode = inforNode;
  1511. }
  1512. },
  1513. openWork: function(e, data){
  1514. o2.api.form.openWork(data.id, "", data.title);
  1515. },
  1516. openJob: function(e, data){
  1517. debugger;
  1518. o2.api.form.openJob(data.item.job);
  1519. },
  1520. closeMoerLogPanel: function(logNode){
  1521. if (logNode){
  1522. logNode.removeClass("mainColor_bg_opacity");
  1523. var workLogPanel = logNode.retrieve("workLogPanel");
  1524. if (workLogPanel) workLogPanel.closePanel();
  1525. logNode.store("workLogPanel", null);
  1526. }
  1527. },
  1528. moreWorkLog: function(e, data){
  1529. var logNode = e.target.getParent(".pf_logItem");
  1530. this.closeMoerLogPanel(this.currentLogNode);
  1531. var _self = this;
  1532. var moreLogNode = new Element("div");
  1533. var url = this.app.path+this.app.options.style+"/view/dlg/moreWorkLog.html";
  1534. moreLogNode.loadHtml(url, {"bind": {"lp": _self.lp, "type": _self.options.type, "data": data}, "module": _self});
  1535. var targetNode = e.target.getParent(".processInfoContent").getElement(".pf_workListArea");
  1536. o2.require("o2.widget.Panel", function(){
  1537. workLogPanel = new o2.widget.Panel(moreLogNode, {
  1538. "style": "flat",
  1539. "title": "",
  1540. "width": 300,
  1541. "height": 540,
  1542. "isMove": false,
  1543. "isClose": true,
  1544. "isMax": false,
  1545. "isExpand": false,
  1546. "isResize": false,
  1547. "target": targetNode,
  1548. "duration": 0,
  1549. "onPostLoad": function(){
  1550. _self.currentLogNode = logNode.addClass("mainColor_bg_opacity");
  1551. },
  1552. "onQueryClose": function(){
  1553. var node = _self.currentLogNode;
  1554. _self.currentLogNode = null;
  1555. if (node) _self.closeMoerLogPanel(node);
  1556. }
  1557. });
  1558. logNode.store("workLogPanel", workLogPanel);
  1559. workLogPanel.logNode = logNode;
  1560. workLogPanel.load();
  1561. });
  1562. }
  1563. });
  1564. MWF.xApplication.process.workcenter.TaskCompletedList = new Class({
  1565. Extends: MWF.xApplication.process.workcenter.ReadList,
  1566. options: {
  1567. "itemHeight": 60,
  1568. "type": "taskCompleted"
  1569. },
  1570. getReference: function(data){
  1571. return this.action.TaskCompletedAction.getReference(data.id).then(function(json){
  1572. json.data.item = json.data.taskCompleted;
  1573. return json.data;
  1574. });
  1575. },
  1576. loadData: function(){
  1577. var _self = this;
  1578. return this.action.TaskCompletedAction.listMyFilterPaging(this.page, this.size, this.filterList||{}).then(function(json){
  1579. _self.fireEvent("loadData");
  1580. _self.total = json.count;
  1581. return json.data;
  1582. }.bind(this));
  1583. // var _self = this;
  1584. // return this.action.TaskCompletedAction.listMyPaging(this.page, this.size).then(function(json){
  1585. // _self.fireEvent("loadData");
  1586. // _self.total = json.size;
  1587. // return json.data;
  1588. // }.bind(this));
  1589. }
  1590. });
  1591. MWF.xApplication.process.workcenter.ReadCompletedList = new Class({
  1592. Extends: MWF.xApplication.process.workcenter.ReadList,
  1593. options: {
  1594. "itemHeight": 60,
  1595. "type": "readCompleted"
  1596. },
  1597. getReference: function(data){
  1598. return this.action.ReadCompletedAction.getReference(data.id).then(function(json){
  1599. json.data.item = json.data.readCompleted;
  1600. return json.data;
  1601. });
  1602. },
  1603. loadData: function(){
  1604. var _self = this;
  1605. return this.action.ReadCompletedAction.listMyFilterPaging(this.page, this.size, this.filterList||{}).then(function(json){
  1606. _self.fireEvent("loadData");
  1607. _self.total = json.count;
  1608. return json.data;
  1609. }.bind(this));
  1610. // var _self = this;
  1611. // return this.action.ReadCompletedAction.listMyPaging(this.page, this.size).then(function(json){
  1612. // _self.fireEvent("loadData");
  1613. // _self.total = json.size;
  1614. // return json.data;
  1615. // }.bind(this));
  1616. }
  1617. });
  1618. MWF.xApplication.process.workcenter.DraftList = new Class({
  1619. Extends: MWF.xApplication.process.workcenter.ReadList,
  1620. options: {
  1621. "itemHeight": 60,
  1622. "type": "draft"
  1623. },
  1624. loadData: function(){
  1625. // var _self = this;
  1626. // return this.action.DraftAction.listMyFilterPaging(this.page, this.size, this.filterList||{}).then(function(json){
  1627. // _self.fireEvent("loadData");
  1628. // _self.total = json.count;
  1629. // return json.data;
  1630. // }.bind(this));
  1631. this.app.filterActionNode.hide();
  1632. var _self = this;
  1633. return this.action.DraftAction.listMyPaging(this.page, this.size, {}).then(function(json){
  1634. _self.fireEvent("loadData");
  1635. _self.total = json.count;
  1636. return json.data;
  1637. }.bind(this));
  1638. },
  1639. openTask: function(e, data){
  1640. var options = {"draftId": data.id, "appId": "process.Work"+data.id,
  1641. "onPostClose": function(){
  1642. if (this.refresh) this.refresh();
  1643. }.bind(this)
  1644. };
  1645. this.app.desktop.openApplication(e, "process.Work", options);
  1646. }
  1647. });
  1648. MWF.xApplication.process.workcenter.ReviewList = new Class({
  1649. Extends: MWF.xApplication.process.workcenter.ReadList,
  1650. options: {
  1651. "itemHeight": 60,
  1652. "type": "review"
  1653. },
  1654. loadData: function(){
  1655. // this.app.filterActionNode.hide();
  1656. var _self = this;
  1657. return this.action.ReviewAction.V2ListPaging(this.page, this.size, this.filterList||{}).then(function(json){
  1658. _self.fireEvent("loadData");
  1659. _self.total = json.count;
  1660. return json.data;
  1661. }.bind(this));
  1662. },
  1663. openTask: function(e, data){
  1664. o2.api.form.openWork(data.work, "", data.title, {
  1665. "onPostClose": function(){
  1666. if (this.refresh) this.refresh();
  1667. }.bind(this)
  1668. });
  1669. },
  1670. loadFilterFlag: function(){
  1671. this.filterNode.empty();
  1672. var filterItemHtml = "<div class='ft_filterItem'>" +
  1673. "<div class='ft_filterItemTitle mainColor_color'>{{$.title}}:</div>" +
  1674. "<div class='ft_filterItemName'>{{$.name}}</div>"+
  1675. "<icon class='o2icon-clear ft_filterItemDel' data-key='{{$.key}}' data-name='{{$.name}}'/>"+
  1676. "</div>";
  1677. var _self = this;
  1678. this.lp.filterCategoryShortListReview.forEach(function(list){
  1679. if (_self.filterNameList && _self.filterNameList[list.key] && _self.filterNameList[list.key].length){
  1680. _self.filterNameList[list.key].forEach(function(i){
  1681. var html = o2.bindJson(filterItemHtml, {"title": list.name, "name": i, "key": list.key});
  1682. _self.filterNode.appendHTML(html);
  1683. });
  1684. }
  1685. });
  1686. this.filterNode.getElements(".ft_filterItemDel").addEvent("click", this.clearFilterItem.bind(this));
  1687. }
  1688. });
  1689. MWF.xApplication.process.workcenter.MyCreatedList = new Class({
  1690. Extends: MWF.xApplication.process.workcenter.ReviewList,
  1691. options: {
  1692. "itemHeight": 60,
  1693. "type": "myCreated"
  1694. },
  1695. loadData: function(){
  1696. // this.app.filterActionNode.hide();
  1697. var _self = this;
  1698. return this.action.ReviewAction.V2ListCreatePaging(this.page, this.size, this.filterList||{}).then(function(json){
  1699. _self.fireEvent("loadData");
  1700. _self.total = json.count;
  1701. return json.data;
  1702. }.bind(this));
  1703. },
  1704. openTask: function(e, data){
  1705. o2.api.form.openWork(data.work, "", data.title, {
  1706. "onPostClose": function(){
  1707. if (this.refresh) this.refresh();
  1708. }.bind(this)
  1709. });
  1710. }
  1711. });
  1712. MWF.xDesktop.requireApp("Template", "MTooltips", null, false);
  1713. MWF.xApplication.process.workcenter.List.Tooltip = new Class({
  1714. Extends: MTooltips,
  1715. options:{
  1716. nodeStyles: {
  1717. "font-size" : "12px",
  1718. "position" : "absolute",
  1719. "max-width" : "500px",
  1720. "min-width" : "180px",
  1721. "z-index" : "1001",
  1722. "background-color" : "#fff",
  1723. "padding" : "10px",
  1724. "border-radius" : "8px",
  1725. "box-shadow": "0 0 18px 0 #999999",
  1726. "-webkit-user-select": "text",
  1727. "-moz-user-select": "text",
  1728. "line-height": "20px"
  1729. },
  1730. priorityOfAuto :{
  1731. x : [ "center", "right", "left" ], //当position x 为 auto 时候的优先级
  1732. y : [ "middle", "top", "bottom" ] //当position y 为 auto 时候的优先级
  1733. },
  1734. isFitToContainer : true,
  1735. overflow : "scroll"
  1736. },
  1737. _loadCustom : function( callback ){
  1738. if(callback)callback();
  1739. },
  1740. _customNode : function( node, contentNode ){
  1741. this.inforNode.inject(contentNode);
  1742. if( this.inforNode.getSize().y > 300 ){
  1743. this.inforNode.setStyle("padding-bottom", "20px");
  1744. }
  1745. this.fireEvent("customContent", [contentNode, node]);
  1746. }
  1747. });