This commit is contained in:
yumoqing 2024-06-05 16:56:50 +08:00
parent 6a87994bdf
commit 6bb13d7702

View File

@ -181,7 +181,7 @@ bricks.Tree = class extends bricks.VScrollPanel {
this.add_widget(this.container);
this.data_id = null;
if (this.opts.dataurl){
this.params = opts.params || {};
this.params = options.params || {};
schedule_once(this.get_children_data.bind(this, this), 0.1);
} else {
this.user_data = {
@ -190,7 +190,6 @@ bricks.Tree = class extends bricks.VScrollPanel {
}
this.create_node_children(this, this.opts.data);
}
this.bind('node_selected',this.node_info_log.bind(this));
}
getValue(){
var v = this.user_data;
@ -267,6 +266,9 @@ bricks.Tree = class extends bricks.VScrollPanel {
}
append_new_subnode(node, data){
data.is_left = true;
if (!node.user_data){
node.user_data = {};
}
if (!node.user_data.children){
node.user_data.children = [];
}
@ -378,9 +380,14 @@ bricks.Tree = class extends bricks.VScrollPanel {
async get_children_data(node){
var jcall = bricks.jcall;
var p = bricks.extend({}, this.params);
if (node != this){
p.id = node.user_data[this.idField];
}
console.log('params=', p);
var d = await jcall(this.opts.dataurl,{
method : this.opts.method || 'GET',
params : node.params
params : p
})
if (d.length == 0){
node.is_leaf = true;
@ -422,20 +429,11 @@ bricks.Tree = class extends bricks.VScrollPanel {
var cb = event.target.bricks_widget;
var stat = cb.getValue().check;
node.user_data[this.checkField] = stat;
if (stat){
console.log('value=', cb.getValue(), 'node=', node);
}
this.dispatch('check_changed', node.user_data);
}
node_info_log(event){
if (event.params.selected == false){
return;
}
var node = event.params.node;
console.log('======node info========');
console.log('user_data=', node.user_data);
console.log('parent=', node.parent_node);
console.log('container=', node.container);
console.log('======node info end========');
}
}
bricks.Factory.register('Tree', bricks.Tree);