MWF.xDesktop.requireApp("query.ViewDesigner", "", null, false); MWF.APPDSTD = MWF.xApplication.query.StatDesigner; MWF.APPDSTD.options = { "multitask": true, "executable": false }; MWF.xDesktop.requireApp("query.StatDesigner", "Stat", null, false); MWF.xApplication.query.StatDesigner.Main = new Class({ Extends: MWF.xApplication.query.ViewDesigner.Main, Implements: [Options, Events], options: { "style": "default", "name": "query.StatDesigner", "icon": "icon.png", "title": MWF.APPDSTD.LP.title, "appTitle": MWF.APPDSTD.LP.title, "id": "", "tooltip": { "unCategory": MWF.APPDSTD.LP.unCategory }, "actions": null, "category": null, "processData": null }, onQueryLoad: function(){ this.shortcut = true; if (this.status){ this.options.application = this.status.applicationId; this.application = this.status.application; this.options.id = this.status.id; } if( !this.application && this.options.application ){ this.application = this.options.application; } if (!this.options.id){ this.options.desktopReload = false; this.options.title = this.options.title + "-"+MWF.APPDSTD.LP.newStat; } if (!this.actions) this.actions = MWF.Actions.get("x_query_assemble_designer"); this.lp = MWF.xApplication.query.StatDesigner.LP; this.addEvent("queryClose", function(e){ if (this.explorer){ this.explorer.reload(); } }.bind(this)); this.addEvent("postLoadWindowMax", function(e){ this.loadWindowOk = true; if (this.loadApplicationOk && this.loadWindowOk) this.view.setViewWidth(); }.bind(this)); this.addEvent("postLoadApplication", function(e){ this.loadApplicationOk = true; if (this.loadApplicationOk && this.loadWindowOk) this.view.setViewWidth(); }.bind(this)); }, loadViewListNodes: function(){ this.viewListTitleNode = new Element("div", { "styles": this.css.viewListTitleNode, "text": MWF.APPDSTD.LP.stat }).inject(this.viewListNode); this.viewListResizeNode = new Element("div", {"styles": this.css.viewListResizeNode}).inject(this.viewListNode); this.createListTitleNodes(); this.viewListAreaSccrollNode = new Element("div", {"styles": this.css.viewListAreaSccrollNode}).inject(this.viewListNode); this.viewListAreaNode = new Element("div", {"styles": this.css.viewListAreaNode}).inject(this.viewListAreaSccrollNode); this.loadViewListResize(); this.loadViewList(); }, openApp: function (){ layout.openApplication(null, 'query.QueryManager', { application: this.application, appId: 'query.QueryManager'+this.application.id }, { "navi":1 }); }, loadViewList: function(){ if( this.itemArray && this.itemArray.length ){ this.itemArray.each(function(i){ if(!i.data.isNewView)i.node.destroy(); }); } this.itemArray = []; this.actions.listStat(this.application.id, function (json) { this.checkSort(json.data); json.data.each(function(view){ this.createListViewItem(view); }.bind(this)); }.bind(this), null, false); }, //列示所有视图列表 createListViewItem: function(view, isNew){ var _self = this; var listViewItem = new Element("div", {"styles": this.css.listViewItem}).inject(this.viewListAreaNode, (isNew) ? "top": "bottom"); var listViewItemIcon = new Element("div", {"styles": this.css.listViewItemIcon}).inject(listViewItem); var listViewItemText = new Element("div", {"styles": this.css.listViewItemText, "text": (view.name) ? view.name+" ("+view.alias+")" : this.lp.newStat}).inject(listViewItem); listViewItem.store("view", view); listViewItem.addEvents({ "click": function(e){_self.loadViewByData(this, e);}, "mouseover": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem_over);}, "mouseout": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem);} }); if( view.id === this.options.id ){ listViewItem.setStyles(this.css.listViewItem_current); this.currentListViewItem = listViewItem; } var itemObj = { node: listViewItem, data: view }; this.itemArray.push(itemObj); this.checkShow(itemObj); }, //打开视图 loadViewByData: function(node, e){ var view = node.retrieve("view"); if (!view.isNewView){ var openNew = true; if (openNew){ var _self = this; var options = { "appId": "query.StatDesigner"+view.id, "id": view.id, // "application": _self.application.id, "application": { "name": _self.application.name, "id": _self.application.id, }, "onQueryLoad": function(){ this.actions = _self.actions; this.category = _self; this.options.id = view.id; this.application = _self.application; this.explorer = _self.explorer; } }; this.desktop.openApplication(e, "query.StatDesigner", options); } } }, //loadView------------------------------------------ loadView: function(callback){ this.getViewData(this.options.id, function(vdata){ this.setTitle(this.options.appTitle + "-"+vdata.name); if(this.taskitem)this.taskitem.setText(this.options.appTitle + "-"+vdata.name); this.options.appTitle = this.options.appTitle + "-"+vdata.name; this.view = new MWF.xApplication.query.StatDesigner.Stat(this, vdata); this.view.load(); if (callback) callback(); }.bind(this)); }, loadNewViewData: function(callback){ var url = "../x_component_query_StatDesigner/$Stat/stat.json"; MWF.getJSON(url, { "onSuccess": function(obj){ this.actions.getUUID(function(id){ obj.id=id; obj.isNewView = true; obj.application = this.application.id; this.createListViewItem(obj, true); if (callback) callback(obj); }.bind(this)); }.bind(this), "onerror": function(text){ this.notice(text, "error"); }.bind(this), "onRequestFailure": function(xhr){ this.notice(xhr.responseText, "error"); }.bind(this) }); }, loadViewData: function(id, callback){ this.actions.getStat(id, function(json){ if (json){ var data = json.data; data.data = JSON.decode(data.data); if (!this.application){ this.actions.getApplication(data.application, function(json){ this.application = {"name": json.data.name, "id": json.data.id}; if (callback) callback(data); }.bind(this)); }else{ if (callback) callback(data); } } }.bind(this)); }, saveView: function(){ this.view.save(function(){ var name = this.view.data.name; this.setTitle(MWF.APPDSTD.LP.title + "-"+name); this.options.desktopReload = true; this.options.id = this.view.data.id; }.bind(this)); }, saveViewAs: function(){ this.view.saveAs(); }, dictionaryExplode: function(){ this.view.explode(); }, dictionaryImplode: function(){ this.view.implode(); } //recordStatus: function(){ // return {"id": this.options.id}; //}, }); MWF.xDesktop.requireApp("Template", "MPopupForm", null, false); MWF.xApplication.query.StatDesigner.Stat.NewNameForm = new Class({ Extends: MPopupForm, Implements: [Options, Events], options: { "style": "design", "width": 700, //"height": 300, "height": "300", "hasTop": true, "hasIcon": false, "draggable": true, "title" : MWF.xApplication.query.StatDesigner.LP.copyStat }, _createTableContent: function () { var html = "
" + " | |||
" + " | |||
" + " |