diff --git a/o2web/source/x_component_cms_DictionaryDesigner/Dictionary.js b/o2web/source/x_component_cms_DictionaryDesigner/Dictionary.js index afffcf728bc93bd6e32a60375a505501b3c6c899..352a81a5379ae2a6f260328fdb776f68257cca36 100644 --- a/o2web/source/x_component_cms_DictionaryDesigner/Dictionary.js +++ b/o2web/source/x_component_cms_DictionaryDesigner/Dictionary.js @@ -51,6 +51,87 @@ MWF.xApplication.cms.DictionaryDesigner.Dictionary = new Class({ if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID); }.bind(this)); }, + loadTab: function(callback){ + var _self = this; + MWF.require("MWF.widget.Tab", null, false); + this.designTabNode = new Element("div").inject(this.areaNode); + this.designTab = new MWF.widget.Tab(this.designTabNode, {"style": "design"}); + this.designTab.load(); + this.designTabPageAreaNode = Element("div"); + + this.designNode = new Element("div", {"styles": {"overflow": "auto","background-color":"#fff"}}).inject(this.designTabPageAreaNode); + + this.designTabScriptAreaNode = Element("div", {"styles": { "height": "100%" }}); + this.scriptNode = new Element("div.scriptNode", {"styles": {"background-color":"#fff"}}).inject(this.designTabScriptAreaNode); + + this.designPage = this.designTab.addTab(this.designTabPageAreaNode, this.designer.lp.design); + this.scriptPage = this.designTab.addTab(this.designTabScriptAreaNode, "JSON"); + this.designPage.showTabIm = function(callback){ + if( _self.scriptEditor && _self.isChanged){ + try{ + var value = _self.scriptEditor.getValue(); + var v = JSON.parse(value); + + if (!this.isShow){ + this.tab.pages.each(function(page){ + if (page.isShow) page.hideIm(); + }); + this.showIm(callback); + } + + }catch (e) { + _self.designer.notice( _self.designer.lp.notice.jsonParseError, "error", _self.node, {"x": "left", "y": "bottom"}); + } + }else{ + if (!this.isShow){ + this.tab.pages.each(function(page){ + if (page.isShow) page.hideIm(); + }); + this.showIm(callback); + } + } + } + + // this.setScriptPageEvent(); + this.designPage.showTabIm(); + this.scriptPage.addEvent("postShow", function(){ + if (this.scriptEditor){ + var value = JSON.stringify(this.data.data, null, "\t"); + if (value) this.scriptEditor.setValue(value); + this.scriptEditor.focus(); + }else{ + this.loadScriptEditor(); + } + this.fireEvent("resize"); + }.bind(this)); + this.designPage.addEvent("postShow", function(){ + if( this.scriptEditor && this.isChanged){ + try{ + var value = this.scriptEditor.getValue(); + this.data.data = JSON.parse(value); + this.reload(); + this.isChanged = false; + }catch (e) { + this.designer.notice( this.designer.lp.notice.jsonParseError, "error", this.node, {"x": "left", "y": "bottom"}); + } + } + this.fireEvent("resize"); + }.bind(this)); + }, + loadScriptEditor:function(){ + var value = JSON.stringify(this.data.data, null, "\t"); + this.scriptEditor = new MWF.widget.JavascriptEditor(this.scriptNode, {"option": {"value": value, "mode" : "json" }}); + this.scriptEditor.load(function(){ + + if (value) this.scriptEditor.setValue(value); + + this.scriptEditor.addEditorEvent("change", function(e){ + if (!this.isChanged){ + this.isChanged = true; + } + }.bind(this)); + }.bind(this)); + }, autoSave: function(){ this.autoSaveTimerID = window.setInterval(function(){ if (!this.autoSaveCheckNode) this.autoSaveCheckNode = this.designer.contentToolbarNode.getElement("#MWFDictionaryAutoSaveCheck"); @@ -63,9 +144,9 @@ MWF.xApplication.cms.DictionaryDesigner.Dictionary = new Class({ }, createTitle: function(){ - this.itemsNode = new Element("div", {"styles": this.css.itemsNode}).inject(this.areaNode); - this.typesNode = new Element("div", {"styles": this.css.typesNode}).inject(this.areaNode); - this.valuesNode = new Element("div", {"styles": this.css.valuesNode}).inject(this.areaNode); + this.itemsNode = new Element("div", {"styles": this.css.itemsNode}).inject(this.designNode); + this.typesNode = new Element("div", {"styles": this.css.typesNode}).inject(this.designNode); + this.valuesNode = new Element("div", {"styles": this.css.valuesNode}).inject(this.designNode); this.itemTitleNode = new Element("div", {"styles": this.css.itemTitleNode}).inject(this.itemsNode); this.typeTitleNode = new Element("div", {"styles": this.css.typeTitleNode}).inject(this.typesNode); @@ -84,6 +165,7 @@ MWF.xApplication.cms.DictionaryDesigner.Dictionary = new Class({ }, load : function(){ + this.loadTab(); this.setAreaNodeSize(); this.designer.addEvent("resize", this.setAreaNodeSize.bind(this)); @@ -140,9 +222,17 @@ MWF.xApplication.cms.DictionaryDesigner.Dictionary = new Class({ if (this.searchNode) searchY = this.searchNode.getSize().y; var y = size.y - tabSize.y - searchY; this.areaNode.setStyle("height", ""+y+"px"); - if (this.editor) if (this.editor.editor) this.editor.editor.resize(); + this.designNode.setStyle("height", ""+(y-18)+"px"); + this.scriptNode.setStyle("height", ""+(y-18)+"px"); + if (this.scriptEditor) if (this.scriptEditor.editor) this.scriptEditor.editor.resize(); }, + reload : function(){ + this.items = []; + this.designNode.empty(); + this.createTitle(); + this.createRootItem(); + }, createRootItem: function() { this.items.push(new MWF.xApplication.cms.DictionaryDesigner.Dictionary.item("ROOT", this.data.data, null, 0, this, true)); }, @@ -150,6 +240,17 @@ MWF.xApplication.cms.DictionaryDesigner.Dictionary = new Class({ saveSilence: function(){ if (!this.isSave){ + if( this.scriptPage.isShow ){ + if( this.scriptEditor ){ + try{ + var value = this.scriptEditor.getValue(); + this.data.data = JSON.parse(value); + }catch (e) { + return false; + } + } + } + var name = this.designer.propertyNameNode.get("value"); var alias = this.designer.propertyAliasNode.get("value"); var description = this.designer.propertyDescriptionNode.get("value"); @@ -179,6 +280,19 @@ MWF.xApplication.cms.DictionaryDesigner.Dictionary = new Class({ save: function(callback){ if (!this.isSave){ if (this.designer.tab.showPage==this.page){ + + if( this.scriptPage.isShow ){ + if( this.scriptEditor ){ + try{ + var value = this.scriptEditor.getValue(); + this.data.data = JSON.parse(value); + }catch (e) { + this.designer.notice( this.designer.lp.notice.jsonParseError, "error", this.node, {"x": "left", "y": "bottom"}); + return false; + } + } + } + var name = this.designer.propertyNameNode.get("value"); var alias = this.designer.propertyAliasNode.get("value"); var description = this.designer.propertyDescriptionNode.get("value"); @@ -232,7 +346,7 @@ MWF.xApplication.cms.DictionaryDesigner.Dictionary = new Class({ this.setAreaNodeSize(); }, createSearchNode: function(){ - this.searchNode = new Element("div", {"styles": this.css.searchNode}).inject(this.areaNode, "before"); + this.searchNode = new Element("div", {"styles": this.css.searchNode}).inject(this.designNode, "before"); this.searchInputNode = new Element("div", {"styles": this.css.searchInputNode}).inject(this.searchNode); this.searchInput = new Element("input", {"styles": this.css.searchInput}).inject(this.searchInputNode); @@ -287,7 +401,7 @@ MWF.xApplication.cms.DictionaryDesigner.Dictionary = new Class({ if (child.key.indexOf(key)!=-1){ child.selected(); this.currentSearchItem = child; - new Fx.Scroll(this.areaNode).toElement(child.itemNode); + new Fx.Scroll(this.designNode).toElement(child.itemNode); return true; }else{ if (child.type=="object"){ diff --git a/o2web/source/x_component_cms_DictionaryDesigner/lp/zh-cn.js b/o2web/source/x_component_cms_DictionaryDesigner/lp/zh-cn.js index 3b8b23a2bf959ba1b158f9378d4d84f2a9a35b58..b410f44d056bdbe0cd6a3ab5eaf1dbfc727a3c65 100644 --- a/o2web/source/x_component_cms_DictionaryDesigner/lp/zh-cn.js +++ b/o2web/source/x_component_cms_DictionaryDesigner/lp/zh-cn.js @@ -13,6 +13,11 @@ MWF.xApplication.cms.DictionaryDesigner.LP = { "name": "名称", "alias": "别名", "description": "描述", + "projectionType": "映射类型", + "projectionProcess": "对应流程", + + "design": "设计", + "script": "脚本", "notice": { "save_success": "数据字典保存成功!", @@ -30,7 +35,8 @@ MWF.xApplication.cms.DictionaryDesigner.LP = { "numberKey": "项目名称不能为数字,请重新输入", "inputName": "请输入数据字典名称", - "noModifyName": "不能修改名称或者别名" + "noModifyName": "不能修改名称或者别名", + "jsonParseError" : "json格式错误,请先修正" }, "isSave": "正在保存,请稍候...", "selectOrganizationByDblclick" : "双击从选择组织"