Main.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. MWF.xDesktop.requireApp("query.QueryManager", "package", null, false);
  2. MWF.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.require("MWF.widget.Identity", null,false);
  4. MWF.xDesktop.requireApp("process.ProcessManager", "", null, false);
  5. MWF.xApplication.query = MWF.xApplication.query || {};
  6. MWF.xApplication.query.QueryManager.Main = new Class({
  7. Extends: MWF.xApplication.process.ProcessManager.Main,
  8. Implements: [Options, Events],
  9. options: {
  10. "application": null,
  11. "style": "default",
  12. "name": "query.QueryManager",
  13. "icon": "icon.png",
  14. "width": "1100",
  15. "height": "700",
  16. "title": MWF.xApplication.query.QueryManager.LP.title
  17. },
  18. onQueryLoad: function(){
  19. this.lp = MWF.xApplication.query.QueryManager.LP;
  20. this.currentContentNode = null;
  21. this.restActions = MWF.Actions.get("x_query_assemble_designer");
  22. },
  23. keyCopyItems: function(e){
  24. if (this.viewConfigurator){
  25. this.viewConfigurator.keyCopy(e);
  26. }
  27. if (this.statConfigurator){
  28. this.statConfigurator.keyCopy(e);
  29. }
  30. },
  31. keyPasteItems: function(e){
  32. if (this.viewConfigurator){
  33. this.viewConfigurator.keyPaste(e);
  34. }
  35. if (this.statConfigurator) {
  36. this.statConfigurator.keyPaste(e);
  37. }
  38. },
  39. loadStartMenu: function(callback){
  40. this.startMenuNode = new Element("div", {
  41. "styles": this.css.startMenuNode
  42. }).inject(this.node);
  43. this.menu = new MWF.xApplication.query.QueryManager.Menu(this, this.startMenuNode, {
  44. "onPostLoad": function(){
  45. if (this.status){
  46. if (this.status.navi!=null){
  47. this.menu.doAction(this.menu.startNavis[this.status.navi]);
  48. }else{
  49. this.menu.doAction(this.menu.startNavis[0]);
  50. }
  51. }else{
  52. this.menu.doAction(this.menu.startNavis[0]);
  53. }
  54. }.bind(this)
  55. });
  56. this.addEvent("resize", function(){
  57. if (this.menu) this.menu.onResize();
  58. }.bind(this));
  59. },
  60. clearContent: function(){
  61. //暂时没有启用---------------------
  62. if (this.selectConfiguratorContent){
  63. if (this.selectConfigurator) delete this.selectConfigurator;
  64. this.selectConfiguratorContent.destroy();
  65. this.selectConfiguratorContent = null;
  66. }
  67. if (this.revealConfiguratorContent){
  68. if (this.revealConfigurator) delete this.revealConfigurator;
  69. this.revealConfiguratorContent.destroy();
  70. this.revealConfiguratorContent = null;
  71. }
  72. //-------------------------------
  73. if (this.viewConfiguratorContent){
  74. if (this.viewConfigurator) delete this.viewConfigurator;
  75. this.viewConfiguratorContent.destroy();
  76. this.viewConfiguratorContent = null;
  77. }
  78. if (this.propertyConfiguratorContent){
  79. if (this.property) delete this.property;
  80. this.propertyConfiguratorContent.destroy();
  81. this.propertyConfiguratorContent = null;
  82. }
  83. if (this.statConfiguratorContent){
  84. if (this.statConfigurator) delete this.statConfigurator;
  85. this.statConfiguratorContent.destroy();
  86. this.statConfiguratorContent = null;
  87. }
  88. if (this.tableConfiguratorContent){
  89. if (this.tableConfigurator) delete this.tableConfigurator;
  90. this.tableConfiguratorContent.destroy();
  91. this.tableConfiguratorContent = null;
  92. }
  93. if (this.statementConfiguratorContent){
  94. if (this.statementConfigurator) delete this.statementConfigurator;
  95. this.statementConfiguratorContent.destroy();
  96. this.statementConfiguratorContent = null;
  97. }
  98. },
  99. queryProperty: function(){
  100. this.clearContent();
  101. this.propertyConfiguratorContent = new Element("div", {
  102. "styles": this.css.rightContentNode
  103. }).inject(this.node);
  104. this.property = new MWF.xApplication.query.QueryManager.QueryProperty(this, this.propertyConfiguratorContent);
  105. this.property.load();
  106. },
  107. selectConfig: function(){
  108. this.clearContent();
  109. this.selectConfiguratorContent = new Element("div", {
  110. "styles": this.css.rightContentNode
  111. }).inject(this.node);
  112. this.loadSelectConfig();
  113. },
  114. loadSelectConfig: function(){
  115. MWF.xDesktop.requireApp("query.QueryManager", "SelectExplorer", function(){
  116. this.selectConfigurator = new MWF.xApplication.query.QueryManager.SelectExplorer(this.selectConfiguratorContent, this.restActions);
  117. this.selectConfigurator.app = this;
  118. this.selectConfigurator.load();
  119. }.bind(this));
  120. },
  121. viewConfig: function(){
  122. this.clearContent();
  123. this.viewConfiguratorContent = new Element("div", {
  124. "styles": this.css.rightContentNode
  125. }).inject(this.node);
  126. this.loadViewConfig();
  127. },
  128. loadViewConfig: function(){
  129. MWF.xDesktop.requireApp("query.QueryManager", "ViewExplorer", function(){
  130. this.viewConfigurator = new MWF.xApplication.query.QueryManager.ViewExplorer(this.viewConfiguratorContent, this.restActions);
  131. this.viewConfigurator.app = this;
  132. this.viewConfigurator.load();
  133. }.bind(this));
  134. },
  135. statConfig: function(){
  136. this.clearContent();
  137. this.statConfiguratorContent = new Element("div", {
  138. "styles": this.css.rightContentNode
  139. }).inject(this.node);
  140. this.loadStatConfig();
  141. },
  142. loadStatConfig: function(){
  143. MWF.xDesktop.requireApp("query.QueryManager", "StatExplorer", function(){
  144. this.statConfigurator = new MWF.xApplication.query.QueryManager.StatExplorer(this.statConfiguratorContent, this.restActions);
  145. this.statConfigurator.app = this;
  146. this.statConfigurator.load();
  147. }.bind(this));
  148. },
  149. revealConfig: function(){
  150. this.clearContent();
  151. this.revealConfiguratorContent = new Element("div", {
  152. "styles": this.css.rightContentNode
  153. }).inject(this.node);
  154. this.loadRevealConfig();
  155. },
  156. loadRevealConfig: function(){
  157. MWF.xDesktop.requireApp("query.QueryManager", "RevealExplorer", function(){
  158. this.revealConfigurator = new MWF.xApplication.query.QueryManager.RevealExplorer(this.revealConfiguratorContent, this.restActions);
  159. this.revealConfigurator.app = this;
  160. this.revealConfigurator.load();
  161. }.bind(this));
  162. },
  163. tableConfig: function(){
  164. this.clearContent();
  165. this.tableConfiguratorContent = new Element("div", {
  166. "styles": this.css.rightContentNode
  167. }).inject(this.node);
  168. this.loadTableConfig();
  169. },
  170. loadTableConfig: function(){
  171. MWF.xDesktop.requireApp("query.QueryManager", "TableExplorer", function(){
  172. this.tableConfigurator = new MWF.xApplication.query.QueryManager.TableExplorer(this.tableConfiguratorContent, this.restActions);
  173. this.tableConfigurator.app = this;
  174. this.tableConfigurator.load();
  175. }.bind(this));
  176. },
  177. statementConfig: function(){
  178. this.clearContent();
  179. this.statementConfiguratorContent = new Element("div", {
  180. "styles": this.css.rightContentNode
  181. }).inject(this.node);
  182. this.loadStatementConfig();
  183. },
  184. loadStatementConfig: function(){
  185. MWF.xDesktop.requireApp("query.QueryManager", "StatementExplorer", function(){
  186. this.statementConfigurator = new MWF.xApplication.query.QueryManager.StatementExplorer(this.statementConfiguratorContent, this.restActions);
  187. this.statementConfigurator.app = this;
  188. this.statementConfigurator.load();
  189. }.bind(this));
  190. }
  191. });
  192. MWF.xApplication.query.QueryManager.Menu = new Class({
  193. Extends: MWF.xApplication.process.ProcessManager.Menu,
  194. Implements: [Options, Events]
  195. });
  196. MWF.xApplication.query.QueryManager.QueryProperty = new Class({
  197. Extends: MWF.xApplication.process.ProcessManager.ApplicationProperty,
  198. createPropertyContentNode: function(){
  199. this.propertyContentNode = new Element("div", {"styles": {
  200. "overflow": "hidden",
  201. "-webkit-user-select": "text",
  202. "-moz-user-select": "text"
  203. }}).inject(this.contentAreaNode);
  204. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  205. html += "<tr><td class='formTitle'>"+this.app.lp.application.name+"</td><td id='formApplicationName'></td></tr>";
  206. html += "<tr><td class='formTitle'>"+this.app.lp.application.alias+"</td><td id='formApplicationAlias'></td></tr>";
  207. html += "<tr><td class='formTitle'>"+this.app.lp.application.description+"</td><td id='formApplicationDescription'></td></tr>";
  208. html += "<tr><td class='formTitle'>"+this.app.lp.application.type+"</td><td id='formApplicationType'></td></tr>";
  209. // html += "<tr><td class='formTitle'>"+this.app.lp.application.firstPage+"</td><td id='formApplicationFirstPage'></td></tr>";
  210. html += "<tr><td class='formTitle'>"+this.app.lp.application.id+"</td><td id='formApplicationId'></td></tr>";
  211. // html += "<tr><td class='formTitle'>"+this.app.lp.application.icon+"</td><td id='formApplicationIcon'></td></tr>";
  212. html += "</table>";
  213. this.propertyContentNode.set("html", html);
  214. this.propertyContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  215. this.nameInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationName"), this.data.name, this.app.css.formInput);
  216. this.aliasInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationAlias"), this.data.alias, this.app.css.formInput);
  217. this.descriptionInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationDescription"), this.data.description, this.app.css.formInput);
  218. //2019年11月15日--ji 接口是queryCategory字段
  219. //this.typeInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.applicationCategory, this.app.css.formInput);
  220. this.typeInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.queryCategory, this.app.css.formInput);
  221. // this.firstPageInput = new MWF.xApplication.query.QueryManager.Select(this.propertyContentNode.getElement("#formApplicationFirstPage"), this.data.firstPage, this.app.css.formInput, function(){
  222. // var pages = {};
  223. // debugger;
  224. // this.app.restActions.listPage(this.app.options.application.id, function(json){
  225. // json.data.each(function(page) {
  226. // pages[page.id] = page.name;
  227. // }.bind(this));
  228. // }.bind(this), null, false);
  229. // return pages;
  230. // }.bind(this));
  231. this.idInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationId"), this.data.id, this.app.css.formInput);
  232. },
  233. editMode: function(){
  234. this.nameInput.editMode();
  235. this.aliasInput.editMode();
  236. this.descriptionInput.editMode();
  237. this.typeInput.editMode();
  238. //this.firstPageInput.editMode();
  239. this.isEdit = true;
  240. },
  241. readMode: function(){
  242. this.nameInput.readMode();
  243. this.aliasInput.readMode();
  244. this.descriptionInput.readMode();
  245. this.typeInput.readMode();
  246. //this.firstPageInput.readMode();
  247. this.isEdit = false;
  248. },
  249. save: function(callback, cancel) {
  250. this.data.name = this.nameInput.input.get("value");
  251. this.data.alias = this.aliasInput.input.get("value");
  252. this.data.description = this.descriptionInput.input.get("value");
  253. //2019年11月15日--ji 接口是queryCategory字段
  254. //this.data.applicationCategory = this.typeInput.input.get("value");
  255. this.data.queryCategory = this.typeInput.input.get("value");
  256. //this.data.firstPage = this.firstPageInput.input.get("value");
  257. this.app.restActions.saveApplication(this.data, function (json) {
  258. this.propertyTitleBar.set("text", this.data.name);
  259. this.data.id = json.data.id;
  260. this.nameInput.save();
  261. this.aliasInput.save();
  262. this.descriptionInput.save();
  263. this.typeInput.save();
  264. //this.firstPageInput.save();
  265. if (callback) callback();
  266. }.bind(this), function (xhr, text, error) {
  267. if (cancel) cancel(xhr, text, error);
  268. }.bind(this));
  269. }
  270. });
  271. MWF.xApplication.query.QueryManager.Input = new Class({
  272. Extends: MWF.xApplication.process.ProcessManager.Input,
  273. Implements: [Events]
  274. });
  275. MWF.xApplication.query.QueryManager.Select = new Class({
  276. Extends: MWF.xApplication.process.ProcessManager.Input,
  277. Implements: [Events],
  278. initialize: function(node, value, style, select){
  279. this.node = $(node);
  280. this.value = (value) ? value: "";
  281. this.style = style;
  282. this.select = select;
  283. this.selectList = null;;
  284. this.load();
  285. },
  286. getSelectList: function(){
  287. if (this.select){
  288. return this.select();
  289. }
  290. return [];
  291. },
  292. getText: function(value){
  293. if (value){
  294. if (this.selectList){
  295. return this.selectList[value] || "";
  296. }
  297. }
  298. return "";
  299. },
  300. load: function(){
  301. this.selectList = this.getSelectList();
  302. this.content = new Element("div", {
  303. "styles": this.style.content,
  304. "text": this.getText(this.value)
  305. }).inject(this.node);
  306. },
  307. editMode: function(){
  308. this.content.empty();
  309. this.input = new Element("select",{
  310. //"styles": this.style.input,
  311. //"value": this.value
  312. }).inject(this.content);
  313. Object.each(this.selectList, function(v, k){
  314. new Element("option", {
  315. "value": k,
  316. "text": v,
  317. "selected": (this.value==v)
  318. }).inject(this.input);
  319. }.bind(this));
  320. //this.input.addEvents({
  321. // //"focus": function(){
  322. // // this.input.setStyles(this.style.input_focus);
  323. // //}.bind(this),
  324. // //"blur": function(){
  325. // // this.input.setStyles(this.style.input);
  326. // //}.bind(this),
  327. // //"change": function(){
  328. // // this.input.setStyles(this.style.input);
  329. // //}.bind(this)
  330. //});
  331. },
  332. readMode: function(){
  333. this.content.empty();
  334. this.input = null;
  335. this.content.set("text", this.getText(this.value));
  336. },
  337. save: function(){
  338. if (this.input) this.value = this.input.options[this.input.selectedIndex].get("value");
  339. return this.value;
  340. }
  341. });