MWF.xApplication.cms.FormDesigner.Module = MWF.xApplication.cms.FormDesigner.Module || {}; MWF.xDesktop.requireApp("process.FormDesigner", "Module.Form", null, false); MWF.xDesktop.requireApp("cms.FormDesigner", "Property", null, false); MWF.xApplication.cms.FormDesigner.Module.Form = MWF.CMSFCForm = new Class({ Extends: MWF.FCForm, options: { "style": "default", "propertyPath": "../x_component_cms_FormDesigner/Module/Form/form.html", "mode": "PC", "fields": ["Calendar", "Checkbox", "Datagrid", "Datagrid$Title", "Datagrid$Data", "Datatable", "Datatable$Title", "Datatable$Data", "Datatemplate", "Htmleditor", "TinyMCEEditor", "Number", "Currency", "Office", "Orgfield", "Personfield", "Readerfield", "Authorfield", "Org", "Reader", "Author", "Radio", "Select", "Textarea", "Textfield", "Address","Combox", "Elcascader","Elcheckbox","Elcolorpicker", "Eldate", "Eldatetime", "Elinput", "Elnumber", "Elradio", "Elrate", "Elselect", "Elslider", "Elswitch", "ElTime"], "injectActions" : [ { "name" : "top", "styles" : "injectActionTop", "event" : "click", "action" : "injectTop", "title": MWF.APPFD.LP.formAction["insertTop"] }, { "name" : "bottom", "styles" : "injectActionBottom", "event" : "click", "action" : "injectBottom", "title": MWF.APPFD.LP.formAction["insertBottom"] } ] }, initialize: function(designer, container, options){ this.setOptions(options); this.path = "../x_component_process_FormDesigner/Module/Form/"; this.cssPath = "../x_component_process_FormDesigner/Module/Form/"+this.options.style+"/css.wcss"; this._loadCss(); this.container = null; this.form = this; this.moduleType = "form"; this.moduleList = []; this.moduleNodeList = []; this.moduleContainerNodeList = []; this.moduleElementNodeList = []; this.moduleComponentNodeList = []; // this.moduleContainerList = []; this.dataTemplate = {}; this.designer = designer; this.container = container; this.selectedModules = []; }, // 移动端表单加载工具栏 loadMobileActionToos: function() { if (this.options.mode==="Mobile"){ if (!this.json.defaultTools){ this.json.defaultTools = o2.JSON.get("../x_component_cms_FormDesigner/Module/Form/toolbars.json", null,false); } if (!this.json.tools) this.json.tools=[]; } }, //loadTemplateStyles : function( file, callback ){ // debugger; // if( !file ){ // if (callback) callback({}); // return; // } // this.templateStylesList = this.templateStylesList || {}; // if( this.templateStylesList[file] ){ // if (callback) callback(this.templateStylesList[file]); // return; // } // var stylesUrl = "../x_component_cms_FormDesigner/Module/Form/skin/"+file; // MWF.getJSON(stylesUrl,{ // "onSuccess": function(responseJSON){ // this.templateStylesList[file] = responseJSON; // if (callback) callback(responseJSON); // }.bind(this), // "onRequestFailure": function(){ // if (callback) callback({}); // }.bind(this), // "onError": function(){ // if (callback) callback({}); // }.bind(this) // } // ); //}, loadTemplateStyleFile : function(file, callback ){ if( !file ){ if (callback) callback({}); return; } var stylesUrl = "../x_component_cms_FormDesigner/Module/Form/skin/"+file; MWF.getJSON(stylesUrl,{ "onSuccess": function(responseJSON){ //this.templateStylesList[file] = responseJSON; if (callback) callback(responseJSON); }.bind(this), "onRequestFailure": function(){ if (callback) callback({}); }.bind(this), "onError": function(){ if (callback) callback({}); }.bind(this) } ); }, loadTemplateExtendStyleFile : function(extendFile, callback ){ if( !extendFile ){ if (callback) callback({}); return; } var stylesUrl = "../x_component_cms_FormDesigner/Module/Form/skin/"+extendFile; MWF.getJSON(stylesUrl,{ "onSuccess": function(responseJSON){ //this.templateStylesList[file] = responseJSON; if (callback) callback(responseJSON); }.bind(this), "onRequestFailure": function(){ if (callback) callback({}); }.bind(this), "onError": function(){ if (callback) callback({}); }.bind(this) } ); }, loadStylesList: function(callback){ //var stylesUrl = "../x_component_process_FormDesigner/Module/Form/template/"+((this.options.mode=="Mobile") ? "mobileStyles": "styles")+".json"; //var stylesUrl = "../x_component_process_FormDesigner/Module/Form/template/"+((this.options.mode=="Mobile") ? "styles": "styles")+".json"; var configUrl = "../x_component_cms_FormDesigner/Module/Form/skin/config.json"; MWF.getJSON(configUrl,{ "onSuccess": function(responseJSON){ this.stylesList = responseJSON; if (callback) callback(this.stylesList); }.bind(this), "onRequestFailure": function(){ this.stylesList = {}; if (callback) callback(this.stylesList); }.bind(this), "onError": function(){ this.stylesList = {}; if (callback) callback(this.stylesList); }.bind(this) } ); }, //loadStylesList: function(callback){ //var stylesUrl = "../x_component_cms_FormDesigner/Module/Form/template/"+((this.options.mode=="Mobile") ? "styles": "styles")+".json"; //MWF.getJSON(stylesUrl,{ // "onSuccess": function(responseJSON){ // this.stylesList= responseJSON; // if (callback) callback(this.stylesList); // }.bind(this), // "onRequestFailure": function(){ // this.stylesList = {}; // if (callback) callback(this.stylesList); // }.bind(this), // "onError": function(){ // this.stylesList = {}; // if (callback) callback(this.stylesList); // }.bind(this) // } //); //}, loadModule: function(json, dom, parent){ var module, className; if( !json ){ className = ( dom.get("MWFType") || "div" ).capitalize(); this.getTemplateData(className, function(data){ var moduleData = Object.clone(data); moduleData.id = dom.get("id"); this.json.moduleList[dom.get("id")] = moduleData; module = new MWF["CMSFC"+className](this); module.load(moduleData, dom, parent); }.bind(this), false); return module; }else if( MWF["CMSFC"+json.type] ){ className = json.type.capitalize(); this.getTemplateData(className, function(data){ var moduleData = Object.clone(data); Object.merge(moduleData, json); Object.merge(json, moduleData); module = new MWF["CMSFC"+json.type](this); module.load(json, dom, parent); }.bind(this), false); return module; }else{ className = json.type.capitalize(); this.getTemplateData(className, function(data){ var moduleData = Object.clone(data); Object.merge(moduleData, json); Object.merge(json, moduleData); module = new MWF["CMSFCDiv"](this); module.load(json, dom, parent); }.bind(this), false); return module; } }, createModule: function(className, e){ //var classPre = MWF.CMSFD.RedesignModules.indexOf( className.toLowerCase() ) != -1 ? "CMSFC" : "FC"; var classPre = "CMSFC"; this.getTemplateData(className, function(data){ var moduleData = Object.clone(data); var newTool = new MWF[classPre+className](this); newTool.create(moduleData, e); }.bind(this)); }, getTemplateData: function(className, callback, async){ if (this.dataTemplate[className]){ if (callback) callback(this.dataTemplate[className]); }else{ var _className = className.indexOf("Process") === 0 ? className.substr( 7, className.length - 1 ) : className; var path = MWF.CMSFD.ResetTemplateModules.indexOf( className.toLowerCase() ) != -1 ? "x_component_cms_FormDesigner" : "x_component_process_FormDesigner"; var templateUrl = "../"+path+"/Module/"+_className+"/template.json"; MWF.getJSON(templateUrl, function(responseJSON, responseText){ this.dataTemplate[className] = responseJSON; if (callback) callback(responseJSON); }.bind(this), async); } }, showProperty: function(callback){ if (!this.property){ this.property = new MWF.xApplication.cms.FormDesigner.Property(this, this.designer.propertyContentArea, this.designer, { "path": this.options.propertyPath, "onPostLoad": function(){ this.property.show(); if (callback) callback(); }.bind(this) }); this.property.load(); }else{ this.property.show(); } }, save: function(callback){ this.designer.saveForm(); //this._getFormData(); //this.designer.actions.saveForm(this.data, function(responseJSON){ // this.form.designer.notice(MWF.APPFD.LP.notice["save_success"], "ok", null, {x: "left", y:"bottom"}); // // //this.json.id = responseJSON.data; // if (!this.json.name) this.treeNode.setText("<"+this.json.type+"> "+this.json.id); // this.treeNode.setTitle(this.json.id); // this.node.set("id", this.json.id); // // if (callback) callback(); // //this.reload(responseJSON.data); //}.bind(this)); }, implode: function(){ MWF.xDesktop.requireApp("cms.FormDesigner", "Import", function(){ MWF.CMSFormImport.create("O2", this); }.bind(this)); }, implodeHTML: function(){ MWF.xDesktop.requireApp("cms.FormDesigner", "Import", function(){ MWF.CMSFormImport.create("html", this, {"type": "process"}); }.bind(this)); }, implodeOffice: function(){ MWF.xDesktop.requireApp("cms.FormDesigner", "Import", function(){ MWF.CMSFormImport.create("office", this); }.bind(this)); }, showFormVersion: function(){ this.versionNode = new Element("div"); this.dlg = o2.DL.open({ "title": MWF.CMSFD.LP.version["title"], "content": this.versionNode, "offset": {"y": -100}, "isMax": false, "width": 500, "height": 300, "buttonList": [ { "type": "cancel", "text": MWF.CMSFD.LP.version["close"], "action": function(){ this.close(); } } ], "onPostShow": function(){ this.loadVersionList(); }.bind(this), "onPostClose": function(){ this.dlg = null; }.bind(this) }); }, loadVersionList : function(){ var tableHtml = "
"+MWF.CMSFD.LP.version["no"]+" | " + ""+MWF.CMSFD.LP.version["person"]+" | " + ""+MWF.CMSFD.LP.version["updateTime"]+" | " + ""+MWF.CMSFD.LP.version["op"]+" | " + "
---|