From f2a57ad40311bd5ffc6c316106cb0885e8ead4fe Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 22 Jun 2022 14:49:26 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feature:=20=E9=80=89=E4=B8=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/multiselect.loader.js | 45 ++++++++++++------- .../multiselect/multiselect.loader.nobar.js | 41 ++++++++++------- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/src/widget/multiselect/multiselect.loader.js b/src/widget/multiselect/multiselect.loader.js index f01ac18bc..6ab276164 100644 --- a/src/widget/multiselect/multiselect.loader.js +++ b/src/widget/multiselect/multiselect.loader.js @@ -18,7 +18,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { valueFormatter: BI.emptyFn, itemsCreator: BI.emptyFn, onLoaded: BI.emptyFn, - itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, + itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT }); }, @@ -64,23 +64,22 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { }, opts.el), itemsCreator: function (op, callback) { var startValue = self._startValue; + var firstItems = []; self.storeValue && (op = BI.extend(op || {}, { selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi ? self.storeValue.value.concat(startValue) : self.storeValue.value })); - opts.itemsCreator(op, function (ob) { - hasNext = ob.hasNext; - var firstItems = []; - if (op.times === 1 && self.storeValue) { - var json = BI.map(self.storeValue.value, function (i, v) { - var txt = opts.valueFormatter(v) || v; - return { - text: txt, - value: v, - title: txt, - selected: self.storeValue.type === BI.Selection.Multi - }; - }); + if (self.storeValue) { + var json = BI.map(self.storeValue.value.slice((op.times - 1) * 10, op.times * 10), function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: self.storeValue.type === BI.Selection.Multi + }; + }); + if (op.times === 1) { if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { var txt = opts.valueFormatter(startValue) || startValue; json.unshift({ @@ -90,10 +89,22 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { selected: true }); } - firstItems = self._createItems(json); } + if (op.times < Math.floor((self.storeValue.value.length - 1) / 10)) { + hasNext = true; + callback(self._createItems(json), op.keyword || ""); + (op.times === 1) && self._scrollToTop(); + return; + } + firstItems = self._createItems(json); + } + var times = op.times - Math.max(0, Math.floor((self.storeValue.value.length - 1) / 10)); + opts.itemsCreator(BI.extend({}, op, { + times: times + }), function (ob) { + hasNext = ob.hasNext; callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); - if (op.times === 1 && self.storeValue) { + if (times === 1 && self.storeValue) { BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); self.setValue(self.storeValue); } @@ -190,4 +201,4 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { }); BI.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multi_select_loader", BI.MultiSelectLoader); \ No newline at end of file +BI.shortcut("bi.multi_select_loader", BI.MultiSelectLoader); diff --git a/src/widget/multiselect/multiselect.loader.nobar.js b/src/widget/multiselect/multiselect.loader.nobar.js index d7744d042..5bcb02551 100644 --- a/src/widget/multiselect/multiselect.loader.nobar.js +++ b/src/widget/multiselect/multiselect.loader.nobar.js @@ -55,23 +55,22 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { }, itemsCreator: function (op, callback) { var startValue = self._startValue; + var firstItems = []; self.storeValue && (op = BI.extend(op || {}, { selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi ? self.storeValue.value.concat(startValue) : self.storeValue.value })); - opts.itemsCreator(op, function (ob) { - hasNext = ob.hasNext; - var firstItems = []; - if (op.times === 1 && self.storeValue) { - var json = BI.map(self.storeValue.value, function (i, v) { - var txt = opts.valueFormatter(v) || v; - return { - text: txt, - value: v, - title: txt, - selected: self.storeValue.type === BI.Selection.Multi - }; - }); + if (self.storeValue) { + var json = BI.map(self.storeValue.value.slice((op.times - 1) * 100, op.times * 100), function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: self.storeValue.type === BI.Selection.Multi + }; + }); + if (op.times === 1) { if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { var txt = opts.valueFormatter(startValue) || startValue; json.unshift({ @@ -81,10 +80,22 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { selected: true }); } - firstItems = self._createItems(json); } + if (op.times < Math.floor((self.storeValue.value.length - 1) / 100)) { + hasNext = true; + callback(self._createItems(json), op.keyword || ""); + (op.times === 1) && self._scrollToTop(); + return; + } + firstItems = self._createItems(json); + } + var times = op.times - Math.max(0, Math.floor((self.storeValue.value.length - 1) / 100)); + opts.itemsCreator(BI.extend({}, op, { + times: times + }), function (ob) { + hasNext = ob.hasNext; callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); - if (op.times === 1 && self.storeValue) { + if (times === 1 && self.storeValue) { BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); self.setValue(self.storeValue); } From f15b0f1156259e85769008f01cb5d69ae8273dd2 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 22 Jun 2022 14:50:32 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feature:=20=E9=80=89=E4=B8=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/multiselect.loader.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widget/multiselect/multiselect.loader.js b/src/widget/multiselect/multiselect.loader.js index 6ab276164..e7e3b2113 100644 --- a/src/widget/multiselect/multiselect.loader.js +++ b/src/widget/multiselect/multiselect.loader.js @@ -70,7 +70,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { ? self.storeValue.value.concat(startValue) : self.storeValue.value })); if (self.storeValue) { - var json = BI.map(self.storeValue.value.slice((op.times - 1) * 10, op.times * 10), function (i, v) { + var json = BI.map(self.storeValue.value.slice((op.times - 1) * 100, op.times * 100), function (i, v) { var txt = opts.valueFormatter(v) || v; return { text: txt, @@ -90,7 +90,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { }); } } - if (op.times < Math.floor((self.storeValue.value.length - 1) / 10)) { + if (op.times < Math.floor((self.storeValue.value.length - 1) / 100)) { hasNext = true; callback(self._createItems(json), op.keyword || ""); (op.times === 1) && self._scrollToTop(); @@ -98,7 +98,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { } firstItems = self._createItems(json); } - var times = op.times - Math.max(0, Math.floor((self.storeValue.value.length - 1) / 10)); + var times = op.times - Math.max(0, Math.floor((self.storeValue.value.length - 1) / 100)); opts.itemsCreator(BI.extend({}, op, { times: times }), function (ob) { From f32bd9861253ee0cae3f6dd58ab9b9dd3dc6ab7f Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 22 Jun 2022 14:54:59 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feature:=20=E9=80=89=E4=B8=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/multiselect.loader.js | 2 +- src/widget/multiselect/multiselect.loader.nobar.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widget/multiselect/multiselect.loader.js b/src/widget/multiselect/multiselect.loader.js index e7e3b2113..0b86f44d4 100644 --- a/src/widget/multiselect/multiselect.loader.js +++ b/src/widget/multiselect/multiselect.loader.js @@ -103,7 +103,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { times: times }), function (ob) { hasNext = ob.hasNext; - callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || op.keyword || ""); if (times === 1 && self.storeValue) { BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); self.setValue(self.storeValue); diff --git a/src/widget/multiselect/multiselect.loader.nobar.js b/src/widget/multiselect/multiselect.loader.nobar.js index 5bcb02551..95c8f6fbc 100644 --- a/src/widget/multiselect/multiselect.loader.nobar.js +++ b/src/widget/multiselect/multiselect.loader.nobar.js @@ -94,7 +94,7 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { times: times }), function (ob) { hasNext = ob.hasNext; - callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || op.keyword || ""); if (times === 1 && self.storeValue) { BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); self.setValue(self.storeValue); From 291554ecb46300820be50fcfc7449c951e24c7f2 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 23 Jun 2022 18:20:31 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feature:=20=E9=80=89=E4=B8=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/loader.js | 244 +++++++++++++++++++ src/widget/multiselect/multiselect.loader.js | 63 ++--- 2 files changed, 262 insertions(+), 45 deletions(-) create mode 100644 src/widget/multiselect/loader.js diff --git a/src/widget/multiselect/loader.js b/src/widget/multiselect/loader.js new file mode 100644 index 000000000..7eddae550 --- /dev/null +++ b/src/widget/multiselect/loader.js @@ -0,0 +1,244 @@ +/** + * 加载控件 + * + * Created by GUY on 2015/8/31. + * @class BI.Loader + * @extends BI.Widget + */ +BI.MultiSelectInnerLoader = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectInnerLoader.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-inner-loader", + + direction: "top", + isDefaultInit: true, // 是否默认初始化数据 + logic: { + dynamic: true, + scrolly: true + }, + + // 下面是button_group的属性 + el: { + type: "bi.button_group", + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + behaviors: { + redmark: function () { + return true; + } + }, + layouts: [{ + type: "bi.vertical" + }] + }, + + items: [], + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn, + + // 下面是分页信息 + count: false, + prev: false, + next: {}, + hasPrev: BI.emptyFn, + hasNext: BI.emptyFn + }); + }, + + _nextLoad: function () { + var self = this, o = this.options; + this.next.setLoading(); + if (this.cachItems && this.cachItems.length > 0) { + this.next.setLoaded(); + this.addItems(this.cachItems.slice(0, 10)); + this.cachItems = this.cachItems.slice(10); + return; + } + o.itemsCreator.apply(this, [{times: ++this.times}, function () { + self.next.setLoaded(); + self.addItems.apply(self, arguments); + }]); + }, + + render: function () { + var self = this, o = this.options; + if (o.itemsCreator === false) { + o.next = false; + } + this.button_group = BI.createWidget(o.el, { + type: "bi.button_group", + chooseType: 0, + items: o.items, + behaviors: {}, + layouts: [{ + type: "bi.vertical" + }], + value: o.value + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { + if (type === BI.Events.CLICK) { + var node = self.cachGroup.getNodeByValue(value); + if (node) { + node.setSelected(obj.isSelected()); + } + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.Loader.EVENT_CHANGE, obj); + } + }); + + this.cachGroup = BI.createWidget(o.el, { + type: "bi.button_group", + root: true, + chooseType: 0, + items: o.items, + behaviors: {}, + layouts: [{ + type: "bi.vertical" + }], + value: o.value + }); + + if (o.next !== false) { + this.next = BI.createWidget(BI.extend({ + type: "bi.loading_bar" + }, o.next)); + this.next.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + self._nextLoad(); + } + }); + } + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.button_group, this.next] + }); + + o.isDefaultInit && BI.isEmpty(o.items) && BI.nextTick(BI.bind(function () { + o.isDefaultInit && BI.isEmpty(o.items) && this._populate(); + }, this)); + }, + + hasNext: function () { + var o = this.options; + if (BI.isNumber(o.count)) { + return this.count < o.count; + } + if (this.cachItems && this.cachItems.length > 0) { + return true; + } + return !!o.hasNext.apply(this, [{ + times: this.times, + count: this.count + }]); + }, + + addItems: function (items) { + this.count += items.length; + if (BI.isObject(this.next)) { + if (this.hasNext()) { + this.options.items = this.options.items.concat(items); + this.next.setLoaded(); + } else { + this.next.setEnd(); + } + } + this.cachGroup.addItems.apply(this.cachGroup, arguments); + this.button_group.addItems.apply(this.button_group, arguments); + }, + + _populate: function (items) { + var self = this, o = this.options; + if (arguments.length === 0 && (BI.isFunction(o.itemsCreator))) { + o.itemsCreator.apply(this, [{times: 1}, function (items, keyword) { + if (arguments.length === 0) { + throw new Error("参数不能为空"); + } + self.populate.apply(self, arguments); + o.onLoaded(); + }]); + return false; + } + this.options.items = (items || []).slice(0, 10); + this.times = 1; + this.count = 0; + this.count += items.length; + if (BI.isObject(this.next)) { + if (this.hasNext()) { + this.next.setLoaded(); + } else { + this.next.invisible(); + } + } + return true; + }, + + populate: function (items, keyword) { + if (this._populate.apply(this, arguments)) { + this.cachItems = []; + if (items.length > 10) { + this.cachItems = items.slice(10); + } + this.cachGroup.populate.call(this.cachGroup, items, keyword); + this.button_group.populate.call(this.button_group, items.slice(0, 10), keyword); + } + }, + + setNotSelectedValue: function () { + this.button_group.setNotSelectedValue.apply(this.button_group, arguments); + this.cachGroup.setNotSelectedValue.apply(this.cachGroup, arguments); + }, + + getNotSelectedValue: function () { + return this.cachGroup.getNotSelectedValue(); + }, + + setValue: function () { + this.cachGroup.setValue.apply(this.cachGroup, arguments); + this.button_group.setValue.apply(this.button_group, arguments); + }, + + getValue: function () { + return this.cachGroup.getValue.apply(this.cachGroup, arguments); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + getAllLeaves: function () { + return this.button_group.getAllLeaves(); + }, + + getSelectedButtons: function () { + return this.button_group.getSelectedButtons(); + }, + + getNotSelectedButtons: function () { + return this.button_group.getNotSelectedButtons(); + }, + + getIndexByValue: function (value) { + return this.button_group.getIndexByValue(value); + }, + + getNodeById: function (id) { + return this.button_group.getNodeById(id); + }, + + getNodeByValue: function (value) { + return this.button_group.getNodeByValue(value); + }, + + empty: function () { + this.button_group.empty(); + this.cachGroup.empty(); + BI.each([this.prev, this.next], function (i, ob) { + ob && ob.setVisible(false); + }); + } +}); +BI.MultiSelectInnerLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multi_select_inner_loader", BI.MultiSelectInnerLoader); diff --git a/src/widget/multiselect/multiselect.loader.js b/src/widget/multiselect/multiselect.loader.js index 0b86f44d4..d344c09ae 100644 --- a/src/widget/multiselect/multiselect.loader.js +++ b/src/widget/multiselect/multiselect.loader.js @@ -18,7 +18,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { valueFormatter: BI.emptyFn, itemsCreator: BI.emptyFn, onLoaded: BI.emptyFn, - itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, }); }, @@ -43,43 +43,28 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { el: BI.extend({ onLoaded: opts.onLoaded, el: { - type: "bi.loader", - isDefaultInit: false, - logic: { - dynamic: true, - scrolly: true - }, - el: { - chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, - behaviors: { - redmark: function () { - return true; - } - }, - layouts: [{ - type: "bi.vertical" - }] - } + type: "bi.multi_select_inner_loader", } }, opts.el), itemsCreator: function (op, callback) { var startValue = self._startValue; - var firstItems = []; self.storeValue && (op = BI.extend(op || {}, { selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi ? self.storeValue.value.concat(startValue) : self.storeValue.value })); - if (self.storeValue) { - var json = BI.map(self.storeValue.value.slice((op.times - 1) * 100, op.times * 100), function (i, v) { - var txt = opts.valueFormatter(v) || v; - return { - text: txt, - value: v, - title: txt, - selected: self.storeValue.type === BI.Selection.Multi - }; - }); - if (op.times === 1) { + opts.itemsCreator(op, function (ob) { + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && self.storeValue) { + var json = BI.map(self.storeValue.value, function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: self.storeValue.type === BI.Selection.Multi + }; + }); if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { var txt = opts.valueFormatter(startValue) || startValue; json.unshift({ @@ -89,22 +74,10 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { selected: true }); } + firstItems = self._createItems(json); } - if (op.times < Math.floor((self.storeValue.value.length - 1) / 100)) { - hasNext = true; - callback(self._createItems(json), op.keyword || ""); - (op.times === 1) && self._scrollToTop(); - return; - } - firstItems = self._createItems(json); - } - var times = op.times - Math.max(0, Math.floor((self.storeValue.value.length - 1) / 100)); - opts.itemsCreator(BI.extend({}, op, { - times: times - }), function (ob) { - hasNext = ob.hasNext; - callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || op.keyword || ""); - if (times === 1 && self.storeValue) { + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + if (op.times === 1 && self.storeValue) { BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); self.setValue(self.storeValue); } From b2fc2f50e32a16c0461d9da240b52b6f8b58726c Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 23 Jun 2022 18:21:22 +0800 Subject: [PATCH 5/6] =?UTF-8?q?feature:=20=E9=80=89=E4=B8=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../multiselect/multiselect.loader.nobar.js | 43 +++++++------------ 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/src/widget/multiselect/multiselect.loader.nobar.js b/src/widget/multiselect/multiselect.loader.nobar.js index 95c8f6fbc..d7744d042 100644 --- a/src/widget/multiselect/multiselect.loader.nobar.js +++ b/src/widget/multiselect/multiselect.loader.nobar.js @@ -55,22 +55,23 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { }, itemsCreator: function (op, callback) { var startValue = self._startValue; - var firstItems = []; self.storeValue && (op = BI.extend(op || {}, { selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi ? self.storeValue.value.concat(startValue) : self.storeValue.value })); - if (self.storeValue) { - var json = BI.map(self.storeValue.value.slice((op.times - 1) * 100, op.times * 100), function (i, v) { - var txt = opts.valueFormatter(v) || v; - return { - text: txt, - value: v, - title: txt, - selected: self.storeValue.type === BI.Selection.Multi - }; - }); - if (op.times === 1) { + opts.itemsCreator(op, function (ob) { + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && self.storeValue) { + var json = BI.map(self.storeValue.value, function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: self.storeValue.type === BI.Selection.Multi + }; + }); if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { var txt = opts.valueFormatter(startValue) || startValue; json.unshift({ @@ -80,22 +81,10 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { selected: true }); } + firstItems = self._createItems(json); } - if (op.times < Math.floor((self.storeValue.value.length - 1) / 100)) { - hasNext = true; - callback(self._createItems(json), op.keyword || ""); - (op.times === 1) && self._scrollToTop(); - return; - } - firstItems = self._createItems(json); - } - var times = op.times - Math.max(0, Math.floor((self.storeValue.value.length - 1) / 100)); - opts.itemsCreator(BI.extend({}, op, { - times: times - }), function (ob) { - hasNext = ob.hasNext; - callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || op.keyword || ""); - if (times === 1 && self.storeValue) { + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + if (op.times === 1 && self.storeValue) { BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); self.setValue(self.storeValue); } From 03a1a7b2ffa5c0613733b9fd6c0a6b4cc6aa91fb Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 23 Jun 2022 18:24:28 +0800 Subject: [PATCH 6/6] =?UTF-8?q?feature:=20=E9=80=89=E4=B8=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/loader.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/widget/multiselect/loader.js b/src/widget/multiselect/loader.js index 7eddae550..f6b6bd3de 100644 --- a/src/widget/multiselect/loader.js +++ b/src/widget/multiselect/loader.js @@ -49,8 +49,8 @@ BI.MultiSelectInnerLoader = BI.inherit(BI.Widget, { this.next.setLoading(); if (this.cachItems && this.cachItems.length > 0) { this.next.setLoaded(); - this.addItems(this.cachItems.slice(0, 10)); - this.cachItems = this.cachItems.slice(10); + this.addItems(this.cachItems.slice(0, 100)); + this.cachItems = this.cachItems.slice(100); return; } o.itemsCreator.apply(this, [{times: ++this.times}, function () { @@ -161,7 +161,7 @@ BI.MultiSelectInnerLoader = BI.inherit(BI.Widget, { }]); return false; } - this.options.items = (items || []).slice(0, 10); + this.options.items = (items || []).slice(0, 100); this.times = 1; this.count = 0; this.count += items.length; @@ -178,11 +178,11 @@ BI.MultiSelectInnerLoader = BI.inherit(BI.Widget, { populate: function (items, keyword) { if (this._populate.apply(this, arguments)) { this.cachItems = []; - if (items.length > 10) { - this.cachItems = items.slice(10); + if (items.length > 100) { + this.cachItems = items.slice(100); } this.cachGroup.populate.call(this.cachGroup, items, keyword); - this.button_group.populate.call(this.button_group, items.slice(0, 10), keyword); + this.button_group.populate.call(this.button_group, items.slice(0, 100), keyword); } },