Main.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. MWF.xDesktop.requireApp("query.ViewDesigner", "", null, false);
  2. MWF.APPDTBD = MWF.xApplication.query.TableDesigner;
  3. MWF.APPDTBD.options = {
  4. "multitask": true,
  5. "executable": false
  6. };
  7. MWF.xDesktop.requireApp("query.StatDesigner", "Stat", null, false);
  8. MWF.xApplication.query.TableDesigner.Main = new Class({
  9. Extends: MWF.xApplication.query.ViewDesigner.Main,
  10. Implements: [Options, Events],
  11. options: {
  12. "style": "default",
  13. "name": "query.TableDesigner",
  14. "icon": "icon.png",
  15. "title": MWF.APPDTBD.LP.title,
  16. "appTitle": MWF.APPDTBD.LP.title,
  17. "id": "",
  18. "tooltip": {
  19. "unCategory": MWF.APPDTBD.LP.unCategory
  20. },
  21. "actions": null,
  22. "category": null,
  23. "processData": null
  24. },
  25. onQueryLoad: function(){
  26. this.shortcut = true;
  27. if (this.status){
  28. this.options.application = this.status.applicationId;
  29. this.application = this.status.application;
  30. this.options.id = this.status.id;
  31. }
  32. if (!this.options.id){
  33. this.options.desktopReload = false;
  34. this.options.title = this.options.title + "-"+MWF.APPDTBD.LP.newTable;
  35. }
  36. if (!this.actions) this.actions = MWF.Actions.get("x_query_assemble_designer");
  37. this.lp = MWF.xApplication.query.TableDesigner.LP;
  38. this.addEvent("queryClose", function(e){
  39. if (this.explorer){
  40. this.explorer.reload();
  41. }
  42. }.bind(this));
  43. },
  44. loadViewList: function(){
  45. this.actions.listTable(this.application.id, function (json) {
  46. json.data.each(function(table){
  47. this.createListViewItem(table);
  48. }.bind(this));
  49. }.bind(this), null, false);
  50. },
  51. //列示所有视图列表
  52. createListViewItem: function(table, isNew){
  53. var _self = this;
  54. var listTableItem = new Element("div", {"styles": this.css.listViewItem}).inject(this.viewListAreaNode, (isNew) ? "top": "bottom");
  55. var listTableItemIcon = new Element("div", {"styles": this.css.listViewItemIcon}).inject(listViewItem);
  56. var listTableItemText = new Element("div", {"styles": this.css.listViewItemText, "text": (table.name) ? table.name+" ("+table.alias+")" : this.lp.newTable}).inject(listTableItem);
  57. listTableItem.store("table", table);
  58. listTableItem.addEvents({
  59. "dblclick": function(e){_self.loadTableByData(this, e);},
  60. "mouseover": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem_over);},
  61. "mouseout": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem);}
  62. });
  63. },
  64. //打开视图
  65. loadViewByData: function(node, e){
  66. var table = node.retrieve("table");
  67. if (openNew){
  68. var _self = this;
  69. var options = {
  70. "onQueryLoad": function(){
  71. this.actions = _self.actions;
  72. this.category = _self;
  73. this.options.id = table.id;
  74. this.application = _self.application;
  75. this.explorer = _self.explorer;
  76. }
  77. };
  78. this.desktop.openApplication(e, "query.StatDesigner", options);
  79. }
  80. },
  81. //loadView------------------------------------------
  82. loadView: function(){
  83. this.getTableData(this.options.id, function(vdata){
  84. this.setTitle(this.options.appTitle + "-"+vdata.name);
  85. this.taskitem.setText(this.options.appTitle + "-"+vdata.name);
  86. this.options.appTitle = this.options.appTitle + "-"+vdata.name;
  87. this.table = new MWF.xApplication.query.TableDesigner.Table(this, vdata);
  88. this.table.load();
  89. }.bind(this));
  90. },
  91. loadNewViewData: function(callback){
  92. var url = "/x_component_query_TableDesigner/$Table/table.json";
  93. MWF.getJSON(url, {
  94. "onSuccess": function(obj){
  95. this.actions.getUUID(function(id){
  96. obj.id=id;
  97. obj.isNewTable = true;
  98. obj.application = this.application.id;
  99. this.createListViewItem(obj, true);
  100. if (callback) callback(obj);
  101. }.bind(this));
  102. }.bind(this),
  103. "onerror": function(text){
  104. this.notice(text, "error");
  105. }.bind(this),
  106. "onRequestFailure": function(xhr){
  107. this.notice(xhr.responseText, "error");
  108. }.bind(this)
  109. });
  110. },
  111. loadViewData: function(id, callback){
  112. this.actions.getTable(id, function(json){
  113. if (json){
  114. var data = json.data;
  115. data.data = JSON.decode(data.data);
  116. if (!this.application){
  117. this.actions.getApplication(data.query, function(json){
  118. this.application = {"name": json.data.name, "id": json.data.id};
  119. if (callback) callback(data);
  120. }.bind(this));
  121. }else{
  122. if (callback) callback(data);
  123. }
  124. }
  125. }.bind(this));
  126. },
  127. saveView: function(){
  128. this.view.save(function(){
  129. var name = this.view.data.name;
  130. this.setTitle(MWF.APPDSTD.LP.title + "-"+name);
  131. this.options.desktopReload = true;
  132. this.options.id = this.view.data.id;
  133. }.bind(this));
  134. },
  135. saveViewAs: function(){
  136. this.view.saveAs();
  137. },
  138. dictionaryExplode: function(){
  139. this.view.explode();
  140. },
  141. dictionaryImplode: function(){
  142. this.view.implode();
  143. }
  144. //recordStatus: function(){
  145. // return {"id": this.options.id};
  146. //},
  147. });