提交 b3afd105 编写于 作者: 蔡祥熠

Merge branch 'feature/JSDoc' into 'wrdp'

Merge of feature/JSDoc 增加树组件的各种事件 to wrdp

See merge request o2oa/o2oa!2638
......@@ -16,7 +16,8 @@ o2.widget.Tree = new Class({
"action": "action",
"icon": "icon",
"style": "",
"sub": "sub"
"sub": "sub",
"defalut" : "defalut"
},
initialize: function(container, options){
this.setOptions(options);
......@@ -155,6 +156,7 @@ o2.widget.Tree = new Class({
obj[this.jsonMapping.text] = options.text;
obj[this.jsonMapping.action] = options.action;
obj[this.jsonMapping.style] = options.style;
obj[this.jsonMapping.defalut] = options.defalut;
obj[this.jsonMapping.icon] = (options.icon) ? options.icon : "none";
return obj;
}
......@@ -169,6 +171,7 @@ o2.widget.Tree.Node = new Class({
"text": "",
"action": "",
"style": "",
"default" : false,
"icon": "folder.png"
},
imgs: {
......@@ -225,6 +228,9 @@ o2.widget.Tree.Node = new Class({
},
load: function(){
debugger;
this.tree.fireEvent("beforeLoadTreeNode", [this]);
this.nodeTable = new Element("table", {
"border": "0",
"cellpadding": "0",
......@@ -246,6 +252,7 @@ o2.widget.Tree.Node = new Class({
this.createIconNode();
this.createTextNode();
this.tree.fireEvent("afterLoadTreeNode", [this]);
},
createLevelNode: function(){
for (var i=0; i<this.level; i++){
......@@ -335,6 +342,9 @@ o2.widget.Tree.Node = new Class({
}.bind(this));
textDivNode.inject(this.textNode);
if( this.options.default ){
textDivNode.click();
}
},
clickNode: function(e){
this.selectNode(e);
......@@ -342,6 +352,7 @@ o2.widget.Tree.Node = new Class({
},
selectNode: function(){
this.tree.fireEvent("beforeSelect", [this]);
if (this.tree.currentNode){
var textDivNode = this.tree.currentNode.textNode.getElement("div");
textDivNode.setStyles(this.tree.css.textDivNode);
......@@ -359,6 +370,7 @@ o2.widget.Tree.Node = new Class({
}
}
this.tree.currentNode = this;
this.tree.fireEvent("afterSelect", [this]);
},
doAction: function(e){
var t = typeOf(this.options.action);
......
......@@ -32,6 +32,38 @@
"code": "",
"html": ""
},
"beforeLoadTree": {
"code": "",
"html": ""
},
"afterLoadTree": {
"code": "",
"html": ""
},
"beforeLoadTreeNode": {
"code": "",
"html": ""
},
"afterLoadTreeNode": {
"code": "",
"html": ""
},
"expand": {
"code": "",
"html": ""
},
"collapse": {
"code": "",
"html": ""
},
"beforeSelect": {
"code": "",
"html": ""
},
"afterSelect": {
"code": "",
"html": ""
},
"click": {
"code": "",
"html": ""
......
......@@ -32,6 +32,38 @@
"code": "",
"html": ""
},
"beforeLoadTree": {
"code": "",
"html": ""
},
"afterLoadTree": {
"code": "",
"html": ""
},
"beforeLoadTreeNode": {
"code": "",
"html": ""
},
"afterLoadTreeNode": {
"code": "",
"html": ""
},
"expand": {
"code": "",
"html": ""
},
"collapse": {
"code": "",
"html": ""
},
"beforeSelect": {
"code": "",
"html": ""
},
"afterSelect": {
"code": "",
"html": ""
},
"click": {
"code": "",
"html": ""
......
......@@ -33,7 +33,7 @@ MWF.xApplication.process.Xform.$Module = MWF.APP$Module = new Class(
* @member {Element}
* @example
* //可以在脚本中获取该组件
* var field = this.form.get("moduleId"); //获取组件对象
* var field = this.form.get("fieldId"); //获取组件对象
* field.node.setStyle("font-size","12px"); //给节点设置样式
*/
this.node = $(node);
......
MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
MWF.xApplication.process.Xform.Tree = MWF.APPTree = new Class({
/**树组件数据结构
* @typedef {Object} TreeData
* @example
* [
* {
* "expand": true, //是否默认展开
* "title": "", //鼠标移上叶子节点的文字
* "text": "根节点", //叶子节点的文字
* "action": "", //执行的脚本
* "default": true, //是否默认选中
* "icon": "folder.png", //图标
* "sub": [ //改节点的子节点
* {
* "expand": true,
* "title": "",
* "text": "[none]",
* "action": "",
* "default": false,
* "icon": "folder.png",
* "sub": []
* },
* ...
* ]
* }
* ]
*/
/** @class Tree 树组件。
* @example
* //可以在脚本中获取该组件
* //方法1:
* var datagrid = this.form.get("name"); //获取组件
* //方法2
* var datagrid = this.target; //在组件事件脚本中获取
* @see {@link TreeData|树组件数据结构}
* @extends MWF.xApplication.process.Xform.$Module
* @category FormComponents
* @hideconstructor
*/
MWF.xApplication.process.Xform.Tree = MWF.APPTree = new Class(
/** @lends MWF.xApplication.process.Xform.Tree# */
{
Extends: MWF.APP$Module,
options: {
/**
* 异步加载树前执行。this.target指向当前组件。
* @event MWF.xApplication.process.Xform.Tree#beforeLoadTree
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* 异步加载树后执行。this.target指向当前组件。
* @event MWF.xApplication.process.Xform.Tree#afterLoadTree
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* 加载树的叶子前执行。this.target指向加载的叶子。
* @event MWF.xApplication.process.Xform.Tree#beforeLoadTreeNode
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* 加载树的叶子后执行。this.target指向加载的叶子。
* @event MWF.xApplication.process.Xform.Tree#afterLoadTreeNode
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* 加载树的叶子后执行。this.target指向加载的叶子。
* @event MWF.xApplication.process.Xform.Tree#expand
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* 折叠节点的时候执行。this.target指向被折叠的节点。
* @event MWF.xApplication.process.Xform.Tree#collapse
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* 选中节点前执行。此时原来被选中的节点还未取消。this.target指向选中的节点。
* @event MWF.xApplication.process.Xform.Tree#beforeSelect
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
/**
* 选中节点后执行。this.target指向选中的节点。
* @event MWF.xApplication.process.Xform.Tree#afterSelect
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/
"moduleEvents": ["load", "queryLoad", "postLoad", "beforeLoadTree", "afterLoadTree", "beforeLoadTreeNode", "afterLoadTreeNode", "expand", "collapse", "beforeSelect", "afterSelect"]
},
_loadUserInterface: function(){
this.node.empty();
MWF.require("MWF.widget.Tree", function(){
this.tree = new MWF.widget.Tree(this.node, {"style":"form"});
var options = {"style":"form"};
if( this.json.events && typeOf(this.json.events) === "object" ){
[
{ "beforeLoadTree" : "onQueryLoad" },
{ "afterLoadTree" : "onPostLoad" },
{ "beforeLoadTreeNode" : "onBeforeLoadTreeNode" },
{ "afterLoadTreeNode" : "onAfterLoadTreeNode" },
{ "expand" : "onPostExpand" },
{ "collapse" : "onPostCollapse" },
{ "beforeSelect" : "onBeforeSelect" },
{ "afterSelect" : "onAfterSelect" }
].each( function (obj) {
var moduleEvent = Object.keys(obj)[0];
var treeEvent = obj[moduleEvent];
if( this.json.events[moduleEvent] && this.json.events[moduleEvent].code ){
options[treeEvent] = function( target ){
return this.form.Macro.fire(this.json.events[moduleEvent].code, target || this);
}.bind(this)
}
}.bind(this));
}
/**
* @summary 树组件,平台使用该组件实现树的功能,该组件为异步加载
* @member {o2.widget.Tree}
* @example
* //可以在脚本中获取该组件
* var tree = this.form.get("fieldId").tree; //获取组件对象
* var children = tree.children[]; //获取第一层树叶
*/
this.tree = new MWF.widget.Tree(this.node, options);
this.tree.form = this.form;
this._setTreeWidgetStyles();
......
......@@ -229,6 +229,10 @@ MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
"isTime": false,
"target": this.module.designer.content,
"format": "%Y-%m-%d",
"onClear" : function () {
debugger;
this.setValue(jsondata, node.value, node);
}.bind(this),
"onComplate": function () {
this.setValue(jsondata, node.value, node);
//this.validationMode();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册