From c10d61889d36dba937a541c5a922bfbac2216f00 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 27 Oct 2021 15:03:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=A1=E5=86=99dataChange=E7=9A=84=E6=95=B4?= =?UTF-8?q?=E7=90=86=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../multiselect/multiselect.insert.combo.nobar.js | 2 +- .../multitextvalue.combo.search.js | 2 +- src/widget/singleselect/singleselect.combo.js | 13 ++++++++++--- .../singleselect/singleselect.insert.combo.js | 12 +++++++++--- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/widget/multiselect/multiselect.insert.combo.nobar.js b/src/widget/multiselect/multiselect.insert.combo.nobar.js index 226cc5260..fe1293a5c 100644 --- a/src/widget/multiselect/multiselect.insert.combo.nobar.js +++ b/src/widget/multiselect/multiselect.insert.combo.nobar.js @@ -401,7 +401,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, { callback(); function adjust () { if (self.wants2Quit === true) { - self.fireEvent(BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM); + self._dataChange && self.fireEvent(BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM); self.wants2Quit = false; } self.requesting = false; diff --git a/src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js b/src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js index def624c1b..cb7fddf9a 100644 --- a/src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js +++ b/src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js @@ -333,7 +333,7 @@ BI.SearchMultiTextValueCombo = BI.inherit(BI.Single, { self._updateAllValue(); self._checkError(); if (self.wants2Quit === true) { - self.fireEvent(BI.SearchMultiTextValueCombo.EVENT_CONFIRM); + self._dataChange && self.fireEvent(BI.SearchMultiTextValueCombo.EVENT_CONFIRM); self.wants2Quit = false; } self.requesting = false; diff --git a/src/widget/singleselect/singleselect.combo.js b/src/widget/singleselect/singleselect.combo.js index 00f3ec366..729b666ef 100644 --- a/src/widget/singleselect/singleselect.combo.js +++ b/src/widget/singleselect/singleselect.combo.js @@ -64,6 +64,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, { self.fireEvent(BI.SingleSelectCombo.EVENT_STOP); }); this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function () { + self._dataChange = true; self.fireEvent(BI.SingleSelectCombo.EVENT_SEARCHING); }); @@ -71,6 +72,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, { self.storeValue = this.getValue(); assertShowValue(); self._defaultState(); + self._dataChange = true; }); this.trigger.on(BI.SingleSelectTrigger.EVENT_COUNTER_CLICK, function () { if (!self.combo.isViewVisible()) { @@ -95,6 +97,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, { listeners: [{ eventName: BI.SingleSelectPopupView.EVENT_CHANGE, action: function () { + self._dataChange = true; self.storeValue = this.getValue(); self._adjust(function () { assertShowValue(); @@ -120,6 +123,9 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, { }); this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + if (!this.isViewVisible()) { + self._dataChange = false;// 标记数据是否发生变化 + } this.setValue(self.storeValue); BI.nextTick(function () { self.populate(); @@ -133,7 +139,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, { if (self.requesting === true) { self.wants2Quit = true; } else { - self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM); + self._dataChange && self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM); } }); @@ -173,7 +179,8 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, { this.combo.hideView(); }, - _assertValue: function (val) {}, + _assertValue: function (val) { + }, _makeMap: function (values) { return BI.makeObject(values || []); @@ -220,7 +227,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, { function adjust () { if (self.wants2Quit === true) { - self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM); + self._dataChange && self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM); self.wants2Quit = false; } self.requesting = false; diff --git a/src/widget/singleselect/singleselect.insert.combo.js b/src/widget/singleselect/singleselect.insert.combo.js index d94f97197..fc5d7db7a 100644 --- a/src/widget/singleselect/singleselect.insert.combo.js +++ b/src/widget/singleselect/singleselect.insert.combo.js @@ -75,6 +75,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { self._defaultState(); }); this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function () { + self._dataChange = true; self.fireEvent(BI.SingleSelectInsertCombo.EVENT_SEARCHING); }); @@ -82,6 +83,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { self.storeValue = this.getValue(); assertShowValue(); self._defaultState(); + self._dataChange = true; }); this.trigger.on(BI.SingleSelectTrigger.EVENT_COUNTER_CLICK, function () { if (!self.combo.isViewVisible()) { @@ -106,6 +108,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { listeners: [{ eventName: BI.SingleSelectPopupView.EVENT_CHANGE, action: function () { + self._dataChange = true; self.storeValue = this.getValue(); self._adjust(function () { assertShowValue(); @@ -131,6 +134,9 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { }); this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + if (!this.isViewVisible()) { + self._dataChange = false;// 标记数据是否发生变化 + } this.setValue(self.storeValue); BI.nextTick(function () { self.populate(); @@ -144,7 +150,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { if (self.requesting === true) { self.wants2Quit = true; } else { - self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM); + self._dataChange && self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM); } }); @@ -198,7 +204,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { function adjust () { if (self.wants2Quit === true) { - self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM); + self._dataChange && self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM); self.wants2Quit = false; } self.requesting = false; @@ -237,4 +243,4 @@ BI.SingleSelectInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING"; BI.SingleSelectInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM"; BI.SingleSelectInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.shortcut("bi.single_select_insert_combo", BI.SingleSelectInsertCombo); \ No newline at end of file +BI.shortcut("bi.single_select_insert_combo", BI.SingleSelectInsertCombo);