MinderExplorer.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  2. MWF.xDesktop.requireApp("OKR", "Minder", null, false);
  3. MWF.xApplication.OKR.MinderExplorer = new Class({
  4. Extends: MWF.xApplication.Template.Explorer,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "hasFilter" : false,
  9. "isAdmin": false,
  10. "searchKey" : ""
  11. },
  12. initialize: function(node, app, actions, options){
  13. this.setOptions(options);
  14. this.app = app;
  15. this.path = "/x_component_OKR/$MinderExplorer/";
  16. //this.exlorerPath = "/x_component_OKR/$MinderExplorer/"+this.options.style+"/css.wcss";
  17. this.loadCss();
  18. this.actions = actions;
  19. this.node = $(node);
  20. this.initData();
  21. },
  22. load: function(){
  23. this.loadToolbar();
  24. if( this.options.hasFilter )this.loadFilter();
  25. this.loadContentNode();
  26. this.loadView();
  27. this.setNodeScroll();
  28. this.app.addEvent("resize", function(){this.reloadView();}.bind(this));
  29. },
  30. reloadView : function(){
  31. if( this.viewContainerNode )this.viewContainerNode.empty();
  32. if( this.minder )delete this.minder;
  33. this.loadView();
  34. },
  35. loadView : function(){
  36. this.actions.getWorksById( "010909f1-7a72-49e3-a1be-20adb39cff43" , function(json){
  37. alert( JSON.stringify(json) )
  38. } )
  39. var data = {
  40. "root": {
  41. "data": {"id": "9f92035021ac", "created": 1463069003, "text": "软装修"},
  42. "children": [{
  43. "data": {"id": "b45yogtullsg", "created": 1463069010918, "text": "包阳台"},
  44. "children": [{
  45. "data" : {"id":"3jl3i3j43", "created": 1463069010923, "text": "凤铝"}
  46. },{
  47. "data" : {"id":"3jl3i3j44", "created": 1463069010923, "text": "断桥"}
  48. }]
  49. },
  50. {"data": {"id": "b45yohdlynco", "created": 1463069012113, "text": "衣柜"}, "children": [
  51. {"data": {"id": "b45yohdlynco", "created": 1463069012113, "text": "主卧"}},
  52. {"data": {"id": "b45yohdlynco", "created": 1463069012113, "text": "次卧"}}
  53. ]},
  54. {"data": {"id": "b45yohdlynco", "created": 1463069012113, "text": "床"}, "children": []},
  55. {"data": {"id": "b45yohdlynco", "created": 1463069012113, "text": "餐桌"}, "children": []},
  56. {"data": {"id": "b45yohdlynco", "created": 1463069012113, "text": "灯具"}, "children": []},
  57. {"data": {"id": "b45yohdlynco", "created": 1463069012113, "text": "窗帘"}, "children": []}
  58. ]
  59. }//, "template": "default", "theme": "fresh-blue", "version": "1.4.33"
  60. };
  61. this.minder = new MWF.xApplication.OKR.Minder(this.viewContainerNode,this,data, {
  62. "template" : "default",
  63. "theme" : "fresh-blue",
  64. "onClickKMNode" : function(node, data){
  65. this.form = new MWF.xApplication.OKR.MinderExplorer.Form(this,data);
  66. this.form.edit();
  67. }.bind(this)
  68. });
  69. this.minder.load();
  70. this.setContentSize();
  71. },
  72. createDocument: function(){
  73. }
  74. });
  75. MWF.xApplication.OKR.MinderExplorer.View = new Class({
  76. Extends: MWF.xApplication.Template.Explorer.View,
  77. _createItem: function(data){
  78. return new MWF.xApplication.OKR.MinderExplorer.Document(this.table, data, this.explorer, this);
  79. },
  80. _getCurrentPageData: function(callback, count){
  81. this.actions.listPersonSetting(function(json){
  82. if (callback) callback(json);
  83. });
  84. },
  85. _removeDocument: function(document, all){
  86. this.actions.deletePersonSetting(document.id, function(json){
  87. this.explorer.view.reload();
  88. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  89. }.bind(this));
  90. },
  91. _create: function(){
  92. var form = new MWF.xApplication.OKR.MinderExplorer.Form(this.explorer);
  93. form.create();
  94. },
  95. _openDocument: function( documentData ){
  96. var form = new MWF.xApplication.OKR.MinderExplorer.Form(this.explorer, documentData );
  97. form.edit();
  98. }
  99. })
  100. MWF.xApplication.OKR.MinderExplorer.Document = new Class({
  101. Extends: MWF.xApplication.Template.Explorer.Document
  102. })
  103. MWF.xApplication.OKR.MinderExplorer.Form = new Class({
  104. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  105. _createTableContent: function(){
  106. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  107. "<tr><td colspan='2' styles='formTableHead'>考勤人员设置</td></tr>" +
  108. "<tr><td styles='formTabelTitle' lable='text'></td>"+
  109. " <td styles='formTableValue' item='text'></td></tr>"
  110. "</table>"
  111. this.formTableArea.set("html",html);
  112. MWF.xDesktop.requireApp("Template", "MForm", function(){
  113. this.form = new MForm( this.formTableArea, this.data, {
  114. style : "popup",
  115. isEdited : this.isEdited || this.isNew,
  116. itemTemplate : {
  117. text : { text:"主题" }
  118. }
  119. }, this.app);
  120. this.form.load();
  121. }.bind(this), true);
  122. },
  123. _ok: function( data, callback ){
  124. this.app.restActions.savePersonSetting( data, function(json){
  125. if( callback )callback(json);
  126. }.bind(this));
  127. }
  128. });