MinderExplorer.js 5.5 KB

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