Browse Source

Merge pull request #186324 in DEC/fineui from master to feature/x

* commit '3cf6e2640c55f6bfbb9e9b44fc0d467f610eb8b3':
  KERNEL-12250 feat:简化一下combolist的api
research/test
superman 2 years ago
parent
commit
e630640bfe
  1. 6
      demo/js/widget/downlist/demo.downlist.js
  2. 45
      src/widget/downlist/combo.downlist.js

6
demo/js/widget/downlist/demo.downlist.js

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

45
src/widget/downlist/combo.downlist.js

@ -1,7 +1,35 @@
/**
(function() {
function transformItems(items) {
if (!items) return items;
var result = BI.cloneDeep(items);
var isComplexItmes = BI.some(items, function (_, item) {
return BI.isArray(item);
});
// 传一维数组,帮转二维
if (!isComplexItmes) {
result = [result];
}
// 帮转 el
BI.each(result, function (_, arr) {
BI.each(arr, function (_, item) {
if (item.children && !item.el) {
item.el = {
text: item.text,
icon: item.icon,
cls: item.cls,
iconCls1: item.iconCls1,
value: item.value
};
}
});
});
return result;
}
/**
* Created by roy on 15/8/14.
*/
BI.DownListCombo = BI.inherit(BI.Widget, {
BI.DownListCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-down-list-combo",
@ -47,7 +75,7 @@ BI.DownListCombo = BI.inherit(BI.Widget, {
ref: function (ref) {
self.popupView = ref;
},
items: o.items,
items: transformItems(o.items),
chooseType: o.chooseType,
value: o.value,
listeners: [{
@ -102,9 +130,10 @@ BI.DownListCombo = BI.inherit(BI.Widget, {
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.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);
BI.shortcut("bi.down_list_combo", BI.DownListCombo);
}());

Loading…
Cancel
Save