diff --git a/o2web/source/x_component_Selector/FormStyle.js b/o2web/source/x_component_Selector/FormStyle.js index f6a603e1530e9411308b090ba1f7b3d631be9182..3e09b5cd06174b7ffadd193016d1134be2e96c57 100644 --- a/o2web/source/x_component_Selector/FormStyle.js +++ b/o2web/source/x_component_Selector/FormStyle.js @@ -16,28 +16,26 @@ MWF.xApplication.Selector.FormStyle = new Class({ var stylesUrl = "../x_component_process_FormDesigner/Module/Form/skin/config.json"; MWF.getJSON(stylesUrl,{ "onSuccess": function(json){ - var category = this._newItemCategory({ - name : "系统样式", - id : "stystem" - }, this, this.itemAreaNode); + debugger; + var subItemList = []; Object.each(json, function(s, key){ if( s.mode.contains( this.options.mode ) ){ - var d = { + subItemList.push({ name : s.name, id : key - }; - var item = this._newItem(d, this, category.children); - this.items.push(item); + }); + } }.bind(this)); - var category = this._newItemCategory({ - name : "脚本", - id : "script" + name : "系统样式", + id : "stystem", + subItemList : subItemList }, this, this.itemAreaNode); var json = {}; var appJs = {}; + var array = []; o2.Actions.load("x_processplatform_assemble_designer").ScriptAction.listNext("(0)", 500, function (scriptJson) { o2.Actions.load("x_processplatform_assemble_designer").ApplicationAction.list(function (appJson) { appJson.data.each( function (app) { @@ -54,12 +52,16 @@ MWF.xApplication.Selector.FormStyle = new Class({ json[script.application].scriptList.push( script ) }.bind(this)); for( var application in json ){ - var category = this._newItemCategory(json[application], this, category.children); - json[application].scriptList.each(function(d){ - var item = this._newItem(d, this, category.children); - this.items.push(item); - }.bind(this)); + if( json[application].scriptList && json[application].scriptList.length ){ + array.push( json[application] ); + } } + + var category = this._newItemCategory({ + name : "自定义样式(脚本)", + id : "script", + applicationList : array + }, this, this.itemAreaNode); }.bind(this)) }.bind(this)); }.bind(this) @@ -87,7 +89,7 @@ MWF.xApplication.Selector.FormStyle = new Class({ return true; }, _getChildrenItemIds: function(data){ - return data.scriptList || []; + return data.scriptList || data.subItemList || data.applicationList; }, _newItemCategory: function(data, selector, item, level){ return new MWF.xApplication.Selector.FormStyle.ItemCategory(data, selector, item, level) @@ -143,8 +145,6 @@ MWF.xApplication.Selector.FormStyle.Item = new Class({ var selectedItem = this.selector.selectedItems.filter(function(item, index){ if( item.data.id && this.data.id){ return item.data.id === this.data.id; - }else{ - return item.data.name === this.data.name; } //return (item.data.id === this.data.id) || (item.data.name === this.data.name); }.bind(this)); @@ -171,8 +171,6 @@ MWF.xApplication.Selector.FormStyle.ItemSelected = new Class({ //return (item.data.id === this.data.id) || (item.data.name === this.data.name); if( item.data.id && this.data.id){ return item.data.id === this.data.id; - }else{ - return item.data.name === this.data.name; } }.bind(this)); this.items = items; @@ -188,9 +186,69 @@ MWF.xApplication.Selector.FormStyle.ItemSelected = new Class({ MWF.xApplication.Selector.FormStyle.ItemCategory = new Class({ Extends: MWF.xApplication.Selector.Person.ItemCategory, + clickItem: function (callback) { + if (this._hasChild() ) { + var firstLoaded = !this.loaded; + this.loadSub(function () { + if (firstLoaded && this._hasChild() ) { + if (!this.selector.isFlatCategory) { + this.children.setStyles({"display": "block", "height": "auto"}); + this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand); + this.isExpand = true; + } + // this.checkSelectAll(); + } else { + var display = this.children.getStyle("display"); + if (display === "none") { + // this.selector.fireEvent("expand", [this] ); + this.children.setStyles({"display": "block", "height": "auto"}); + this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand); + this.isExpand = true; + } else { + // this.selector.fireEvent("collapse", [this] ); + this.children.setStyles({"display": "none", "height": "0px"}); + this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse); + this.isExpand = false; + } + } + if (callback) callback(); + }.bind(this)); + } + }, + loadSub: function (callback) { + if (!this.loaded) { + if( this.data.subItemList ){ + this.data.subItemList.each(function (subItem, index) { + var item = this.selector._newItem(subItem, this.selector, this.children, this.level + 1, this); + this.selector.items.push(item); + if(this.subItems)this.subItems.push( item ); + }.bind(this)); + } + if( this.data.scriptList ){ + this.data.scriptList.each(function (subItem, index) { + var item = this.selector._newItem(subItem, this.selector, this.children, this.level + 1, this); + this.selector.items.push(item); + if(this.subItems)this.subItems.push( item ); + }.bind(this)); + } + if ( this.data.applicationList ) { + this.data.applicationList.each(function (subCategory, index) { + var category = this.selector._newItemCategory(subCategory, this.selector, this.children, this.level + 1, this); + this.subCategorys.push( category ); + }.bind(this)); + } + this.loaded = true; + if (callback) callback(); + } else { + if (callback) callback(); + } + }, _getShowName: function(){ return this.data.name; }, + _getTtiteText: function () { + return this.data.name; + }, createNode: function(){ this.node = new Element("div", { "styles": this.selector.css.selectorItemCategory_department @@ -200,7 +258,14 @@ MWF.xApplication.Selector.FormStyle.ItemCategory = new Class({ this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/applicationicon.png)"); }, _hasChild: function(){ - return (this.data.scriptList && this.data.scriptList.length); + return ( this.data.scriptList && this.data.scriptList.length ) || + ( this.data.subItemList && this.data.subItemList.length) || + ( this.data.applicationList && this.data.applicationList.length); + }, + afterLoad: function(){ + if ( this._hasChild() ){ + this.clickItem(); + } }, check: function(){} }); diff --git a/o2web/source/x_component_process_FormDesigner/Module/Form.js b/o2web/source/x_component_process_FormDesigner/Module/Form.js index 4d33cd588310121ccbd845d5ce17c55b7e3ebb52..bd95c60f91abf2af9f6ae5ea4ba5cdff69bf268f 100644 --- a/o2web/source/x_component_process_FormDesigner/Module/Form.js +++ b/o2web/source/x_component_process_FormDesigner/Module/Form.js @@ -214,16 +214,19 @@ MWF.xApplication.process.FormDesigner.Module.Form = MWF.FCForm = new Class({ // "application": script.application // } this.designer.actions.getScriptByName( scriptObject.name, scriptObject.application, function( json ) { - debugger; try{ var f = eval("(function(){\n return "+json.data.text+"\n})"); var j = f(); - if(callback)callback(j); + if( typeOf(j) !== "object" ){ + this.designer.notice( MWF.APPFD.LP.notValidJson, "error" ); + }else{ + if(callback)callback(j); + } }catch (e) { this.designer.notice( e.message, "error" ) } }.bind(this), function( responseJSON ){ - this.designer.notice( JSON.parse(responseJSON.responseText).message, "error" ) + this.designer.notice( JSON.parse(responseJSON.responseText).message, "error" ); if(callback)callback({}); }.bind(this)) }, diff --git a/o2web/source/x_component_process_FormDesigner/Module/Form/form.html b/o2web/source/x_component_process_FormDesigner/Module/Form/form.html index f91138a657b401c969f369bfec65e816df1c8458..70c51c258973f3c820d5dd4e07fc658dd06c0fdb 100644 --- a/o2web/source/x_component_process_FormDesigner/Module/Form/form.html +++ b/o2web/source/x_component_process_FormDesigner/Module/Form/form.html @@ -42,9 +42,15 @@ -