ProjectList.js 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038
  1. MWF.xApplication.TeamWork = MWF.xApplication.TeamWork || {};
  2. MWF.xDesktop.requireApp("TeamWork", "Common", null, false);
  3. MWF.xApplication.TeamWork.ProjectList = new Class({
  4. Extends: MWF.widget.Common,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "hasNavi" : true,
  9. "align" : "center"
  10. },
  11. initialize: function (container, app, data, options) {
  12. this.setOptions(options);
  13. this.container = container;
  14. this.app = app;
  15. this.lp = this.app.lp.ProjectList;
  16. this.actions = this.app.restActions;
  17. this.path = "/x_component_TeamWork/$ProjectList/";
  18. this.cssPath = this.path+this.options.style+"/css.wcss";
  19. this._loadCss();
  20. this.data = data;
  21. },
  22. load: function () {
  23. this.container.empty();
  24. this.container.setStyles({display:"flex"});
  25. this.currentListType = "block";
  26. this.currentNavi = "allItem";
  27. this.naviTable = new Element("div",{styles:this.css.naviTable}).inject(this.container);
  28. this.createNavi();
  29. this.contentTable = new Element("div.contentTable",{styles:this.css.contentTable}).inject(this.container);
  30. this.createContent();
  31. this.clickNavi();
  32. //this.allItemAdd.click(); //临时
  33. },
  34. reload:function(){
  35. this.createNavi();
  36. this.clickNavi();
  37. },
  38. createNavi:function(){
  39. this.app.setLoading(this.naviTable);
  40. this.actions.projectGroupGet(function(json){
  41. this.naviTable.empty();
  42. if(json.type == "success") {
  43. var resData = json.data;
  44. this.projectGroup = json.data;
  45. var _self = this;
  46. if(this.naviTable)this.naviTable.empty();
  47. this.naviContent = new Element("div.naviContent",{
  48. styles:this.css.naviContent
  49. }).inject(this.naviTable);
  50. new Element("div.naviTitle",{styles:this.css.naviTitle,text:this.lp.navi.title}).inject(this.naviContent);
  51. //全部项目
  52. if(resData.hasOwnProperty("allCount")){
  53. this.allItem = new Element("div.allItem",{styles:this.css.naviMenu}).inject(this.naviContent);
  54. this.allItemText = new Element("div",{styles:this.css.allItemText,text:this.lp.navi.allItem}).inject(this.allItem);
  55. this.allItemCount = new Element("div.allItemCount",{
  56. styles:this.css.allItemCount,
  57. text:"("+(resData.allCount ||"") +")"
  58. }).inject(this.allItem);
  59. this.allItemAdd = new Element("div.allItemAdd",{styles:this.css.allItemAdd}).inject(this.allItem);
  60. this.allItemAdd.addEvents({
  61. click:function(e){
  62. this.addNewProject();
  63. e.stopPropagation();
  64. }.bind(this),
  65. mouseover:function(){
  66. this.app.showTips(this.allItemAdd,{_html:"<div style='margin:2px 5px;'>"+this.lp.content.addProjectBlockText+"</div>"});
  67. }.bind(this)
  68. });
  69. this.allItem.addEvents({
  70. mouseover:function(){
  71. this.allItem.setStyles({
  72. "background-color":"#F2F5F7"
  73. });
  74. this.allItemText.setStyles({"color":"#4A90E2"});
  75. this.allItemCount.setStyles({"color":"#4A90E2"});
  76. this.allItemAdd.setStyles({
  77. "background-image":"url(/x_component_TeamWork/$ProjectList/default/icon/icon_zengjia_blue2_click.png)"
  78. });
  79. }.bind(this),
  80. mouseout:function(){
  81. this.allItem.setStyles(this.css.naviMenu);
  82. this.allItemText.setStyles(this.css.allItemText);
  83. this.allItemCount.setStyles(this.css.allItemCount);
  84. this.allItemAdd.setStyles(this.css.allItemAdd);
  85. }.bind(this),
  86. click:function(){
  87. this.openItem({type:"all"});
  88. this.currentNavi = "all"
  89. }.bind(this)
  90. });
  91. }
  92. //我的星标
  93. if(resData.hasOwnProperty("starCount")){
  94. this.starItem = new Element("div.starItem",{styles:this.css.naviItem}).inject(this.naviContent);
  95. this.starItemImg = new Element("div.starItemImg",{styles:this.css.starItemImg}).inject(this.starItem);
  96. this.starItemText = new Element("div.starItemText",{styles:this.css.starItemText,text:this.lp.navi.starItem}).inject(this.starItem);
  97. this.starItemCount = new Element("div.starItemCount",{styles:this.css.starItemCount,text:resData.starCount}).inject(this.starItem);
  98. this.starItemIcon = new Element("div.starItemIcon",{styles:this.css.starItemIcon}).inject(this.starItem);
  99. this.starItem.addEvents({
  100. mouseover:function(){
  101. this.starItem.setStyles({
  102. "background-color":"#F2F5F7"
  103. });
  104. this.starItemImg.setStyles({
  105. "background-image":"url(/x_component_TeamWork/$ProjectList/default/icon/icon_wdxx_1_blue.png)"
  106. });
  107. this.starItemText.setStyles({
  108. "color":"#4A90E2"
  109. });
  110. }.bind(this),
  111. mouseout:function(){
  112. this.starItem.setStyles(this.css.naviItem);
  113. this.starItemImg.setStyles(this.css.starItemImg);
  114. this.starItemText.setStyles(this.css.starItemText);
  115. }.bind(this),
  116. click:function(){
  117. this.openItem({type:"star"});
  118. this.currentNavi = "star"
  119. }.bind(this)
  120. });
  121. }
  122. //我的项目
  123. if(resData.hasOwnProperty("myCount")){
  124. this.myItem = new Element("div.myItem",{styles:this.css.naviItem}).inject(this.naviContent);
  125. this.myItemImg = new Element("div.myItemImg",{styles:this.css.myItemImg}).inject(this.myItem);
  126. this.myItemText = new Element("div.myItemText",{styles:this.css.myItemText,text:this.lp.navi.myItem}).inject(this.myItem);
  127. this.myItemCount = new Element("div.myItemCount",{styles:this.css.myItemCount,text:resData.myCount}).inject(this.myItem);
  128. // this.myItemIcon = new Element("div.myItemIcon",{styles:this.css.myItemIcon}).inject(this.myItem);
  129. this.myItem.addEvents({
  130. mouseover:function(){
  131. this.myItem.setStyles({
  132. "background-color":"#F2F5F7"
  133. });
  134. this.myItemImg.setStyles({
  135. "background-image":"url(/x_component_TeamWork/$ProjectList/default/icon/icon_wdxm_xm_click.png)"
  136. });
  137. this.myItemText.setStyles({
  138. "color":"#4A90E2"
  139. });
  140. }.bind(this),
  141. mouseout:function(){
  142. this.myItem.setStyles(this.css.naviItem);
  143. this.myItemImg.setStyles(this.css.myItemImg);
  144. this.myItemText.setStyles(this.css.myItemText);
  145. }.bind(this),
  146. click:function(){
  147. this.openItem({type:"my"});
  148. this.currentNavi = "my"
  149. }.bind(this)
  150. });
  151. }
  152. //未分组项目
  153. if(resData.hasOwnProperty("unGroupCount")){
  154. this.unGroupItem = new Element("div.unGroupItem",{styles:this.css.naviItem}).inject(this.naviContent);
  155. this.unGroupItemImg = new Element("div.unGroupItemImg",{styles:this.css.unGroupItemImg}).inject(this.unGroupItem);
  156. this.unGroupItemText = new Element("div.unGroupItemText",{styles:this.css.unGroupItemText,text:this.lp.navi.unGroupItem}).inject(this.unGroupItem);
  157. this.unGroupItemCount = new Element("div.unGroupItemCount",{styles:this.css.unGroupItemCount,text:resData.unGroupCount}).inject(this.unGroupItem);
  158. this.unGroupItem.addEvents({
  159. mouseover:function(){
  160. this.unGroupItem.setStyles({
  161. "background-color":"#F2F5F7"
  162. });
  163. this.unGroupItemImg.setStyles({
  164. "background-image":"url(/x_component_TeamWork/$ProjectList/default/icon/icon_wfzxm_xm_click.png)"
  165. });
  166. this.unGroupItemText.setStyles({
  167. "color":"#4A90E2"
  168. });
  169. }.bind(this),
  170. mouseout:function(){
  171. this.unGroupItem.setStyles(this.css.naviItem);
  172. this.unGroupItemImg.setStyles(this.css.unGroupItemImg);
  173. this.unGroupItemText.setStyles(this.css.unGroupItemText);
  174. }.bind(this),
  175. click:function(){
  176. this.openItem({type:"unGroup"});
  177. this.currentNavi = "unGroup"
  178. }.bind(this)
  179. });
  180. }
  181. //已完成项目
  182. if(resData.hasOwnProperty("completedCount")){
  183. this.completeItem = new Element("div.completeItem",{styles:this.css.naviItem}).inject(this.naviContent);
  184. this.completeItemImg = new Element("div.completeItemImg",{styles:this.css.completeItemImg}).inject(this.completeItem);
  185. this.completeItemText = new Element("div.completeItemText",{styles:this.css.completeItemText,text:this.lp.navi.completeItem}).inject(this.completeItem);
  186. this.completeItemCount = new Element("div.completeItemCount",{styles:this.css.completeItemCount,text:resData.completedCount}).inject(this.completeItem);
  187. this.completeItem.addEvents({
  188. mouseover:function(){
  189. this.completeItem.setStyles({
  190. "background-color":"#F2F5F7"
  191. });
  192. this.completeItemImg.setStyles({
  193. "background-image":"url(/x_component_TeamWork/$ProjectList/default/icon/icon_renwu_ywc_click.png)"
  194. });
  195. this.completeItemText.setStyles({
  196. "color":"#4A90E2"
  197. });
  198. }.bind(this),
  199. mouseout:function(){
  200. this.completeItem.setStyles(this.css.naviItem);
  201. this.completeItemImg.setStyles(this.css.completeItemImg);
  202. this.completeItemText.setStyles(this.css.completeItemText);
  203. }.bind(this),
  204. click:function(){
  205. this.openItem({type:"complete"});
  206. this.currentNavi = "complete"
  207. }.bind(this)
  208. });
  209. }
  210. //已归档
  211. if(resData.hasOwnProperty("archiveCount")){
  212. this.historyItem = new Element("div.historyItem",{styles:this.css.naviItem}).inject(this.naviContent);
  213. this.historyItemImg = new Element("div.historyItemImg",{styles:this.css.historyItemImg}).inject(this.historyItem);
  214. this.historyItemText = new Element("div.historyItemText",{styles:this.css.historyItemText,text:this.lp.navi.historyItem}).inject(this.historyItem);
  215. this.historyItemCount = new Element("div.historyItemCount",{styles:this.css.historyItemCount,text:resData.archiveCount}).inject(this.historyItem);
  216. // this.historyItemIcon = new Element("div.historyItemIcon",{styles:this.css.historyItemIcon}).inject(this.historyItem);
  217. this.historyItem.addEvents({
  218. mouseover:function(){
  219. this.historyItem.setStyles({
  220. "background-color":"#F2F5F7"
  221. });
  222. this.historyItemImg.setStyles({
  223. "background-image":"url(/x_component_TeamWork/$ProjectList/default/icon/icon_lsck_xm_click.png)"
  224. });
  225. this.historyItemText.setStyles({
  226. "color":"#4A90E2"
  227. });
  228. }.bind(this),
  229. mouseout:function(){
  230. this.historyItem.setStyles(this.css.naviItem);
  231. this.historyItemImg.setStyles(this.css.historyItemImg);
  232. this.historyItemText.setStyles(this.css.historyItemText);
  233. }.bind(this),
  234. click:function(){
  235. this.openItem({type:"archive"});
  236. this.currentNavi = "archive"
  237. }.bind(this)
  238. });
  239. }
  240. //回收站
  241. if(resData.hasOwnProperty("deleteCount")){
  242. this.removeItem = new Element("div.removeItem",{styles:this.css.naviItem}).inject(this.naviContent);
  243. this.removeItemImg = new Element("div.removeItemImg",{styles:this.css.removeItemImg}).inject(this.removeItem);
  244. this.removeItemText = new Element("div.removeItemText",{styles:this.css.removeItemText,text:this.lp.navi.removeItem}).inject(this.removeItem);
  245. this.removeItemCount = new Element("div.removeItemCount",{styles:this.css.removeItemCount,text:resData.deleteCount}).inject(this.removeItem);
  246. this.removeItem.addEvents({
  247. mouseover:function(){
  248. this.removeItem.setStyles({
  249. "background-color":"#F2F5F7"
  250. });
  251. this.removeItemImg.setStyles({
  252. "background-image":"url(/x_component_TeamWork/$ProjectList/default/icon/icon_delete_blue_click.png)"
  253. });
  254. this.removeItemText.setStyles({
  255. "color":"#4A90E2"
  256. });
  257. }.bind(this),
  258. mouseout:function(){
  259. this.removeItem.setStyles(this.css.naviItem);
  260. this.removeItemImg.setStyles(this.css.removeItemImg);
  261. this.removeItemText.setStyles(this.css.removeItemText);
  262. }.bind(this),
  263. click:function(){
  264. this.openItem({type:"remove"});
  265. this.currentNavi = "remove"
  266. }.bind(this)
  267. });
  268. }
  269. //项目分组
  270. this.groupMenu = new Element("div.groupMenu",{styles:this.css.naviMenu}).inject(this.naviContent);
  271. this.groupMenuText = new Element("div.groupMenu",{styles:this.css.groupMenuText,text:this.lp.navi.groupMenu}).inject(this.groupMenu);
  272. this.groupMenuAdd = new Element("div.groupMenuAdd",{styles:this.css.groupMenuAdd}).inject(this.groupMenu);
  273. this.groupMenuAdd.addEvents({
  274. click:function(e){
  275. this.createProjectGroup(this.groupMenuAdd);
  276. e.stopPropagation();
  277. }.bind(this),
  278. mouseover:function(e){
  279. this.app.showTips(this.groupMenuAdd,{_html:"<div style='margin:2px 5px;'>"+this.lp.navi.addGroup+"</div>"});
  280. e.stopPropagation();
  281. }.bind(this)
  282. });
  283. this.groupMenu.addEvents({
  284. mouseover:function(){
  285. this.groupMenu.setStyles({
  286. "background-color":"#F2F5F7"
  287. });
  288. this.groupMenuText.setStyles({"color":"#4A90E2"});
  289. this.groupMenuAdd.setStyles({
  290. "background-image":"url(/x_component_TeamWork/$ProjectList/default/icon/icon_zengjia_blue2_click.png)"
  291. })
  292. }.bind(this),
  293. mouseout:function(){
  294. this.groupMenu.setStyles(this.css.naviMenu);
  295. this.groupMenuText.setStyles(this.css.groupMenuText);
  296. this.groupMenuAdd.setStyles(this.css.groupMenuAdd);
  297. }.bind(this),
  298. click:function(){
  299. }.bind(this)
  300. });
  301. this.loadProjectGroup();
  302. //新建项目分组
  303. this.groupAdd = new Element("div.groupAdd",{styles:this.css.groupAdd}).inject(this.naviContent);
  304. this.groupAdd.addEvents({
  305. mouseover:function(){
  306. this.groupAdd.setStyles({"background-color":"#F2F5F7"});
  307. }.bind(this),
  308. mouseout:function(){
  309. this.groupAdd.setStyles(this.css.groupAdd);
  310. }.bind(this),
  311. click:function(){
  312. this.createProjectGroup(this.groupAdd);
  313. }.bind(this)
  314. });
  315. new Element("div.groupAddIcon",{styles:this.css.groupAddIcon}).inject(this.groupAdd);
  316. new Element("div.groupAddText",{styles:this.css.groupAddText,text:this.lp.navi.addGroup}).inject(this.groupAdd);
  317. }
  318. }.bind(this));
  319. },
  320. clickNavi:function(){
  321. //点击
  322. if(this.currentNavi = "allItem"){
  323. this.openItem({"type":"all"})
  324. }else if(this.currentNavi = "star"){
  325. this.openItem({"type":"star"})
  326. }else if(this.currentNavi = "my"){
  327. this.openItem({"type":"my"})
  328. }else if(this.currentNavi = "complete"){
  329. this.openItem({"type":"complete"})
  330. }else if(this.currentNavi = "unGroup"){
  331. this.openItem({"unGroup":"all"})
  332. }else if(this.currentNavi = "archive"){
  333. this.openItem({"type":"archive"})
  334. }else if(this.currentNavi = "remove"){
  335. this.openItem({"type":"remove"})
  336. }else{
  337. }
  338. },
  339. addNewProject:function(){
  340. MWF.xDesktop.requireApp("TeamWork", "NewProject", function(){
  341. this.np = new MWF.xApplication.TeamWork.NewProject(this,{},
  342. {"width": 350,"height": 350,
  343. onPostOpen:function(){
  344. this.np.formAreaNode.setStyles({"top":"10px"});
  345. var fx = new Fx.Tween(this.np.formAreaNode,{duration:200});
  346. fx.start(["top"] ,"10px", "100px");
  347. }.bind(this),
  348. onPostClose:function(json){
  349. //this.reloadLayoutList();
  350. if(json.data && json.data.id){
  351. this.actions.projectGet(json.data.id,function(jsonr){
  352. if(jsonr.data){
  353. this.openProject(jsonr.data)
  354. }
  355. }.bind(this));
  356. }
  357. }.bind(this)
  358. },{
  359. container : this.container
  360. }
  361. );
  362. this.np.open();
  363. }.bind(this));
  364. },
  365. loadProjectGroup:function(){
  366. var _self = this;
  367. //自定义项目分组
  368. //if(this.customGroup) this.customGroup.empty();
  369. //else this.customGroup = new Element("div.customGroup",{styles:this.css.customGroup}).inject(this.naviContent);
  370. this.customGroup = new Element("div.customGroup",{styles:this.css.customGroup}).inject(this.naviContent);
  371. if(this.projectGroup.groups){
  372. this.projectGroup.groups.each(function(d){
  373. var customGroupItemContainer = new Element("div.customGroupItemContainer",{styles:this.css.customGroupItemContainer}).inject(this.customGroup);
  374. customGroupItemContainer.addEvents({
  375. mouseover:function(e){
  376. this.setStyles({"background-color":"#F2F5F7","color":"#4A90E2"});
  377. this.getElements(".customGroupItemRemove").setStyles({"display":"block"});
  378. this.getElements(".customGroupItemEdit").setStyles({"display":"block"});
  379. //_self.app.showTips(this,{_html:"<div>"+d.title+"</div>"});
  380. },
  381. mouseout:function(){
  382. if(this.get("atIn")!="yes"){
  383. this.setStyles(_self.css.customGroupItemContainer);
  384. this.getElements(".customGroupItemRemove").setStyles({"display":"none"});
  385. this.getElements(".customGroupItemEdit").setStyles({"display":"none"});
  386. }
  387. },
  388. click:function(){
  389. _self.openItem({group:d.id});
  390. _self.currentNavi = d.id;
  391. }
  392. });
  393. var customGroupItem = new Element("div.customGroupItem",{styles:this.css.customGroupItem,text:d.name}).inject(customGroupItemContainer);
  394. var customGroupItemRemove = new Element("div.customGroupItemRemove",{styles:this.css.customGroupItemRemove}).inject(customGroupItemContainer);
  395. customGroupItemRemove.addEvents({
  396. click:function(e){
  397. customGroupItemContainer.set("atIn","yes");
  398. _self.app.confirm("warn",e,_self.app.lp.common.confirm.removeTitle,_self.app.lp.common.confirm.removeContent,300,120,function(){
  399. // var newData1 = [];
  400. // data1.each(function(dd){
  401. // if(dd.title != d.title) newData1.push(dd)
  402. // });
  403. // data1 = newData1;
  404. // var id ="";
  405. _self.actions.groupRemove(d.id,function(){
  406. _self.reloadProjectGroup();
  407. }.bind(this));
  408. this.close();
  409. customGroupItemContainer.set("atIn","no");
  410. },function(){
  411. this.close();
  412. customGroupItemContainer.set("atIn","no");
  413. });
  414. e.stopPropagation();
  415. }
  416. });
  417. var customGroupItemEdit = new Element("div.customGroupItemEdit",{styles:this.css.customGroupItemEdit}).inject(customGroupItemContainer);
  418. customGroupItemEdit.addEvents({
  419. click:function(e){
  420. customGroupItemContainer.set("atIn","yes");
  421. MWF.xDesktop.requireApp("TeamWork", "Group", function(){
  422. var json = d;
  423. json.do = "edit";
  424. var tooltip = new MWF.xApplication.TeamWork.Group(_self.container, customGroupItemEdit, _self.app, json, {
  425. axis : "y",
  426. nodeStyles : {
  427. "z-index" : "101"
  428. },
  429. onPostLoad:function(){
  430. tooltip.node.setStyles({"opacity":"0"});
  431. var fx = new Fx.Tween(tooltip.node,{duration:200});
  432. fx.start(["opacity"] ,"0", "1");
  433. tooltip.groupIn.select();
  434. },
  435. onClose:function(rd){
  436. customGroupItemContainer.set("atIn","no");
  437. if(rd)_self.reloadProjectGroup();
  438. }
  439. });
  440. tooltip.load()
  441. });
  442. e.stopPropagation()
  443. }
  444. });
  445. }.bind(this))
  446. }
  447. },
  448. reloadProjectGroup:function(){
  449. var _self = this;
  450. this.actions.groupList(function(json){
  451. var data = json.data;
  452. if(data.length == 0) return;
  453. this.customGroup.empty();
  454. data.each(function(d){
  455. var customGroupItemContainer = new Element("div.customGroupItemContainer",{styles:this.css.customGroupItemContainer}).inject(this.customGroup);
  456. customGroupItemContainer.addEvents({
  457. mouseover:function(e){
  458. this.setStyles({"background-color":"#F2F5F7","color":"#4A90E2"});
  459. this.getElements(".customGroupItemRemove").setStyles({"display":"block"});
  460. this.getElements(".customGroupItemEdit").setStyles({"display":"block"});
  461. //_self.app.showTips(this,{_html:"<div>"+d.title+"</div>"});
  462. },
  463. mouseout:function(){
  464. if(this.get("atIn")!="yes"){
  465. this.setStyles(_self.css.customGroupItemContainer);
  466. this.getElements(".customGroupItemRemove").setStyles({"display":"none"});
  467. this.getElements(".customGroupItemEdit").setStyles({"display":"none"});
  468. }
  469. },
  470. click:function(){
  471. alert(this.get("text"))
  472. }
  473. });
  474. var customGroupItem = new Element("div.customGroupItem",{styles:this.css.customGroupItem,text:d.name}).inject(customGroupItemContainer);
  475. var customGroupItemRemove = new Element("div.customGroupItemRemove",{styles:this.css.customGroupItemRemove}).inject(customGroupItemContainer);
  476. customGroupItemRemove.addEvents({
  477. click:function(e){
  478. customGroupItemContainer.set("atIn","yes");
  479. _self.app.confirm("warn",e,_self.app.lp.common.confirm.removeTitle,_self.app.lp.common.confirm.removeContent,300,120,function(){
  480. // var newData1 = [];
  481. // data1.each(function(dd){
  482. // if(dd.title != d.title) newData1.push(dd)
  483. // });
  484. // data1 = newData1;
  485. // var id ="";
  486. _self.actions.groupRemove(d.id,function(){
  487. _self.reloadProjectGroup();
  488. }.bind(this));
  489. this.close();
  490. customGroupItemContainer.set("atIn","no");
  491. },function(){
  492. this.close();
  493. customGroupItemContainer.set("atIn","no");
  494. });
  495. e.stopPropagation();
  496. }
  497. });
  498. var customGroupItemEdit = new Element("div.customGroupItemEdit",{styles:this.css.customGroupItemEdit}).inject(customGroupItemContainer);
  499. customGroupItemEdit.addEvents({
  500. click:function(e){
  501. customGroupItemContainer.set("atIn","yes");
  502. MWF.xDesktop.requireApp("TeamWork", "Group", function(){
  503. var json = d;
  504. json.do = "edit";
  505. var tooltip = new MWF.xApplication.TeamWork.Group(_self.container, customGroupItemEdit, _self.app, json, {
  506. axis : "y",
  507. nodeStyles : {
  508. "z-index" : "101"
  509. },
  510. onPostLoad:function(){
  511. tooltip.node.setStyles({"opacity":"0"});
  512. var fx = new Fx.Tween(tooltip.node,{duration:200});
  513. fx.start(["opacity"] ,"0", "1");
  514. tooltip.groupIn.select();
  515. },
  516. onClose:function(rd){
  517. customGroupItemContainer.set("atIn","no");
  518. if(rd)_self.reloadProjectGroup();
  519. }
  520. });
  521. tooltip.load()
  522. });
  523. e.stopPropagation()
  524. }
  525. });
  526. }.bind(this));
  527. }.bind(this));
  528. },
  529. createProjectGroup:function(node){
  530. MWF.xDesktop.requireApp("TeamWork", "Group", function(){
  531. var json = {};
  532. json.do = "add";
  533. var tooltip = new MWF.xApplication.TeamWork.Group(this.container, node, this.app, json, {
  534. axis : "y",
  535. nodeStyles : {
  536. "z-index" : "101"
  537. },
  538. onPostLoad:function(){
  539. tooltip.node.setStyles({"opacity":"0"});
  540. var fx = new Fx.Tween(tooltip.node,{duration:200});
  541. fx.start(["opacity"] ,"0", "1");
  542. }.bind(this),
  543. onClose:function(d){
  544. //if(d && d.title){
  545. // data1.push({"title":d.title});
  546. if(d)this.reloadProjectGroup();
  547. //}
  548. }.bind(this)
  549. });
  550. tooltip.load()
  551. }.bind(this));
  552. },
  553. //右边项目展示
  554. createContent:function(){
  555. if(this.contentTable) this.contentTable.empty();
  556. this.columnGray = new Element("div.columnGray",{styles:this.css.columnGray}).inject(this.contentTable); //灰色竖线
  557. this.projectContent = new Element("div.projectContent",{
  558. styles:this.css.projectContent
  559. }).inject(this.contentTable);
  560. this.rowGray = new Element("div.rowGray",{styles:this.css.rowGray}).inject(this.projectContent); //灰色竖线
  561. this.layoutMenu();
  562. this.layoutList();
  563. },
  564. layoutMenu:function(){
  565. //alert(this.currentListType)
  566. this.menuContainer = new Element("div.menuContainer",{styles:this.css.menuContainer}).inject(this.projectContent);
  567. this.menuTitle = new Element("div.menuTitle",{styles:this.css.menuTitle}).inject(this.menuContainer);
  568. this.menuCount = new Element("div.menuCount",{styles:this.css.menuCount}).inject(this.menuContainer);
  569. this.menuSetting = new Element("div.menuSetting",{styles:this.css.menuSetting}).inject(this.menuContainer);
  570. this.menuSettingList = new Element("dis.menuSettingList",{styles:this.css.menuSettingList}).inject(this.menuSetting);
  571. this.menuSettingList.addEvents({
  572. click:function(){
  573. this.currentListType = "list";
  574. this.menuSettingList.setStyle("background-image","url(/x_component_TeamWork/$ProjectList/default/icon/icon_liebiao_click.png)");
  575. this.menuSettingBlock.setStyle("background-image","url(/x_component_TeamWork/$ProjectList/default/icon/icon_tubiao.png)");
  576. this.openItem()
  577. }.bind(this),
  578. mouseover:function(){
  579. //this.app.showTips(this.menuSettingList,{_html:"<div style=''> "+this.lp.content.listTip+" </div>"},{axis:"y",position : { x : "auto", y : "top" }});
  580. }.bind(this)
  581. });
  582. this.menuSettingBlock = new Element("dis.menuSettingBlock",{styles:this.css.menuSettingBlock}).inject(this.menuSetting);
  583. this.menuSettingBlock.addEvents({
  584. click:function(){
  585. this.currentListType = "block";
  586. this.menuSettingList.setStyle("background-image","url(/x_component_TeamWork/$ProjectList/default/icon/icon_liebiao.png)");
  587. this.menuSettingBlock.setStyle("background-image","url(/x_component_TeamWork/$ProjectList/default/icon/icon_tubiao_click.png)");
  588. this.openItem()
  589. }.bind(this),
  590. mouseover:function(){
  591. //this.app.showTips(this.menuSettingList,{_html:"<div style=''> "+this.lp.content.blockTip+" </div>"},{axis:"y",position : { x : "auto", y : "top" }});
  592. }.bind(this)
  593. });
  594. if(this.currentListType == "block"){
  595. this.menuSettingBlock.setStyle("background-image","url(/x_component_TeamWork/$ProjectList/default/icon/icon_tubiao_click.png)");
  596. }else{
  597. this.menuSettingList.setStyle("background-image","url(/x_component_TeamWork/$ProjectList/default/icon/icon_liebiao_click.png)");
  598. }
  599. },
  600. reloadLayoutList:function(){
  601. if(this.layoutList)this.layoutList.empty();
  602. this.openItem()
  603. },
  604. layoutList:function(){
  605. this.layoutListContainer = new Element("div.layoutListContainer",{styles:this.css.layoutListContainer}).inject(this.projectContent);
  606. this.layoutList = new Element("div.layoutList",{styles:this.css.layoutList}).inject(this.layoutListContainer);
  607. //this.menuSettingBlock.click();
  608. },
  609. openItem:function(options){
  610. var _self = this;
  611. if(this.layoutList) this.layoutList.empty();
  612. var _self = this;
  613. var id = "(0)";
  614. var count = 100;
  615. var filter = {};
  616. var typeAction = "projectListNext";
  617. if(options && options.type && options.type=="all"){
  618. typeAction = "projectListNext"
  619. }else if(options && options.type && options.type=="star"){
  620. typeAction = "projectStarListNext"
  621. }else if(options && options.type && options.type=="my"){
  622. typeAction = "projectMyListNext"
  623. }else if(options && options.type && options.type=="complete"){
  624. typeAction = "projectCompleteListNext"
  625. }else if(options && options.type && options.type=="archive"){
  626. typeAction = "projectArchiveListNext"
  627. }else if(options && options.type && options.type=="remove"){
  628. typeAction = "projectRemoveListNext"
  629. }else if(options && options.type && options.type=="unGroup"){
  630. typeAction = "projectUnGroupListNext"
  631. }
  632. if(options && options.group){
  633. groupId = options.group;
  634. typeAction = "projectListNext";
  635. filter = {group:groupId};
  636. }
  637. //alert(typeAction)
  638. this.app.setLoading(this.layoutList);
  639. this.actions[typeAction](id, count, filter,function(json){
  640. this.layoutList.empty();
  641. var projectItemData = json.data;
  642. if(options && options.type && options.type=="all"){
  643. this.menuTitle.set("text","全部项目");
  644. }else if(options && options.type && options.type=="star"){
  645. this.menuTitle.set("text","我的星标")
  646. }else if(options && options.type && options.type=="my"){
  647. typeAction = "projectMyListNext"
  648. }else if(options && options.type && options.type=="complete"){
  649. typeAction = "projectCompleteListNext"
  650. }else if(options && options.type && options.type=="archive"){
  651. typeAction = "projectArchiveListNext"
  652. }else if(options && options.type && options.type=="remove"){
  653. typeAction = "projectRemoveListNext"
  654. }else if(options && options.type && options.type=="unGroup"){
  655. typeAction = "projectUnGroupListNext"
  656. }
  657. if(options && options.group){
  658. groupId = options.group;
  659. typeAction = "projectListNext";
  660. filter = {group:groupId};
  661. }
  662. this.menuCount.set("text","("+json.count+")");
  663. //debugger;
  664. if(this.currentListType=="list"){
  665. projectItemData.each(function(d){
  666. var projectListItem = new Element("div.projectListItem",{styles:this.css.projectListItem}).inject(this.layoutList);
  667. projectListItem.addEvents({
  668. click:function(){
  669. _self.openProject(d);
  670. },
  671. mouseenter:function(){
  672. this.setStyles({
  673. "background-color":"#F2F5F7"
  674. });
  675. //projectListItem.getElements(".projectListItemRemoveIcon").setStyles({"display":"block"});
  676. //projectListItem.getElements(".projectListItemSettingIcon").setStyles({"display":"block"});
  677. projectListItem.getElements(".projectListItemContainer").setStyles({"border-bottom-width":"0px"});
  678. },
  679. mouseleave:function(){
  680. this.setStyles({
  681. "background-color":""
  682. });
  683. //projectListItem.getElements(".projectListItemRemoveIcon").setStyles({"display":"none"});
  684. //projectListItem.getElements(".projectListItemSettingIcon").setStyles({"display":"none"});
  685. projectListItem.getElements(".projectListItemContainer").setStyles({"border-bottom-width":"1px"});
  686. }
  687. });
  688. this.loadSingleListItem(projectListItem,d);
  689. }.bind(this));
  690. this.addProjectList = new Element("div.addProjectList",{styles:this.css.addProjectList}).inject(this.layoutList);
  691. this.addProjectList.addEvents({
  692. click:function(){
  693. _self.addNewProject();
  694. },
  695. mouseover:function(){
  696. this.setStyles({
  697. "background-color":"#F2F5F7"
  698. });
  699. },
  700. mouseout:function(){
  701. this.setStyles({
  702. "background-color":""
  703. });
  704. }
  705. });
  706. this.addProjectListImgContainer = new Element("div.addProjectListImgContainer",{styles:this.css.addProjectListImgContainer}).inject(this.addProjectList);
  707. this.addProjectListImg = new Element("div.addProjectListImg",{styles:this.css.addProjectListImg}).inject(this.addProjectListImgContainer);
  708. this.addProjectListText = new Element("div.addProjectListText",{styles:this.css.addProjectListText,text:this.lp.content.addProjectListText}).inject(this.addProjectList);
  709. }else{
  710. projectItemData.each(function(d){
  711. var projectBlockItem = new Element("div.projectBlockItem",{styles:this.css.projectBlockItem}).inject(this.layoutList);
  712. if(d.icon && d.icon!=""){
  713. projectBlockItem.setStyles({
  714. "background-image":"url('"+MWF.xDesktop.getImageSrc( d.icon )+"')"
  715. });
  716. }
  717. projectBlockItem.addEvents({
  718. click:function(){
  719. _self.openProject(d);
  720. },
  721. mouseenter:function(){
  722. this.setStyles({
  723. "box-shadow":"0px 0px 10px #4a90e2"
  724. });
  725. //projectBlockItem.getElements(".projectBlockItemIconSetting").setStyles({"display":"block"});
  726. //projectBlockItem.getElements(".projectBlockItemIconRemove").setStyles({"display":"block"});
  727. },
  728. mouseleave:function(){
  729. this.setStyles({
  730. "box-shadow":"0px 0px 0px #DFDFDF"
  731. });
  732. //projectBlockItem.getElements(".projectBlockItemIconSetting").setStyles({"display":"none"});
  733. //projectBlockItem.getElements(".projectBlockItemIconRemove").setStyles({"display":"none"});
  734. }
  735. });
  736. this.loadSingleBlockItem(projectBlockItem,d);
  737. }.bind(this));
  738. this.addProjectBlock = new Element("div.addProjectBlock",{styles:this.css.addProjectBlock}).inject(this.layoutList);
  739. this.addProjectBlockIcon = new Element("div.addProjectBlockIcon",{styles:this.css.addProjectBlockIcon}).inject(this.addProjectBlock);
  740. this.addProjectBlockText = new Element("div.addProjectBlockText",{styles:this.css.addProjectBlockText,text:this.lp.content.addProjectBlockText}).inject(this.addProjectBlock);
  741. this.addProjectBlock.addEvents({
  742. click:function(){
  743. _self.addNewProject();
  744. },
  745. mouseenter:function(){
  746. this.setStyles({
  747. "box-shadow":"0px 0px 10px #4a90e2"
  748. });
  749. //var fx = new Fx.Tween(this,{duration:50});
  750. //fx.start(["margin-top"] ,"10px", "5px");
  751. },
  752. mouseleave:function(){
  753. this.setStyles({
  754. "box-shadow":"0px 0px 0px #DFDFDF"
  755. });
  756. //var fx = new Fx.Tween(this,{duration:50});
  757. //fx.start(["margin-top"] ,"5px", "10px");
  758. }
  759. })
  760. }
  761. }.bind(this));
  762. },
  763. loadSingleBlockItem:function(container,d){
  764. if(container) container.empty();
  765. var projectBlockItemCover = new Element("div.projectBlockItemCover",{styles:this.css.projectBlockItemCover}).inject(container);
  766. var _self = this;
  767. var projectBlockItemIconContainer = new Element("div.projectBlockItemIconContainer",{styles:this.css.projectBlockItemIconContainer}).inject(projectBlockItemCover);
  768. var projectBlockItemIconFav = new Element("div.projectBlockItemIconFav",{styles:this.css.projectBlockItemIconFav}).inject(projectBlockItemIconContainer);
  769. projectBlockItemIconFav.addEvents({
  770. click:function(e){
  771. _self.setFav(d,function(data){
  772. _self.actions.projectGet(data.data.id,function(json){
  773. _self.loadSingleBlockItem(container,json.data)
  774. });
  775. _self.createNavi();
  776. });
  777. e.stopPropagation();
  778. }
  779. });
  780. if(d.star){
  781. projectBlockItemIconFav.setStyles({
  782. "background-image":"url(/x_component_TeamWork/$ProjectList/default/icon/icon_wdxx_click.png)"
  783. });
  784. }
  785. var projectBlockItemIconSetting = new Element("div.projectBlockItemIconSetting",{styles:this.css.projectBlockItemIconSetting}).inject(projectBlockItemIconContainer);
  786. projectBlockItemIconSetting.addEvents({
  787. click:function(e){
  788. MWF.xDesktop.requireApp("TeamWork", "ProjectSetting", function(){
  789. var ps = new MWF.xApplication.TeamWork.ProjectSetting(_self,d,
  790. {"width": 700,"height": 600,
  791. onPostOpen:function(){
  792. ps.formAreaNode.setStyles({"top":"10px"});
  793. var fx = new Fx.Tween(ps.formAreaNode,{duration:200});
  794. fx.start(["top"] ,"10px", "100px");
  795. },
  796. onPostClose:function(json){
  797. // _self.actions.projectGet(d.id,function(json){
  798. // _self.loadSingleBlockItem(container,json.data)
  799. // });
  800. _self.reload();
  801. }
  802. },{
  803. container : _self.container,
  804. lp : _self.lp.projectSetting,
  805. css:_self.css
  806. }
  807. );
  808. ps.open();
  809. });
  810. e.stopPropagation();
  811. }
  812. });
  813. var projectBlockItemIconRemove = new Element("div.projectBlockItemIconRemove",{styles:this.css.projectBlockItemIconRemove}).inject(projectBlockItemIconContainer);
  814. projectBlockItemIconRemove.addEvents({
  815. click:function(e){
  816. _self.app.confirm("warn",e,_self.app.lp.common.confirm.removeTitle,_self.app.lp.common.confirm.removeContent,300,120,function(){
  817. var id = d.id;
  818. _self.actions.projectRemove(id,function(){
  819. //刷新代码
  820. this.close();
  821. _self.reload();
  822. }.bind(this));
  823. },function(){
  824. this.close();
  825. });
  826. e.stopPropagation();
  827. }.bind(this)
  828. });
  829. var projectBlockItemName = new Element("div.projectBlockItemName",{styles:this.css.projectBlockItemName,text:d.title}).inject(projectBlockItemCover);
  830. var projectBlockItemDes = new Element("div.projectBlockItemDes",{styles:this.css.projectBlockItemDes,text:(d.projectDetail && d.projectDetail.description)||""}).inject(projectBlockItemCover);
  831. },
  832. loadSingleListItem:function(container,d){
  833. if(container) container.empty();
  834. var _self = this;
  835. var projectListItemImgContainer = new Element("div.projectListItemImgContainer",{styles:this.css.projectListItemImgContainer}).inject(container);
  836. var projectListItemImg = new Element("div.projectListItemImg",{styles:this.css.projectListItemImg}).inject(projectListItemImgContainer);
  837. if(d.icon && d.icon!=""){
  838. projectListItemImg.setStyles({
  839. "background-image":"url('"+MWF.xDesktop.getImageSrc( d.icon )+"')"
  840. });
  841. }
  842. var projectListItemContainer = new Element("div.projectListItemContainer",{styles:this.css.projectListItemContainer}).inject(container);
  843. var projectListItemInforContainer = new Element("div.projectListItemInforContainer",{styles:this.css.projectListItemInforContainer}).inject(projectListItemContainer);
  844. var projectListItemTitle = new Element("div.projectListItemTitle",{styles:this.css.projectListItemTitle,text:d.title}).inject(projectListItemInforContainer);
  845. var projectListItemDes = new Element("div.projectListItemDes",{styles:this.css.projectListItemDes,text:(d.projectDetail && d.projectDetail.description)||""}).inject(projectListItemInforContainer);
  846. var projectListItemIconContainer = new Element("div.projectListItemIconContainer",{styles:this.css.projectListItemIconContainer}).inject(projectListItemContainer);
  847. var projectListItemFavIcon = new Element("div.projectListItemFavIcon",{styles:this.css.projectListItemFavIcon}).inject(projectListItemIconContainer);
  848. projectListItemFavIcon.addEvents({
  849. click:function(e){
  850. _self.setFav(d,function(data){
  851. _self.actions.projectGet(data.data.id,function(json){
  852. _self.loadSingleListItem(container,json.data)
  853. });
  854. _self.createNavi();
  855. });
  856. if(projectListItemFavIcon.getStyle("background-image").indexOf("icon_wdxx_click.png")>-1){
  857. projectListItemFavIcon.setStyles({
  858. "background-image":"url(/x_component_TeamWork/$ProjectList/default/icon/icon_wdxx_1.png)"
  859. })
  860. }else{
  861. projectListItemFavIcon.setStyles({
  862. "background-image":"url(/x_component_TeamWork/$ProjectList/default/icon/icon_wdxx_click.png)"
  863. })
  864. }
  865. e.stopPropagation();
  866. }
  867. });
  868. if(d.star){
  869. projectListItemFavIcon.setStyles({
  870. "background-image":"url(/x_component_TeamWork/$ProjectList/default/icon/icon_wdxx_click.png)"
  871. });
  872. }
  873. var projectListItemSettingIcon = new Element("div.projectListItemSettingIcon",{styles:this.css.projectListItemSettingIcon}).inject(projectListItemIconContainer);
  874. projectListItemSettingIcon.addEvents({
  875. click:function(e){
  876. MWF.xDesktop.requireApp("TeamWork", "ProjectSetting", function(){
  877. var ps = new MWF.xApplication.TeamWork.ProjectSetting(_self,d,
  878. {"width": 700,"height": 600,
  879. onPostOpen:function(){
  880. ps.formAreaNode.setStyles({"top":"10px"});
  881. var fx = new Fx.Tween(ps.formAreaNode,{duration:200});
  882. fx.start(["top"] ,"10px", "100px");
  883. },
  884. onPostClose:function(json){
  885. _self.actions.projectGet(d.id,function(json){
  886. _self.loadSingleListItem(container,json.data)
  887. });
  888. }
  889. },{
  890. container : _self.container,
  891. lp : _self.lp.projectSetting,
  892. css:_self.css
  893. }
  894. );
  895. ps.open();
  896. });
  897. e.stopPropagation();
  898. }
  899. });
  900. var projectListItemRemoveIcon = new Element("div.projectListItemRemoveIcon",{styles:this.css.projectListItemRemoveIcon}).inject(projectListItemIconContainer);
  901. projectListItemRemoveIcon.addEvents({
  902. click:function(e){
  903. _self.app.confirm("warn",e,_self.app.lp.common.confirm.removeTitle,_self.app.lp.common.confirm.removeContent,300,120,function(){
  904. var id = d.id;
  905. _self.actions.projectRemove(id,function(){
  906. //刷新代码
  907. this.close();
  908. _self.reload();
  909. }.bind(this));
  910. },function(){
  911. this.close();
  912. });
  913. e.stopPropagation();
  914. }
  915. });
  916. },
  917. setFav:function(d,callback){
  918. if(d.star){
  919. this.actions.projectUnStar(d.id,function(d){
  920. if(callback)callback(d)
  921. }.bind(this))
  922. }else if(!d.star){
  923. this.actions.projectStar(d.id,function(d){
  924. if(callback)callback(d)
  925. }.bind(this))
  926. }
  927. },
  928. openProject:function(d){
  929. MWF.xDesktop.requireApp("TeamWork", "Project", function(){
  930. var p = new MWF.xApplication.TeamWork.Project(this.container,this.app,d,{
  931. }
  932. );
  933. p.load();
  934. }.bind(this));
  935. },
  936. test:function(){
  937. }
  938. });