From 8fce13ef6937e2a0220b35fca256e2772c04c3c9 Mon Sep 17 00:00:00 2001 From: zsmj Date: Fri, 16 Dec 2022 17:02:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?BI-118262=20fix:=20=E6=A0=91=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E7=BB=84=E4=BB=B6=E6=90=9C=E7=B4=A2=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E4=B8=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 搜索面板点击node,会发请求去adjust数据,回调之后才发change事件,如果在这之前点确定,_datachange还没有发生呢 当然即使这样,外部getValue的数据也可能是没adjust的数据,这就是另外的问题了 --- src/case/ztree/parttree.js | 8 +- src/widget/multitree/multi.tree.combo.js | 124 ++++++++------- .../multitree/multi.tree.insert.combo.js | 143 ++++++++++-------- .../trigger/multi.tree.search.insert.pane.js | 108 +++++++------ .../trigger/multi.tree.search.pane.js | 30 ++-- .../multitree/trigger/searcher.multi.tree.js | 31 ++-- 6 files changed, 249 insertions(+), 195 deletions(-) diff --git a/src/case/ztree/parttree.js b/src/case/ztree/parttree.js index 974196b33..8a347548a 100644 --- a/src/case/ztree/parttree.js +++ b/src/case/ztree/parttree.js @@ -37,6 +37,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { var self = this, o = this.options; var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode)); var name = this._getNodeValue(treeNode); + this.fireEvent(BI.PartTree.EVENT_CLICK_TREE_NODE); if (treeNode.checked === true) { this.options.paras.selectedValues = this._getUnionValue(); // this._buildTree(self.options.paras.selectedValues, BI.concat(parentValues, name)); @@ -80,7 +81,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { var rootNoots = this.nodes.getNodes(); track(rootNoots); - function track (nodes) { + function track(nodes) { BI.each(nodes, function (i, node) { var checkState = node.getCheckStatus(); if (checkState.checked === false) { @@ -135,7 +136,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { self.fireEvent(BI.Events.AFTERINIT); }; - function callback (nodes) { + function callback(nodes) { if (self._stop === true) { return; } @@ -171,7 +172,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { track([], valueA, valueB); track([], valueB, valueA); - function track (parent, node, compare) { + function track(parent, node, compare) { BI.each(node, function (n, item) { if (BI.isNull(compare[n])) { self._addTreeNode(map, parent, n, item); @@ -197,4 +198,5 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { } }); +BI.PartTree.EVENT_CLICK_TREE_NODE = "EVENT_CLICK_TREE_NODE"; BI.shortcut("bi.part_tree", BI.PartTree); diff --git a/src/widget/multitree/multi.tree.combo.js b/src/widget/multitree/multi.tree.combo.js index bdf374f07..5fca0ca4f 100644 --- a/src/widget/multitree/multi.tree.combo.js +++ b/src/widget/multitree/multi.tree.combo.js @@ -42,7 +42,15 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { }, searcher: { type: "bi.multi_tree_searcher", - itemsCreator: o.itemsCreator + itemsCreator: o.itemsCreator, + listeners: [ + { + eventName: BI.MultiTreeSearcher.EVENT_CLICK_TREE_NODE, + action: function () { + self._dataChange = true; + } + } + ], }, value: { value: o.value || {} } }); @@ -61,43 +69,45 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { self.trigger.setAdapter(this); self.numberCounter.setAdapter(this); }, - listeners: [{ - eventName: BI.MultiTreePopup.EVENT_AFTERINIT, - action: function () { - self.numberCounter.adjustView(); - isInit = true; - if (want2showCounter === true) { - showCounter(); + listeners: [ + { + eventName: BI.MultiTreePopup.EVENT_AFTERINIT, + action: function () { + self.numberCounter.adjustView(); + isInit = true; + if (want2showCounter === true) { + showCounter(); + } + } + }, { + eventName: BI.MultiTreePopup.EVENT_CHANGE, + action: function () { + change = true; + var val = { + type: BI.Selection.Multi, + value: this.hasChecked() ? this.getValue() : {} + }; + self.trigger.getSearcher().setState(val); + self.numberCounter.setButtonChecked(val); + self.storeValue = { value: self.combo.getValue() }; + self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM, self.combo.getValue()); + self._dataChange = true; + } + }, { + eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM, + action: function () { + self.combo.hideView(); + } + }, { + eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR, + action: function () { + clear = true; + self._dataChange = true; + self.setValue(); + self._defaultState(); } } - }, { - eventName: BI.MultiTreePopup.EVENT_CHANGE, - action: function () { - change = true; - var val = { - type: BI.Selection.Multi, - value: this.hasChecked() ? this.getValue() : {} - }; - self.trigger.getSearcher().setState(val); - self.numberCounter.setButtonChecked(val); - self.storeValue = { value: self.combo.getValue() }; - self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM, self.combo.getValue()); - self._dataChange = true; - } - }, { - eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM, - action: function () { - self.combo.hideView(); - } - }, { - eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR, - action: function () { - clear = true; - self._dataChange = true; - self.setValue(); - self._defaultState(); - } - }], + ], itemsCreator: o.itemsCreator, onLoaded: function () { BI.nextTick(function () { @@ -293,26 +303,28 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.absolute", element: this, - items: [{ - el: this.combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.vertical_adapt", - items: [this.numberCounter] - }, - right: o.height, - top: 0, - bottom: 0 - }] + items: [ + { + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }, { + el: { + type: "bi.vertical_adapt", + items: [this.numberCounter] + }, + right: o.height, + top: 0, + bottom: 0 + } + ] }); }, diff --git a/src/widget/multitree/multi.tree.insert.combo.js b/src/widget/multitree/multi.tree.insert.combo.js index 6db34dc61..acacbb875 100644 --- a/src/widget/multitree/multi.tree.insert.combo.js +++ b/src/widget/multitree/multi.tree.insert.combo.js @@ -47,18 +47,25 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { itemsCreator: o.itemsCreator, popup: { type: "bi.multi_tree_search_insert_pane", - listeners: [{ - eventName: BI.MultiTreeSearchInsertPane.EVENT_ADD_ITEM, - action: function () { - self.storeValue.value[self.trigger.getSearcher().getKeyword()] = {}; - self._assertShowValue(); - // setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了 - self.combo.setValue(self.storeValue); - self.numberCounter.setValue(self.storeValue); - self._stopEditing(); - self._dataChange = true; + listeners: [ + { + eventName: BI.MultiTreeSearchInsertPane.EVENT_ADD_ITEM, + action: function () { + self.storeValue.value[self.trigger.getSearcher().getKeyword()] = {}; + self._assertShowValue(); + // setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了 + self.combo.setValue(self.storeValue); + self.numberCounter.setValue(self.storeValue); + self._stopEditing(); + self._dataChange = true; + } + }, { + eventName: BI.MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE, + action: function () { + self._dataChange = true; + } } - }] + ] } }, value: { value: o.value || {} } @@ -79,43 +86,45 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { self.trigger.setAdapter(this); self.numberCounter.setAdapter(this); }, - listeners: [{ - eventName: BI.MultiTreePopup.EVENT_AFTERINIT, - action: function () { - self.numberCounter.adjustView(); - isInit = true; - if (want2showCounter === true) { - showCounter(); + listeners: [ + { + eventName: BI.MultiTreePopup.EVENT_AFTERINIT, + action: function () { + self.numberCounter.adjustView(); + isInit = true; + if (want2showCounter === true) { + showCounter(); + } + } + }, { + eventName: BI.MultiTreePopup.EVENT_CHANGE, + action: function () { + change = true; + var val = { + type: BI.Selection.Multi, + value: this.hasChecked() ? this.getValue() : {} + }; + self.trigger.getSearcher().setState(val); + self.numberCounter.setButtonChecked(val); + self.storeValue = { value: self.combo.getValue() }; + self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.getValue()); + self._dataChange = true; + } + }, { + eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM, + action: function () { + self.combo.hideView(); + } + }, { + eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR, + action: function () { + clear = true; + self._dataChange = true; + self.setValue(); + self._defaultState(); } } - }, { - eventName: BI.MultiTreePopup.EVENT_CHANGE, - action: function () { - change = true; - var val = { - type: BI.Selection.Multi, - value: this.hasChecked() ? this.getValue() : {} - }; - self.trigger.getSearcher().setState(val); - self.numberCounter.setButtonChecked(val); - self.storeValue = { value: self.combo.getValue() }; - self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.getValue()); - self._dataChange = true; - } - }, { - eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM, - action: function () { - self.combo.hideView(); - } - }, { - eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR, - action: function () { - clear = true; - self._dataChange = true; - self.setValue(); - self._defaultState(); - } - }], + ], itemsCreator: o.itemsCreator, onLoaded: function () { BI.nextTick(function () { @@ -303,26 +312,28 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.absolute", element: this, - items: [{ - el: this.combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.vertical_adapt", - items: [this.numberCounter] - }, - right: o.height, - top: 0, - height: o.height, - }] + items: [ + { + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }, { + el: { + type: "bi.vertical_adapt", + items: [this.numberCounter] + }, + right: o.height, + top: 0, + height: o.height, + } + ] }); }, diff --git a/src/widget/multitree/trigger/multi.tree.search.insert.pane.js b/src/widget/multitree/trigger/multi.tree.search.insert.pane.js index cc5bff3c9..345d8dab2 100644 --- a/src/widget/multitree/trigger/multi.tree.search.insert.pane.js +++ b/src/widget/multitree/trigger/multi.tree.search.insert.pane.js @@ -25,55 +25,64 @@ BI.MultiTreeSearchInsertPane = BI.inherit(BI.Widget, { return { type: "bi.absolute", - items: [{ - el: { - type: "bi.text_button", - invisible: true, - ref: function (_ref) { - self.addTip = _ref; - }, - text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""), - height: this.constants.height, - cls: "bi-high-light", - handler: function () { - self.fireEvent(BI.MultiTreeSearchInsertPane.EVENT_ADD_ITEM, opts.keywordGetter()); - } - }, - top: 5, - left: 0, - right: 0 - }, { - el: BI.extend({ - type: "bi.part_tree", - tipText: BI.i18nText("BI-No_Select"), - itemsCreator: function (op, callback) { - op.keyword = opts.keywordGetter(); - opts.itemsCreator(op, function (res) { - callback(res); - self.setKeyword(opts.keywordGetter(), res.items); - }); - }, - ref: function (_ref) { - self.partTree = _ref; - }, - value: opts.value, - listeners: [{ - eventName: BI.Controller.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + items: [ + { + el: { + type: "bi.text_button", + invisible: true, + ref: function (_ref) { + self.addTip = _ref; + }, + text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""), + height: this.constants.height, + cls: "bi-high-light", + handler: function () { + self.fireEvent(BI.MultiTreeSearchInsertPane.EVENT_ADD_ITEM, opts.keywordGetter()); } - }, { - eventName: BI.TreeView.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.MultiTreeSearchInsertPane.EVENT_CHANGE); - } - }] - }, opts.el), - left: 0, - top: 0, - bottom: 0, - right: 0 - }] + }, + top: 5, + left: 0, + right: 0 + }, { + el: BI.extend({ + type: "bi.part_tree", + tipText: BI.i18nText("BI-No_Select"), + itemsCreator: function (op, callback) { + op.keyword = opts.keywordGetter(); + opts.itemsCreator(op, function (res) { + callback(res); + self.setKeyword(opts.keywordGetter(), res.items); + }); + }, + ref: function (_ref) { + self.partTree = _ref; + }, + value: opts.value, + listeners: [ + { + eventName: BI.Controller.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + } + }, { + eventName: BI.TreeView.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.MultiTreeSearchInsertPane.EVENT_CHANGE); + } + }, { + eventName: BI.PartTree.EVENT_CLICK_TREE_NODE, + action: function () { + self.fireEvent(BI.MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE); + } + } + ] + }, opts.el), + left: 0, + top: 0, + bottom: 0, + right: 0 + } + ] }; }, @@ -115,5 +124,6 @@ BI.MultiTreeSearchInsertPane.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiTreeSearchInsertPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; BI.MultiTreeSearchInsertPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; BI.MultiTreeSearchInsertPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; +BI.MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE = "EVENT_CLICK_TREE_NODE"; -BI.shortcut("bi.multi_tree_search_insert_pane", BI.MultiTreeSearchInsertPane); \ No newline at end of file +BI.shortcut("bi.multi_tree_search_insert_pane", BI.MultiTreeSearchInsertPane); diff --git a/src/widget/multitree/trigger/multi.tree.search.pane.js b/src/widget/multitree/trigger/multi.tree.search.pane.js index a18ab2a04..82c221d18 100644 --- a/src/widget/multitree/trigger/multi.tree.search.pane.js +++ b/src/widget/multitree/trigger/multi.tree.search.pane.js @@ -25,17 +25,24 @@ BI.MultiTreeSearchPane = BI.inherit(BI.Pane, { opts.itemsCreator(op, callback); }, value: opts.value, - listeners: [{ - eventName: BI.Controller.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + listeners: [ + { + eventName: BI.Controller.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + } + }, { + eventName: BI.TreeView.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE); + } + }, { + eventName: BI.PartTree.EVENT_CLICK_TREE_NODE, + action: function () { + self.fireEvent(BI.MultiTreeSearchPane.EVENT_CLICK_TREE_NODE); + } } - }, { - eventName: BI.TreeView.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE); - } - }], + ], ref: function (_ref) { self.partTree = _ref; } @@ -72,5 +79,6 @@ BI.MultiTreeSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiTreeSearchPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; BI.MultiTreeSearchPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; +BI.MultiTreeSearchPane.EVENT_CLICK_TREE_NODE = "EVENT_CLICK_TREE_NODE"; -BI.shortcut("bi.multi_tree_search_pane", BI.MultiTreeSearchPane); \ No newline at end of file +BI.shortcut("bi.multi_tree_search_pane", BI.MultiTreeSearchPane); diff --git a/src/widget/multitree/trigger/searcher.multi.tree.js b/src/widget/multitree/trigger/searcher.multi.tree.js index 8b9c4f004..1b2dc6983 100644 --- a/src/widget/multitree/trigger/searcher.multi.tree.js +++ b/src/widget/multitree/trigger/searcher.multi.tree.js @@ -33,17 +33,19 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, { defaultText: o.defaultText, height: o.height }, - listeners: [{ - eventName: BI.MultiSelectEditor.EVENT_FOCUS, - action: function () { - self.fireEvent(BI.MultiSelectSearcher.EVENT_FOCUS); + listeners: [ + { + eventName: BI.MultiSelectEditor.EVENT_FOCUS, + action: function () { + self.fireEvent(BI.MultiSelectSearcher.EVENT_FOCUS); + } + }, { + eventName: BI.MultiSelectEditor.EVENT_BLUR, + action: function () { + self.fireEvent(BI.MultiSelectSearcher.EVENT_BLUR); + } } - }, { - eventName: BI.MultiSelectEditor.EVENT_BLUR, - action: function () { - self.fireEvent(BI.MultiSelectSearcher.EVENT_BLUR); - } - }] + ] }); this.searcher = BI.createWidget({ @@ -67,6 +69,14 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, { op.keyword = self.editor.getValue(); o.itemsCreator(op, callback); }, + listeners: [ + { + eventName: BI.MultiTreeSearchPane.EVENT_CLICK_TREE_NODE, + action: function () { + self.fireEvent(BI.MultiTreeSearcher.EVENT_CLICK_TREE_NODE, arguments); + } + } + ], value: o.value }, o.popup), @@ -206,4 +216,5 @@ BI.MultiTreeSearcher.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiTreeSearcher.EVENT_START = "EVENT_START"; BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP"; BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE"; +BI.MultiTreeSearcher.EVENT_CLICK_TREE_NODE = "EVENT_CLICK_TREE_NODE"; BI.shortcut("bi.multi_tree_searcher", BI.MultiTreeSearcher); From 3a57a96f957ed8860b4e51bfcb7c8fa35ec8b417 Mon Sep 17 00:00:00 2001 From: data Date: Sun, 18 Dec 2022 19:45:59 +0800 Subject: [PATCH 2/2] auto upgrade version to 2.0.20221218194544 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 17810a088..0c0ff4c72 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20221216170431", + "version": "2.0.20221218194544", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts",