Main.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. MWF.xDesktop.requireApp("query.ViewDesigner", "", null, false);
  2. MWF.APPDIPD = MWF.xApplication.query.ImporterDesigner;
  3. MWF.APPDIPD.options = {
  4. "multitask": true,
  5. "executable": false
  6. };
  7. MWF.xDesktop.requireApp("query.ImporterDesigner", "Importer", null, false);
  8. MWF.xApplication.query.ImporterDesigner.Main = new Class({
  9. Extends: MWF.xApplication.query.ViewDesigner.Main,
  10. Implements: [Options, Events],
  11. options: {
  12. "style": "default",
  13. "name": "query.ImporterDesigner",
  14. "icon": "icon.png",
  15. "title": MWF.APPDIPD.LP.title,
  16. "appTitle": MWF.APPDIPD.LP.title,
  17. "id": "",
  18. "tooltip": {
  19. "unCategory": MWF.APPDIPD.LP.unCategory
  20. },
  21. "actions": null,
  22. "category": null
  23. },
  24. onQueryLoad: function(){
  25. this.shortcut = true;
  26. if (this.status){
  27. this.options.application = this.status.applicationId;
  28. this.application = this.status.application;
  29. this.options.id = this.status.id;
  30. }
  31. if( !this.application && this.options.application ){
  32. this.application = this.options.application;
  33. }
  34. if (!this.options.id){
  35. this.options.desktopReload = false;
  36. this.options.title = this.options.title + "-"+MWF.APPDIPD.LP.newImporter;
  37. }
  38. if (!this.actions) this.actions = MWF.Actions.get("x_query_assemble_designer");
  39. this.lp = MWF.xApplication.query.ImporterDesigner.LP;
  40. this.addEvent("queryClose", function(e){
  41. if (this.explorer){
  42. this.explorer.reload();
  43. }
  44. }.bind(this));
  45. },
  46. loadViewListNodes: function(){
  47. this.viewListTitleNode = new Element("div", {
  48. "styles": this.css.viewListTitleNode,
  49. "text": MWF.APPDIPD.LP.importer
  50. }).inject(this.viewListNode);
  51. this.viewListResizeNode = new Element("div", {"styles": this.css.viewListResizeNode}).inject(this.viewListNode);
  52. this.viewListAreaSccrollNode = new Element("div", {"styles": this.css.viewListAreaSccrollNode}).inject(this.viewListNode);
  53. this.viewListAreaNode = new Element("div", {"styles": this.css.viewListAreaNode}).inject(this.viewListAreaSccrollNode);
  54. this.loadViewListResize();
  55. this.loadViewList();
  56. },
  57. loadViewList: function(){
  58. debugger;
  59. this.actions.listImportModel(this.application.id, function (json) {
  60. json.data.each(function(importer){
  61. this.createListViewItem(importer);
  62. }.bind(this));
  63. }.bind(this), null, false);
  64. },
  65. //列示所有数据表列表
  66. createListViewItem: function(importer, isNew){
  67. debugger;
  68. var _self = this;
  69. var listImporterItem = new Element("div", {"styles": this.css.listViewItem}).inject(this.viewListAreaNode, (isNew) ? "top": "bottom");
  70. var listImporterItemIcon = new Element("div", {"styles": this.css.listViewItemIcon}).inject(listImporterItem);
  71. var listImporterItemText = new Element("div", {"styles": this.css.listViewItemText, "text": (importer.name) ? importer.name+" ("+importer.alias+")" : this.lp.newImporter}).inject(listImporterItem);
  72. listImporterItem.store("importer", importer);
  73. listImporterItem.addEvents({
  74. "click": function(e){_self.loadImporterByData(this, e);},
  75. "mouseover": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem_over);},
  76. "mouseout": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem);}
  77. });
  78. },
  79. //打开数据表
  80. loadImporterByData: function(node, e){
  81. var importer = node.retrieve("importer");
  82. if (!importer.isNewImportModel){
  83. var openNew = true;
  84. if (openNew){
  85. var _self = this;
  86. var options = {
  87. "appId": "query.ImporterDesigner"+importer.id,
  88. "id": importer.id,
  89. // "application": _self.application.id,
  90. "application": {
  91. "name": _self.application.name,
  92. "id": _self.application.id,
  93. },
  94. "onQueryLoad": function(){
  95. this.actions = _self.actions;
  96. this.category = _self;
  97. this.options.id = importer.id;
  98. this.application = _self.application;
  99. this.explorer = _self.explorer;
  100. }
  101. };
  102. this.desktop.openApplication(e, "query.ImporterDesigner", options);
  103. }
  104. }
  105. },
  106. //loadView------------------------------------------
  107. loadView: function(){
  108. this.getViewData(this.options.id, function(vdata){
  109. this.setTitle(this.options.appTitle + "-"+vdata.name);
  110. if(this.taskitem)this.taskitem.setText(this.options.appTitle + "-"+vdata.name);
  111. this.options.appTitle = this.options.appTitle + "-"+vdata.name;
  112. this.importer = new MWF.xApplication.query.ImporterDesigner.Importer(this, vdata);
  113. this.view = this.importer;
  114. this.importer.load();
  115. }.bind(this));
  116. },
  117. loadNewViewData: function(callback){
  118. var url = "../x_component_query_ImporterDesigner/$Importer/importer.json";
  119. MWF.getJSON(url, {
  120. "onSuccess": function(obj){
  121. this.actions.getUUID(function(id){
  122. obj.id=id;
  123. obj.isNewImportModel = true;
  124. obj.application = this.application.id;
  125. this.createListViewItem(obj, true);
  126. if (callback) callback(obj);
  127. }.bind(this));
  128. }.bind(this),
  129. "onerror": function(text){
  130. this.notice(text, "error");
  131. }.bind(this),
  132. "onRequestFailure": function(xhr){
  133. this.notice(xhr.responseText, "error");
  134. }.bind(this)
  135. });
  136. },
  137. loadViewData: function(id, callback){
  138. this.actions.getImportModel(id, function(json){
  139. if (json){
  140. var data = json.data;
  141. // data.draftData = JSON.decode(data.draftData);
  142. if (!this.application){
  143. this.actions.getApplication(data.query, function(json){
  144. this.application = {"name": json.data.name, "id": json.data.id};
  145. if (callback) callback(data);
  146. }.bind(this));
  147. }else{
  148. if (callback) callback(data);
  149. }
  150. }
  151. }.bind(this));
  152. },
  153. saveView: function(){
  154. this.view.save(function(){
  155. var name = this.view.data.name;
  156. this.setTitle(MWF.APPDIPD.LP.title + "-"+name);
  157. this.options.desktopReload = true;
  158. this.options.id = this.view.data.id;
  159. }.bind(this));
  160. },
  161. statusBuild: function(){
  162. this.view.statusBuild();
  163. },
  164. statusDraft: function(){
  165. this.view.statusDraft();
  166. },
  167. buildAllView: function(){
  168. this.view.buildAllView();
  169. }
  170. });
  171. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  172. MWF.xApplication.query.ImporterDesigner.Importer.NewNameForm = new Class({
  173. Extends: MPopupForm,
  174. Implements: [Options, Events],
  175. options: {
  176. "style": "design",
  177. "width": 700,
  178. //"height": 300,
  179. "height": "260",
  180. "hasTop": true,
  181. "hasIcon": false,
  182. "draggable": true,
  183. "title" : MWF.xApplication.query.ImporterDesigner.LP.newImporter
  184. },
  185. _createTableContent: function () {
  186. var html = "<table width='80%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin: 20px auto 0px auto; '>" +
  187. "<tr><td styles='formTableTitle' lable='selectQuery' width='25%'></td>" +
  188. " <td styles='formTableValue' item='selectQuery' colspan='3' width='75%'></td></tr>" +
  189. "<tr><td styles='formTableTitle' lable='name'></td>" +
  190. " <td styles='formTableValue' item='name' colspan='3'></td></tr>" +
  191. "</table>";
  192. this.formTableArea.set("html", html);
  193. MWF.xDesktop.requireApp("Template", "MForm", function () {
  194. this.form = new MForm(this.formTableArea, this.data || {}, {
  195. isEdited: true,
  196. style: "cms",
  197. hasColon: true,
  198. itemTemplate: {
  199. selectQuery : { text: MWF.xApplication.query.ImporterDesigner.LP.application , type : "org", orgType : "Query", defaultValue : this.data.queryName, orgWidgetOptions : {
  200. "canRemove" : false
  201. }},
  202. name: {text: MWF.xApplication.query.ImporterDesigner.LP.name, notEmpty: true}
  203. }
  204. }, this.app);
  205. this.form.load();
  206. }.bind(this),null, true)
  207. },
  208. ok: function(){
  209. var data = this.form.getResult(true,null,true,false,true);
  210. if( data ){
  211. var selectQuery = this.form.getItem("selectQuery").orgObject;
  212. if( selectQuery && selectQuery.length > 0 ){
  213. var queryData = selectQuery[0].data;
  214. data.query = queryData.id;
  215. data.queryName = queryData.name;
  216. }else{
  217. //data.query 和 data.queryName 还是传进来的值
  218. }
  219. this.fireEvent("save", [data , function(){
  220. this.close();
  221. }.bind(this)])
  222. }
  223. }
  224. });