Main.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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.TableDesigner", "Table", 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. loadViewListNodes: function(){
  45. this.viewListTitleNode = new Element("div", {
  46. "styles": this.css.viewListTitleNode,
  47. "text": MWF.APPDTBD.LP.table
  48. }).inject(this.viewListNode);
  49. this.viewListResizeNode = new Element("div", {"styles": this.css.viewListResizeNode}).inject(this.viewListNode);
  50. this.viewListAreaSccrollNode = new Element("div", {"styles": this.css.viewListAreaSccrollNode}).inject(this.viewListNode);
  51. this.viewListAreaNode = new Element("div", {"styles": this.css.viewListAreaNode}).inject(this.viewListAreaSccrollNode);
  52. this.loadViewListResize();
  53. this.loadViewList();
  54. },
  55. loadViewList: function(){
  56. debugger;
  57. this.actions.listTable(this.application.id, function (json) {
  58. json.data.each(function(table){
  59. this.createListViewItem(table);
  60. }.bind(this));
  61. }.bind(this), null, false);
  62. },
  63. //列示所有数据表列表
  64. createListViewItem: function(table, isNew){
  65. var _self = this;
  66. var listTableItem = new Element("div", {"styles": this.css.listViewItem}).inject(this.viewListAreaNode, (isNew) ? "top": "bottom");
  67. var listTableItemIcon = new Element("div", {"styles": this.css.listViewItemIcon}).inject(listTableItem);
  68. var listTableItemText = new Element("div", {"styles": this.css.listViewItemText, "text": (table.name) ? table.name+" ("+table.alias+")" : this.lp.newTable}).inject(listTableItem);
  69. listTableItem.store("table", table);
  70. listTableItem.addEvents({
  71. "dblclick": function(e){_self.loadTableByData(this, e);},
  72. "mouseover": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem_over);},
  73. "mouseout": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem);}
  74. });
  75. },
  76. //打开数据表
  77. loadViewByData: function(node, e){
  78. var table = node.retrieve("table");
  79. if (openNew){
  80. var _self = this;
  81. var options = {
  82. "onQueryLoad": function(){
  83. this.actions = _self.actions;
  84. this.category = _self;
  85. this.options.id = table.id;
  86. this.application = _self.application;
  87. this.explorer = _self.explorer;
  88. }
  89. };Table
  90. this.desktop.openApplication(e, "query.TableDesigner", options);
  91. }
  92. },
  93. //loadView------------------------------------------
  94. loadView: function(){
  95. this.getViewData(this.options.id, function(vdata){
  96. this.setTitle(this.options.appTitle + "-"+vdata.name);
  97. this.taskitem.setText(this.options.appTitle + "-"+vdata.name);
  98. this.options.appTitle = this.options.appTitle + "-"+vdata.name;
  99. this.table = new MWF.xApplication.query.TableDesigner.Table(this, vdata);
  100. this.table.load();
  101. }.bind(this));
  102. },
  103. loadNewViewData: function(callback){
  104. var url = "/x_component_query_TableDesigner/$Table/table.json";
  105. MWF.getJSON(url, {
  106. "onSuccess": function(obj){
  107. this.actions.getUUID(function(id){
  108. obj.id=id;
  109. obj.isNewTable = true;
  110. obj.application = this.application.id;
  111. this.createListViewItem(obj, true);
  112. if (callback) callback(obj);
  113. }.bind(this));
  114. }.bind(this),
  115. "onerror": function(text){
  116. this.notice(text, "error");
  117. }.bind(this),
  118. "onRequestFailure": function(xhr){
  119. this.notice(xhr.responseText, "error");
  120. }.bind(this)
  121. });
  122. },
  123. loadViewData: function(id, callback){
  124. this.actions.getTable(id, function(json){
  125. if (json){
  126. var data = json.data;
  127. data.data = JSON.decode(data.data);
  128. if (!this.application){
  129. this.actions.getApplication(data.query, function(json){
  130. this.application = {"name": json.data.name, "id": json.data.id};
  131. if (callback) callback(data);
  132. }.bind(this));
  133. }else{
  134. if (callback) callback(data);
  135. }
  136. }
  137. }.bind(this));
  138. },
  139. saveView: function(){
  140. this.view.save(function(){
  141. var name = this.view.data.name;
  142. this.setTitle(MWF.APPDSTD.LP.title + "-"+name);
  143. this.options.desktopReload = true;
  144. this.options.id = this.view.data.id;
  145. }.bind(this));
  146. },
  147. saveViewAs: function(){
  148. this.view.saveAs();
  149. },
  150. dictionaryExplode: function(){
  151. this.view.explode();
  152. },
  153. dictionaryImplode: function(){
  154. this.view.implode();
  155. }
  156. //recordStatus: function(){
  157. // return {"id": this.options.id};
  158. //},
  159. });