ProjectSetting.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. MWF.xApplication.TeamWork = MWF.xApplication.TeamWork || {};
  2. MWF.xApplication.TeamWork.ProjectSetting = new Class({
  3. Extends: MWF.xApplication.TeamWork.Common.Popup,
  4. options:{
  5. "closeByClickMask" : false
  6. },
  7. open: function (e) {
  8. //设置css 和 lp等
  9. var css = this.css;
  10. this.cssPath = "/x_component_TeamWork/$ProjectSetting/"+this.options.style+"/css.wcss";
  11. this._loadCss();
  12. if(css) this.css = Object.merge( css, this.css );
  13. this.lp = this.app.lp.projectSetting;
  14. this.fireEvent("queryOpen");
  15. this.isNew = false;
  16. this.isEdited = false;
  17. this._open();
  18. this.fireEvent("postOpen");
  19. },
  20. _createTableContent: function () {
  21. this.projectInfor(function(rs){
  22. this.groups = rs.groups;
  23. this.groupsArr = [];
  24. this.projectSettingTop = new Element("div.projectSettingTop",{styles:this.css.projectSettingTop}).inject(this.formTableArea);
  25. this.projectSettingTopText = new Element("div.projectSettingTopText",{styles:this.css.projectSettingTopText,text:this.lp.title}).inject(this.projectSettingTop);
  26. this.projectSettingTopClose = new Element("div.projectSettingTopClose",{styles:this.css.projectSettingTopClose}).inject(this.projectSettingTop);
  27. this.projectSettingTopClose.addEvents({
  28. click:function(){this.close()}.bind(this)
  29. });
  30. this.projectSettingContent = new Element("div.projectSettingContent",{styles:this.css.projectSettingContent}).inject(this.formTableArea);
  31. this.projectSettingNaviLayout = new Element("div.projectSettingNaviLayout",{styles:this.css.projectSettingNaviLayout}).inject(this.projectSettingContent);
  32. this.projectSettingLayout = new Element("div.projectSettingLayout",{styles:this.css.projectSettingLayout}).inject(this.projectSettingContent);
  33. this.createNavi();
  34. }.bind(this));
  35. },
  36. createNavi:function(){
  37. var _self = this;
  38. this.projectSettingNaviLayout.empty();
  39. //概况
  40. this.naviGeneral = new Element("div.naviGeneral",{styles:this.css.naviItem}).inject(this.projectSettingNaviLayout);
  41. this.naviGeneralHover = new Element("div.naviItemHover",{styles:this.css.naviItemHover}).inject(this.naviGeneral);
  42. this.naviGeneralHover.setStyles({"height":"58px","margin-top":"2px"});
  43. this.naviGeneralIcon = new Element("div.naviItemIcon",{styles:this.css.naviItemIcon}).inject(this.naviGeneral);
  44. this.naviGeneralIcon.setStyles({"background-image":"url(/x_component_TeamWork/$ProjectSetting/default/icon/icon_general.png)"});
  45. this.naviGeneralText = new Element("div.naviItemText",{styles:this.css.naviItemText,text:this.lp.general}).inject(this.naviGeneral);
  46. this.naviGeneral.addEvents({
  47. "mouseover":function(){
  48. if(_self.curNavi == "general") return;
  49. this.getElements(".naviItemIcon").setStyles({"background-image":"url(/x_component_TeamWork/$ProjectSetting/default/icon/icon_general_click.png)"});
  50. this.getElements(".naviItemText").setStyles({"color":"#4a90e2"});
  51. },
  52. mouseout:function(){
  53. if(_self.curNavi == "general") return;
  54. this.getElement(".naviItemIcon").setStyles({"background-image":"url(/x_component_TeamWork/$ProjectSetting/default/icon/icon_general.png)"});
  55. this.getElement(".naviItemText").setStyles({"color":""});
  56. },
  57. click:function(){
  58. _self.curNavi = "general";
  59. _self.changeNavi(this);
  60. _self.loadGeneral();
  61. }
  62. })
  63. //自定义字段
  64. this.naviCustom = new Element("div.naviCustom",{styles:this.css.naviItem}).inject(this.projectSettingNaviLayout);
  65. this.naviCustomHover = new Element("div.naviItemHover",{styles:this.css.naviItemHover}).inject(this.naviCustom);
  66. this.naviCustomIcon = new Element("div.naviItemIcon",{styles:this.css.naviItemIcon}).inject(this.naviCustom);
  67. this.naviCustomIcon.setStyles({"background-image":"url(/x_component_TeamWork/$ProjectSetting/default/icon/icon_custom.png)"});
  68. this.naviCustomText = new Element("div.naviItemText",{styles:this.css.naviItemText,text:this.lp.customField}).inject(this.naviCustom);
  69. this.naviCustom.addEvents({
  70. mouseover:function(){
  71. if(_self.curNavi == "custom") return;
  72. this.getElements(".naviItemIcon").setStyles({"background-image":"url(/x_component_TeamWork/$ProjectSetting/default/icon/icon_custom_click.png)"});
  73. this.getElements(".naviItemText").setStyles({"color":"#4a90e2"});
  74. },
  75. mouseout:function(){
  76. if(_self.curNavi == "custom") return;
  77. this.getElement(".naviItemIcon").setStyles({"background-image":"url(/x_component_TeamWork/$ProjectSetting/default/icon/icon_custom.png)"});
  78. this.getElement(".naviItemText").setStyles({"color":""});
  79. },
  80. click:function(){
  81. _self.curNavi = "custom";
  82. _self.changeNavi(this);
  83. _self.loadCustom()
  84. }
  85. })
  86. this.naviCustom = new Element("div.naviCustom",{styles:this.css.naviItem}).inject(this.projectSettingNaviLayout);
  87. this.naviCustomHover = new Element("div.naviItemHover",{styles:this.css.naviItemHover}).inject(this.naviCustom);
  88. this.naviCustomIcon = new Element("div.naviItemIcon",{styles:this.css.naviItemIcon}).inject(this.naviCustom);
  89. this.naviCustomIcon.setStyles({"background-image":"url(/x_component_TeamWork/$ProjectSetting/default/icon/icon_custom.png)"});
  90. this.naviCustomText = new Element("div.naviItemText",{styles:this.css.naviItemText,text:"任务设置"}).inject(this.naviCustom);
  91. this.naviCustom.addEvents({
  92. mouseover:function(){
  93. if(_self.curNavi == "custom") return;
  94. this.getElements(".naviItemIcon").setStyles({"background-image":"url(/x_component_TeamWork/$ProjectSetting/default/icon/icon_custom_click.png)"});
  95. this.getElements(".naviItemText").setStyles({"color":"#4a90e2"});
  96. },
  97. mouseout:function(){
  98. if(_self.curNavi == "custom") return;
  99. this.getElement(".naviItemIcon").setStyles({"background-image":"url(/x_component_TeamWork/$ProjectSetting/default/icon/icon_custom.png)"});
  100. this.getElement(".naviItemText").setStyles({"color":""});
  101. },
  102. click:function(){
  103. _self.curNavi = "custom";
  104. _self.changeNavi(this);
  105. _self.loadCustom()
  106. }
  107. })
  108. this.naviCustom = new Element("div.naviCustom",{styles:this.css.naviItem}).inject(this.projectSettingNaviLayout);
  109. this.naviCustomHover = new Element("div.naviItemHover",{styles:this.css.naviItemHover}).inject(this.naviCustom);
  110. this.naviCustomIcon = new Element("div.naviItemIcon",{styles:this.css.naviItemIcon}).inject(this.naviCustom);
  111. this.naviCustomIcon.setStyles({"background-image":"url(/x_component_TeamWork/$ProjectSetting/default/icon/icon_custom.png)"});
  112. this.naviCustomText = new Element("div.naviItemText",{styles:this.css.naviItemText,text:"更多设置"}).inject(this.naviCustom);
  113. this.naviCustom.addEvents({
  114. mouseover:function(){
  115. if(_self.curNavi == "custom") return;
  116. this.getElements(".naviItemIcon").setStyles({"background-image":"url(/x_component_TeamWork/$ProjectSetting/default/icon/icon_custom_click.png)"});
  117. this.getElements(".naviItemText").setStyles({"color":"#4a90e2"});
  118. },
  119. mouseout:function(){
  120. if(_self.curNavi == "custom") return;
  121. this.getElement(".naviItemIcon").setStyles({"background-image":"url(/x_component_TeamWork/$ProjectSetting/default/icon/icon_custom.png)"});
  122. this.getElement(".naviItemText").setStyles({"color":""});
  123. },
  124. click:function(){
  125. _self.curNavi = "custom";
  126. _self.changeNavi(this);
  127. _self.loadCustom()
  128. }
  129. })
  130. this.naviGeneral.click()
  131. },
  132. changeNavi:function(obj){
  133. this.projectSettingNaviLayout.getElements(".naviItemHover").setStyles({"background-color":"#ffffff"});
  134. this.projectSettingNaviLayout.getElements(".naviItemText").setStyles({"color":""});
  135. this.projectSettingNaviLayout.getElements(".naviItemIcon").each(function(dom){
  136. var bgurl = dom.getStyle("background-image");
  137. if(bgurl.indexOf("_click")>-1){
  138. bgurl = bgurl.replace("_click","");
  139. }
  140. dom.setStyles({"background-image":bgurl});
  141. }.bind(this))
  142. obj.getElement(".naviItemHover").setStyles({"background-color":"#4a90e2"});
  143. obj.getElement(".naviItemIcon").setStyles({"background-image":obj.getElement(".naviItemIcon").getStyle("background-image").replace(".png","_click.png")});
  144. obj.getElement(".naviItemText").setStyles({"color":"#4a90e2"});
  145. },
  146. loadCustom:function(){
  147. this.projectSettingLayout.empty();
  148. this.customTopLayout = new Element("div.customTopLayout",{styles:this.css.customTopLayout}).inject(this.projectSettingLayout);
  149. this.customTopText = new Element("div.customTopText",{styles:this.css.customTopText,text:this.lp.customTip}).inject(this.customTopLayout);
  150. this.customTopNew = new Element("div.customTopNew",{styles:this.css.customTopNew,text:this.lp.customNew}).inject(this.customTopLayout);
  151. this.customTopNew.addEvents({
  152. mouseover:function(){this.setStyles({"opacity":"0.7"})},
  153. mouseout:function(){this.setStyles({"opacity":"1"})},
  154. click:function(){
  155. MWF.xDesktop.requireApp("TeamWork", "ExtField", function(){
  156. var pc = new MWF.xApplication.TeamWork.ExtField(this,this.container, this.customTopNew, this.app, {projectId:this.data.id}, {
  157. axis : "x",
  158. position : { //node 固定的位置
  159. x : "left",
  160. y : "middle"
  161. },
  162. nodeStyles : {
  163. "min-width":"200px",
  164. "width":"300px",
  165. "padding":"2px",
  166. "border-radius":"5px",
  167. "box-shadow":"0px 0px 4px 0px #999999",
  168. "z-index" : "201"
  169. },
  170. onPostLoad:function(){
  171. pc.node.setStyles({"opacity":"0","top":(pc.node.getStyle("top").toInt())+"px"});
  172. var fx = new Fx.Tween(pc.node,{duration:400});
  173. fx.start(["opacity"] ,"0", "1");
  174. },
  175. onClose:function(rd){
  176. if(!rd) return;
  177. if(rd.value && rd.value !=""){
  178. this.chatTextarea.set("value",this.chatTextarea.get("value")+"["+rd.value+"]")
  179. }
  180. }.bind(this)
  181. });
  182. pc.load();
  183. }.bind(this));
  184. }.bind(this)
  185. })
  186. this.customContent = new Element("div.customContent",{styles:this.css.customContent}).inject(this.projectSettingLayout);
  187. this.createExtFieldList();
  188. },
  189. createExtFieldList:function(){
  190. this.customContent.empty();
  191. this.app.setLoading(this.customContent);
  192. this.actions.projectExtFieldByProject(this.data.id,function(json){
  193. this.customContent.empty();
  194. json.data.each(function(data){
  195. this.createExtFieldItem(data);
  196. }.bind(this));
  197. }.bind(this))
  198. },
  199. createExtFieldItem:function(data){
  200. var _self = this;
  201. var customExtItem = new Element("div.customExtItem",{styles:this.css.customExtItem,id:data.id}).inject(this.customContent);
  202. customExtItem.addEvents({
  203. mouseover:function(){
  204. this.setStyles({"background-color":"#f5f5f5"});
  205. customExitItemRemove.show();
  206. customExitItemEdit.show();
  207. },
  208. mouseout:function(){
  209. this.setStyles({"background-color":""});
  210. customExitItemRemove.hide();
  211. customExitItemEdit.hide();
  212. }
  213. })
  214. var customExtItemTop = new Element("div.customExtItemTop",{styles:this.css.customExtItemTop}).inject(customExtItem);
  215. var customExtName = new Element("div.customExtName",{styles:this.css.customExtName,text:data.displayName}).inject(customExtItemTop);
  216. var customExitItemRemove = new Element("div.customExitItemRemove",{styles:this.css.customExitItemAction,text:this.lp.remove}).inject(customExtItemTop);
  217. customExitItemRemove.addEvents({
  218. click:function(e){
  219. _self.app.confirm("warn",e,_self.app.lp.common.confirm.removeTitle,_self.app.lp.common.confirm.removeContent,300,120,function(){
  220. _self.actions.projectExtFieldRemove(data.id,function(json){
  221. customExtItem.destroy();
  222. this.close();
  223. }.bind(this))
  224. },function(){
  225. this.close();
  226. });
  227. }
  228. })
  229. var customExitItemEdit = new Element("div.customExitItemEdit",{styles:this.css.customExitItemAction,text:this.lp.edit}).inject(customExtItemTop);
  230. customExitItemEdit.addEvents({
  231. click:function(){
  232. MWF.xDesktop.requireApp("TeamWork", "ExtField", function(){
  233. var pc = new MWF.xApplication.TeamWork.ExtField(this,this.container, this.customTopNew, this.app, {projectId:this.data.id,id:data.id}, {
  234. axis : "x",
  235. position : { //node 固定的位置
  236. x : "left",
  237. y : "middle"
  238. },
  239. nodeStyles : {
  240. "min-width":"200px",
  241. "width":"300px",
  242. "padding":"2px",
  243. "border-radius":"5px",
  244. "box-shadow":"0px 0px 4px 0px #999999",
  245. "z-index" : "201"
  246. },
  247. onPostLoad:function(){
  248. pc.node.setStyles({"opacity":"0","top":(pc.node.getStyle("top").toInt())+"px"});
  249. var fx = new Fx.Tween(pc.node,{duration:400});
  250. fx.start(["opacity"] ,"0", "1");
  251. },
  252. onClose:function(rd){
  253. if(!rd) return;
  254. if(rd.value && rd.value !=""){
  255. this.chatTextarea.set("value",this.chatTextarea.get("value")+"["+rd.value+"]")
  256. }
  257. }.bind(this)
  258. });
  259. pc.load();
  260. }.bind(this));
  261. }.bind(this)
  262. })
  263. var customExtValueList = new Element("div.customExtValueList",{styles:this.css.customExtValueList}).inject(customExtItem);
  264. new Element("span.customExtCreator",{styles:this.customExtText,text:this.lp.description+":"+data.description}).inject(customExtValueList);
  265. customExtValueList = new Element("div.customExtValueList",{styles:this.css.customExtValueList}).inject(customExtItem);
  266. new Element("span.customExtCreator",{styles:this.customExtText,text:this.lp.option + ":"+data.optionsData}).inject(customExtValueList);
  267. },
  268. loadGeneral:function(){
  269. this.projectSettingLayout.empty();
  270. this.groupsArr = [];
  271. this.projectSettingBgText = new Element("div.projectSettingBgText",{styles:this.css.projectSettingBgText,"text":this.lp.projectSettingBgText}).inject(this.projectSettingLayout);
  272. this.projectSettingBgContainer = new Element("div.projectSettingBgContainer",{styles:this.css.projectSettingBgContainer}).inject(this.projectSettingLayout);
  273. this.projectSettingBgImg = new Element("div.projectSettingBgImg",{styles:this.css.projectSettingBgImg}).inject(this.projectSettingBgContainer);
  274. if(this.data.icon && this.data.icon!=""){
  275. this.projectSettingBgImg.setStyles({
  276. "background-image":"url('"+MWF.xDesktop.getImageSrc( this.data.icon )+"')"
  277. });
  278. }
  279. this.projectSettingBgUpload = new Element("div.projectSettingBgUpload",{styles:this.css.projectSettingBgUpload,text:this.lp.upload}).inject(this.projectSettingBgContainer);
  280. this.projectSettingBgUpload.addEvents({
  281. click:function(){
  282. var data = {};
  283. MWF.xDesktop.requireApp("TeamWork", "UploadImage", function(){
  284. var ui = new MWF.xApplication.TeamWork.UploadImage(this, data, {
  285. documentId : this.data.id ||"",
  286. onPostOk : function( id ){
  287. this.data.icon = id;
  288. this.projectSettingBgImg.setStyles({
  289. "background-image":"url('"+MWF.xDesktop.getImageSrc( id )+"')"
  290. });
  291. }.bind(this)
  292. });
  293. ui.open()
  294. }.bind(this));
  295. }.bind(this)
  296. });
  297. this.projectSettingContainer = new Element("div.projectSettingContainer",{styles:this.css.projectSettingContainer}).inject(this.projectSettingLayout);
  298. this.projectSettingTitleContainer = new Element("div.projectSettingTitleContainer",{styles:this.css.projectSettingTitleContainer}).inject(this.projectSettingContainer);
  299. this.projectSettingTitleText = new Element("div.projectSettingTitleText",{styles:this.css.projectSettingTitleText,text:this.lp.projectTitle}).inject(this.projectSettingTitleContainer);
  300. this.projectSettingTitleDiv = new Element("div.projectSettingTitleDiv",{styles:this.css.projectSettingTitleDiv}).inject(this.projectSettingTitleContainer);
  301. this.projectSettingTitleIn = new Element("input.projectSettingTitleIn",{styles:this.css.projectSettingTitleIn,value:this.projectData.title || ""}).inject(this.projectSettingTitleDiv);
  302. // this.projectSettingContainer = new Element("div.projectSettingContainer",{styles:this.css.projectSettingContainer}).inject(this.formTableArea);
  303. this.projectSettingGroupContainer = new Element("div.projectSettingGroupContainer",{styles:this.css.projectSettingGroupContainer}).inject(this.projectSettingContainer);
  304. this.projectSettingGroupText = new Element("div.projectSettingGroupText",{styles:this.css.projectSettingGroupText,text:this.lp.projectGroup}).inject(this.projectSettingGroupContainer);
  305. this.projectSettingGroupDiv = new Element("div.projectSettingGroupDiv",{styles:this.css.projectSettingGroupDiv}).inject(this.projectSettingGroupContainer);
  306. this.projectSettingGroupDiv.addEvents({
  307. click:function(){
  308. var data = {groups:this.groups};
  309. MWF.xDesktop.requireApp("TeamWork", "GroupSelect", function(){
  310. var gs = new MWF.xApplication.TeamWork.GroupSelect(this.container, this.projectSettingGroupDiv, this.app, data, {
  311. axis : "y",
  312. nodeStyles : {
  313. "min-width":"190px",
  314. "z-index" : "102"
  315. },
  316. onClose:function(d){
  317. if(d){
  318. this.actions.groupWithIds({ids:d},function(json){
  319. this.groups = json.data;
  320. var tmp = [];
  321. json.data.each(function(ddd){
  322. tmp.push(ddd.name);
  323. });
  324. this.projectSettingGroupValue.set("text",tmp.join());
  325. this.projectSettingGroupValue.set("title",tmp.join())
  326. }.bind(this));
  327. }else{
  328. this.groups = [];
  329. }
  330. //this.newProjectGroupValue.set("text",d)
  331. }.bind(this)
  332. });
  333. gs.load()
  334. }.bind(this));
  335. }.bind(this)
  336. });
  337. this.projectSettingGroupValue = new Element("div.projectSettingGroupValue",{styles:this.css.projectSettingGroupValue}).inject(this.projectSettingGroupDiv);
  338. this.projectSettingGroupIcon = new Element("div.projectSettingGroupIcon",{styles:this.css.projectSettingGroupIcon}).inject(this.projectSettingGroupDiv);
  339. if(this.groups){
  340. this.groups.each(function(data){
  341. this.groupsArr.push(data.name);
  342. }.bind(this));
  343. }
  344. this.projectSettingGroupValue.set("text",this.groupsArr.join());
  345. this.projectSettingGroupValue.set("title",this.groupsArr.join());
  346. this.projectSettingContainer = new Element("div.projectSettingContainer",{styles:this.css.projectSettingContainer}).inject(this.projectSettingLayout);
  347. this.projectSettingContainer.setStyles({"height":"120px"});
  348. this.projectSettingDesText = new Element("div.projectSettingDesText",{styles:this.css.projectSettingDesText,text:this.lp.projectDes}).inject(this.projectSettingContainer);
  349. this.projectSettingDesContainer = new Element("div.projectSettingDesContainer",{styles:this.css.projectSettingDesContainer}).inject(this.projectSettingContainer);
  350. this.projectSettingDesIn = new Element("textarea.projectSettingDesIn",{styles:this.css.projectSettingDesIn,value:this.projectData.description||""}).inject(this.projectSettingDesContainer);
  351. this.projectSettingContainer = new Element("div.projectSettingContainer",{styles:this.css.projectSettingContainer}).inject(this.projectSettingLayout);
  352. this.projectSettingConfirm = new Element("div.projectSettingConfirm",{styles:this.css.projectSettingConfirm,text:this.lp.confirm}).inject(this.projectSettingContainer);
  353. this.projectSettingConfirm.addEvents({
  354. click:function(){
  355. if(this.projectSettingTitleIn.get("value").trim()=="") return;
  356. var groups = [];
  357. if(this.groups){
  358. this.groups.each(function(d){
  359. groups.push(d.id);
  360. });
  361. }
  362. var data = {
  363. "id":this.data.id,
  364. "icon":this.data.icon || "",
  365. "title":this.projectSettingTitleIn.get("value").trim(),
  366. "description":this.projectSettingDesIn.get("value"),
  367. "groups":groups
  368. };
  369. this.actions.projectSave(data,function(json){
  370. this.projectSettingLayout.empty();
  371. this.app.setLoading(this.projectSettingLayout);
  372. this.projectInfor(function(json){
  373. this.loadGeneral(json);
  374. if(this.explorer.currentListType == "block"){
  375. this.explorer.loadSingleBlockItem(this.explorer.container.getElementById(json.id),json)
  376. }else if(this.explorer.currentListType == "list"){
  377. this.explorer.loadSingleListItem(this.explorer.container.getElementById(json.id),json)
  378. }
  379. }.bind(this));
  380. }.bind(this));
  381. }.bind(this)
  382. });
  383. // this.projectSettingClose = new Element("div.projectSettingClose",{styles:this.css.projectSettingClose,text:this.lp.close}).inject(this.projectSettingContainer);
  384. // this.projectSettingClose.addEvents({
  385. // click:function(){
  386. // this.close();
  387. // }.bind(this)
  388. // });
  389. //this.projectSettingAction = new Element("div.projectSettingAction",{styles:this.css.projectSettingAction,text:this.lp.confirm}).inject(this.formTableArea);
  390. },
  391. projectInfor:function(callback){
  392. if(this.data.id){
  393. this.actions.projectGet(this.data.id,function(json){
  394. this.projectData = json.data;
  395. if(callback)callback(json.data)
  396. }.bind(this));
  397. }
  398. },
  399. groupInfor:function(ids){
  400. if(!ids) return;
  401. var resGroups = [];
  402. ids.each(function(data){
  403. this.actions.groupGet(data,function(json){
  404. }.bind(this))
  405. }.bind(this))
  406. }
  407. });