提交 534a8760 编写于 作者: U unknown

表单自定义

上级 ed7cd3a4
MWF.xApplication.Selector = MWF.xApplication.Selector || {};
MWF.xDesktop.requireApp("Selector", "Person", null, false);
MWF.xApplication.Selector.FormStyle = new Class({
Extends: MWF.xApplication.Selector.Person,
options: {
"style": "default",
"count": 0,
"title": MWF.xApplication.Selector.LP.selectFormStyle,
"values": [],
"names": [],
"expand": false,
"mode" : "pc",
"forceSearchInItem" : true
},
loadSelectItems: function(addToNext){
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);
Object.each(json, function(s, key){
if( s.mode.contains( this.options.mode ) ){
var d = {
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"
}, this, this.itemAreaNode);
var json = {};
var appJs = {};
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) {
appJs[ app.id ] = app;
});
scriptJson.data.each( function (script) {
if( !json[script.application] ){
json[script.application] = appJs[ script.application ];
json[script.application].scriptList = [];
}
script.appName = appJs[ script.application ].name;
script.appId = script.application;
script.type = "script";
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));
}
}.bind(this))
}.bind(this));
}.bind(this)
}
);
// this.processAction.listApplications(function(json){
// json.data.each(function(data){
// if (!data.scriptList){
// this.designerAction.listScript(data.id, function(scriptJson){
// data.scriptList = scriptJson.data;
// }.bind(this), null, false);
// }
// if (data.scriptList && data.scriptList.length){
// var category = this._newItemCategory(data, this, this.itemAreaNode);
// data.scriptList.each(function(d){
// d.applicationName = data.name;
// var item = this._newItem(d, this, category.children);
// this.items.push(item);
// }.bind(this));
// }
// }.bind(this));
// }.bind(this));
},
_scrollEvent: function(y){
return true;
},
_getChildrenItemIds: function(data){
return data.scriptList || [];
},
_newItemCategory: function(data, selector, item, level){
return new MWF.xApplication.Selector.FormStyle.ItemCategory(data, selector, item, level)
},
_listItemByKey: function(callback, failure, key){
return false;
},
_getItem: function(callback, failure, id, async){
this.queryAction.getTable(function(json){
if (callback) callback.apply(this, [json]);
}.bind(this), failure, ((typeOf(id)==="string") ? id : id.id), async);
},
_newItemSelected: function(data, selector, item){
return new MWF.xApplication.Selector.FormStyle.ItemSelected(data, selector, item)
},
_listItemByPinyin: function(callback, failure, key){
return false;
},
_newItem: function(data, selector, container, level){
return new MWF.xApplication.Selector.FormStyle.Item(data, selector, container, level);
}
});
MWF.xApplication.Selector.FormStyle.Item = new Class({
Extends: MWF.xApplication.Selector.Person.Item,
_getShowName: function(){
return this.data.name;
},
_setIcon: function(){
this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/attr.png)");
},
loadSubItem: function(){
return false;
},
checkSelectedSingle: function(){
var selectedItem = this.selector.options.values.filter(function(item, index){
if (typeOf(item)==="object"){
if( this.data.id && item.id ){
return this.data.id === item.id;
}
//return (this.data.id === item.id) || (this.data.name === item.name) ;
}
//if (typeOf(item)==="object") return (this.data.id === item.id) || (this.data.name === item.name) ;
if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
return false;
}.bind(this));
if (selectedItem.length){
this.selectedSingle();
}
},
checkSelected: function(){
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));
if (selectedItem.length){
//selectedItem[0].item = this;
selectedItem[0].addItem(this);
this.selectedItem = selectedItem[0];
this.setSelected();
}
}
});
MWF.xApplication.Selector.FormStyle.ItemSelected = new Class({
Extends: MWF.xApplication.Selector.Person.ItemSelected,
_getShowName: function(){
return this.data.name;
},
_setIcon: function(){
this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/attr.png)");
},
check: function(){
if (this.selector.items.length){
var items = this.selector.items.filter(function(item, index){
//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;
if (items.length){
items.each(function(item){
item.selectedItem = this;
item.setSelected();
}.bind(this));
}
}
}
});
MWF.xApplication.Selector.FormStyle.ItemCategory = new Class({
Extends: MWF.xApplication.Selector.Person.ItemCategory,
_getShowName: function(){
return this.data.name;
},
createNode: function(){
this.node = new Element("div", {
"styles": this.selector.css.selectorItemCategory_department
}).inject(this.container);
},
_setIcon: function(){
this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/applicationicon.png)");
},
_hasChild: function(){
return (this.data.scriptList && this.data.scriptList.length);
},
check: function(){}
});
......@@ -12,23 +12,48 @@ MWF.xApplication.Selector.Script = new Class({
"forceSearchInItem" : true
},
loadSelectItems: function(addToNext){
this.processAction.listApplications(function(json){
json.data.each(function(data){
if (!data.scriptList){
this.designerAction.listScript(data.id, function(scriptJson){
data.scriptList = scriptJson.data;
}.bind(this), null, false);
var json = {};
var appJs = {};
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) {
appJs[ app.id ] = app;
});
scriptJson.data.each( function (script) {
if( !json[script.application] ){
json[script.application] = appJs[ script.application ];
json[script.application].scriptList = [];
}
if (data.scriptList && data.scriptList.length){
var category = this._newItemCategory(data, this, this.itemAreaNode);
data.scriptList.each(function(d){
d.applicationName = data.name;
script.appName = appJs[ script.application ].name;
script.appId = script.application;
json[script.application].scriptList.push( script )
}.bind(this));
for( var application in json ){
var category = this._newItemCategory(json[application], this, this.itemAreaNode);
json[application].scriptList.each(function(d){
var item = this._newItem(d, this, category.children);
this.items.push(item);
}.bind(this));
}
}.bind(this))
}.bind(this));
}.bind(this));
// this.processAction.listApplications(function(json){
// json.data.each(function(data){
// if (!data.scriptList){
// this.designerAction.listScript(data.id, function(scriptJson){
// data.scriptList = scriptJson.data;
// }.bind(this), null, false);
// }
// if (data.scriptList && data.scriptList.length){
// var category = this._newItemCategory(data, this, this.itemAreaNode);
// data.scriptList.each(function(d){
// d.applicationName = data.name;
// var item = this._newItem(d, this, category.children);
// this.items.push(item);
// }.bind(this));
// }
// }.bind(this));
// }.bind(this));
},
_scrollEvent: function(y){
return true;
......
......@@ -13,6 +13,7 @@ MWF.xApplication.Selector.LP = MWF.SelectorLP = {
"selectProcess": "选择流程",
"selectView": "选择视图",
"selectTable": "选择数据表",
"selectFormStyle" : "选择表单样式",
"selectCMSApplication": "选择内容管理应用",
"selectCMSCategory": "选择内容管理栏目",
"noSelectableItemText" : "无待选项",
......
......@@ -106,27 +106,31 @@ MWF.xApplication.process.FormDesigner.Module.Form = MWF.FCForm = new Class({
this.container.set("html", this.html);
this.loadStylesList(function(){
if( typeOf(this.json.currentFormStyle) === "object" ){ //如果是自定义表单样式
this.loadCustomTemplateStyles( this.json.currentFormStyle, function ( templateStyles ) {
var formStyleType = this.json.formStyleType;
if( typeOf( formStyleType ) === "object" && formStyleType.type === "script" ){ //如果是自定义表单样式
this.loadCustomTemplateStyles( formStyleType, function ( templateStyles ) {
this._load( templateStyles );
}.bind(this))
}else {
if( typeOf( formStyleType ) === "object" )formStyleType = formStyleType.id;
var oldStyleValue = "";
if ((!this.json.formStyleType) || !this.stylesList[this.json.formStyleType]){
if ((!formStyleType) || !this.stylesList[formStyleType]){
this.json.formStyleType = "blue-simple";
formStyleType = "blue-simple";
}
if (this.options.mode == "Mobile") {
if (this.json.formStyleType != "defaultMobile") {
var styles = this.stylesList[this.json.formStyleType];
if ( formStyleType != "defaultMobile") {
var styles = this.stylesList[formStyleType];
if (!styles || typeOf(styles.mode) !== "array" || !styles.mode.contains("mobile")) {
oldStyleValue = this.json.formStyleType;
oldStyleValue = formStyleType;
this.json.formStyleType = "defaultMobile";
formStyleType = "defaultMobile";
}
}
}
if( !this.json.currentFormStyle )this.json.currentFormStyle = this.json.formStyleType;
this.loadTemplateStyles(this.stylesList[this.json.formStyleType].file, this.stylesList[this.json.formStyleType].extendFile, function (templateStyles) {
this.loadTemplateStyles(this.stylesList[formStyleType].file, this.stylesList[formStyleType].extendFile, function (templateStyles) {
//this.templateStyles = (this.stylesList && this.json.formStyleType) ? this.stylesList[this.json.formStyleType] : null;
this._load(templateStyles, oldStyleValue);
}.bind(this));
......@@ -1158,39 +1162,42 @@ MWF.xApplication.process.FormDesigner.Module.Form = MWF.FCForm = new Class({
this.treeNode.setTitle(this.json.id);
this.node.set("id", this.json.id);
}
if (name=="formStyleType" || name=="formStyleCustom" ){
if ( name=="formStyleType" ){
var loadOldTemplateStyle = function () {
if( typeOf(this.json.currentFormStyle) === "object" ){ //如果原来是自定义表单样式
this.loadCustomTemplateStyles( this.json.currentFormStyle , function (oldTemplateStyles) {
if( typeOf(oldValue) === "object" && oldValue.type === "script" ){ //如果原来是自定义表单样式
this.loadCustomTemplateStyles( oldValue , function (oldTemplateStyles) {
this.switchTemplateStyles( oldTemplateStyles );
this.setCurrentFormStyle( name );
}.bind(this))
}else{
if( !oldValue )oldValue = this.json.currentFormStyle;
var oldFile, oldExtendFile;
if( typeOf(oldValue) === "object" )oldValue === oldValue.id;
if( oldValue && this.stylesList[oldValue] ){
oldFile = this.stylesList[oldValue].file;
oldExtendFile = this.stylesList[oldValue].extendFile;
}
this.loadTemplateStyles( oldFile, oldExtendFile, function( oldTemplateStyles ){
this.switchTemplateStyles( oldTemplateStyles );
this.setCurrentFormStyle( name );
}.bind(this))
}
}.bind(this);
if( name=="formStyleCustom" ){
this.loadCustomTemplateStyles( this.json.formStyleCustom , function (templateStyles) {
var formStyleType = this.json.formStyleType;
if( typeOf(formStyleType) === "object" && formStyleType.type === "script" ){
this.loadCustomTemplateStyles( formStyleType , function (templateStyles) {
this.templateStyles = templateStyles;
loadOldTemplateStyle();
this.json.styleConfig = formStyleType;
}.bind(this))
}else{
var file = (this.stylesList && this.json.formStyleType) ? this.stylesList[this.json.formStyleType].file : null;
var extendFile = (this.stylesList && this.json.formStyleType) ? this.stylesList[this.json.formStyleType].extendFile : null;
if( typeOf(formStyleType) === "object" )formStyleType = formStyleType.id;
var file = (this.stylesList && formStyleType) ? this.stylesList[formStyleType].file : null;
var extendFile = (this.stylesList && formStyleType) ? this.stylesList[formStyleType].extendFile : null;
this.loadTemplateStyles( file, extendFile, function( templateStyles ){
this.templateStyles = templateStyles;
loadOldTemplateStyle();
this.json.styleConfig = (this.stylesList && formStyleType) ? this.stylesList[formStyleType] : null;
}.bind(this))
}
}
......@@ -1213,15 +1220,6 @@ MWF.xApplication.process.FormDesigner.Module.Form = MWF.FCForm = new Class({
module.setAllStyles();
}.bind(this));
},
setCurrentFormStyle : function ( name ) {
if( name=="formStyleCustom" ){
this.json.styleConfig = this.json.formStyleCustom;
this.json.currentFormStyle = this.json.formStyleCustom;
}else{
this.json.styleConfig = (this.stylesList && this.json.formStyleType) ? this.stylesList[this.json.formStyleType] : null;
this.json.currentFormStyle = this.json.formStyleType;
}
},
parseCSS: function(css){
var rex = /(url\(.*\))/g;
......
......@@ -23,27 +23,29 @@
<!--<select class="" name="titleField"></select>-->
<!--</td>-->
<!--</tr>-->
<tr>
<td class="editTableTitle" rowspan="2">表单样式:</td>
<td class="editTableValue">
<input type="radio" onclick="if (this.checked) {
$('text{$.pid}formStyleTypeTr').setStyle('display', '');
$('text{$.pid}formStyleTypeCustomTr').setStyle('display', 'none');
}" name="formStyleTypeRadio" value="default" text{(typeOf($.currentFormStyle)!='object' )?'checked':''}/>系统
<input type="radio" onclick="if (this.checked) {
$('text{$.pid}formStyleTypeTr').setStyle('display', 'none');
$('text{$.pid}formStyleTypeCustomTr').setStyle('display', '');
}" name="formStyleTypeRadio" value="custom" text{(typeOf($.currentFormStyle)=='object')?'checked':''}/>自定义
</td>
</tr>
<!-- <tr>-->
<!-- <td class="editTableTitle" rowspan="2">表单样式:</td>-->
<!-- <td class="editTableValue">-->
<!-- <input type="radio" onclick="if (this.checked) {-->
<!-- $('text{$.pid}formStyleTypeTr').setStyle('display', '');-->
<!-- $('text{$.pid}formStyleTypeCustomTr').setStyle('display', 'none');-->
<!-- }" name="formStyleTypeRadio" value="default" text{(typeOf($.currentFormStyle)!='object' )?'checked':''}/>系统-->
<!-- <input type="radio" onclick="if (this.checked) {-->
<!-- $('text{$.pid}formStyleTypeTr').setStyle('display', 'none');-->
<!-- $('text{$.pid}formStyleTypeCustomTr').setStyle('display', '');-->
<!-- }" name="formStyleTypeRadio" value="custom" text{(typeOf($.currentFormStyle)=='object')?'checked':''}/>自定义-->
<!-- </td>-->
<!-- </tr>-->
<!-- <tr id="text{$.pid}formStyleTypeCustomTr" style="display: text{(typeOf($.currentFormStyle)=='object')?'':'none'}">-->
<!-- <td class="editTableValue">-->
<!-- <div class="MWFScriptSelect" name="formStyleCustom"></div>-->
<!-- <div class="MWFScriptSelectRefresh"></div>-->
<!-- </td>-->
<!-- </tr>-->
<tr id="text{$.pid}formStyleTypeTr" style="display: text{(typeOf($.currentFormStyle)!='object')?'':'none'}">
<td class="editTableValue">
<select class="MWFFormStyle" name="formStyleType"></select>
</td>
</tr>
<tr id="text{$.pid}formStyleTypeCustomTr" style="display: text{(typeOf($.currentFormStyle)=='object')?'':'none'}">
<td class="editTableValue">
<div class="MWFScriptSelect" name="formStyleCustom"></div>
<!-- <select class="MWFFormStyle" name="formStyleType"></select>-->
<div class="MWFFormStyleSelect" name="formStyleType"></div>
<div class="MWFScriptSelectRefresh"></div>
</td>
</tr>
......
......@@ -1160,6 +1160,32 @@ debugger;
}.bind(node));
}.bind(this));
},
// loadStylesList: function(){
// var _self = this;
// var styleSelNodes = this.propertyContent.getElements(".MWFFormStyle");
// styleSelNodes.each(function(node){
// if (this.module.form.stylesList){
// if (!this.data.formStyleType) this.data.formStyleType = "default";
// var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
// Object.each(this.module.form.stylesList, function(s, key){
// if( s.mode.contains( mode ) ){
// new Element("option", {
// "text": s.name,
// "value": key,
// "selected": ((!this.data.formStyleType && key=="default") || (this.data.formStyleType==key))
// }).inject(node)
// }
// }.bind(this));
// }else{
// node.getParent("tr").setStyle("display", "none");
// }
//
// var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node, "after");
// refreshNode.addEvent("click", function(e){
// _self.changeData(this.get("name"), this );
// }.bind(node));
// }.bind(this));
// },
loadDivTemplateType: function(){
var nodes = this.propertyContent.getElements(".MWFDivTemplate");
if (nodes.length){
......@@ -1217,6 +1243,7 @@ debugger;
var fileNodes = this.propertyContent.getElements(".MWFImageFileSelect");
var processFileNodes = this.propertyContent.getElements(".MWFProcessImageFileSelect");
var scriptNodes = this.propertyContent.getElements(".MWFScriptSelect");
var formStyleNodes = this.propertyContent.getElements(".MWFFormStyleSelect");
MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
personIdentityNodes.each(function(node){
......@@ -1285,13 +1312,46 @@ debugger;
});
}.bind(this));
var _self = this;
scriptNodes.each(function(node){
new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
"type": "Script",
"count": 1,
"names": [this.data[node.get("name")]],
"onChange": function(ids){this.saveScriptSelectItem(node, ids);}.bind(this)
"onChange": function(ids){
this.saveScriptSelectItem(node, ids);
}.bind(this)
});
}.bind(this));
var _self = this;
formStyleNodes.each(function(node){
var data = this.data[node.get("name")];
if( typeOf( data ) === "string" ){
for( var key in this.module.form.stylesList ){
var s = this.module.form.stylesList[key];
if( ((!data && key=="default") || (data==key)) ){
data = {
name : s.name,
id : key
};
break;
}
}
}
new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
"type": "FormStyle",
"count": 1,
"names": [data],
"onChange": function(ids){
if( ids.length === 0 ){
this.designer.notice(MWF.APPFD.LP.mustSelectFormStyle, "error", this.module.form.designer.propertyContentArea, {
x: "right",
y: "bottom"
});
}else{
this.saveFormStyleItem(node, ids);
}
}.bind(this)
});
var next = node.getNext();
......@@ -1399,6 +1459,34 @@ 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")] || []);
......
......@@ -145,6 +145,7 @@ MWF.xApplication.process.FormDesigner.LP = {
"save": "保存",
"cancel": "取消",
"newCategory": "新分类",
"mustSelectFormStyle" : "必须选择一种表单样式",
"imageClipper" : "图片编辑",
......
......@@ -89,6 +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));
}.bind(this));
}
}.bind(this));
......@@ -151,6 +152,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));
}.bind(this));
if (this.options.type.toLowerCase()==="duty") {
items.each(function(item){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册