Main.js 15 KB

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