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