Main.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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.application && this.options.application ){
  33. this.application = this.options.application;
  34. }
  35. if (!this.options.id){
  36. this.options.desktopReload = false;
  37. this.options.title = this.options.title + "-"+MWF.APPDTBD.LP.newTable;
  38. }
  39. if (!this.actions) this.actions = MWF.Actions.get("x_query_assemble_designer");
  40. this.lp = MWF.xApplication.query.TableDesigner.LP;
  41. this.addEvent("queryClose", function(e){
  42. if (this.explorer){
  43. this.explorer.reload();
  44. }
  45. }.bind(this));
  46. },
  47. loadViewListNodes: function(){
  48. this.viewListTitleNode = new Element("div", {
  49. "styles": this.css.viewListTitleNode,
  50. "text": MWF.APPDTBD.LP.table
  51. }).inject(this.viewListNode);
  52. this.viewListResizeNode = new Element("div", {"styles": this.css.viewListResizeNode}).inject(this.viewListNode);
  53. this.createListTitleNodes();
  54. this.viewListAreaSccrollNode = new Element("div", {"styles": this.css.viewListAreaSccrollNode}).inject(this.viewListNode);
  55. this.viewListAreaNode = new Element("div", {"styles": this.css.viewListAreaNode}).inject(this.viewListAreaSccrollNode);
  56. this.loadViewListResize();
  57. this.loadViewList();
  58. },
  59. openApp: function (){
  60. layout.openApplication(null, 'query.QueryManager', {
  61. application: this.application,
  62. appId: 'query.QueryManager'+this.application.id
  63. }, {
  64. "navi":2
  65. });
  66. },
  67. loadViewList: function(){
  68. debugger;
  69. if( this.itemArray && this.itemArray.length ){
  70. this.itemArray.each(function(i){
  71. if(!i.data.isNewTable)i.node.destroy();
  72. });
  73. }
  74. this.itemArray = [];
  75. this.actions.listTable(this.application.id, function (json) {
  76. this.checkSort(json.data);
  77. json.data.each(function(table){
  78. this.createListViewItem(table);
  79. }.bind(this));
  80. }.bind(this), null, false);
  81. },
  82. //列示所有数据表列表
  83. createListViewItem: function(table, isNew){
  84. var _self = this;
  85. var listTableItem = new Element("div", {"styles": this.css.listViewItem}).inject(this.viewListAreaNode, (isNew) ? "top": "bottom");
  86. var listTableItemIcon = new Element("div", {"styles": this.css.listViewItemIcon}).inject(listTableItem);
  87. var listTableItemText = new Element("div", {"styles": this.css.listViewItemText, "text": (table.name) ? table.name+" ("+table.alias+")" : this.lp.newTable}).inject(listTableItem);
  88. listTableItem.store("table", table);
  89. listTableItem.addEvents({
  90. "click": function(e){_self.loadTableByData(this, e);},
  91. "mouseover": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem_over);},
  92. "mouseout": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem);}
  93. });
  94. if( table.id === this.options.id ){
  95. listTableItem.setStyles(this.css.listViewItem_current);
  96. this.currentListViewItem = listTableItem;
  97. }
  98. var itemObj = {
  99. node: listTableItem,
  100. data: table
  101. };
  102. this.itemArray.push(itemObj);
  103. this.checkShow(itemObj);
  104. },
  105. //打开数据表
  106. loadTableByData: function(node, e){
  107. var table = node.retrieve("table");
  108. if (!table.isNewTable){
  109. var openNew = true;
  110. if (openNew){
  111. var _self = this;
  112. var options = {
  113. "appId": "query.TableDesigner"+table.id,
  114. "id": table.id,
  115. // "application": _self.application.id,
  116. "application": {
  117. "name": _self.application.name,
  118. "id": _self.application.id,
  119. },
  120. "onQueryLoad": function(){
  121. this.actions = _self.actions;
  122. this.category = _self;
  123. this.options.id = table.id;
  124. this.application = _self.application;
  125. this.explorer = _self.explorer;
  126. }
  127. };
  128. this.desktop.openApplication(e, "query.TableDesigner", options);
  129. }
  130. }
  131. },
  132. //loadView------------------------------------------
  133. loadView: function(){
  134. this.getViewData(this.options.id, function(vdata){
  135. this.setTitle(this.options.appTitle + "-"+vdata.name);
  136. if(this.taskitem)this.taskitem.setText(this.options.appTitle + "-"+vdata.name);
  137. this.options.appTitle = this.options.appTitle + "-"+vdata.name;
  138. this.table = new MWF.xApplication.query.TableDesigner.Table(this, vdata);
  139. this.table.load();
  140. }.bind(this));
  141. },
  142. loadNewViewData: function(callback){
  143. var url = "../x_component_query_TableDesigner/$Table/table.json";
  144. MWF.getJSON(url, {
  145. "onSuccess": function(obj){
  146. this.actions.getUUID(function(id){
  147. obj.id=id;
  148. obj.isNewTable = true;
  149. obj.application = this.application.id;
  150. this.createListViewItem(obj, true);
  151. if (callback) callback(obj);
  152. }.bind(this));
  153. }.bind(this),
  154. "onerror": function(text){
  155. this.notice(text, "error");
  156. }.bind(this),
  157. "onRequestFailure": function(xhr){
  158. this.notice(xhr.responseText, "error");
  159. }.bind(this)
  160. });
  161. },
  162. loadViewData: function(id, callback){
  163. this.actions.getTable(id, function(json){
  164. if (json){
  165. var data = json.data;
  166. data.draftData = JSON.decode(data.draftData);
  167. if (!this.application){
  168. this.actions.getApplication(data.query, function(json){
  169. this.application = {"name": json.data.name, "id": json.data.id};
  170. if (callback) callback(data);
  171. }.bind(this));
  172. }else{
  173. if (callback) callback(data);
  174. }
  175. }
  176. }.bind(this));
  177. },
  178. saveView: function(){
  179. this.view.save(function(){
  180. var name = this.view.data.name;
  181. this.setTitle(MWF.APPDTBD.LP.title + "-"+name);
  182. this.options.desktopReload = true;
  183. this.options.id = this.view.data.id;
  184. }.bind(this));
  185. },
  186. statusBuild: function(){
  187. this.view.statusBuild();
  188. },
  189. statusDraft: function(){
  190. this.view.statusDraft();
  191. },
  192. buildAllView: function(){
  193. this.view.buildAllView();
  194. },
  195. bulidCurrentApp: function(){
  196. this.view.bulidCurrentApp();
  197. },
  198. tableExplode: function(){
  199. this.view.tableExplode();
  200. },
  201. tableImplode: function(){
  202. this.view.tableImplode();
  203. },
  204. tableExcelExplode: function(){
  205. this.view.tableExcelExplode();
  206. },
  207. tableExcelImplode: function(){
  208. this.view.tableExcelImplode();
  209. },
  210. tableClear: function(){
  211. this.view.tableClear();
  212. },
  213. tableHelp: function(){
  214. var content = new Element("div", {"styles": {"margin": "20px"}});
  215. content.set("html", this.lp.tableHelp);
  216. o2.DL.open({
  217. "title": "table help",
  218. "content": content,
  219. "width": 500,
  220. "height": 320,
  221. "buttonList": [
  222. {
  223. "text": "ok",
  224. "action": function(){this.close();}
  225. }
  226. ]
  227. });
  228. }
  229. // dictionaryExplode: function(){
  230. // this.view.explode();
  231. // },
  232. // dictionaryImplode: function(){
  233. // this.view.implode();
  234. // }
  235. //recordStatus: function(){
  236. // return {"id": this.options.id};
  237. //},
  238. });