123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- MWF.xDesktop.requireApp("query.ViewDesigner", "", null, false);
- MWF.APPDTBD = MWF.xApplication.query.TableDesigner;
- MWF.APPDTBD.options = {
- "multitask": true,
- "executable": false
- };
- MWF.xDesktop.requireApp("query.TableDesigner", "Table", null, false);
- MWF.xApplication.query.TableDesigner.Main = new Class({
- Extends: MWF.xApplication.query.ViewDesigner.Main,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "name": "query.TableDesigner",
- "icon": "icon.png",
- "title": MWF.APPDTBD.LP.title,
- "appTitle": MWF.APPDTBD.LP.title,
- "id": "",
- "tooltip": {
- "unCategory": MWF.APPDTBD.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.APPDTBD.LP.newTable;
- }
- if (!this.actions) this.actions = MWF.Actions.get("x_query_assemble_designer");
- this.lp = MWF.xApplication.query.TableDesigner.LP;
- this.addEvent("queryClose", function(e){
- if (this.explorer){
- this.explorer.reload();
- }
- }.bind(this));
- },
- loadViewListNodes: function(){
- this.viewListTitleNode = new Element("div", {
- "styles": this.css.viewListTitleNode,
- "text": MWF.APPDTBD.LP.table
- }).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":2
- });
- },
- loadViewList: function(){
- debugger;
- if( this.itemArray && this.itemArray.length ){
- this.itemArray.each(function(i){
- if(!i.data.isNewTable)i.node.destroy();
- });
- }
- this.itemArray = [];
- this.actions.listTable(this.application.id, function (json) {
- this.checkSort(json.data);
- json.data.each(function(table){
- this.createListViewItem(table);
- }.bind(this));
- }.bind(this), null, false);
- },
- //列示所有数据表列表
- createListViewItem: function(table, isNew){
- var _self = this;
- var listTableItem = new Element("div", {"styles": this.css.listViewItem}).inject(this.viewListAreaNode, (isNew) ? "top": "bottom");
- var listTableItemIcon = new Element("div", {"styles": this.css.listViewItemIcon}).inject(listTableItem);
- var listTableItemText = new Element("div", {"styles": this.css.listViewItemText, "text": (table.name) ? table.name+" ("+table.alias+")" : this.lp.newTable}).inject(listTableItem);
- listTableItem.store("table", table);
- listTableItem.addEvents({
- "click": function(e){_self.loadTableByData(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( table.id === this.options.id ){
- listTableItem.setStyles(this.css.listViewItem_current);
- this.currentListViewItem = listTableItem;
- }
- var itemObj = {
- node: listTableItem,
- data: table
- };
- this.itemArray.push(itemObj);
- this.checkShow(itemObj);
- },
- //打开数据表
- loadTableByData: function(node, e){
- var table = node.retrieve("table");
- if (!table.isNewTable){
- var openNew = true;
- if (openNew){
- var _self = this;
- var options = {
- "appId": "query.TableDesigner"+table.id,
- "id": table.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 = table.id;
- this.application = _self.application;
- this.explorer = _self.explorer;
- }
- };
- this.desktop.openApplication(e, "query.TableDesigner", options);
- }
- }
- },
- //loadView------------------------------------------
- loadView: function(){
- 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.table = new MWF.xApplication.query.TableDesigner.Table(this, vdata);
- this.table.load();
- }.bind(this));
- },
- loadNewViewData: function(callback){
- var url = "../x_component_query_TableDesigner/$Table/table.json";
- MWF.getJSON(url, {
- "onSuccess": function(obj){
- this.actions.getUUID(function(id){
- obj.id=id;
- obj.isNewTable = 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.getTable(id, function(json){
- if (json){
- var data = json.data;
- data.draftData = JSON.decode(data.draftData);
- if (!this.application){
- this.actions.getApplication(data.query, 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.APPDTBD.LP.title + "-"+name);
- this.options.desktopReload = true;
- this.options.id = this.view.data.id;
- }.bind(this));
- },
- statusBuild: function(){
- this.view.statusBuild();
- },
- statusDraft: function(){
- this.view.statusDraft();
- },
- buildAllView: function(){
- this.view.buildAllView();
- },
- bulidCurrentApp: function(){
- this.view.bulidCurrentApp();
- },
- tableExplode: function(){
- this.view.tableExplode();
- },
- tableImplode: function(){
- this.view.tableImplode();
- },
- tableExcelExplode: function(){
- this.view.tableExcelExplode();
- },
- tableExcelImplode: function(){
- this.view.tableExcelImplode();
- },
- tableClear: function(){
- this.view.tableClear();
- },
- tableHelp: function(){
- var content = new Element("div", {"styles": {"margin": "20px"}});
- content.set("html", this.lp.tableHelp);
- o2.DL.open({
- "title": "table help",
- "content": content,
- "width": 500,
- "height": 320,
- "buttonList": [
- {
- "text": "ok",
- "action": function(){this.close();}
- }
- ]
- });
- }
- // dictionaryExplode: function(){
- // this.view.explode();
- // },
- // dictionaryImplode: function(){
- // this.view.implode();
- // }
- //recordStatus: function(){
- // return {"id": this.options.id};
- //},
- });
|