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 @@ - - + + + + + + 表单样式: + +
diff --git a/o2web/source/x_component_process_FormDesigner/Property.js b/o2web/source/x_component_process_FormDesigner/Property.js index 2634e2430a47676544a88615bad371742ec7c2f0..bcbc7e8633c9badbbeeea5f595d93424bf5575cd 100644 --- a/o2web/source/x_component_process_FormDesigner/Property.js +++ b/o2web/source/x_component_process_FormDesigner/Property.js @@ -1325,6 +1325,7 @@ debugger; var _self = this; formStyleNodes.each(function(node){ + debugger; var data = this.data[node.get("name")]; if( typeOf( data ) === "string" ){ for( var key in this.module.form.stylesList ){ @@ -1342,15 +1343,54 @@ debugger; "type": "FormStyle", "count": 1, "names": [data], - "onChange": function(ids){ + "selectorOptions" : { + "mode" : ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc" + }, + "validFun" : function (ids) { + var flag = true; if( ids.length === 0 ){ - this.designer.notice(MWF.APPFD.LP.mustSelectFormStyle, "error", this.module.form.designer.propertyContentArea, { - x: "right", - y: "bottom" - }); + this.designer.notice(MWF.APPFD.LP.mustSelectFormStyle, "error"); + flag = false; + }else if( ids[0].data.type === "script" ){ + this.designer.actions.getScriptByName( ids[0].data.name, ids[0].data.application, function( json ) { + debugger; + try{ + var f = eval("(function(){\n return "+json.data.text+"\n})"); + var j = f(); + if( typeOf(j) !== "object" ){ + this.designer.notice( MWF.APPFD.LP.notValidJson, "error" ); + flag = false; + } + }catch (e) { + this.designer.notice( MWF.APPFD.LP.notValidJson +":"+ e.message, "error" ); + flag = false; + } + }.bind(this), function () { + flag = false; + }, false); + } + return flag; + }.bind(this), + "onChange": function(ids){ + var d = ids[0].data; + var data; + if( d.type === "script" ){ + data = { + "type" : "script", + "name": d.name, + "alias": d.alias, + "id": d.id, + "appName" : d.appName || d.applicationName, + "appId": d.appId, + "application": d.application + }; }else{ - this.saveFormStyleItem(node, ids); + data = d.id; } + var name = node.get("name"); + var oldValue = this.data[name]; + this.data[name] = data; + this.changeData(name, node, oldValue); }.bind(this) }); @@ -1459,34 +1499,6 @@ debugger; // this.data[node.get("name")] = null; } }, - saveFormStyleItem: function(node, ids){ - debugger; - if (ids[0]){ - var d = ids[0].data; - if( d.type === "script" ){ - var data = d; - }else{ - var data = { - "type" : "script", - "name": d.name, - "alias": d.alias, - "id": d.id, - "appName" : d.appName || d.applicationName, - "appId": d.appId, - "application": d.application - }; - } - - var name = node.get("name"); - var oldValue = this.data[name]; - this.data[name] = data; - - // this.changeJsonDate(name, data ); - this.changeData(name, node, oldValue); - }else{ - // this.data[node.get("name")] = null; - } - }, removeDutyItem: function(node, item){ if (item.data.id){ var values = JSON.decode(this.data[node.get("name")] || []); diff --git a/o2web/source/x_component_process_FormDesigner/lp/zh-cn.js b/o2web/source/x_component_process_FormDesigner/lp/zh-cn.js index 264f9909a55b6dd64792e553118c49b18edf2a5a..91d38fb6edb2ec89ec20921937b1f7e819913749 100644 --- a/o2web/source/x_component_process_FormDesigner/lp/zh-cn.js +++ b/o2web/source/x_component_process_FormDesigner/lp/zh-cn.js @@ -146,6 +146,7 @@ MWF.xApplication.process.FormDesigner.LP = { "cancel": "取消", "newCategory": "新分类", "mustSelectFormStyle" : "必须选择一种表单样式", + "notValidJson" : "错误的json格式", "imageClipper" : "图片编辑", diff --git a/o2web/source/x_component_process_ProcessDesigner/widget/PersonSelector.js b/o2web/source/x_component_process_ProcessDesigner/widget/PersonSelector.js index cc8b60abd6da443df492bcb493cc6b914adc4fdb..401fbfd2df90bac6172079ec2334d594b239948b 100644 --- a/o2web/source/x_component_process_ProcessDesigner/widget/PersonSelector.js +++ b/o2web/source/x_component_process_ProcessDesigner/widget/PersonSelector.js @@ -89,7 +89,7 @@ MWF.xApplication.process.ProcessDesigner.widget.PersonSelector = new Class({ if (this.options.type.toLowerCase()==="processfile") this.identitys.push(new MWF.widget.O2File(data, this.node)); if (this.options.type.toLowerCase()==="script") this.identitys.push(new MWF.widget.O2Other(data, this.node)); - if (this.options.type.toLowerCase()==="formStyle") this.identitys.push(new MWF.widget.O2Other(data, this.node)); + if (this.options.type.toLowerCase()==="formstyle") this.identitys.push(new MWF.widget.O2Other(data, this.node)); }.bind(this)); } }.bind(this)); @@ -128,6 +128,9 @@ MWF.xApplication.process.ProcessDesigner.widget.PersonSelector = new Class({ "isImage": this.options.isImage, "include" : include, "onComplete": function(items){ + if( typeOf(this.options.validFun)==="function" && !this.options.validFun( items ) ){ + return; + } this.identitys = []; if (this.options.type.toLowerCase()!=="duty") this.node.empty(); MWF.require("MWF.widget.O2Identity", function(){ @@ -152,7 +155,7 @@ MWF.xApplication.process.ProcessDesigner.widget.PersonSelector = new Class({ if (this.options.type.toLowerCase()==="processfile") this.identitys.push(new MWF.widget.O2File(item.data, this.node)); if (this.options.type.toLowerCase()==="script") this.identitys.push(new MWF.widget.O2Other(item.data, this.node)); - if (this.options.type.toLowerCase()==="formStyle") this.identitys.push(new MWF.widget.O2Other(item.data, this.node)); + if (this.options.type.toLowerCase()==="formstyle") this.identitys.push(new MWF.widget.O2Other(item.data, this.node)); }.bind(this)); if (this.options.type.toLowerCase()==="duty") { items.each(function(item){ @@ -164,6 +167,9 @@ MWF.xApplication.process.ProcessDesigner.widget.PersonSelector = new Class({ }.bind(this) }; if( this.options.title )options.title = this.options.title; + if( this.options.selectorOptions ){ + options = Object.merge(options, this.options.selectorOptions ); + } var selector = new MWF.O2Selector(this.app.content, options); }.bind(this)); } diff --git a/o2web/source/x_component_process_Xform/Htmleditor.js b/o2web/source/x_component_process_Xform/Htmleditor.js index ee334183969959c2203a3d767a1c26d2f2e0751f..575e93786ffcf6b05eb9408dc62fdf21878584f4 100644 --- a/o2web/source/x_component_process_Xform/Htmleditor.js +++ b/o2web/source/x_component_process_Xform/Htmleditor.js @@ -37,7 +37,7 @@ MWF.xApplication.process.Xform.Htmleditor = MWF.APPHtmleditor = new Class({ var config = Object.clone(this.json.editorProperties); if (this.json.config){ if (this.json.config.code){ - var obj = MWF.Macro.exec(this.json.config.code, this); + var obj = this.form.Macro.exec(this.json.config.code, this); Object.each(obj, function(v, k){ config[k] = v; });