Browse Source

KERNEL-10944 feat: AllValueChooser内置分页逻辑

es6
zsmj 3 years ago
parent
commit
8cb626d0a2
  1. 17
      src/component/allvaluechooser/abstract.allvaluechooser.js
  2. 7
      src/component/allvaluechooser/pane.allvaluechooser.js
  3. 4
      src/widget/multiselectlist/multiselectlist.js

17
src/component/allvaluechooser/abstract.allvaluechooser.js

@ -40,6 +40,18 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
return text; return text;
}, },
_getItemsByTimes: function (items, times) {
var res = [];
for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
res.push(items[i]);
}
return res;
},
_hasNextByTimes: function (items, times) {
return times * this._const.perPage < items.length;
},
_itemsCreator: function (options, callback) { _itemsCreator: function (options, callback) {
var self = this, o = this.options; var self = this, o = this.options;
if (!o.cache || !this.items) { if (!o.cache || !this.items) {
@ -50,6 +62,7 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
} else { } else {
call(this.items); call(this.items);
} }
function call(items) { function call(items) {
var keywords = (options.keywords || []).slice(); var keywords = (options.keywords || []).slice();
if (options.keyword) { if (options.keyword) {
@ -81,8 +94,8 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
return; return;
} }
callback({ callback({
items: resultItems, items: self._getItemsByTimes(resultItems, options.times),
hasNext: false hasNext: self._hasNextByTimes(resultItems, options.times)
}); });
} }
}, },

7
src/component/allvaluechooser/pane.allvaluechooser.js

@ -50,10 +50,11 @@ BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, {
getValue: function () { getValue: function () {
var val = this.list.getValue() || {}; var val = this.list.getValue() || {};
if (val.type === BI.Selection.All) { if (val.type === BI.Selection.Multi) {
return val.assist;
}
return val.value || []; return val.value || [];
}
return BI.difference(BI.map(this.items, "value"), val.value || []);
}, },
populate: function (items) { populate: function (items) {

4
src/widget/multiselectlist/multiselectlist.js

@ -235,7 +235,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
text: o.valueFormatter(v) || v, text: o.valueFormatter(v) || v,
value: v value: v
}; };
}), this.trigger.getKey()); }), this.trigger.getKeyword());
var change = false; var change = false;
var map = this._makeMap(this.storeValue.value); var map = this._makeMap(this.storeValue.value);
BI.each(BI.concat(result.match, result.find), function (i, obj) { BI.each(BI.concat(result.match, result.find), function (i, obj) {
@ -251,7 +251,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
} }
o.itemsCreator({ o.itemsCreator({
type: BI.MultiSelectList.REQ_GET_ALL_DATA, type: BI.MultiSelectList.REQ_GET_ALL_DATA,
keywords: [this.trigger.getKey()], keywords: [this.trigger.getKeyword()],
selectedValues: BI.filter(this.storeValue.value, function (_i, v) { selectedValues: BI.filter(this.storeValue.value, function (_i, v) {
return !BI.contains(res.value, v); return !BI.contains(res.value, v);
}), }),

Loading…
Cancel
Save