ListView.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. MWF.require("o2.widget.Paging", null, false);
  2. MWF.xApplication.Meeting.ListView = new Class({
  3. Extends: MWF.widget.Common,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "date": null,
  8. "action" : ""
  9. },
  10. initialize: function(node, app, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_Meeting/$ListView/";
  13. this.cssPath = "../x_component_Meeting/$ListView/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.app = app;
  16. this.container = $(node);
  17. this.date = this.options.date || new Date();
  18. this.load();
  19. },
  20. load: function(){
  21. this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
  22. this.leftNode = new Element("div", {"styles": this.css.leftNode}).inject(this.node);
  23. this.contentAreaNode = new Element("div.contentAreaNode", {"styles": this.css.contentAreaNode}).inject(this.node);
  24. this.contentNode = new Element("div.contentNode", {"styles": this.css.contentNode}).inject(this.contentAreaNode);
  25. //this.loadSideBar();
  26. this.resetNodeSizeFun = this.resetNodeSize.bind(this);
  27. this.app.addEvent("resize", this.resetNodeSizeFun );
  28. this.loadLeftNavi();
  29. this.resetNodeSize();
  30. },
  31. resetNodeSize: function(){
  32. //var size = this.container.getSize();
  33. //if (this.app.meetingConfig.hideMenu=="static"){
  34. // var y = size.y-120;
  35. // this.node.setStyle("height", ""+y+"px");
  36. // this.node.setStyle("margin-top", "60px");
  37. //}else{
  38. // var y = size.y-20;
  39. // this.node.setStyle("height", ""+y+"px");
  40. //}
  41. //if( this.app.inContainer )return;
  42. var size = this.container.getSize();
  43. var y = size.y-60;
  44. this.node.setStyle("margin-top", "60px");
  45. this.node.setStyle("height", ""+y+"px");
  46. var sideBar = this.app.sideBar ? this.app.sideBar.getSize() : { x : 0, y : 0 };
  47. //var x = size.x - sideBar.x;
  48. //this.node.setStyle("width", ""+x+"px");
  49. this.contentAreaNode.setStyle("margin-right",sideBar.x+"px");
  50. },
  51. loadLeftNavi: function(){
  52. var menuNode = new Element("div.menuNode", {"styles": this.css.menuNode, "text": this.app.lp.listNavi.myApply}).inject(this.leftNode);
  53. this.loadNaviItem(this.app.lp.listNavi.wait, "toApplyWait");
  54. this.loadNaviItem(this.app.lp.listNavi.processing, "toApplyProcessing");
  55. this.loadNaviItem(this.app.lp.listNavi.completed, "toApplyCompleted");
  56. this.loadNaviItem(this.app.lp.listNavi.apply, "toApply");
  57. var menuNode = new Element("div.menuNode", {"styles": this.css.menuNode, "text": this.app.lp.listNavi.myMeeting}).inject(this.leftNode);
  58. this.loadNaviItem(this.app.lp.listNavi.wait, "toMeetingWait");
  59. this.loadNaviItem(this.app.lp.listNavi.processing, "toMeetingProcessing");
  60. this.loadNaviItem(this.app.lp.listNavi.completed, "toMeetingCompleted");
  61. this.loadNaviItem(this.app.lp.listNavi.reject, "toMeetingReject");
  62. //var menuNode = new Element("div", {"styles": this.css.menuNode, "text": this.app.lp.listNavi.room}).inject(this.leftNode);
  63. },
  64. loadNaviItem: function(text, action){
  65. var itemNode = new Element("div", {"styles": this.css.menuItemNode, "text": text}).inject(this.leftNode);
  66. var _self = this;
  67. itemNode.addEvents({
  68. "mouseover": function(){if (_self.currentNavi != this) this.setStyles(_self.css.menuItemNode_over);},
  69. "mouseout": function(){if (_self.currentNavi != this) this.setStyles(_self.css.menuItemNode);},
  70. "click": function(){
  71. if (_self.currentNavi){
  72. _self.currentNavi.setStyles(_self.css.menuItemNode);
  73. _self.currentNavi.removeClass("mainColor_bg_opacity");
  74. _self.currentNavi.removeClass("mainColor_color");
  75. }
  76. _self.currentNavi = this;
  77. this.setStyles(_self.css.menuItemNode_current);
  78. _self.currentNavi.addClass("mainColor_bg_opacity");
  79. _self.currentNavi.addClass("mainColor_color");
  80. if (_self[action]) _self[action]();
  81. }
  82. });
  83. itemNode.store("action",action);
  84. if( this.options.action == action){
  85. itemNode.click();
  86. }else if( action == "toApplyWait"){
  87. itemNode.click();
  88. }
  89. },
  90. toApplyWait: function(){
  91. if (this.currentView) this.currentView.destroy();
  92. this.currentView = new MWF.xApplication.Meeting.ListView.ApplyWait(this,{
  93. "meetingStatus" : "wait"
  94. });
  95. },
  96. toApplyProcessing: function(){
  97. if (this.currentView) this.currentView.destroy();
  98. this.currentView = new MWF.xApplication.Meeting.ListView.ApplyProcessing(this,{
  99. "meetingStatus" : "processing"
  100. });
  101. },
  102. toApplyCompleted: function(){
  103. if (this.currentView) this.currentView.destroy();
  104. this.currentView = new MWF.xApplication.Meeting.ListView.ApplyCompleted(this,{
  105. "meetingStatus" : "completed"
  106. });
  107. },
  108. toApply: function(){
  109. if (this.currentView) this.currentView.destroy();
  110. this.currentView = new MWF.xApplication.Meeting.ListView.Apply(this,{
  111. "meetingStatus" : "applying"
  112. });
  113. },
  114. toMeetingWait: function(){
  115. if (this.currentView) this.currentView.destroy();
  116. this.currentView = new MWF.xApplication.Meeting.ListView.MeetingWait(this);
  117. },
  118. toMeetingProcessing: function(){
  119. if (this.currentView) this.currentView.destroy();
  120. this.currentView = new MWF.xApplication.Meeting.ListView.MeetingProcessing(this);
  121. },
  122. toMeetingCompleted: function(){
  123. if (this.currentView) this.currentView.destroy();
  124. this.currentView = new MWF.xApplication.Meeting.ListView.MeetingCompleted(this);
  125. },
  126. toMeetingReject: function(){
  127. if (this.currentView) this.currentView.destroy();
  128. this.currentView = new MWF.xApplication.Meeting.ListView.MeetingReject(this);
  129. },
  130. hide: function(){
  131. var fx = new Fx.Morph(this.node, {
  132. "duration": "300",
  133. "transition": Fx.Transitions.Expo.easeOut
  134. });
  135. fx.start({
  136. "opacity": 0
  137. }).chain(function(){
  138. this.node.setStyle("display", "none");
  139. }.bind(this));
  140. },
  141. show: function(){
  142. this.node.setStyles(this.css.node);
  143. if( this.app.inContainer ){
  144. this.node.setStyles({
  145. "opacity": 1,
  146. "position": "static",
  147. "width": "auto"
  148. });
  149. }else{
  150. var fx = new Fx.Morph(this.node, {
  151. "duration": "800",
  152. "transition": Fx.Transitions.Expo.easeOut
  153. });
  154. this.app.fireAppEvent("resize");
  155. fx.start({
  156. "opacity": 1,
  157. "left": "0px"
  158. }).chain(function(){
  159. this.node.setStyles({
  160. "position": "static",
  161. "width": "auto"
  162. });
  163. }.bind(this));
  164. }
  165. },
  166. reload: function(){
  167. if( this.currentView ){
  168. this.currentView.reload();
  169. }else{
  170. this.app.reload();
  171. }
  172. },
  173. recordStatus : function(){
  174. var action = "";
  175. if( this.currentNavi )action = this.currentNavi.retrieve("action");
  176. return {
  177. action : action
  178. };
  179. },
  180. destroy : function(){
  181. if( this.currentView ){
  182. this.currentView.destroy()
  183. }
  184. this.app.removeEvent("resize", this.resetNodeSizeFun );
  185. this.node.destroy();
  186. }
  187. });
  188. MWF.xApplication.Meeting.ListView.View = new Class({
  189. Implements: [Options, Events],
  190. options: {
  191. "meetingStatus" : "completed"
  192. },
  193. initialize: function(view,options){
  194. this.setOptions(options);
  195. this.view = view;
  196. this.css = this.view.css;
  197. this.container = this.view.contentNode;
  198. this.app = this.view.app;
  199. this.items = [];
  200. this.page = 1;
  201. this.pageSize = 10;
  202. this.action = o2.Actions.load("x_meeting_assemble_control");
  203. this.load();
  204. },
  205. reload : function(){
  206. this.items = [];
  207. this.container.empty();
  208. this.load();
  209. },
  210. load: function(){
  211. this.loadHead();
  212. MWF.require("MWF.widget.Mask", function(){
  213. this.mask = new MWF.widget.Mask({"style": "desktop"});
  214. this.mask.loadNode(this.view.contentAreaNode);
  215. }.bind(this));
  216. this.loadList();
  217. this.docPaginationNode = new Element("div").inject(this.container);
  218. },
  219. loadHead: function(){
  220. this.table = new Element("table", {
  221. "styles": this.css.listViewTable,
  222. "border": "0",
  223. "cellPadding": "0",
  224. "cellSpacing": "0",
  225. "html": "<tr><th>"+this.app.lp.applyPerson+"</th><th>"+this.app.lp.beginDate+"</th><th>"+this.app.lp.time+"</th><th>"+this.app.lp.subject+"</th><th>"+this.app.lp.room+"</th></tr>"
  226. }).inject(this.container);
  227. this.table.getElements("th").setStyles(this.css.listViewTableTh);
  228. this.tableBody = new Element("tbody").inject(this.table);
  229. },
  230. loadList: function() {
  231. this.tableBody.empty();
  232. this.action.MeetingAction.listApplyMeetingPaging(this.page,this.pageSize,{"meetingStatus" : this.options.meetingStatus},function (json) {
  233. this.loadLines(json.data);
  234. this.docTotal = json.count;
  235. this.loadDocPagination( );
  236. }.bind(this));
  237. },
  238. loadDocPagination: function(text){
  239. this.docPaginationNode.empty();
  240. if( o2.typeOf(this.docTotal) === "number" && this.docTotal > 0 ){
  241. this.docPaging = new o2.widget.Paging(this.docPaginationNode, {
  242. style: "blue_round",
  243. countPerPage: this.pageSize,
  244. visiblePages: 9,
  245. currentPage: this.page,
  246. itemSize: this.docTotal,
  247. useMainColor: true,
  248. text: {
  249. firstPage: "第一页",
  250. lastPage: "最后一页"
  251. },
  252. // pageSize: pageSize,
  253. onJumpingPage: function (pageNum) {
  254. this.page = pageNum;
  255. this.loadList();
  256. }.bind(this),
  257. hasInfor: true,
  258. inforTextStyle: "",
  259. onPostLoad: function () {
  260. // this.wraper.setStyle("border-top", "1px solid #4A90E2");
  261. // this.wraper.addClass("mainColor_border");
  262. }
  263. });
  264. this.docPaging.load();
  265. }
  266. },
  267. loadLines: function(items){
  268. items.each(function(item){
  269. this.loadLine(item);
  270. }.bind(this));
  271. if (this.mask){
  272. this.mask.hide(function(){
  273. //MWF.release(this.mask);
  274. this.mask = null;
  275. }.bind(this));
  276. }
  277. },
  278. loadLine: function(item){
  279. this.items.push(new MWF.xApplication.Meeting.ListView.View.Line(this, item));
  280. },
  281. destroy: function(){
  282. this.items.each(function(item){
  283. item.destroy();
  284. });
  285. this.items = [];
  286. this.view.currentView = null;
  287. this.table.destroy();
  288. this.docPaginationNode.destroy();
  289. }
  290. });
  291. MWF.xApplication.Meeting.ListView.ApplyWait = new Class({
  292. Extends: MWF.xApplication.Meeting.ListView.View
  293. });
  294. MWF.xApplication.Meeting.ListView.ApplyProcessing = new Class({
  295. Extends: MWF.xApplication.Meeting.ListView.View
  296. });
  297. MWF.xApplication.Meeting.ListView.ApplyCompleted = new Class({
  298. Extends: MWF.xApplication.Meeting.ListView.View
  299. });
  300. MWF.xApplication.Meeting.ListView.Apply = new Class({
  301. Extends: MWF.xApplication.Meeting.ListView.View
  302. });
  303. MWF.xApplication.Meeting.ListView.MeetingWait = new Class({
  304. Extends: MWF.xApplication.Meeting.ListView.View,
  305. loadList: function() {
  306. this.tableBody.empty();
  307. this.action.MeetingAction.listInviteMeetingPaging(this.page,this.pageSize,{"meetingStatus" : "wait"},function (json) {
  308. this.loadLines(json.data);
  309. this.docTotal = json.count;
  310. this.loadDocPagination( );
  311. }.bind(this));
  312. }
  313. });
  314. MWF.xApplication.Meeting.ListView.MeetingProcessing = new Class({
  315. Extends: MWF.xApplication.Meeting.ListView.View,
  316. loadList: function() {
  317. this.tableBody.empty();
  318. this.action.MeetingAction.listInviteMeetingPaging(this.page,this.pageSize,{"meetingStatus" : "processing"},function (json) {
  319. this.loadLines(json.data);
  320. this.docTotal = json.count;
  321. this.loadDocPagination( );
  322. }.bind(this));
  323. }
  324. });
  325. MWF.xApplication.Meeting.ListView.MeetingCompleted = new Class({
  326. Extends: MWF.xApplication.Meeting.ListView.View,
  327. loadList: function() {
  328. this.tableBody.empty();
  329. this.action.MeetingAction.listInviteMeetingPaging(this.page,this.pageSize,{"meetingStatus" : "completed"},function (json) {
  330. this.loadLines(json.data);
  331. this.docTotal = json.count;
  332. this.loadDocPagination( );
  333. }.bind(this));
  334. }
  335. });
  336. MWF.xApplication.Meeting.ListView.MeetingReject = new Class({
  337. Extends: MWF.xApplication.Meeting.ListView.View,
  338. loadList: function() {
  339. this.tableBody.empty();
  340. this.action.MeetingAction.listInviteMeetingPaging(this.page,this.pageSize,{"meetingStatus" : "completed","rejectFlag":true},function (json) {
  341. this.loadLines(json.data);
  342. this.docTotal = json.count;
  343. this.loadDocPagination( );
  344. }.bind(this));
  345. }
  346. });
  347. MWF.xApplication.Meeting.ListView.View.Line = new Class({
  348. initialize: function(table, item){
  349. this.table = table;
  350. this.view = this.table.view;
  351. this.css = this.view.css;
  352. this.container = this.table.tableBody;
  353. this.app = this.view.app;
  354. this.data = item;
  355. this.load();
  356. },
  357. load: function(){
  358. var sTime = Date.parse(this.data.startTime);
  359. var bdate = sTime.format(this.app.lp.dateFormatDay);
  360. var btime = sTime.format("%H:%M");
  361. var etime = Date.parse(this.data.completedTime).format("%H:%M");
  362. //this.app.actions.getRoom(this.data.room, function (json){
  363. var room = "";
  364. if( this.data.woRoom ){
  365. var roomData = this.data.woRoom;
  366. var bulidingData = this.getBulidingData( roomData.building );
  367. room = roomData.name+"("+bulidingData.name+((roomData.roomNumber) ? " #"+roomData.roomNumber : "")+")";
  368. }
  369. // this.node = new Element("tr",{
  370. // "html": "<td></td><td>"+bdate+"</td><td>"+btime+"-"+etime+"</td><td>"+this.data.subject+"</td><td>"+room+"</td>"
  371. // }).inject(this.container);
  372. this.node = new Element("tr",{
  373. "html": "<td></td><td></td><td></td><td></td><td></td>"
  374. }).inject(this.container);
  375. this.node.getElements("td").each(function (td, i) {
  376. switch (i) {
  377. case 1:
  378. td.set("text", bdate); break;
  379. case 2:
  380. td.set("text", btime+"-"+etime); break;
  381. case 3:
  382. td.set("text", this.data.subject); break;
  383. case 4:
  384. td.set("text", room); break;
  385. }
  386. }.bind(this));
  387. this.personNode = this.node.getFirst("td");
  388. if (this.data.applicant){
  389. // var explorer = {
  390. // "actions": this.app.personActions,
  391. // "app": {
  392. // "lp": this.app.lp
  393. // }
  394. // };
  395. MWF.require("MWF.widget.O2Identity", function(){
  396. var person = new MWF.widget.O2Person({"displayName": this.data.applicant.split("@")[0], "name": this.data.applicant}, this.personNode, {"style": "room"});
  397. }.bind(this));
  398. }
  399. this.node.getElements("td").setStyles(this.css.listViewTableTd);
  400. this.node.addEvent("click", function(e){
  401. this.openMeeting(e);
  402. }.bind(this));
  403. },
  404. getBulidingData : function( id ){
  405. if( !this.bulidingList )this.bulidingList = {};
  406. if( !this.bulidingList[ id ] ){
  407. this.app.actions.getBuilding(id, function (bjson){
  408. this.bulidingList[ id ] = bjson.data;
  409. }.bind(this), null, false)
  410. }
  411. return this.bulidingList[ id ];
  412. },
  413. openMeeting: function(e){
  414. this.form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  415. this.form.view = this.view;
  416. this.form.open();
  417. },
  418. destroy: function(){
  419. if (this.node) this.node.destroy();
  420. //MWF.release(this);
  421. }
  422. });