guy 2 years ago
parent
commit
73b66eeb77
  1. 18
      demo/js/widget/downlist/demo.downlist.js
  2. 2
      package.json
  3. 4
      src/component/treevaluechooser/abstract.treevaluechooser.js
  4. 243
      src/widget/downlist/combo.downlist.js

18
demo/js/widget/downlist/demo.downlist.js

@ -47,11 +47,9 @@ Demo.Downlist = BI.inherit(BI.Widget, {
width: 100, width: 100,
items: [ items: [
[{ [{
el: { text: "column 1111",
text: "column 1111", iconCls1: "dot-e-font",
iconCls1: "dot-e-font", value: 12,
value: 12
},
children: [{ children: [{
text: "column 1.1", text: "column 1.1",
value: 21, value: 21,
@ -166,12 +164,10 @@ Demo.Downlist = BI.inherit(BI.Widget, {
}], }],
items: [ items: [
[{ [{
el: { text: "选项一",
text: "选项一", value: 1,
value: 1, icon: {
icon: { type: "demo.downlist.icon",
type: "demo.downlist.icon",
},
}, },
children: [{ children: [{
text: "选项一", text: "选项一",

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "fineui", "name": "fineui",
"version": "2.0.20220926101524", "version": "2.0.20220926194535",
"description": "fineui", "description": "fineui",
"main": "dist/fineui_without_conflict.min.js", "main": "dist/fineui_without_conflict.min.js",
"types": "dist/lib/index.d.ts", "types": "dist/lib/index.d.ts",

4
src/component/treevaluechooser/abstract.treevaluechooser.js

@ -547,7 +547,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
value: nodes[i].value, value: nodes[i].value,
text: nodes[i].text, text: nodes[i].text,
times: 1, times: 1,
isParent: nodes[i].getChildrenLength() > 0, isParent: nodes[i].isParent || nodes[i].getChildrenLength() > 0,
checked: state[0], checked: state[0],
half: state[1], half: state[1],
halfCheck: openState ? false : state[1], halfCheck: openState ? false : state[1],
@ -712,7 +712,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
times: 1, times: 1,
isParent: false, isParent: false,
checked: true, checked: true,
halfCheck: false halfCheck: false,
}; };
}); });
}, },

243
src/widget/downlist/combo.downlist.js

@ -1,110 +1,139 @@
/** (function() {
* Created by roy on 15/8/14. function transformItems(items) {
*/ if (!items) return items;
BI.DownListCombo = BI.inherit(BI.Widget, { var result = BI.cloneDeep(items);
_defaultConfig: function () { var isComplexItmes = BI.some(items, function (_, item) {
return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), { return BI.isArray(item);
baseCls: "bi-down-list-combo",
height: 24,
items: [],
adjustLength: 0,
direction: "bottom",
trigger: "click",
container: null,
stopPropagation: false,
el: {},
minWidth: 140,
maxHeight: 1000,
destroyWhenHide: false
}); });
}, // 传一维数组,帮转二维
if (!isComplexItmes) {
_init: function () { result = [result];
BI.DownListCombo.superclass._init.apply(this, arguments); }
var self = this, o = this.options; // 帮转 el
BI.each(result, function (_, arr) {
this.downlistcombo = BI.createWidget({ BI.each(arr, function (_, item) {
element: this, if (item.children && !item.el) {
type: "bi.combo", item.el = {
trigger: o.trigger, text: item.text,
isNeedAdjustWidth: false, icon: item.icon,
isDefaultInit: true, cls: item.cls,
container: o.container, iconCls1: item.iconCls1,
adjustLength: o.adjustLength, value: item.value
direction: o.direction, };
belowMouse: o.belowMouse, }
stopPropagation: o.stopPropagation, });
destroyWhenHide: o.destroyWhenHide,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls,
width: o.width,
height: o.height
}),
popup: {
el: {
type: "bi.down_list_popup",
ref: function (ref) {
self.popupView = ref;
},
items: o.items,
chooseType: o.chooseType,
value: o.value,
listeners: [{
eventName: BI.DownListPopup.EVENT_CHANGE,
action: function (value) {
self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value);
self.downlistcombo.hideView();
}
}, {
eventName: BI.DownListPopup.EVENT_SON_VALUE_CHANGE,
action: function (value, fatherValue) {
self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
self.downlistcombo.hideView();
}
}]
},
stopPropagation: o.stopPropagation,
maxHeight: o.maxHeight,
minWidth: o.minWidth
}
});
this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW);
}); });
}, return result;
hideView: function () {
this.downlistcombo.hideView();
},
showView: function (e) {
this.downlistcombo.showView(e);
},
populate: function (items) {
this.popupView.populate(items);
},
setValue: function (v) {
this.popupView.setValue(v);
},
getValue: function () {
return this.popupView.getValue();
},
adjustWidth: function () {
this.downlistcombo.adjustWidth();
},
adjustHeight: function () {
this.downlistcombo.adjustHeight();
} }
});
BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE"; /**
BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; * Created by roy on 15/8/14.
BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; */
BI.DownListCombo = BI.inherit(BI.Widget, {
BI.shortcut("bi.down_list_combo", BI.DownListCombo); _defaultConfig: function () {
return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-down-list-combo",
height: 24,
items: [],
adjustLength: 0,
direction: "bottom",
trigger: "click",
container: null,
stopPropagation: false,
el: {},
minWidth: 140,
maxHeight: 1000,
destroyWhenHide: false
});
},
_init: function () {
BI.DownListCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.downlistcombo = BI.createWidget({
element: this,
type: "bi.combo",
trigger: o.trigger,
isNeedAdjustWidth: false,
isDefaultInit: true,
container: o.container,
adjustLength: o.adjustLength,
direction: o.direction,
belowMouse: o.belowMouse,
stopPropagation: o.stopPropagation,
destroyWhenHide: o.destroyWhenHide,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls,
width: o.width,
height: o.height
}),
popup: {
el: {
type: "bi.down_list_popup",
ref: function (ref) {
self.popupView = ref;
},
items: transformItems(o.items),
chooseType: o.chooseType,
value: o.value,
listeners: [{
eventName: BI.DownListPopup.EVENT_CHANGE,
action: function (value) {
self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value);
self.downlistcombo.hideView();
}
}, {
eventName: BI.DownListPopup.EVENT_SON_VALUE_CHANGE,
action: function (value, fatherValue) {
self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
self.downlistcombo.hideView();
}
}]
},
stopPropagation: o.stopPropagation,
maxHeight: o.maxHeight,
minWidth: o.minWidth
}
});
this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW);
});
},
hideView: function () {
this.downlistcombo.hideView();
},
showView: function (e) {
this.downlistcombo.showView(e);
},
populate: function (items) {
this.popupView.populate(items);
},
setValue: function (v) {
this.popupView.setValue(v);
},
getValue: function () {
return this.popupView.getValue();
},
adjustWidth: function () {
this.downlistcombo.adjustWidth();
},
adjustHeight: function () {
this.downlistcombo.adjustHeight();
}
});
BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.down_list_combo", BI.DownListCombo);
}());

Loading…
Cancel
Save