StartRecordView.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  2. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  3. MWF.xDesktop.requireApp("Template", "MSelector", null, false);
  4. MWF.xApplication.Report.StartRecordView = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "action" : ""
  10. },
  11. initialize: function(node, app, options){
  12. this.setOptions(options);
  13. this.path = "../x_component_Report/$StartRecordView/";
  14. this.cssPath = "../x_component_Report/$StartRecordView/"+this.options.style+"/css.wcss";
  15. this._loadCss();
  16. this.app = app;
  17. this.container = $(node);
  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.filterNode = new Element("div.filterNode", {"styles": this.css.filterNode}).inject(this.contentNode);
  26. this.viewNode = new Element("div.viewNode", {"styles": this.css.viewNode}).inject(this.contentNode);
  27. //this.loadSideBar();
  28. this.resetNodeSizeFun = this.resetNodeSize.bind(this);
  29. this.app.addEvent("resize", this.resetNodeSizeFun );
  30. this.loadFilter();
  31. this.loadView();
  32. this.resetNodeSize();
  33. },
  34. resetNodeSize: function(){
  35. //var size = this.container.getSize();
  36. //if (this.app.reportConfig.hideMenu=="static"){
  37. // var y = size.y-120;
  38. // this.node.setStyle("height", ""+y+"px");
  39. // this.node.setStyle("margin-top", "60px");
  40. //}else{
  41. // var y = size.y-20;
  42. // this.node.setStyle("height", ""+y+"px");
  43. //}
  44. var size = this.container.getSize();
  45. var y = size.y-120;
  46. //this.node.setStyle("margin-top", "60px");
  47. //this.node.setStyle("height", ""+y+"px");
  48. if( !this.app.inContainer )this.viewNode.setStyle("height", ""+y+"px");
  49. //this.leftNode.setStyle("height", ""+size.y-60+"px");
  50. var sideBar = this.app.sideBar ? this.app.sideBar.getSize() : { x : 0, y : 0 };
  51. this.contentAreaNode.setStyle("margin-right",sideBar.x+"px");
  52. },
  53. loadFilter: function(options, callback){
  54. this.yearSelectorArea = new Element("div",{ styles : this.css.yearSelectorArea }).inject(this.filterNode);
  55. this.selector = new MWF.xApplication.Report.StartRecordView.YearSelect(this.yearSelectorArea, {
  56. "onSelectItem" : function( itemNode, itemData ){
  57. this.loadView()
  58. }.bind(this)
  59. } , this.app );
  60. this.selector.load();
  61. },
  62. loadView: function(){
  63. if (this.currentView) this.currentView.destroy();
  64. this.currentView = new MWF.xApplication.Report.StartRecordView.View( this.viewNode, this.app, this, {
  65. year : this.selector.getValue() || (new Date().getFullYear()),
  66. templateUrl : this.path + this.options.style+"/listItem.json"
  67. });
  68. this.currentView.load();
  69. },
  70. hide: function(){
  71. var fx = new Fx.Morph(this.node, {
  72. "duration": "300",
  73. "transition": Fx.Transitions.Expo.easeOut
  74. });
  75. fx.start({
  76. "opacity": 0
  77. }).chain(function(){
  78. this.node.setStyle("display", "none");
  79. }.bind(this));
  80. },
  81. show: function(){
  82. this.node.setStyles(this.css.node);
  83. var fx = new Fx.Morph(this.node, {
  84. "duration": "800",
  85. "transition": Fx.Transitions.Expo.easeOut
  86. });
  87. this.app.fireAppEvent("resize");
  88. fx.start({
  89. "opacity": 1,
  90. "left": "0px"
  91. }).chain(function(){
  92. this.node.setStyles({
  93. "position": "static",
  94. "width": "auto"
  95. });
  96. }.bind(this));
  97. },
  98. reload: function(){
  99. this.app.reload();
  100. },
  101. recordStatus : function(){
  102. var action = "";
  103. if( this.currentNavi )action = this.currentNavi.retrieve("action");
  104. return {
  105. action : action
  106. };
  107. },
  108. destroy : function(){
  109. if( this.currentView ){
  110. this.currentView.destroy()
  111. }
  112. this.app.removeEvent("resize", this.resetNodeSizeFun );
  113. this.node.destroy();
  114. }
  115. });
  116. MWF.xApplication.Report.StartRecordView.YearSelect = new Class({
  117. Extends: MSelector,
  118. options : {
  119. "style": "default",
  120. "width": "230px",
  121. "height": "30px",
  122. "textField" : "text",
  123. "valueField" : "value",
  124. "emptyOptionEnable" : false,
  125. "value" : (new Date()).getFullYear().toString()
  126. },
  127. _selectItem : function( itemNode, itemData ){
  128. },
  129. _loadData : function( callback ){
  130. var arr = [];
  131. var data = new Date();
  132. data.decrement("year",5);
  133. for( var i=0; i<11; i++ ){
  134. data.increment("year",1);
  135. arr.push({
  136. text : data.getFullYear(),
  137. value : data.getFullYear().toString()
  138. })
  139. }
  140. if(callback)callback( arr );
  141. }
  142. });
  143. MWF.xApplication.Report.StartRecordView.View = new Class({
  144. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  145. options : {
  146. "scrollEnable" : true,
  147. "scrollType" : "window"
  148. },
  149. _createDocument: function(data, index){
  150. return new MWF.xApplication.Report.StartRecordView.Document(this.viewNode, data, this.explorer, this, null, index);
  151. },
  152. _getCurrentPageData: function(callback, count){
  153. this.actions.listStartProfileByYear( this.options.year, function(json){
  154. if( !json.data )json.data = [];
  155. if (callback)callback(json);
  156. });
  157. },
  158. _removeDocument: function(documentData, all){
  159. this.actions.deleteStartProfile(documentData.id, function(json){
  160. this.reload();
  161. this.app.notice(this.app.lp.deleteStartRecordOK, "success");
  162. }.bind(this));
  163. },
  164. _create: function(){},
  165. _openDocument: function( documentData,index ){
  166. },
  167. _queryCreateViewNode: function(){
  168. },
  169. _postCreateViewNode: function( viewNode ){
  170. },
  171. _queryCreateViewHead:function(){},
  172. _postCreateViewHead: function( headNode ){}
  173. //destroyScroll: function(){
  174. // if( this.scrollContainerFun ){
  175. // var scrollNode = this.app.scrollNode ? this.app.scrollNode : this.container;
  176. // scrollNode.removeEvent("scroll", this.scrollContainerFun );
  177. // this.scrollContainerFun = null;
  178. // }
  179. //},
  180. //setScroll: function(){
  181. // var scrollNode = this.app.scrollNode ? this.app.scrollNode : this.container;
  182. // scrollNode.setStyle("overflow","auto");
  183. // this.scrollContainerFun = function(){
  184. // if( !this.options.pagingEnable ){
  185. // var scrollSize = scrollNode.getScrollSize();
  186. // var clientSize = scrollNode.getSize();
  187. // var scrollHeight = scrollSize.y - clientSize.y;
  188. // if (scrollNode.scrollTop + 150 > scrollHeight ) {
  189. // if (! this.isItemsLoaded) this.loadElementList();
  190. // }
  191. // }
  192. // }.bind(this)
  193. // scrollNode.addEvent("scroll", this.scrollContainerFun )
  194. //}
  195. });
  196. MWF.xApplication.Report.StartRecordView.Document = new Class({
  197. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  198. _queryCreateDocumentNode:function( itemData ){
  199. },
  200. _postCreateDocumentNode: function( itemNode, itemData ){
  201. if(this.index % 2 == 1){
  202. itemNode.setStyle("background-color","#f0f0f0");
  203. }
  204. },
  205. open: function (e) {
  206. //this.view._openDocument(this.data, this.index);
  207. },
  208. edit : function(){
  209. },
  210. supplement: function(e){
  211. var form = new MWF.xApplication.Report.StartRecordView.StartedForm( this.view.explorer, this.data, {}, { app : this.app } );
  212. form.create();
  213. },
  214. remove: function (e) {
  215. var lp = this.app.lp;
  216. var title = this.data.reportYear + "年" + this.data.reportMonth + "月";
  217. var text = lp.deleteStartRecord.replace(/{title}/g, title).replace(/{count}/g, this.data.createDocumentCount);
  218. var _self = this;
  219. this.node.setStyles(this.css.listViewTableTr_remove);
  220. this.readyRemove = true;
  221. this.view.lockNodeStyle = true;
  222. this.app.confirm("warn", e, lp.deleteStartRecordTitle, text, 350, 120, function () {
  223. _self.view._removeDocument(_self.data, false);
  224. _self.view.lockNodeStyle = false;
  225. this.close();
  226. }, function () {
  227. _self.node.setStyles(_self.css.listViewTableTr );
  228. e.setStyles(_self.css.actionDeleteNode);
  229. _self.readyRemove = false;
  230. _self.view.lockNodeStyle = false;
  231. this.close();
  232. });
  233. },
  234. mouseoverDocument : function(){
  235. this.node.setStyle("background-color","#fff7eb");
  236. },
  237. mouseoutDocument : function(){
  238. if(this.index % 2 == 1){
  239. this.node.setStyle("background-color","#f0f0f0");
  240. }else{
  241. this.node.setStyle("background-color","#fff");
  242. }
  243. }
  244. });
  245. MWF.xApplication.Report.StartRecordView.StartedForm = new Class({
  246. Extends: MPopupForm,
  247. Implements: [Options, Events],
  248. options: {
  249. "style": "report",
  250. "width": 800,
  251. "height": 450,
  252. "hasTop": true,
  253. "hasIcon": false,
  254. "maxAction" : true,
  255. "draggable": true,
  256. "resizeable": true,
  257. "editedAble" : true
  258. },
  259. _createTableContent: function () {
  260. this.lp = {
  261. ok : "确定",
  262. close : "取消"
  263. };
  264. this.formTopTextNode.set( "text", "补充工作汇报" );
  265. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  266. this.formTableArea.setStyle("margin-top","20px");
  267. var css = {
  268. "formTable" : {
  269. "border-collapse" : "collapse",
  270. "margin": "0px auto",
  271. "margin-bottom" : "15px"
  272. },
  273. "formTableTitleP14" : {
  274. "border":"1px solid #d8d5d5",
  275. "background-color" : "#effafe",
  276. "color" : "#444",
  277. "font-size": "14px",
  278. "height" : "30px",
  279. "line-height" : "30px",
  280. "font-weight" : "bold",
  281. "text-align": "center"
  282. },
  283. "formTableValueP14" : {
  284. "border" : "1px solid #d8d5d5",
  285. "color" : "#444",
  286. "font-size": "14px",
  287. "font-weight" : "400",
  288. "text-align": "left"
  289. }
  290. }
  291. var table = new Element( "table", {
  292. "width":"96%",
  293. "border":"0",
  294. "cellpadding":"5",
  295. "cellspacing":"0",
  296. "styles" : this.css.formTable
  297. }).inject( this.formTableArea );
  298. var tr = new Element("tr").inject( table );
  299. new Element("td", { "text" : "部门","width" : "230", "styles": css.formTableTitleP14 }).inject( tr );
  300. new Element("td", { "text" : "状态", "width" : "40", "styles": css.formTableTitleP14 }).inject( tr );
  301. MWF.Actions.get("x_report_assemble_control").checkStarted( this.data.id, function(json){
  302. for( var unit in json.data ){
  303. var tr = new Element("tr").inject( table );
  304. new Element("td", { "text" : unit.split("@")[0],"styles": css.formTableValueP14 }).inject( tr );
  305. new Element("td", { "text" : json.data[unit], "styles": css.formTableValueP14 }).inject( tr );
  306. }
  307. }.bind(this))
  308. },
  309. _createBottomContent: function () {
  310. if (this.isNew || this.isEdited) {
  311. this.okActionNode = new Element("button.inputOkButton", {
  312. "styles": this.css.inputOkButton,
  313. "text": "补充"
  314. }).inject(this.formBottomNode);
  315. this.okActionNode.addEvent("click", function (e) {
  316. this.supplemental(e);
  317. }.bind(this));
  318. }
  319. this.cancelActionNode = new Element("button.inputCancelButton", {
  320. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  321. "text": this.lp.close
  322. }).inject(this.formBottomNode);
  323. this.cancelActionNode.addEvent("click", function (e) {
  324. this.close(e);
  325. }.bind(this));
  326. },
  327. supplemental: function(){
  328. MWF.Actions.get("x_report_assemble_control").supplemental( this.data.id, function(json){
  329. this.app.notice("补充成功!");
  330. this.close();
  331. }.bind(this))
  332. }
  333. });