Main.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  1. MWF.xApplication.query.InquiryDesigner =MWF.xApplication.query.InquiryDesigner || {};
  2. MWF.APPDIQD = MWF.xApplication.query.InquiryDesigner;
  3. MWF.APPDIQD.options = {
  4. "multitask": true,
  5. "executable": false
  6. };
  7. MWF.xDesktop.requireApp("query.InquiryDesigner", "Inquiry", null, false);
  8. MWF.xApplication.query.InquiryDesigner.Main = new Class({
  9. Extends: MWF.xApplication.Common.Main,
  10. Implements: [Options, Events],
  11. options: {
  12. "style": "default",
  13. "name": "query.InquiryDesigner",
  14. "icon": "icon.png",
  15. "title": MWF.APPDIQD.LP.title,
  16. "appTitle": MWF.APPDIQD.LP.title,
  17. "id": "",
  18. "actions": null,
  19. "category": null
  20. },
  21. onQueryLoad: function(){
  22. this.shortcut = true;
  23. if (this.status){
  24. this.options.application = this.status.applicationId;
  25. this.application = this.status.application;
  26. this.options.id = this.status.id;
  27. }
  28. if (!this.options.id){
  29. this.options.desktopReload = false;
  30. this.options.title = this.options.title + "-"+MWF.APPDIQD.LP.title;
  31. }
  32. if (!this.actions) this.actions = MWF.Actions.get("x_query_assemble_designer");
  33. this.lp = MWF.xApplication.query.InquiryDesigner.LP;
  34. this.addEvent("queryClose", function(e){
  35. if (this.explorer){
  36. this.explorer.reload();
  37. }
  38. }.bind(this));
  39. this.addEvent("postLoadWindowMax", function(e){
  40. this.loadWindowOk = true;
  41. if (this.loadApplicationOk && this.loadWindowOk){
  42. //if (this.tab.showPage) {
  43. // var view = this.tab.showPage.view;
  44. // if (view) {
  45. this.view.setViewWidth();
  46. // }
  47. //}
  48. }
  49. }.bind(this));
  50. this.addEvent("postLoadApplication", function(e){
  51. this.loadApplicationOk = true;
  52. if (this.loadApplicationOk && this.loadWindowOk){
  53. //if (this.tab.showPage) {
  54. // var view = this.tab.showPage.view;
  55. // if (view) {
  56. this.view.setViewWidth();
  57. // }
  58. //}
  59. }
  60. }.bind(this));
  61. },
  62. loadApplication: function(callback){
  63. this.createNode();
  64. if (!this.options.isRefresh){
  65. this.maxSize(function(){
  66. this.openView(function(){
  67. if (callback) callback();
  68. });
  69. }.bind(this));
  70. }else{
  71. this.openView(function(){
  72. if (callback) callback();
  73. });
  74. }
  75. if (!this.options.readMode) this.addKeyboardEvents();
  76. },
  77. keySave: function(e){
  78. if (this.shortcut) {
  79. //if (this.tab.showPage) {
  80. // var view = this.tab.showPage.view;
  81. // if (view) {
  82. this.view.save();
  83. e.preventDefault();
  84. // }
  85. //}
  86. }
  87. },
  88. keyDelete: function(){
  89. if (this.shortcut) {
  90. //if (this.tab.showPage) {
  91. //var view = this.tab.showPage.view;
  92. //if (view) {
  93. if (this.view.currentSelectedModule) {
  94. var item = this.view.currentSelectedModule;
  95. item["delete"]();
  96. }
  97. //}
  98. //}
  99. }
  100. },
  101. copyModule: function(){
  102. if (this.shortcut) {
  103. //if (this.tab.showPage) {
  104. //var view = this.tab.showPage.view;
  105. //if (view) {
  106. if (this.view.currentSelectedModule) {
  107. var item = this.view.currentSelectedModule;
  108. MWF.clipboard.data = {
  109. "type": "view",
  110. "data": item.json
  111. };
  112. }
  113. //}
  114. //}
  115. }
  116. },
  117. cutModule: function(){
  118. if (this.shortcut) {
  119. //if (this.tab.showPage) {
  120. //var view = this.tab.showPage.view;
  121. //if (view) {
  122. if (this.view.currentSelectedModule) {
  123. this.copyModule();
  124. var item = this.view.currentSelectedModule;
  125. item.destroy();
  126. }
  127. //}
  128. //}
  129. }
  130. },
  131. pasteModule: function(){
  132. if (this.shortcut) {
  133. if (MWF.clipboard.data) {
  134. if (MWF.clipboard.data.type == "view") {
  135. //if (this.tab.showPage) {
  136. //var view = this.tab.showPage.view;
  137. //if (view) {
  138. if (this.view.currentSelectedModule) {
  139. var item = this.view.currentSelectedModule;
  140. var data = MWF.clipboard.data.data;
  141. item.addColumn(null, data);
  142. }
  143. //}
  144. //}
  145. }
  146. }
  147. }
  148. },
  149. createNode: function(){
  150. this.content.setStyle("overflow", "hidden");
  151. this.node = new Element("div", {
  152. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  153. }).inject(this.content);
  154. },
  155. getApplication:function(callback){
  156. if (!this.application){
  157. this.actions.getApplication(this.options.application, function(json){
  158. this.application = {"name": json.data.name, "id": json.data.id};
  159. if (callback) callback();
  160. }.bind(this));
  161. }else{
  162. if (callback) callback();
  163. }
  164. },
  165. openView: function(callback){
  166. this.getApplication(function(){
  167. this.initOptions();
  168. this.loadNodes();
  169. this.loadViewListNodes();
  170. // this.loadToolbar();
  171. this.loadContentNode();
  172. this.loadProperty();
  173. // this.loadTools();
  174. this.resizeNode();
  175. this.addEvent("resize", this.resizeNode.bind(this));
  176. this.loadView(function(){
  177. if (callback) callback();
  178. });
  179. this.setScrollBar(this.propertyDomArea, null, {
  180. "V": {"x": 0, "y": 0},
  181. "H": {"x": 0, "y": 0}
  182. });
  183. }.bind(this));
  184. },
  185. initOptions: function(){
  186. //this.toolsData = null;
  187. //this.toolbarMode = "all";
  188. //this.tools = [];
  189. //this.toolbarDecrease = 0;
  190. //
  191. //this.designNode = null;
  192. //this.form = null;
  193. },
  194. loadNodes: function(){
  195. this.viewListNode = new Element("div", {
  196. "styles": this.css.viewListNode
  197. }).inject(this.node);
  198. this.propertyNode = new Element("div", {
  199. "styles": this.css.propertyNode
  200. }).inject(this.node);
  201. this.contentNode = new Element("div", {
  202. "styles": this.css.contentNode
  203. }).inject(this.node);
  204. },
  205. //loadViewListNodes-------------------------------
  206. loadViewListNodes: function(){
  207. this.viewListTitleNode = new Element("div", {
  208. "styles": this.css.viewListTitleNode,
  209. "text": MWF.APPDIQD.LP.view
  210. }).inject(this.viewListNode);
  211. this.viewListResizeNode = new Element("div", {"styles": this.css.viewListResizeNode}).inject(this.viewListNode);
  212. this.viewListAreaSccrollNode = new Element("div", {"styles": this.css.viewListAreaSccrollNode}).inject(this.viewListNode);
  213. this.viewListAreaNode = new Element("div", {"styles": this.css.viewListAreaNode}).inject(this.viewListAreaSccrollNode);
  214. this.loadViewListResize();
  215. this.loadViewList();
  216. },
  217. loadViewListResize: function(){
  218. this.viewListResize = new Drag(this.viewListResizeNode,{
  219. "snap": 1,
  220. "onStart": function(el, e){
  221. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  222. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  223. el.store("position", {"x": x, "y": y});
  224. var size = this.viewListAreaSccrollNode.getSize();
  225. el.store("initialWidth", size.x);
  226. }.bind(this),
  227. "onDrag": function(el, e){
  228. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  229. // var y = e.event.y;
  230. var bodySize = this.content.getSize();
  231. var position = el.retrieve("position");
  232. var initialWidth = el.retrieve("initialWidth").toFloat();
  233. var dx = x.toFloat() - position.x.toFloat();
  234. var width = initialWidth+dx;
  235. if (width> bodySize.x/2) width = bodySize.x/2;
  236. if (width<40) width = 40;
  237. this.contentNode.setStyle("margin-left", width+1);
  238. this.viewListNode.setStyle("width", width);
  239. //this.tab.pages.each(function(page){
  240. (this.view || this.table).setViewWidth();
  241. //});
  242. }.bind(this)
  243. });
  244. this.viewListResizeNode.addEvents({
  245. "touchstart": function(e){
  246. el = e.target;
  247. var x = (Browser.name=="firefox") ? e.page.clientX : e.page.x;
  248. var y = (Browser.name=="firefox") ? e.page.clientY : e.page.y;
  249. el.store("position", {"x": x, "y": y});
  250. var size = this.viewListAreaSccrollNode.getSize();
  251. el.store("initialWidth", size.x);
  252. }.bind(this),
  253. "touchmove": function(e){
  254. //Object.each(e, function(v, k){
  255. // alert(k+": "+ v);
  256. //});
  257. el = e.target;
  258. var x = (Browser.name=="firefox") ? e.page.clientX : e.page.x;
  259. // var y = e.event.y;
  260. var bodySize = this.content.getSize();
  261. var position = el.retrieve("position");
  262. var initialWidth = el.retrieve("initialWidth").toFloat();
  263. var dx = x.toFloat() - position.x.toFloat();
  264. var width = initialWidth+dx;
  265. if (width> bodySize.x/2) width = bodySize.x/2;
  266. if (width<40) width = 40;
  267. this.contentNode.setStyle("margin-left", width+1);
  268. this.viewListNode.setStyle("width", width);
  269. //this.tab.pages.each(function(page){
  270. (this.view || this.table).setViewWidth();
  271. //});
  272. }.bind(this)
  273. });
  274. },
  275. loadViewList: function(){
  276. this.actions.listView(this.application.id, function (json) {
  277. json.data.each(function(view){
  278. this.createListViewItem(view);
  279. }.bind(this));
  280. }.bind(this), null, false);
  281. },
  282. //列示所有视图列表
  283. createListViewItem: function(view, isNew){
  284. var _self = this;
  285. var listViewItem = new Element("div", {"styles": this.css.listViewItem}).inject(this.viewListAreaNode, (isNew) ? "top": "bottom");
  286. var listViewItemIcon = new Element("div", {"styles": this.css.listViewItemIcon}).inject(listViewItem);
  287. var listViewItemText = new Element("div", {"styles": this.css.listViewItemText, "text": (view.name) ? view.name+" ("+view.alias+")" : this.lp.newView}).inject(listViewItem);
  288. listViewItem.store("view", view);
  289. listViewItem.addEvents({
  290. "dblclick": function(e){_self.loadViewByData(this, e);},
  291. "mouseover": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem_over);},
  292. "mouseout": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem);}
  293. });
  294. },
  295. //打开视图
  296. loadViewByData: function(node, e){
  297. var view = node.retrieve("view");
  298. if (!view.isNewView){
  299. var openNew = true;
  300. //for (var i = 0; i<this.tab.pages.length; i++){
  301. // if (view.id==this.tab.pages[i].view.data.id){
  302. // this.tab.pages[i].showTabIm();
  303. // openNew = false;
  304. // break;
  305. // }
  306. //}
  307. if (openNew){
  308. //this.loadViewData(view.id, function(vdata){
  309. // var view = new MWF.xApplication.process.InquiryDesigner.View(this, vdata);
  310. // view.load();
  311. //}.bind(this));
  312. var _self = this;
  313. var options = {
  314. "appId": "query.InquiryDesigner"+view.id,
  315. "onQueryLoad": function(){
  316. this.actions = _self.actions;
  317. this.category = _self;
  318. this.options.id = view.id;
  319. this.application = _self.application;
  320. this.explorer = _self.explorer;
  321. }
  322. };
  323. this.desktop.openApplication(e, "query.InquiryDesigner", options);
  324. }
  325. }
  326. },
  327. //loadContentNode------------------------------
  328. loadContentNode: function(){
  329. this.contentToolbarNode = new Element("div", {
  330. "styles": this.css.contentToolbarNode
  331. }).inject(this.contentNode);
  332. if (!this.options.readMode) this.loadContentToolbar();
  333. this.editContentNode = new Element("div", {
  334. "styles": this.css.editContentNode
  335. }).inject(this.contentNode);
  336. this.loadEditContent(function(){
  337. // if (this.designDcoument) this.designDcoument.body.setStyles(this.css.designBody);
  338. if (this.designNode) this.designNode.setStyles(this.css.designNode);
  339. }.bind(this));
  340. },
  341. loadContentToolbar: function(callback){
  342. this.getFormToolbarHTML(function(toolbarNode){
  343. var spans = toolbarNode.getElements("span");
  344. spans.each(function(item, idx){
  345. var img = item.get("MWFButtonImage");
  346. if (img){
  347. item.set("MWFButtonImage", this.path+""+this.options.style+"/toolbar/"+img);
  348. }
  349. }.bind(this));
  350. $(toolbarNode).inject(this.contentToolbarNode);
  351. MWF.require("MWF.widget.Toolbar", function(){
  352. this.toolbar = new MWF.widget.Toolbar(toolbarNode, {"style": "ProcessCategory"}, this);
  353. this.toolbar.load();
  354. if (this.table) if (this.table.checkToolbars) this.table.checkToolbars();
  355. if (callback) callback();
  356. }.bind(this));
  357. }.bind(this));
  358. },
  359. getFormToolbarHTML: function(callback){
  360. var toolbarUrl = this.path+this.options.style+"/toolbars.html";
  361. var r = new Request.HTML({
  362. url: toolbarUrl,
  363. method: "get",
  364. onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
  365. var toolbarNode = responseTree[0];
  366. if (callback) callback(toolbarNode);
  367. }.bind(this),
  368. onFailure: function(xhr){
  369. this.notice("request processToolbars error: "+xhr.responseText, "error");
  370. }.bind(this)
  371. });
  372. r.send();
  373. },
  374. maxOrReturnEditor: function(){
  375. if (!this.isMax){
  376. this.designNode.inject(this.node);
  377. this.designNode.setStyles({
  378. "position": "absolute",
  379. "width": "100%",
  380. "height": "100%",
  381. "top": "0px",
  382. "margin": "0px",
  383. "left": "0px"
  384. });
  385. //this.tab.pages.each(function(page){
  386. this.view.setAreaNodeSize();
  387. //});
  388. this.isMax = true;
  389. }else{
  390. this.isMax = false;
  391. this.designNode.inject(this.editContentNode);
  392. this.designNode.setStyles(this.css.designNode);
  393. this.designNode.setStyles({
  394. "position": "static"
  395. });
  396. this.resizeNode();
  397. //this.tab.pages.each(function(page){
  398. this.view.setAreaNodeSize();
  399. //});
  400. }
  401. },
  402. loadEditContent: function(callback){
  403. this.designNode = new Element("div", {
  404. "styles": this.css.designNode
  405. }).inject(this.editContentNode);
  406. //MWF.require("MWF.widget.Tab", function(){
  407. // this.tab = new MWF.widget.Tab(this.designNode, {"style": "dictionary"});
  408. // this.tab.load();
  409. //}.bind(this), false);
  410. // MWF.require("MWF.widget.ScrollBar", function(){
  411. // new MWF.widget.ScrollBar(this.designNode, {"distance": 100});
  412. // }.bind(this));
  413. },
  414. //loadProperty------------------------
  415. loadProperty: function(){
  416. this.propertyTitleNode = new Element("div", {
  417. "styles": this.css.propertyTitleNode,
  418. "text": MWF.APPDIQD.LP.property
  419. }).inject(this.propertyNode);
  420. this.propertyResizeBar = new Element("div", {
  421. "styles": this.css.propertyResizeBar
  422. }).inject(this.propertyNode);
  423. this.loadPropertyResize();
  424. this.propertyContentNode = new Element("div", {
  425. "styles": this.css.propertyContentNode
  426. }).inject(this.propertyNode);
  427. this.propertyDomArea = new Element("div", {
  428. "styles": this.css.propertyDomArea
  429. }).inject(this.propertyContentNode);
  430. this.propertyDomPercent = 0.3;
  431. this.propertyContentResizeNode = new Element("div", {
  432. "styles": this.css.propertyContentResizeNode
  433. }).inject(this.propertyContentNode);
  434. this.propertyContentArea = new Element("div", {
  435. "styles": this.css.propertyContentArea
  436. }).inject(this.propertyContentNode);
  437. this.loadPropertyContentResize();
  438. //this.setPropertyContent();
  439. this.propertyNode.addEvent("keydown", function(e){e.stopPropagation();});
  440. },
  441. loadPropertyResize: function(){
  442. // var size = this.propertyNode.getSize();
  443. // var position = this.propertyResizeBar.getPosition();
  444. this.propertyResize = new Drag(this.propertyResizeBar,{
  445. "snap": 1,
  446. "onStart": function(el, e){
  447. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  448. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  449. el.store("position", {"x": x, "y": y});
  450. var size = this.propertyNode.getSize();
  451. el.store("initialWidth", size.x);
  452. }.bind(this),
  453. "onDrag": function(el, e){
  454. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  455. // var y = e.event.y;
  456. var bodySize = this.content.getSize();
  457. var position = el.retrieve("position");
  458. var initialWidth = el.retrieve("initialWidth").toFloat();
  459. var dx = position.x.toFloat()-x.toFloat();
  460. var width = initialWidth+dx;
  461. if (width> bodySize.x/2) width = bodySize.x/2;
  462. if (width<40) width = 40;
  463. this.contentNode.setStyle("margin-right", width+1);
  464. this.propertyNode.setStyle("width", width);
  465. //this.tab.pages.each(function(page){
  466. (this.view || this.table).setViewWidth();
  467. //});
  468. }.bind(this)
  469. });
  470. },
  471. loadPropertyContentResize: function(){
  472. this.propertyContentResize = new Drag(this.propertyContentResizeNode, {
  473. "snap": 1,
  474. "onStart": function(el, e){
  475. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  476. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  477. el.store("position", {"x": x, "y": y});
  478. var size = this.propertyDomArea.getSize();
  479. el.store("initialHeight", size.y);
  480. }.bind(this),
  481. "onDrag": function(el, e){
  482. var size = this.propertyContentNode.getSize();
  483. // var x = e.event.x;
  484. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  485. var position = el.retrieve("position");
  486. var dy = y.toFloat()-position.y.toFloat();
  487. var initialHeight = el.retrieve("initialHeight").toFloat();
  488. var height = initialHeight+dy;
  489. if (height<40) height = 40;
  490. if (height> size.y-40) height = size.y-40;
  491. this.propertyDomPercent = height/size.y;
  492. this.setPropertyContentResize();
  493. }.bind(this)
  494. });
  495. },
  496. setPropertyContentResize: function(){
  497. var size = this.propertyContentNode.getSize();
  498. var resizeNodeSize = this.propertyContentResizeNode.getSize();
  499. var height = size.y-resizeNodeSize.y;
  500. var domHeight = this.propertyDomPercent*height;
  501. var contentHeight = height-domHeight;
  502. this.propertyDomArea.setStyle("height", ""+domHeight+"px");
  503. this.propertyContentArea.setStyle("height", ""+contentHeight+"px");
  504. if (this.table) this.view = this.table;
  505. if (this.view){
  506. if (this.view.currentSelectedModule){
  507. if (this.view.currentSelectedModule.property){
  508. var tab = this.view.currentSelectedModule.property.propertyTab;
  509. if (tab){
  510. var tabTitleSize = tab.tabNodeContainer.getSize();
  511. tab.pages.each(function(page){
  512. var topMargin = page.contentNodeArea.getStyle("margin-top").toFloat();
  513. var bottomMargin = page.contentNodeArea.getStyle("margin-bottom").toFloat();
  514. var tabContentNodeAreaHeight = contentHeight - topMargin - bottomMargin - tabTitleSize.y.toFloat()-15;
  515. page.contentNodeArea.setStyle("height", tabContentNodeAreaHeight);
  516. }.bind(this));
  517. }
  518. }
  519. }
  520. }
  521. },
  522. //resizeNode------------------------------------------------
  523. resizeNode: function(){
  524. var nodeSize = this.node.getSize();
  525. this.contentNode.setStyle("height", ""+nodeSize.y+"px");
  526. this.propertyNode.setStyle("height", ""+nodeSize.y+"px");
  527. var contentToolbarMarginTop = this.contentToolbarNode.getStyle("margin-top").toFloat();
  528. var contentToolbarMarginBottom = this.contentToolbarNode.getStyle("margin-bottom").toFloat();
  529. var allContentToolberSize = this.contentToolbarNode.getComputedSize();
  530. var y = nodeSize.y - allContentToolberSize.totalHeight - contentToolbarMarginTop - contentToolbarMarginBottom;
  531. this.editContentNode.setStyle("height", ""+y+"px");
  532. if (this.designNode){
  533. var designMarginTop = this.designNode.getStyle("margin-top").toFloat();
  534. var designMarginBottom = this.designNode.getStyle("margin-bottom").toFloat();
  535. y = nodeSize.y - allContentToolberSize.totalHeight - contentToolbarMarginTop - contentToolbarMarginBottom - designMarginTop - designMarginBottom;
  536. this.designNode.setStyle("height", ""+y+"px");
  537. }
  538. titleSize = this.propertyTitleNode.getSize();
  539. titleMarginTop = this.propertyTitleNode.getStyle("margin-top").toFloat();
  540. titleMarginBottom = this.propertyTitleNode.getStyle("margin-bottom").toFloat();
  541. titlePaddingTop = this.propertyTitleNode.getStyle("padding-top").toFloat();
  542. titlePaddingBottom = this.propertyTitleNode.getStyle("padding-bottom").toFloat();
  543. y = titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom;
  544. y = nodeSize.y-y;
  545. this.propertyContentNode.setStyle("height", ""+y+"px");
  546. this.propertyResizeBar.setStyle("height", ""+y+"px");
  547. this.setPropertyContentResize();
  548. titleSize = this.viewListTitleNode.getSize();
  549. titleMarginTop = this.viewListTitleNode.getStyle("margin-top").toFloat();
  550. titleMarginBottom = this.viewListTitleNode.getStyle("margin-bottom").toFloat();
  551. titlePaddingTop = this.viewListTitleNode.getStyle("padding-top").toFloat();
  552. titlePaddingBottom = this.viewListTitleNode.getStyle("padding-bottom").toFloat();
  553. nodeMarginTop = this.viewListAreaSccrollNode.getStyle("margin-top").toFloat();
  554. nodeMarginBottom = this.viewListAreaSccrollNode.getStyle("margin-bottom").toFloat();
  555. y = titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom+nodeMarginTop+nodeMarginBottom;
  556. y = nodeSize.y-y;
  557. this.viewListAreaSccrollNode.setStyle("height", ""+y+"px");
  558. this.viewListResizeNode.setStyle("height", ""+y+"px");
  559. },
  560. //loadView------------------------------------------
  561. loadView: function(callback){
  562. this.getViewData(this.options.id, function(vdata){
  563. this.setTitle(this.options.appTitle + "-"+vdata.name);
  564. this.taskitem.setText(this.options.appTitle + "-"+vdata.name);
  565. this.options.appTitle = this.options.appTitle + "-"+vdata.name;
  566. //if (this.options.readMode){
  567. // this.view = new MWF.xApplication.process.DictionaryDesigner.DictionaryReader(this, ddata);
  568. //}else{
  569. this.view = new MWF.xApplication.query.InquiryDesigner.View(this, vdata);
  570. //}
  571. this.view.load();
  572. if (callback) callback();
  573. //if (this.status){
  574. // if (this.status.openViews){
  575. // this.status.openViews.each(function(id){
  576. // this.loadViewData(id, function(data){
  577. // var showTab = true;
  578. // if (this.status.currentId){
  579. // if (this.status.currentId!=data.id) showTab = false;
  580. // }
  581. // //if (this.options.readMode){
  582. // // var view = new MWF.xApplication.process.DictionaryDesigner.DictionaryReader(this, data, {"showTab": showTab});
  583. // //}else{
  584. // var view = new MWF.xApplication.process.DictionaryDesigner.View(this, data, {"showTab": showTab});
  585. // //}
  586. //
  587. // view.load();
  588. // }.bind(this), true);
  589. // }.bind(this));
  590. // }
  591. //}
  592. }.bind(this));
  593. },
  594. getViewData: function(id, callback){
  595. if (!this.options.id){
  596. this.loadNewViewData(callback);
  597. }else{
  598. this.loadViewData(id, callback);
  599. }
  600. },
  601. loadNewViewData: function(callback){
  602. var url = "../x_component_query_ViewDesigner/$View/view.json";
  603. MWF.getJSON(url, {
  604. "onSuccess": function(obj){
  605. this.actions.getUUID(function(id){
  606. obj.id=id;
  607. obj.isNewView = true;
  608. obj.application = this.application.id;
  609. this.createListViewItem(obj, true);
  610. if (callback) callback(obj);
  611. }.bind(this));
  612. }.bind(this),
  613. "onerror": function(text){
  614. this.notice(text, "error");
  615. }.bind(this),
  616. "onRequestFailure": function(xhr){
  617. this.notice(xhr.responseText, "error");
  618. }.bind(this)
  619. });
  620. },
  621. loadViewData: function(id, callback){
  622. this.actions.getView(id, function(json){
  623. if (json){
  624. var data = json.data;
  625. var dataJson = JSON.decode(data.data);
  626. data.data = dataJson;
  627. if (!this.application){
  628. this.actions.getApplication(data.application, function(json){
  629. this.application = {"name": json.data.name, "id": json.data.id};
  630. if (callback) callback(data);
  631. }.bind(this));
  632. }else{
  633. if (callback) callback(data);
  634. }
  635. }
  636. }.bind(this));
  637. },
  638. saveView: function(){
  639. this.view.save(function(){
  640. var name = this.view.data.name;
  641. this.setTitle(MWF.APPDIQD.LP.title + "-"+name);
  642. this.options.desktopReload = true;
  643. this.options.id = this.view.data.id;
  644. }.bind(this));
  645. },
  646. preview : function(){
  647. this.view.preview();
  648. },
  649. saveViewAs: function(){
  650. this.view.saveAs();
  651. },
  652. dictionaryExplode: function(){
  653. this.view.explode();
  654. },
  655. dictionaryImplode: function(){
  656. this.view.implode();
  657. },
  658. //recordStatus: function(){
  659. // return {"id": this.options.id};
  660. //},
  661. recordStatus: function(){
  662. //if (this.tab){
  663. var openViews = [];
  664. openViews.push(this.view.data.id);
  665. var currentId = this.view.data.id;
  666. return {
  667. "id": this.options.id,
  668. "application": this.application,
  669. "openViews": openViews,
  670. "currentId": currentId
  671. };
  672. //}
  673. //return {"id": this.options.id, "application": this.application};
  674. }
  675. });
  676. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  677. MWF.xApplication.query.InquiryDesigner.View.NewNameForm = new Class({
  678. Extends: MPopupForm,
  679. Implements: [Options, Events],
  680. options: {
  681. "style": "design",
  682. "width": 700,
  683. //"height": 300,
  684. "height": "260",
  685. "hasTop": true,
  686. "hasIcon": false,
  687. "draggable": true,
  688. "title" : MWF.xApplication.query.InquiryDesigner.LP.newView
  689. },
  690. _createTableContent: function () {
  691. var html = "<table width='80%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin: 20px auto 0px auto; '>" +
  692. "<tr><td styles='formTableTitle' lable='selectQuery' width='25%'></td>" +
  693. " <td styles='formTableValue' item='selectQuery' colspan='3' width='75%'></td></tr>" +
  694. "<tr><td styles='formTableTitle' lable='name'></td>" +
  695. " <td styles='formTableValue' item='name' colspan='3'></td></tr>" +
  696. "</table>";
  697. this.formTableArea.set("html", html);
  698. MWF.xDesktop.requireApp("Template", "MForm", function () {
  699. this.form = new MForm(this.formTableArea, this.data || {}, {
  700. isEdited: true,
  701. style: "cms",
  702. hasColon: true,
  703. itemTemplate: {
  704. selectQuery : { text: MWF.xApplication.query.InquiryDesigner.LP.application , type : "org", orgType : "Query", defaultValue : this.data.queryName, orgWidgetOptions : {
  705. "canRemove" : false
  706. }},
  707. name: {text: MWF.xApplication.query.InquiryDesigner.LP.name, notEmpty: true}
  708. }
  709. }, this.app);
  710. this.form.load();
  711. }.bind(this),null, true)
  712. },
  713. ok: function(){
  714. var data = this.form.getResult(true,null,true,false,true);
  715. if( data ){
  716. var selectQuery = this.form.getItem("selectQuery").orgObject;
  717. if( selectQuery && selectQuery.length > 0 ){
  718. var queryData = selectQuery[0].data;
  719. data.query = queryData.id;
  720. data.queryName = queryData.name;
  721. }else{
  722. //data.query 和 data.queryName 还是传进来的值
  723. }
  724. this.fireEvent("save", [data , function(){
  725. this.close();
  726. }.bind(this)])
  727. }
  728. }
  729. });