forked from fanruan/fineui
刘荣歆
7 years ago
3 changed files with 83 additions and 97 deletions
@ -1,31 +0,0 @@
|
||||
/** |
||||
* Created by Dailer on 2017/7/12. |
||||
*/ |
||||
Demo.MultiSelectCombo = BI.inherit(BI.Widget, { |
||||
props: { |
||||
baseCls: "demo-exceltable" |
||||
}, |
||||
|
||||
render: function () { |
||||
var self = this; |
||||
return { |
||||
type: "bi.horizontal_auto", |
||||
items: [{ |
||||
type: "bi.multi_select_combo", |
||||
ref: function (_ref) { |
||||
self.numerical = _ref; |
||||
}, |
||||
itemsCreator:BI.emptyFn |
||||
}, { |
||||
type: "bi.label", |
||||
ref: function (_ref) { |
||||
self.label = _ref; |
||||
}, |
||||
text: "显示结果" |
||||
}], |
||||
vgap: 20 |
||||
} |
||||
} |
||||
}) |
||||
|
||||
BI.shortcut("demo.musdflti_select_combo", Demo.MultiSelectCombo); |
@ -0,0 +1,83 @@
|
||||
/** |
||||
* Created by User on 2017/3/22. |
||||
*/ |
||||
Demo.MultiSelectCombo = BI.inherit(BI.Widget, { |
||||
props: { |
||||
baseCls: "demo-multi-select-combo" |
||||
}, |
||||
|
||||
_createMultiSelectCombo: function () { |
||||
var self = this; |
||||
var widget = BI.createWidget({ |
||||
type: 'bi.multi_select_combo', |
||||
itemsCreator: BI.bind(this._itemsCreator, this), |
||||
width: 200 |
||||
}); |
||||
|
||||
widget.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () { |
||||
BI.Msg.toast(JSON.stringify(this.getValue())); |
||||
}); |
||||
|
||||
return widget; |
||||
}, |
||||
|
||||
_getItemsByTimes: function (items, times) { |
||||
var res = []; |
||||
for (var i = (times - 1) * 3; items[i] && i < times * 3; i++) { |
||||
res.push(items[i]); |
||||
} |
||||
return res; |
||||
}, |
||||
|
||||
_hasNextByTimes: function (items, times) { |
||||
return times * 3 < items.length; |
||||
}, |
||||
|
||||
_itemsCreator: function (options, callback) { |
||||
var self = this; |
||||
var items = Demo.CONSTANTS.ITEMS; |
||||
var keywords = (options.keywords || []).slice(); |
||||
if (options.keyword) { |
||||
keywords.push(options.keyword); |
||||
} |
||||
BI.each(keywords, function (i, kw) { |
||||
var search = BI.Func.getSearchResult(items, kw); |
||||
items = search.matched.concat(search.finded); |
||||
}); |
||||
if (options.selected_values) {//过滤
|
||||
var filter = BI.makeObject(options.selected_values, true); |
||||
items = BI.filter(items, function (i, ob) { |
||||
return !filter[ob.value]; |
||||
}); |
||||
} |
||||
if (options.type == BI.MultiSelectCombo.REQ_GET_ALL_DATA) { |
||||
callback({ |
||||
items: items |
||||
}); |
||||
return; |
||||
} |
||||
if (options.type == BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) { |
||||
callback({count: items.length}); |
||||
return; |
||||
} |
||||
BI.delay(function () { |
||||
callback({ |
||||
items: self._getItemsByTimes(items, options.times), |
||||
hasNext: self._hasNextByTimes(items, options.times) |
||||
}); |
||||
}, 1000); |
||||
}, |
||||
|
||||
render: function () { |
||||
return { |
||||
type: 'bi.absolute', |
||||
scrolly: false, |
||||
items: [{ |
||||
el: this._createMultiSelectCombo(), |
||||
right: "50%", |
||||
top: 10 |
||||
}] |
||||
} |
||||
} |
||||
}); |
||||
BI.shortcut("demo.multi_select_combo", Demo.MultiSelectCombo); |
@ -1,66 +0,0 @@
|
||||
/** |
||||
* Created by User on 2017/3/22. |
||||
*/ |
||||
Demo.MultiSelectCombo = BI.inherit(BI.Widget, { |
||||
props: {}, |
||||
|
||||
render: function (vessel) { |
||||
var TREEWITHCHILDREN = [{ |
||||
id: -1, value: "根目录", text: "根目录", children: [ |
||||
{ |
||||
id: 1, value: "第一级目录1", text: "第一级目录1", children: [ |
||||
{id: 11, value: "第二级文件1", text: "第二级文件1"}, |
||||
{ |
||||
id: 12, value: "第二级目录2", text: "第二级目录2", children: [ |
||||
{ |
||||
id: 121, value: "第三级目录1", text: "第三级目录1", children: [ |
||||
{ |
||||
id: 1211, value: "第四级目录1", text: "第四级目录1", children: [ |
||||
{id: 12111, value: "第五级文件1", text: "第五级文件1"} |
||||
] |
||||
} |
||||
] |
||||
}, |
||||
{id: 122, value: "第三级文件1", text: "第三级文件1"} |
||||
] |
||||
} |
||||
] |
||||
}, |
||||
{ |
||||
id: 2, value: "第一级目录2", text: "第一级目录2", children: [ |
||||
{ |
||||
id: 21, value: "第二级目录3", text: "第二级目录3", children: [ |
||||
{ |
||||
id: 211, value: "第三级目录2", text: "第三级目录2", children: [ |
||||
{id: 2111, value: "第四级文件1", text: "第四级文件1"} |
||||
] |
||||
}, |
||||
{id: 212, value: "第三级文件2", text: "第三级文件2"} |
||||
] |
||||
}, |
||||
{id: 22, value: "第二级文件2", text: "第二级文件2"} |
||||
] |
||||
} |
||||
] |
||||
}]; |
||||
var items = BI.deepClone(TREEWITHCHILDREN); |
||||
var combo = BI.createWidget({ |
||||
type: "bi.multilayer_select_tree_combo", |
||||
}); |
||||
|
||||
combo.populate(items); |
||||
return { |
||||
type: "bi.vertical", |
||||
items: [combo, { |
||||
type: "bi.button", |
||||
width: 100, |
||||
text: "getValue", |
||||
handler: function () { |
||||
BI.Msg.alert("", JSON.stringify(combo.getValue())); |
||||
} |
||||
}], |
||||
vgap: 100 |
||||
} |
||||
} |
||||
}); |
||||
BI.shortcut("demo.multilayer_select_tree_combo", Demo.MultiSelectCombo); |
Loading…
Reference in new issue