diff --git a/src/case/colorchooser/colorchooser.js b/src/case/colorchooser/colorchooser.js index d1fc4a74d..b2e1f6999 100644 --- a/src/case/colorchooser/colorchooser.js +++ b/src/case/colorchooser/colorchooser.js @@ -64,12 +64,6 @@ BI.ColorChooser = BI.inherit(BI.Widget, { var fn = function () { var color = self.colorPicker.getValue(); self.trigger.setValue(color); - var colors = BI.string2Array(BI.Cache.getItem("colors") || ""); - var que = new BI.Queue(8); - que.fromArray(colors); - que.remove(color); - que.unshift(color); - BI.Cache.setItem("colors", BI.array2String(que.toArray())); }; this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { self.colorPicker.setStoreColors(BI.string2Array(BI.Cache.getItem("colors") || "")); diff --git a/src/case/colorchooser/colorchooser.popup.js b/src/case/colorchooser/colorchooser.popup.js index 5e4f0b87e..2931c80a0 100644 --- a/src/case/colorchooser/colorchooser.popup.js +++ b/src/case/colorchooser/colorchooser.popup.js @@ -24,43 +24,21 @@ BI.ColorChooserPopup = BI.inherit(BI.Widget, { this.colorEditor.on(BI.ColorPickerEditor.EVENT_CHANGE, function () { self.setValue(this.getValue()); + self._dealStoreColors(); self.fireEvent(BI.ColorChooserPopup.EVENT_VALUE_CHANGE, arguments); }); this.storeColors = BI.createWidget({ type: "bi.color_picker", cls: "bi-border-bottom bi-border-right", - items: [[{ - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }]], + items: [this._digestStoreColors(BI.string2Array(BI.Cache.getItem("colors") || ""))], width: 210, height: 24, value: o.value }); this.storeColors.on(BI.ColorPicker.EVENT_CHANGE, function () { self.setValue(this.getValue()[0]); + self._dealStoreColors(); self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments); }); @@ -73,6 +51,7 @@ BI.ColorChooserPopup = BI.inherit(BI.Widget, { this.colorPicker.on(BI.ColorPicker.EVENT_CHANGE, function () { self.setValue(this.getValue()[0]); + self._dealStoreColors(); self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments); }); @@ -120,6 +99,7 @@ BI.ColorChooserPopup = BI.inherit(BI.Widget, { break; case 1: self.setValue(self.customColorChooser.getValue()); + self._dealStoreColors(); self.more.hideView(); self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments); break; @@ -193,20 +173,36 @@ BI.ColorChooserPopup = BI.inherit(BI.Widget, { this.mask.setVisible(!enable); }, + _dealStoreColors: function () { + var color = this.getValue(); + var colors = BI.string2Array(BI.Cache.getItem("colors") || ""); + var que = new BI.Queue(8); + que.fromArray(colors); + que.remove(color); + que.unshift(color); + var array = que.toArray(); + BI.Cache.setItem("colors", BI.array2String(array)); + this.setStoreColors(array); + }, + + _digestStoreColors: function (colors) { + var items = BI.map(colors, function (i, color) { + return { + value: color + }; + }); + BI.count(colors.length, 8, function (i) { + items.push({ + value: "", + disabled: true + }); + }); + return items; + }, + setStoreColors: function (colors) { if (BI.isArray(colors)) { - var items = BI.map(colors, function (i, color) { - return { - value: color - }; - }); - BI.count(colors.length, 8, function (i) { - items.push({ - value: "", - disabled: true - }); - }); - this.storeColors.populate([items]); + this.storeColors.populate([this._digestStoreColors(colors)]); } }, diff --git a/src/widget/multiselect/multiselect.combo.js b/src/widget/multiselect/multiselect.combo.js index af2f24585..a3afda789 100644 --- a/src/widget/multiselect/multiselect.combo.js +++ b/src/widget/multiselect/multiselect.combo.js @@ -123,7 +123,9 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { self.fireEvent(BI.MultiSelectCombo.EVENT_CLICK_ITEM); }); this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - this.getCounter().setValue(self.storeValue); + // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数) + // 只需要更新查看面板的selectedValue用以请求已选数据 + this.getCounter().updateSelectedValue(self.storeValue); }); this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () { if (!self.combo.isViewVisible()) { diff --git a/src/widget/multiselect/multiselect.insert.combo.js b/src/widget/multiselect/multiselect.insert.combo.js index 1a6671c5b..291e3935a 100644 --- a/src/widget/multiselect/multiselect.insert.combo.js +++ b/src/widget/multiselect/multiselect.insert.combo.js @@ -116,7 +116,9 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, { self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CLICK_ITEM); }); this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - this.getCounter().setValue(self.storeValue); + // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数) + // 只需要更新查看面板的selectedValue用以请求已选数据 + this.getCounter().updateSelectedValue(self.storeValue); }); this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () { if (!self.combo.isViewVisible()) { diff --git a/src/widget/multiselect/multiselect.insert.combo.nobar.js b/src/widget/multiselect/multiselect.insert.combo.nobar.js index f0b61ebb2..dede350d3 100644 --- a/src/widget/multiselect/multiselect.insert.combo.nobar.js +++ b/src/widget/multiselect/multiselect.insert.combo.nobar.js @@ -113,7 +113,9 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, { } }); this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - this.getCounter().setValue(self.storeValue); + // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数) + // 只需要更新查看面板的selectedValue用以请求已选数据 + this.getCounter().updateSelectedValue(self.storeValue); }); this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () { if (!self.combo.isViewVisible()) { diff --git a/src/widget/multiselect/trigger/switcher.checkselected.js b/src/widget/multiselect/trigger/switcher.checkselected.js index 4737bd0ac..c9b000ba7 100644 --- a/src/widget/multiselect/trigger/switcher.checkselected.js +++ b/src/widget/multiselect/trigger/switcher.checkselected.js @@ -42,6 +42,9 @@ BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, { onClickContinueSelect: function () { self.switcher.hideView(); }, + ref: function (_ref) { + self.checkPane = _ref; + }, value: o.value }, o.popup), adapter: o.adapter, @@ -82,6 +85,11 @@ BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, { this.switcher.setValue(v); }, + // 与setValue的区别是只更新查看已选面板的的selectedValue, 不会更新按钮的计数 + updateSelectedValue: function (v) { + this.checkPane.setValue(v); + }, + setButtonChecked: function (v) { this.button.setValue(v); },