提交 04304920 编写于 作者: U unknown

自定义表单样式

上级 534a8760
......@@ -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(){}
});
......@@ -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))
},
......
......@@ -42,9 +42,15 @@
<!-- <div class="MWFScriptSelectRefresh"></div>-->
<!-- </td>-->
<!-- </tr>-->
<tr id="text{$.pid}formStyleTypeTr" style="display: text{(typeOf($.currentFormStyle)!='object')?'':'none'}">
<td class="editTableValue">
<!-- <tr id="text{$.pid}formStyleTypeTr" style="display: text{(typeOf($.currentFormStyle)!='object')?'':'none'}">-->
<!-- <td class="editTableValue">-->
<!-- <select class="MWFFormStyle" name="formStyleType"></select>-->
<!-- </td>-->
<!-- </tr>-->
<tr>
<td class="editTableTitle">表单样式:</td>
<td class="editTableValue">
<!-- <select class="MWFFormStyle" name="formStyleType"></select>-->
<div class="MWFFormStyleSelect" name="formStyleType"></div>
<div class="MWFScriptSelectRefresh"></div>
</td>
......
......@@ -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")] || []);
......
......@@ -146,6 +146,7 @@ MWF.xApplication.process.FormDesigner.LP = {
"cancel": "取消",
"newCategory": "新分类",
"mustSelectFormStyle" : "必须选择一种表单样式",
"notValidJson" : "错误的json格式",
"imageClipper" : "图片编辑",
......
......@@ -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));
}
......
......@@ -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;
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册