This commit is contained in:
yumoqing 2025-07-30 16:13:24 +08:00
parent f34d761407
commit 1a46504618

View File

@ -10,6 +10,7 @@ bricks.TreeNode = class extends bricks.VBox {
this.parent_node = pnode;
this.children_loaded = false;
this.user_data = data;
this.setup_icon_urls()
this.is_leaf_field = this.tree.is_leafField || 'is_leaf';
this.is_leaf = this.user_data[this.is_leaf_field];
this.params = bricks.extend(this.tree.params, {id:this.user_data[this.tree.opts.idField]});
@ -34,7 +35,6 @@ bricks.TreeNode = class extends bricks.VBox {
}
this.container.hide();
}
this.setup_icon_urls()
}
getValue(){
var v = this.user_data;
@ -124,17 +124,18 @@ bricks.TreeNode = class extends bricks.VBox {
this.check_w.bind('changed', this.tree.node_checked.bind(this.tree, this))
}
var icon_url;
if ( isString(this.icons_urls){
icon_url = this.icons_urls);
if ( isString(this.icons_urls)){
icon_url = this.icons_urls;
} else {
icon_url = this.icons_urls.leaf;
if (this.is_leaf) icon_url = this.icons_urls.leaf;
else if (this.node_state == 'expand') this.icon_url = this.icons_urls.open;
else this.icon_url = this.icons_urls.close;
}
console.log('icons=', this.icons_urls, 'icon_url=', icon_url, this.user_data);
var img = new bricks.Svg({
rate:1,
url:this.icon_url
url:icon_url
});
widget.add_widget(img);
if (this.tree.node_view){
@ -159,10 +160,9 @@ bricks.TreeNode = class extends bricks.VBox {
this.str_w.set_text(this.user_data[this.tree.opts.textField]);
}
setup_icon_urls(){
var icons = null;
if (this.tree.opts.typeField){
var ntype = this.user_data[this.opts.typeField];
var icons = null;
var ntype = this.user_data[this.tree.opts.typeField];
if (this.tree.node_typeicons){
icons = this.tree.node_typeicons[ntype];
if (!icons){
@ -170,6 +170,7 @@ bricks.TreeNode = class extends bricks.VBox {
icons = this.tree.node_typeicons[dt];
}
}
console.log('ntype=', ntype, 'icons=', icons, this.user_data, this.tree.opts.typeField);
}
if (! icons){
icons = {