Main.js 52 KB

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