This commit is contained in:
yumoqing 2024-06-21 17:14:05 +08:00
parent dc99fc98cf
commit bff98def06

View File

@ -658,6 +658,7 @@ bricks.UiCode =class extends bricks.UiType {
name:
value:
valueField:
nullable:
textField:
defaultValue:
readonly:
@ -708,7 +709,16 @@ bricks.UiCode =class extends bricks.UiType {
build_options(data){
var e = this.dom_element;
e.replaceChildren();
var v = this.opts.value || this.opts.defaultvalue;
var v = this.opts.value || this.opts.defaultvalue || null;
if (!v && ! this.opts.nullable){
v = data[0][this.opts.valueField]
}
if (this.opts.nullable){
var tmp = {};
tmp[this.opts.valueField] = null;
tmp[this.opts.textField] = '';
data.unshift(tmp);
}
this.value = v;
e.value = v;
this.option_widgets = {};
@ -717,10 +727,6 @@ bricks.UiCode =class extends bricks.UiType {
o.value = data[i][this.opts.valueField||'value'];
o.innerText = bricks.app.i18n._(data[i][this.opts.textField||'text']);
this.option_widgets[o.value] = o;
if (!v && i == 0){
v = o.value;
e.value = o.value;
}
if (o.value == v){
o.selected = true;
}