提交 ad85151d 编写于 作者: U unknown

tiny

上级 4c08a2a3
......@@ -91,7 +91,7 @@
"cancel_mobile": {
"color": "#333",
"font-size": "16px",
"width": "36px",
"width": "40px",
"height": "36px",
"font-weight": "bold",
"position": "absolute",
......@@ -101,7 +101,7 @@
"save_mobile": {
"color": "#4A90E2",
"font-size": "16px",
"width": "36px",
"width": "40px",
"height": "36px",
"font-weight": "bold",
"position": "absolute",
......
......@@ -80,6 +80,8 @@ MWF.xApplication.cms.FormDesigner.Script = new Class({
this.loadDatatemplateScript(v); break;
case "Htmleditor":
this.loadHtmleditorScript(v); break;
case "TinyMCEEditor":
this.loadTinyMCEEditorScript(v); break;
case "ImageClipper":
this.loadImageClipperScript(v); break;
case "WritingBoard":
......
......@@ -188,6 +188,8 @@ MWF.xApplication.portal.PageDesigner.Script = new Class({
this.loadDatatemplateScript(v); break;
case "Htmleditor":
this.loadHtmleditorScript(v); break;
case "TinyMCEEditor":
this.loadTinyMCEEditorScript(v); break;
case "ImageClipper":
this.loadImageClipperScript(v); break;
case "WritingBoard":
......@@ -575,6 +577,10 @@ MWF.xApplication.portal.PageDesigner.Script = new Class({
this.addScriptItem(data.config, "code", data, "config");
this.loadEventsScript(data);
},
loadTinyMCEEditorScript: function(data){
this.addScriptItem(data.config, "code", data, "config");
this.loadEventsScript(data);
},
loadImageClipperScript: function(data){ this.loadEventsScript(data); },
loadWritingBoardScript: function(data){ this.loadEventsScript(data); },
......
{
"label": {
"icon": "label.png",
"text": "文本",
"className": "Label"
},
"textfield": {
"icon": "textfield.png",
"text": "域",
"className": "Textfield"
},
"personfield": {
"icon": "personfield.png",
"text": "人员",
"className": "Personfield"
},
"calendar": {
"icon": "calendar.png",
"text": "日期选择",
"className": "Calendar"
},
"textarea": {
"icon": "textarea.png",
"text": "多行文本",
"className": "Textarea"
},
"select": {
"icon": "select.png",
"text": "下拉框",
"className": "Select"
},
"radio": {
"icon": "radio.png",
"text": "单选框",
"className": "Radio"
},
"checkbox": {
"icon": "checkbox.png",
"text": "多选框",
"className": "Checkbox"
},
"button": {
"icon": "button.png",
"text": "按钮",
"className": "Button"
},
"Actionbar": {
"icon": "actionbar.png",
"text": "操作条",
"className": "Actionbar"
},
"image": {
"icon": "image.png",
"text": "图片",
"className": "Image"
},
"image": {
"icon": "attachment.png",
"text": "附件",
"className": "Attachment"
},
"div": {
"icon": "div.png",
"text": "容器",
"className": "Div"
},
"table": {
"icon": "table.png",
"text": "表格",
"className": "Table"
},
"datagrid": {
"icon": "datagrid.png",
"text": "数据网格",
"className": "Datagrid"
},
"html": {
"icon": "html.png",
"text": "HTML",
"className": "Html"
},
"tab": {
"icon": "tabs.png",
"text": "分页",
"className": "Tab"
},
"tree": {
"icon": "tree.png",
"text": "树",
"className": "Tree"
},
"log": {
"icon": "log.png",
"text": "流程记录",
"className": "Log"
},
"monitor": {
"icon": "monitor.png",
"text": "流程监控",
"className": "Monitor"
},
"iframe": {
"icon": "iframe.png",
"text": "Iframe",
"className": "Iframe"
},
"htmledit": {
"icon": "htmleditor.png",
"text": "HTML编辑器",
"className": "Htmleditor"
},
"office": {
"icon": "office.png",
"text": "Office控件",
"className": "Office"
}
}
\ No newline at end of file
{
"label": {
"icon": "label.png",
"text": "文本",
"className": "Label"
},
"textfield": {
"icon": "textfield.png",
"text": "域",
"className": "Textfield"
},
"personfield": {
"icon": "personfield.png",
"text": "人员",
"className": "Personfield"
},
"calendar": {
"icon": "calendar.png",
"text": "日期选择",
"className": "Calendar"
},
"textarea": {
"icon": "textarea.png",
"text": "多行文本",
"className": "Textarea"
},
"select": {
"icon": "select.png",
"text": "下拉框",
"className": "Select"
},
"radio": {
"icon": "radio.png",
"text": "单选框",
"className": "Radio"
},
"checkbox": {
"icon": "checkbox.png",
"text": "多选框",
"className": "Checkbox"
},
"button": {
"icon": "button.png",
"text": "按钮",
"className": "Button"
},
"Actionbar": {
"icon": "actionbar.png",
"text": "操作条",
"className": "Actionbar"
},
"image": {
"icon": "image.png",
"text": "图片",
"className": "Image"
},
"image": {
"icon": "attachment.png",
"text": "附件",
"className": "Attachment"
},
"div": {
"icon": "div.png",
"text": "容器",
"className": "Div"
},
"table": {
"icon": "table.png",
"text": "表格",
"className": "Table"
},
"datagrid": {
"icon": "datagrid.png",
"text": "数据网格",
"className": "Datagrid"
},
"html": {
"icon": "html.png",
"text": "HTML",
"className": "Html"
},
"tab": {
"icon": "tabs.png",
"text": "分页",
"className": "Tab"
},
"tree": {
"icon": "tree.png",
"text": "树",
"className": "Tree"
},
"log": {
"icon": "log.png",
"text": "流程记录",
"className": "Log"
},
"monitor": {
"icon": "monitor.png",
"text": "流程监控",
"className": "Monitor"
},
"iframe": {
"icon": "iframe.png",
"text": "Iframe",
"className": "Iframe"
},
"htmledit": {
"icon": "htmleditor.png",
"text": "HTML编辑器",
"className": "Htmleditor"
},
"office": {
"icon": "office.png",
"text": "Office控件",
"className": "Office"
}
}
\ No newline at end of file
......@@ -22,8 +22,6 @@ MWF.xApplication.process.FormDesigner.Main = new Class({
"processData": null
},
onQueryLoad: function(){
debugger;
debugger;
this.shortcut = true;
if (this.status){
this.options.id = this.status.id;
......@@ -1853,7 +1851,6 @@ MWF.xApplication.process.FormDesigner.ToolsGroup = new Class({
// imgNode.setStyle("background-color", color);
},
setContentHeight: function(height){
debugger;
this.height = height;
if (this.isShow){
this.toolbarContentNode.setStyle("height", ""+this.height+"px");
......
......@@ -98,7 +98,7 @@ MWF.xApplication.process.FormDesigner.Module.TinyMCEEditor = MWF.FCTinyMCEEditor
if (value=="true") this.json.editorProperties[key] = true;
if (value=="false") this.json.editorProperties[key] = false;
}.bind(this));
this.distroyCkeditor();
this.distroyEditor();
var config = Object.clone(this.json.editorProperties);
if (this.json.config){
......@@ -115,7 +115,9 @@ MWF.xApplication.process.FormDesigner.Module.TinyMCEEditor = MWF.FCTinyMCEEditor
}
if (name=="templateCode"){
if (this.editor) this.editor.setData(this.json.templateCode);
if (this.editor) {
this.editor.setContent(this.json.templateCode);
}
}
},
......@@ -144,14 +146,20 @@ MWF.xApplication.process.FormDesigner.Module.TinyMCEEditor = MWF.FCTinyMCEEditor
o2.load("../o2_lib/tinymce/tinymce_5.9.2/tinymce.min.js", function(){
var editorConfig = Object.merge(this.getDefaultConfig(), config || {});
var id = this.json.id + "_div";
var id = this.form.json.id +"_"+this.json.id + "_div";
editorConfig.selector = '#'+id;
var editorDiv = new Element("div", {"id": id}).inject(this.node);
editorConfig.readonly = true;
tinymce.init(editorConfig).then(function(v1, v2, v3){
editorConfig.init_instance_callback = function(editor) {
debugger;
}.bind(this));
this.editor = editor;
if( this.json.templateCode ){
this.editor.setContent(this.json.templateCode);
}
}.bind(this);
tinymce.init(editorConfig);
// this.editor.on("dataReady", function(){
// this.editor.setReadOnly(true);
......@@ -159,7 +167,7 @@ MWF.xApplication.process.FormDesigner.Module.TinyMCEEditor = MWF.FCTinyMCEEditor
}.bind(this));
},
destroy: function(){
this.distroyCkeditor();
this.distroyEditor();
this.form.moduleList.erase(this);
this.form.moduleNodeList.erase(this.node);
this.form.moduleElementNodeList.erase(this.node);
......@@ -179,7 +187,7 @@ MWF.xApplication.process.FormDesigner.Module.TinyMCEEditor = MWF.FCTinyMCEEditor
this.treeNode.destroy();
o2.release(this);
},
distroyCkeditor: function(){
distroyEditor: function(){
if (this.editor) this.editor.destroy();
this.editor = null;
}
......
......@@ -50,7 +50,7 @@
}
},
"editorProperties": {
"height": "200",
"height": "650",
"readOnly": false
},
"config": {
......
......@@ -544,7 +544,6 @@ MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = new Class({
}
},
loadStatementFilter: function(){
debugger;
var nodes = this.propertyContent.getElements(".MWFStatementFilter");
var filtrData = this.data.filterList;
nodes.each(function(node){
......@@ -652,7 +651,6 @@ MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = new Class({
var nodes = this.propertyContent.getElements(".MWFFieldConfigArea");
if (nodes.length){
nodes.each(function(node){
debugger;
var name = node.get("name");
var data;
if( this.data[name] ){
......@@ -665,7 +663,6 @@ MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = new Class({
"title": node.get("data-title"),
"hasRefresh": true,
"onRefresh": function () {
debugger;
var _self = this;
if( typeOf(this.data[name]) === "array" && this.data[name].length > 0 ){
//this.form.designer.lp.selectIcon
......@@ -686,7 +683,6 @@ MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = new Class({
}
}.bind(this),
"onChange": function(){
debugger;
this.data[name] = filedConfigurator.getData();
}.bind(this)
}, data);
......@@ -744,7 +740,6 @@ MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = new Class({
}
},
loadElSelectIcon: function(){
debugger;
var nodes = this.propertyContent.getElements(".MWFElIcon");
if (nodes.length){
var _self = this;
......@@ -1047,7 +1042,7 @@ MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = new Class({
var pathInput = node.getElement("input");
//var select = new Element("select").inject(node);
//var methodSelect = new Element("select").inject(node);
debugger;
var getValue = function(){
var v;
try {
......@@ -1478,7 +1473,6 @@ debugger;
}.bind(this));
dutyNameNodes.each(function(node){
debugger;
new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
"type": "dutyName",
"names": this.data[node.get("name")],
......@@ -1619,7 +1613,6 @@ 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 ){
......@@ -1647,7 +1640,6 @@ debugger;
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();
......@@ -1709,7 +1701,6 @@ debugger;
if( ids.length > 0 ){
// var d = ids[0].data;
ids.each( function (id) {
debugger;
var d = id.data;
data.push({
"type" : "dictionary",
......@@ -2141,7 +2132,6 @@ debugger;
loadMaplist: function(){
var maplists = this.propertyContent.getElements(".MWFMaplist");
debugger;
maplists.each(function(node){
var title = node.get("title");
var name = node.get("name");
......
{
"label": {
"icon": "label.png",
"text": "文本",
"className": "Label"
},
"textfield": {
"icon": "textfield.png",
"text": "域",
"className": "Textfield"
},
"personfield": {
"icon": "personfield.png",
"text": "人员",
"className": "Personfield"
},
"calendar": {
"icon": "calendar.png",
"text": "日期选择",
"className": "Calendar"
},
"textarea": {
"icon": "textarea.png",
"text": "多行文本",
"className": "Textarea"
},
"select": {
"icon": "select.png",
"text": "下拉框",
"className": "Select"
},
"radio": {
"icon": "radio.png",
"text": "单选框",
"className": "Radio"
},
"checkbox": {
"icon": "checkbox.png",
"text": "多选框",
"className": "Checkbox"
},
"button": {
"icon": "button.png",
"text": "按钮",
"className": "Button"
},
"Actionbar": {
"icon": "actionbar.png",
"text": "操作条",
"className": "Actionbar"
},
"image": {
"icon": "image.png",
"text": "图片",
"className": "Image"
},
"image": {
"icon": "attachment.png",
"text": "附件",
"className": "Attachment"
},
"div": {
"icon": "div.png",
"text": "容器",
"className": "Div"
},
"table": {
"icon": "table.png",
"text": "表格",
"className": "Table"
},
"datagrid": {
"icon": "datagrid.png",
"text": "数据网格",
"className": "Datagrid"
},
"html": {
"icon": "html.png",
"text": "HTML",
"className": "Html"
},
"tab": {
"icon": "tabs.png",
"text": "分页",
"className": "Tab"
},
"tree": {
"icon": "tree.png",
"text": "树",
"className": "Tree"
},
"log": {
"icon": "log.png",
"text": "流程记录",
"className": "Log"
},
"monitor": {
"icon": "monitor.png",
"text": "流程监控",
"className": "Monitor"
},
"iframe": {
"icon": "iframe.png",
"text": "Iframe",
"className": "Iframe"
},
"htmledit": {
"icon": "htmleditor.png",
"text": "HTML编辑器",
"className": "Htmleditor"
},
"office": {
"icon": "office.png",
"text": "Office控件",
"className": "Office"
}
}
\ No newline at end of file
......@@ -1821,6 +1821,8 @@ MWF.xApplication.process.Xform.DatagridPC = new Class(
colWidthArr.push(260);
} else if (module && module.json.type === "Htmleditor") {
colWidthArr.push(500);
} else if (module && module.json.type === "TinyMCEEditor") {
colWidthArr.push(500);
} else if (module && module.json.type === "Calendar") {
colWidthArr.push(150);
} else {
......
......@@ -1883,6 +1883,8 @@ MWF.xApplication.process.Xform.DatatablePC.Exporter = new Class({
colWidthArr.push(260);
} else if (c.mJson && c.mJson.type === "Htmleditor") {
colWidthArr.push(500);
} else if (c.mJson && c.mJson.type === "TinyMCEEditor") {
colWidthArr.push(500);
} else if (c.mJson && c.mJson.type === "Calendar") {
colWidthArr.push(150);
} else {
......
......@@ -1472,6 +1472,8 @@ MWF.xApplication.process.Xform.Datatemplate.Exporter = new Class({
colWidthArr.push(260);
} else if (json.type === "Htmleditor") {
colWidthArr.push(500);
} else if (json.type === "TinyMCEEditor") {
colWidthArr.push(500);
} else if (json.type === "Calendar") {
colWidthArr.push(150);
} else {
......
......@@ -29,6 +29,7 @@ MWF.xApplication.process.Xform.require = function(callback){
["process.Xform", "Tree"],
["process.Xform", "Iframe"],
["process.Xform", "Htmleditor"],
["process.Xform", "TinyMCEEditor"],
["process.Xform", "Office"],
["process.Xform", "IWebOffice"],
["process.Xform", "YozoOffice"],
......
MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
/** @class TinyMCEEditor HTML编辑器。
* @example
* //可以在脚本中获取该组件
* //方法1:
* var tinyMCEEditor = this.form.get("name"); //获取组件
* //方法2
* var tinyMCEEditor = this.target; //在组件事件脚本中获取
* @extends MWF.xApplication.process.Xform.$Module
* @o2category FormComponents
* @o2range {Process|CMS}
* @hideconstructor
*/
MWF.xApplication.process.Xform.TinyMCEEditor = MWF.APPTinyMCEEditor = new Class(
/** @lends MWF.xApplication.process.Xform.TinyMCEEditor# */
{
Extends: MWF.APP$Module,
options: {
/**
* 组件异步加载后触发.
* @event MWF.xApplication.process.Xform.TinyMCEEditor#afterLoad
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
"moduleEvents": ["queryLoad", "load", "postLoad", "afterLoad"]
},
initialize: function (node, json, form, options) {
this.node = $(node);
this.node.store("module", this);
this.json = json;
this.form = form;
this.field = true;
this.fieldModuleLoaded = false;
},
load: function () {
this._loadModuleEvents();
if (this.fireEvent("queryLoad")) {
this._queryLoaded();
this._loadUserInterface();
this._loadStyles();
//this._loadEvents();
this._afterLoaded();
this.fireEvent("postLoad");
this.fireEvent("load");
}
},
_loadUserInterface: function () {
debugger;
this.node.empty();
if (this.readonly || this.json.isReadonly) {
// this.node.set("html", this._getBusinessData());
this.node.setStyles({
"-webkit-user-select": "text",
"-moz-user-select": "text"
});
if (layout.mobile) {
this.loadLazyImage(function () { //图片懒加载
var images = this.node.getElements("img");
//移动端设置图片宽度为100%
images.each(function (img) {
if (img.hasClass("lozad")) {
img.setStyles({
"max-width": "100%"
});
} else {
img.setStyles({
"height": "auto",
"max-width": "100%"
});
}
}.bind(this));
this.fireEvent("afterLoad");
this.fieldModuleLoaded = true;
}.bind(this))
} else {
this.loadLazyImage(function () { //图片懒加载
if (this.json.enablePreview !== "n") {
this.loadImageViewer(); //PC端点击显示大图
this.fireEvent("afterLoad");
this.fieldModuleLoaded = true;
}
}.bind(this))
}
} else {
var config = Object.clone(this.json.editorProperties);
if (this.json.config) {
if (this.json.config.code) {
var obj = this.form.Macro.exec(this.json.config.code, this);
Object.each(obj, function (v, k) {
config[k] = v;
});
}
}
this.loadTinyMCEEditor(config);
}
// this._loadValue();
},
loadLazyImage: function (callback) {
o2.require("o2.widget.ImageLazyLoader", function () {
var loadder = new o2.widget.ImageLazyLoader(this.node, this._getBusinessData());
loadder.load(function () {
if (callback) callback();
}.bind(this))
}.bind(this));
},
loadImageViewer: function () {
o2.require("o2.widget.ImageViewer", function () {
var imageViewer = new o2.widget.ImageViewer(this.node);
imageViewer.load();
}.bind(this));
},
getDefaultConfig: function () {
var config = {
"branding": false,
//skin:'oxide-dark',
// language:'zh_CN',
plugins: 'print preview searchreplace autolink directionality visualblocks visualchars fullscreen image link' +
' media template code codesample table charmap hr pagebreak nonbreaking anchor insertdatetime' +
' advlist lists wordcount imagetools textpattern help emoticons autosave' +
' o2indent2em autoresize o2upimgs', //bdmap formatpainter
toolbar: 'code undo redo | cut copy paste pastetext | forecolor backcolor bold italic underline strikethrough |' + //restoredraft
' alignleft aligncenter alignright alignjustify outdent indent o2indent2em lineheight | table image o2upimgs link |' + //\\'+
' styleselect formatselect fontselect fontsizeselect | bullist numlist | blockquote subscript superscript removeformat |' + // \\'+
' media charmap emoticons anchor hr pagebreak insertdatetime print preview | fullscreen', //bdmap formatpainter
height: 650, //编辑器高度
min_height: 400,
toolbar_mode: 'sliding',
fontsize_formats: '12px 14px 16px 18px 24px 36px 48px 56px 72px',
importcss_append: true,
//自定义文件选择器的回调内容
// file_picker_callback: function (callback, value, meta) {
// if (meta.filetype === 'file') {
// callback('https://www.baidu.com/img/bd_logo1.png', { text: 'My text' });
// }
// if (meta.filetype === 'image') {
// callback('https://www.baidu.com/img/bd_logo1.png', { alt: 'My alt text' });
// }
// if (meta.filetype === 'media') {
// callback('movie.mp4', { source2: 'alt.ogg', poster: 'https://www.baidu.com/img/bd_logo1.png' });
// }
// },
toolbar_sticky: true,
autosave_ask_before_unload: false,
};
if (o2.language === "zh-cn") {
config.language = 'zh_CN';
config.font_formats = '微软雅黑=Microsoft YaHei,Helvetica Neue,PingFang SC,sans-serif;' +
'苹果苹方=PingFang SC,Microsoft YaHei,sans-serif;' +
'宋体=simsun,serif;' +
'仿宋体=FangSong,serif;' +
'黑体=SimHei,sans-serif;' +
'Arial=arial,helvetica,sans-serif;' +
'Arial Black=arial black,avant garde;' +
'Book Antiqua=book antiqua,palatino;';
}
return config;
},
loadTinyMCEEditor: function (config) {
o2.load("../o2_lib/tinymce/tinymce_5.9.2/tinymce.min.js", function(){
var editorConfig = Object.merge(this.getDefaultConfig(), config || {});
var id = this.form.json.id +"_"+this.json.id + "_div";
editorConfig.selector = '#'+id;
var editorDiv = new Element("div", {"id": id}).inject(this.node);
var htmlData = this._getBusinessData();
if (htmlData) {
editorDiv.set("html", htmlData);
} else if (this.json.templateCode) {
editorDiv.set("html", this.json.templateCode);
}
var height = this.node.getSize().y;
if (this.form.json.mode === "Mobile") {
if (!editorConfig.toolbar && !editorConfig.toolbarGroups) {
editorConfig.toolbar = [
{
name: 'paragraph',
items: ['Bold', 'Italic', "-", 'TextColor', "BGColor", 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', "-", 'Undo', 'Redo']
},
{name: 'basicstyles', items: ['Styles', 'FontSize']},
{name: 'insert', items: ['Image']}
];
}
}
editorConfig.base64Encode = (this.json.base64Encode === "y");
editorConfig.enablePreview = (this.json.enablePreview !== "n");
editorConfig.localImageMaxWidth = 2000;
editorConfig.reference = this.form.businessData.work.job;
editorConfig.referenceType = "processPlatformJob";
var init_instance_callback;
if(editorConfig.init_instance_callback){
init_instance_callback = editorConfig.init_instance_callback;
}
editorConfig.init_instance_callback = function(editor) {
this.editor = editor;
this.editor.on("change", function () {
this._setBusinessData(this.getData());
}.bind(this));
if(init_instance_callback)init_instance_callback(editor);
}.bind(this);
tinymce.init(editorConfig);
this._loadEvents();
this.fireEvent("afterLoad");
this.fieldModuleLoaded = true;
// this._loadEvents();
}.bind(this));
},
_loadEvents: function (editorConfig) {
Object.each(this.json.events, function (e, key) {
if (e.code) {
this.editor.on(key, function (event) {
return this.form.Macro.fire(e.code, this, event);
}.bind(this), this);
}
}.bind(this));
},
addModuleEvent: function (key, fun) {
this.editor.on(key, function (event) {
return (fun) ? fun(this, event) : null;
}.bind(this), this);
},
_loadValue: function () {
var data = this._getBusinessData();
},
/**
* @summary 重置组件的值为默认值或置空。
* @example
* this.form.get('fieldId').resetData();
*/
resetData: function () {
this.setData(this._getBusinessData());
},
/**
* @summary 判断组件值是否为空.
* @example
* if( this.form.get('fieldId').isEmpty() ){
* this.form.notice('HTML编辑器不能为空', 'warn');
* }
* @return {Boolean} 值是否为空.
*/
isEmpty: function () {
return !this.getData().trim();
},
/**
* 当表单上没有对应组件的时候,可以使用this.data[fieldId]获取值,但是this.form.get('fieldId')无法获取到组件。
* @summary 获取组件值。
* @example
* var data = this.form.get('fieldId').getData();
* @example
* //如果无法确定表单上是否有组件,需要判断
* var data;
* if( this.form.get('fieldId') ){ //判断表单是否有无对应组件
* data = this.form.get('fieldId').getData();
* }else{
* data = this.data['fieldId']; //直接从数据中获取字段值
* }
* @return 组件的数据.
*/
getData: function () {
return this.editor ? this.editor.getContent() : this._getBusinessData();
},
/**
* 当表单上没有对应组件的时候,可以使用this.data[fieldId] = data赋值。
* @summary 为组件赋值。
* @param data{String} .
* @example
* this.form.get("fieldId").setData("test"); //赋文本值
* @example
* //如果无法确定表单上是否有组件,需要判断
* if( this.form.get('fieldId') ){ //判断表单是否有无对应组件
* this.form.get('fieldId').setData( data );
* }else{
* this.data['fieldId'] = data;
* }
*/
setData: function (data) {
this._setBusinessData(data);
if (this.editor) this.editor.setContent(data);
},
createErrorNode: function (text) {
var node = new Element("div");
var iconNode = new Element("div", {
"styles": {
"width": "20px",
"height": "20px",
"float": "left",
"background": "url(" + "../x_component_process_Xform/$Form/default/icon/error.png) center center no-repeat"
}
}).inject(node);
var textNode = new Element("div", {
"styles": {
"line-height": "20px",
"margin-left": "20px",
"color": "red",
"word-break": "keep-all"
},
"text": text
}).inject(node);
return node;
},
notValidationMode: function (text) {
if (!this.isNotValidationMode) {
this.isNotValidationMode = true;
this.node.store("borderStyle", this.node.getStyles("border-left", "border-right", "border-top", "border-bottom"));
this.node.setStyle("border", "1px solid red");
this.errNode = this.createErrorNode(text).inject(this.node, "after");
this.showNotValidationMode(this.node);
if (!this.node.isIntoView()) this.node.scrollIntoView();
}
},
showNotValidationMode: function (node) {
var p = node.getParent("div");
if (p) {
if (p.get("MWFtype") == "tab$Content") {
if (p.getParent("div").getStyle("display") == "none") {
var contentAreaNode = p.getParent("div").getParent("div");
var tabAreaNode = contentAreaNode.getPrevious("div");
var idx = contentAreaNode.getChildren().indexOf(p.getParent("div"));
var tabNode = tabAreaNode.getLast().getFirst().getChildren()[idx];
tabNode.click();
p = tabAreaNode.getParent("div");
}
}
this.showNotValidationMode(p);
}
},
validationMode: function () {
if (this.isNotValidationMode) {
this.isNotValidationMode = false;
this.node.setStyles(this.node.retrieve("borderStyle"));
if (this.errNode) {
this.errNode.destroy();
this.errNode = null;
}
}
},
validationConfigItem: function (routeName, data) {
var flag = (data.status == "all") ? true : (routeName == data.decision);
if (flag) {
var n = this.getData();
var v = (data.valueType == "value") ? n : n.length;
switch (data.operateor) {
case "isnull":
if (!v) {
this.notValidationMode(data.prompt);
return false;
}
break;
case "notnull":
if (v) {
this.notValidationMode(data.prompt);
return false;
}
break;
case "gt":
if (v > data.value) {
this.notValidationMode(data.prompt);
return false;
}
break;
case "lt":
if (v < data.value) {
this.notValidationMode(data.prompt);
return false;
}
break;
case "equal":
if (v == data.value) {
this.notValidationMode(data.prompt);
return false;
}
break;
case "neq":
if (v != data.value) {
this.notValidationMode(data.prompt);
return false;
}
break;
case "contain":
if (v.indexOf(data.value) != -1) {
this.notValidationMode(data.prompt);
return false;
}
break;
case "notcontain":
if (v.indexOf(data.value) == -1) {
this.notValidationMode(data.prompt);
return false;
}
break;
}
}
return true;
},
validationConfig: function (routeName, opinion) {
if (this.json.validationConfig) {
if (this.json.validationConfig.length) {
for (var i = 0; i < this.json.validationConfig.length; i++) {
var data = this.json.validationConfig[i];
if (!this.validationConfigItem(routeName, data)) return false;
}
}
return true;
}
return true;
},
/**
* @summary 根据组件的校验设置进行校验。
* @param {String} [routeName] - 可选,路由名称.
* @example
* if( !this.form.get('fieldId').validation() ){
* return false;
* }
* @return {Boolean} 是否通过校验
*/
validation: function (routeName, opinion) {
if (!this.validationConfig(routeName, opinion)) return false;
if (!this.json.validation) return true;
if (!this.json.validation.code) return true;
this.currentRouteName = routeName;
var flag = this.form.Macro.exec(this.json.validation.code, this);
this.currentRouteName = "";
if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
if (flag.toString() != "true") {
this.notValidationMode(flag);
return false;
}
return true;
}
});
\ No newline at end of file
{
"label": {
"icon": "label.png",
"text": "文本",
"className": "Label"
},
"textfield": {
"icon": "textfield.png",
"text": "域",
"className": "Textfield"
},
"personfield": {
"icon": "personfield.png",
"text": "人员",
"className": "Personfield"
},
"calendar": {
"icon": "calendar.png",
"text": "日期选择",
"className": "Calendar"
},
"textarea": {
"icon": "textarea.png",
"text": "多行文本",
"className": "Textarea"
},
"select": {
"icon": "select.png",
"text": "下拉框",
"className": "Select"
},
"radio": {
"icon": "radio.png",
"text": "单选框",
"className": "Radio"
},
"checkbox": {
"icon": "checkbox.png",
"text": "多选框",
"className": "Checkbox"
},
"button": {
"icon": "button.png",
"text": "按钮",
"className": "Button"
},
"Actionbar": {
"icon": "actionbar.png",
"text": "操作条",
"className": "Actionbar"
},
"image": {
"icon": "image.png",
"text": "图片",
"className": "Image"
},
"image": {
"icon": "attachment.png",
"text": "附件",
"className": "Attachment"
},
"div": {
"icon": "div.png",
"text": "容器",
"className": "Div"
},
"table": {
"icon": "table.png",
"text": "表格",
"className": "Table"
},
"datagrid": {
"icon": "datagrid.png",
"text": "数据网格",
"className": "Datagrid"
},
"html": {
"icon": "html.png",
"text": "HTML",
"className": "Html"
},
"tab": {
"icon": "tabs.png",
"text": "分页",
"className": "Tab"
},
"tree": {
"icon": "tree.png",
"text": "树",
"className": "Tree"
},
"log": {
"icon": "log.png",
"text": "流程记录",
"className": "Log"
},
"monitor": {
"icon": "monitor.png",
"text": "流程监控",
"className": "Monitor"
},
"iframe": {
"icon": "iframe.png",
"text": "Iframe",
"className": "Iframe"
},
"htmledit": {
"icon": "htmleditor.png",
"text": "HTML编辑器",
"className": "Htmleditor"
},
"office": {
"icon": "office.png",
"text": "Office控件",
"className": "Office"
}
}
\ No newline at end of file
{
"label": {
"icon": "label.png",
"text": "文本",
"className": "Label"
},
"textfield": {
"icon": "textfield.png",
"text": "域",
"className": "Textfield"
},
"personfield": {
"icon": "personfield.png",
"text": "人员",
"className": "Personfield"
},
"calendar": {
"icon": "calendar.png",
"text": "日期选择",
"className": "Calendar"
},
"textarea": {
"icon": "textarea.png",
"text": "多行文本",
"className": "Textarea"
},
"select": {
"icon": "select.png",
"text": "下拉框",
"className": "Select"
},
"radio": {
"icon": "radio.png",
"text": "单选框",
"className": "Radio"
},
"checkbox": {
"icon": "checkbox.png",
"text": "多选框",
"className": "Checkbox"
},
"button": {
"icon": "button.png",
"text": "按钮",
"className": "Button"
},
"Actionbar": {
"icon": "actionbar.png",
"text": "操作条",
"className": "Actionbar"
},
"image": {
"icon": "image.png",
"text": "图片",
"className": "Image"
},
"image": {
"icon": "attachment.png",
"text": "附件",
"className": "Attachment"
},
"div": {
"icon": "div.png",
"text": "容器",
"className": "Div"
},
"table": {
"icon": "table.png",
"text": "表格",
"className": "Table"
},
"datagrid": {
"icon": "datagrid.png",
"text": "数据网格",
"className": "Datagrid"
},
"html": {
"icon": "html.png",
"text": "HTML",
"className": "Html"
},
"tab": {
"icon": "tabs.png",
"text": "分页",
"className": "Tab"
},
"tree": {
"icon": "tree.png",
"text": "树",
"className": "Tree"
},
"log": {
"icon": "log.png",
"text": "流程记录",
"className": "Log"
},
"monitor": {
"icon": "monitor.png",
"text": "流程监控",
"className": "Monitor"
},
"iframe": {
"icon": "iframe.png",
"text": "Iframe",
"className": "Iframe"
},
"htmledit": {
"icon": "htmleditor.png",
"text": "HTML编辑器",
"className": "Htmleditor"
},
"office": {
"icon": "office.png",
"text": "Office控件",
"className": "Office"
}
}
\ No newline at end of file
{
"label": {
"icon": "label.png",
"text": "文本",
"className": "Label"
},
"textfield": {
"icon": "textfield.png",
"text": "域",
"className": "Textfield"
},
"personfield": {
"icon": "personfield.png",
"text": "人员",
"className": "Personfield"
},
"calendar": {
"icon": "calendar.png",
"text": "日期选择",
"className": "Calendar"
},
"textarea": {
"icon": "textarea.png",
"text": "多行文本",
"className": "Textarea"
},
"select": {
"icon": "select.png",
"text": "下拉框",
"className": "Select"
},
"radio": {
"icon": "radio.png",
"text": "单选框",
"className": "Radio"
},
"checkbox": {
"icon": "checkbox.png",
"text": "多选框",
"className": "Checkbox"
},
"button": {
"icon": "button.png",
"text": "按钮",
"className": "Button"
},
"Actionbar": {
"icon": "actionbar.png",
"text": "操作条",
"className": "Actionbar"
},
"image": {
"icon": "image.png",
"text": "图片",
"className": "Image"
},
"image": {
"icon": "attachment.png",
"text": "附件",
"className": "Attachment"
},
"div": {
"icon": "div.png",
"text": "容器",
"className": "Div"
},
"table": {
"icon": "table.png",
"text": "表格",
"className": "Table"
},
"datagrid": {
"icon": "datagrid.png",
"text": "数据网格",
"className": "Datagrid"
},
"html": {
"icon": "html.png",
"text": "HTML",
"className": "Html"
},
"tab": {
"icon": "tabs.png",
"text": "分页",
"className": "Tab"
},
"tree": {
"icon": "tree.png",
"text": "树",
"className": "Tree"
},
"log": {
"icon": "log.png",
"text": "流程记录",
"className": "Log"
},
"monitor": {
"icon": "monitor.png",
"text": "流程监控",
"className": "Monitor"
},
"iframe": {
"icon": "iframe.png",
"text": "Iframe",
"className": "Iframe"
},
"htmledit": {
"icon": "htmleditor.png",
"text": "HTML编辑器",
"className": "Htmleditor"
},
"office": {
"icon": "office.png",
"text": "Office控件",
"className": "Office"
}
}
\ No newline at end of file
{
"label": {
"icon": "label.png",
"text": "文本",
"className": "Label"
},
"textfield": {
"icon": "textfield.png",
"text": "域",
"className": "Textfield"
},
"personfield": {
"icon": "personfield.png",
"text": "人员",
"className": "Personfield"
},
"calendar": {
"icon": "calendar.png",
"text": "日期选择",
"className": "Calendar"
},
"textarea": {
"icon": "textarea.png",
"text": "多行文本",
"className": "Textarea"
},
"select": {
"icon": "select.png",
"text": "下拉框",
"className": "Select"
},
"radio": {
"icon": "radio.png",
"text": "单选框",
"className": "Radio"
},
"checkbox": {
"icon": "checkbox.png",
"text": "多选框",
"className": "Checkbox"
},
"button": {
"icon": "button.png",
"text": "按钮",
"className": "Button"
},
"Actionbar": {
"icon": "actionbar.png",
"text": "操作条",
"className": "Actionbar"
},
"image": {
"icon": "image.png",
"text": "图片",
"className": "Image"
},
"image": {
"icon": "attachment.png",
"text": "附件",
"className": "Attachment"
},
"div": {
"icon": "div.png",
"text": "容器",
"className": "Div"
},
"table": {
"icon": "table.png",
"text": "表格",
"className": "Table"
},
"datagrid": {
"icon": "datagrid.png",
"text": "数据网格",
"className": "Datagrid"
},
"html": {
"icon": "html.png",
"text": "HTML",
"className": "Html"
},
"tab": {
"icon": "tabs.png",
"text": "分页",
"className": "Tab"
},
"tree": {
"icon": "tree.png",
"text": "树",
"className": "Tree"
},
"log": {
"icon": "log.png",
"text": "流程记录",
"className": "Log"
},
"monitor": {
"icon": "monitor.png",
"text": "流程监控",
"className": "Monitor"
},
"iframe": {
"icon": "iframe.png",
"text": "Iframe",
"className": "Iframe"
},
"htmledit": {
"icon": "htmleditor.png",
"text": "HTML编辑器",
"className": "Htmleditor"
},
"office": {
"icon": "office.png",
"text": "Office控件",
"className": "Office"
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册