From 504af4e069e41780b714e335562bc6f23dcb4626 Mon Sep 17 00:00:00 2001 From: "Jimmy.Chai" Date: Wed, 24 Jul 2024 17:15:04 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-18940=20refactor:=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=B1=9E=E6=80=A7=E5=92=8C=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widget/dynamicdate/dynamicdate.combo.js | 5 +++ .../dynamicdatetime/dynamicdatetime.combo.js | 7 +++- .../multiselect/multiselect.insert.combo.js | 17 +++++++- .../trigger/switcher.checkselected.js | 4 ++ .../src/widget/multitree/multi.tree.combo.js | 41 +++++++++---------- .../src/widget/multitree/multi.tree.popup.js | 4 ++ .../singleselect/singleselect.insert.combo.js | 7 ++++ .../src/widget/timeinterval/dateinterval.js | 18 ++++++++ .../src/widget/timeinterval/timeinterval.js | 18 ++++++++ packages/fineui/src/widget/year/combo.year.js | 5 +++ .../src/widget/yearmonth/combo.yearmonth.js | 5 +++ .../yearmonthinterval/yearmonthinterval.js | 18 ++++++++ .../widget/yearquarter/combo.yearquarter.js | 5 +++ 13 files changed, 131 insertions(+), 23 deletions(-) diff --git a/packages/fineui/src/widget/dynamicdate/dynamicdate.combo.js b/packages/fineui/src/widget/dynamicdate/dynamicdate.combo.js index 3fa097e55..ac22f8057 100644 --- a/packages/fineui/src/widget/dynamicdate/dynamicdate.combo.js +++ b/packages/fineui/src/widget/dynamicdate/dynamicdate.combo.js @@ -261,6 +261,7 @@ export class DynamicDateCombo extends Single { }, } ], + ...opts.popup, }, }, // // DEC-4250 和复选下拉一样,点击triggerBtn不默认收起 @@ -356,6 +357,10 @@ export class DynamicDateCombo extends Single { return this.trigger.getKey(); } + getPopup() { + return this.popup; + } + hidePopupView() { this.combo.hideView(); } diff --git a/packages/fineui/src/widget/dynamicdatetime/dynamicdatetime.combo.js b/packages/fineui/src/widget/dynamicdatetime/dynamicdatetime.combo.js index e65e12768..315008c0c 100644 --- a/packages/fineui/src/widget/dynamicdatetime/dynamicdatetime.combo.js +++ b/packages/fineui/src/widget/dynamicdatetime/dynamicdatetime.combo.js @@ -271,7 +271,8 @@ export class DynamicDateTimeCombo extends Single { this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); } } - ] + ], + ...opts.popup, } }, listeners: [ @@ -363,6 +364,10 @@ export class DynamicDateTimeCombo extends Single { return this.trigger.getKey(); } + getPopup() { + return this.popup; + } + hidePopupView() { this.combo.hideView(); } diff --git a/packages/fineui/src/widget/multiselect/multiselect.insert.combo.js b/packages/fineui/src/widget/multiselect/multiselect.insert.combo.js index 61e9f125a..0e41b1b10 100644 --- a/packages/fineui/src/widget/multiselect/multiselect.insert.combo.js +++ b/packages/fineui/src/widget/multiselect/multiselect.insert.combo.js @@ -53,6 +53,8 @@ export class MultiSelectInsertCombo extends Single { static EVENT_CONFIRM = "EVENT_CONFIRM"; static EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; static EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"; + static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; + static EVENT_BEFORE_NUMBER_COUNTER_POPUPVIEW = "EVENT_BEFORE_NUMBER_COUNTER_POPUPVIEW"; _defaultConfig() { return extend(super._defaultConfig(...arguments), { @@ -241,12 +243,13 @@ export class MultiSelectInsertCombo extends Single { self.trigger.getSearcher().adjustView(); }); }, + ...o.popup, }, value: o.value, hideChecker(e) { return ( triggerBtn.element.find(e.target).length === 0 && - self.numberCounter.element.find(e.target).length === 0 + size(self.numberCounter.getView()?.element.find(e.target)) === 0 ); }, }); @@ -259,6 +262,7 @@ export class MultiSelectInsertCombo extends Single { nextTick(() => { self._populate(); }); + self.fireEvent(MultiSelectInsertCombo.EVENT_BEFORE_POPUPVIEW); }); // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 this.wants2Quit = false; @@ -290,6 +294,8 @@ export class MultiSelectInsertCombo extends Single { valueFormatter: o.valueFormatter, itemsCreator: bind(this._itemsCreator4Trigger, this), value: o.value, + masker: o.masker, + popup: o.popup, }); this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => { if (!self.combo.isViewVisible()) { @@ -298,6 +304,7 @@ export class MultiSelectInsertCombo extends Single { }); this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function() { this.updateSelectedValue(self.storeValue); + self.fireEvent(MultiSelectInsertCombo.EVENT_BEFORE_NUMBER_COUNTER_POPUPVIEW); }); this.numberCounter.on(Events.VIEW, b => { @@ -555,4 +562,12 @@ export class MultiSelectInsertCombo extends Single { this._populate(...arguments); this.numberCounter.populateSwitcher(...arguments); } + + getPopup() { + return this.popup; + } + + getNumberCounter() { + return this.numberCounter; + } } diff --git a/packages/fineui/src/widget/multiselect/trigger/switcher.checkselected.js b/packages/fineui/src/widget/multiselect/trigger/switcher.checkselected.js index 4d5bab1da..c4773e549 100644 --- a/packages/fineui/src/widget/multiselect/trigger/switcher.checkselected.js +++ b/packages/fineui/src/widget/multiselect/trigger/switcher.checkselected.js @@ -80,6 +80,10 @@ export class MultiSelectCheckSelectedSwitcher extends Widget { this.switcher.adjustView(); } + getView() { + return this.switcher.getView(); + } + hideView() { this.switcher.empty(); this.switcher.hideView(); diff --git a/packages/fineui/src/widget/multitree/multi.tree.combo.js b/packages/fineui/src/widget/multitree/multi.tree.combo.js index 7d61b6e9d..cc8ab0e60 100644 --- a/packages/fineui/src/widget/multitree/multi.tree.combo.js +++ b/packages/fineui/src/widget/multitree/multi.tree.combo.js @@ -10,7 +10,7 @@ import { VerticalAdaptLayout, deepClone, Selection, - SIZE_CONSANTS + size } from "@/core"; import { Single, Combo } from "@/base"; import { MultiTreeSearcher } from "./trigger/searcher.multi.tree"; @@ -33,6 +33,7 @@ export class MultiTreeCombo extends Single { static EVENT_CONFIRM = "EVENT_CONFIRM"; static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; static EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"; + static EVENT_BEFORE_NUMBER_COUNTER_POPUPVIEW = "EVENT_BEFORE_NUMBER_COUNTER_POPUPVIEW"; _defaultConfig() { return extend(super._defaultConfig(...arguments), { @@ -70,13 +71,8 @@ export class MultiTreeCombo extends Single { text: o.text, defaultText: o.defaultText, watermark: o.watermark, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1, - }, + adapter: () => { + return this.popup.getView(); }, searcher: { type: "bi.multi_tree_searcher", @@ -104,8 +100,6 @@ export class MultiTreeCombo extends Single { type: MultiTreePopup.xtype, ref() { self.popup = this; - self.trigger.setAdapter(this); - self.numberCounter.setAdapter(this); }, listeners: [ { @@ -160,13 +154,14 @@ export class MultiTreeCombo extends Single { }); }, maxWidth: o.isNeedAdjustWidth ? "auto" : 500, + ...o.popup, }, isNeedAdjustWidth: o.isNeedAdjustWidth, value: { value: o.value || {} }, hideChecker(e) { return ( triggerBtn.element.find(e.target).length === 0 && - self.numberCounter.element.find(e.target).length === 0 + size(self.numberCounter.getView()?.element.find(e.target)) === 0 ); }, }); @@ -295,23 +290,18 @@ export class MultiTreeCombo extends Single { }); this.numberCounter = createWidget({ - type: "bi.multi_select_check_selected_switcher", + type: MultiSelectCheckSelectedSwitcher, el: { - // type: "bi.multi_tree_check_selected_button", type: MultiTreeCheckSelectedButton.xtype, }, popup: { - // type: "bi.multi_tree_check_pane", type: MultiTreeCheckPane.xtype, + ...o.popup, }, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1, - }, + adapter: () => { + return this.popup.getView(); }, + masker: o.masker, itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, value: { value: o.value || {} }, @@ -334,6 +324,7 @@ export class MultiTreeCombo extends Single { want2showCounter = null; showCounter(); } + this.fireEvent(MultiTreeCombo.EVENT_BEFORE_NUMBER_COUNTER_POPUPVIEW); } ); @@ -443,4 +434,12 @@ export class MultiTreeCombo extends Single { setWaterMark(v) { this.trigger.setWaterMark(v); } + + getPopup() { + return this.popup; + } + + getNumberCounter() { + return this.numberCounter; + } } diff --git a/packages/fineui/src/widget/multitree/multi.tree.popup.js b/packages/fineui/src/widget/multitree/multi.tree.popup.js index 44c91a591..4bd078ab1 100644 --- a/packages/fineui/src/widget/multitree/multi.tree.popup.js +++ b/packages/fineui/src/widget/multitree/multi.tree.popup.js @@ -105,4 +105,8 @@ export class MultiTreePopup extends Pane { resetWidth(w) { this.popupView.resetWidth(w); } + + getView() { + return this.popupView.getView(); + } } diff --git a/packages/fineui/src/widget/singleselect/singleselect.insert.combo.js b/packages/fineui/src/widget/singleselect/singleselect.insert.combo.js index eb528ec7a..5bf6dc855 100644 --- a/packages/fineui/src/widget/singleselect/singleselect.insert.combo.js +++ b/packages/fineui/src/widget/singleselect/singleselect.insert.combo.js @@ -29,6 +29,7 @@ export class SingleSelectInsertCombo extends Single { static EVENT_SEARCHING = "EVENT_SEARCHING"; static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM"; static EVENT_CONFIRM = "EVENT_CONFIRM"; + static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW" _defaultConfig() { return extend(super._defaultConfig(...arguments), { @@ -156,6 +157,7 @@ export class SingleSelectInsertCombo extends Single { self.trigger.getSearcher().adjustView(); }); }, + ...o.popup, }, hideChecker(e) { return triggerBtn.element.find(e.target).length === 0; @@ -171,6 +173,7 @@ export class SingleSelectInsertCombo extends Single { nextTick(() => { self.populate(); }); + self.fireEvent(SingleSelectInsertCombo .EVENT_BEFORE_POPUPVIEW); }); // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 this.wants2Quit = false; @@ -261,4 +264,8 @@ export class SingleSelectInsertCombo extends Single { populate() { this.combo.populate(...arguments); } + + getPopup() { + return this.popup; + } } diff --git a/packages/fineui/src/widget/timeinterval/dateinterval.js b/packages/fineui/src/widget/timeinterval/dateinterval.js index 4c7f784da..d98510c7b 100644 --- a/packages/fineui/src/widget/timeinterval/dateinterval.js +++ b/packages/fineui/src/widget/timeinterval/dateinterval.js @@ -30,6 +30,8 @@ export class DateInterval extends Single { static EVENT_ERROR = "EVENT_ERROR"; static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"; + static EVENT_BEFORE_START_POPUPVIEW = "EVENT_BEFORE_START_POPUPVIEW"; + static EVENT_BEFORE_END_POPUPVIEW = "EVENT_BEFORE_END_POPUPVIEW"; _defaultConfig() { const conf = super._defaultConfig(...arguments); @@ -50,6 +52,13 @@ export class DateInterval extends Single { this.left = this._createCombo(o.value.start, o.watermark?.start); this.right = this._createCombo(o.value.end, o.watermark?.end); + this.left.on(DynamicDateCombo.EVENT_BEFORE_POPUPVIEW, () => { + this.fireEvent(DateInterval.EVENT_BEFORE_START_POPUPVIEW); + }) + this.right.on(DynamicDateCombo.EVENT_BEFORE_POPUPVIEW, () => { + this.fireEvent(DateInterval.EVENT_BEFORE_END_POPUPVIEW); + }) + return { type: HorizontalFillLayout.xtype, columnSize: ["fill", "", "fill"], @@ -79,6 +88,8 @@ export class DateInterval extends Single { const o = this.options; const combo = createWidget({ type: DynamicDateCombo.xtype, + container: o.container, + popup: o.popup, isPreview: o.isPreview, supportDynamic: o.supportDynamic, minDate: o.minDate, @@ -243,4 +254,11 @@ export class DateInterval extends Single { end: this.right.getValue(), }; } + + getPopup() { + return { + start: this.left.getPopup(), + end: this.right.getPopup(), + }; + } } diff --git a/packages/fineui/src/widget/timeinterval/timeinterval.js b/packages/fineui/src/widget/timeinterval/timeinterval.js index 85deda173..4ae530169 100644 --- a/packages/fineui/src/widget/timeinterval/timeinterval.js +++ b/packages/fineui/src/widget/timeinterval/timeinterval.js @@ -29,6 +29,8 @@ export class TimeInterval extends Single { static EVENT_VALID = "EVENT_VALID"; static EVENT_ERROR = "EVENT_ERROR"; static EVENT_CHANGE = "EVENT_CHANGE"; + static EVENT_BEFORE_START_POPUPVIEW = "EVENT_BEFORE_START_POPUPVIEW"; + static EVENT_BEFORE_END_POPUPVIEW = "EVENT_BEFORE_END_POPUPVIEW"; _defaultConfig() { const conf = super._defaultConfig(...arguments); @@ -48,6 +50,13 @@ export class TimeInterval extends Single { this.left = this._createCombo(o.value.start, o.watermark?.start); this.right = this._createCombo(o.value.end, o.watermark?.end); + this.left.on(DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW, () => { + this.fireEvent(TimeInterval.EVENT_BEFORE_START_POPUPVIEW); + }) + this.right.on(DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW, () => { + this.fireEvent(TimeInterval.EVENT_BEFORE_END_POPUPVIEW); + }) + return { type: HorizontalFillLayout.xtype, columnSize: ["fill", "", "fill"], @@ -77,6 +86,8 @@ export class TimeInterval extends Single { const o = this.options; const combo = createWidget({ type: DynamicDateTimeCombo.xtype, + container: o.container, + popup: o.popup, isPreview: o.isPreview, timeSelectTypes: o.timeSelectTypes, simple: o.simple, @@ -250,4 +261,11 @@ export class TimeInterval extends Single { end: this.right.getValue(), }; } + + getPopup() { + return { + start: this.left.getPopup(), + end: this.right.getPopup(), + }; + } } diff --git a/packages/fineui/src/widget/year/combo.year.js b/packages/fineui/src/widget/year/combo.year.js index 50056e22e..562ad5cc9 100644 --- a/packages/fineui/src/widget/year/combo.year.js +++ b/packages/fineui/src/widget/year/combo.year.js @@ -138,6 +138,7 @@ export class DynamicYearCombo extends Widget { behaviors: o.behaviors, min: o.minDate, max: o.maxDate, + ...o.popup, }, value: o.value || "", }, @@ -240,6 +241,10 @@ export class DynamicYearCombo extends Widget { setWaterMark(v) { this.trigger.setWaterMark(v); } + + getPopup() { + return this.popup; + } } extend(DynamicYearCombo, { Static: 1, diff --git a/packages/fineui/src/widget/yearmonth/combo.yearmonth.js b/packages/fineui/src/widget/yearmonth/combo.yearmonth.js index 79dfa5da8..ba7d693e8 100644 --- a/packages/fineui/src/widget/yearmonth/combo.yearmonth.js +++ b/packages/fineui/src/widget/yearmonth/combo.yearmonth.js @@ -159,6 +159,7 @@ export class DynamicYearMonthCombo extends Single { behaviors: o.behaviors, min: o.minDate, max: o.maxDate, + ...o.popup, }, value: o.value || "", }, @@ -251,6 +252,10 @@ export class DynamicYearMonthCombo extends Single { this.popup && this.popup.setMaxDate(maxDate); } + getPopup() { + return this.popup; + } + hideView() { this.combo.hideView(); } diff --git a/packages/fineui/src/widget/yearmonthinterval/yearmonthinterval.js b/packages/fineui/src/widget/yearmonthinterval/yearmonthinterval.js index c6bc874bb..c7abfff4e 100644 --- a/packages/fineui/src/widget/yearmonthinterval/yearmonthinterval.js +++ b/packages/fineui/src/widget/yearmonthinterval/yearmonthinterval.js @@ -20,6 +20,8 @@ export class YearMonthInterval extends Single { static EVENT_ERROR = "EVENT_ERROR"; static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; + static EVENT_BEFORE_START_POPUPVIEW = "EVENT_BEFORE_START_POPUPVIEW"; + static EVENT_BEFORE_END_POPUPVIEW = "EVENT_BEFORE_END_POPUPVIEW"; constants = { width: 25, @@ -43,6 +45,13 @@ export class YearMonthInterval extends Single { this.left = this._createCombo(o.value.start, o.watermark?.start); this.right = this._createCombo(o.value.end, o.watermark?.end); + this.left.on(DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW, () => { + this.fireEvent(YearMonthInterval.EVENT_BEFORE_START_POPUPVIEW); + }) + this.right.on(DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW, () => { + this.fireEvent(YearMonthInterval.EVENT_BEFORE_END_POPUPVIEW); + }) + return { type: HorizontalFillLayout.xtype, columnSize: ["fill", "", "fill"], @@ -72,6 +81,8 @@ export class YearMonthInterval extends Single { const o = this.options; const combo = createWidget({ type: DynamicYearMonthCombo.xtype, + container: o.container, + popup: o.popup, isPreview: o.isPreview, simple: o.simple, supportDynamic: o.supportDynamic, @@ -235,4 +246,11 @@ export class YearMonthInterval extends Single { getValue() { return { start: this.left.getValue(), end: this.right.getValue() }; } + + getPopup() { + return { + start: this.left.getPopup(), + end: this.right.getPopup(), + }; + } } diff --git a/packages/fineui/src/widget/yearquarter/combo.yearquarter.js b/packages/fineui/src/widget/yearquarter/combo.yearquarter.js index c14100a38..c6cbb18c9 100644 --- a/packages/fineui/src/widget/yearquarter/combo.yearquarter.js +++ b/packages/fineui/src/widget/yearquarter/combo.yearquarter.js @@ -162,6 +162,7 @@ export class DynamicYearQuarterCombo extends Widget { behaviors: o.behaviors, min: o.minDate, max: o.maxDate, + ...o.popup, }, value: o.value || "", }, @@ -254,6 +255,10 @@ export class DynamicYearQuarterCombo extends Widget { this.popup && this.popup.setMaxDate(maxDate); } + getPopup() { + return this.popup; + } + hideView() { this.combo.hideView(); }