From 8c5779a1a3c57ea7f4a23a54fd1a0b9d54b2fd33 Mon Sep 17 00:00:00 2001 From: iapyang Date: Mon, 11 Oct 2021 17:12:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?chore:=20=E4=BF=AE=E6=94=B9eslint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index 084bf54ca..56c26d0b0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -27,7 +27,10 @@ "plugins": ["@typescript-eslint/eslint-plugin"], "overrides": [{ "files": ["src/*.js","src/**/*.js", "demo/*.js", "demo/**/*.js", "i18n/**/*.js", "i18n/*.js", "test/**/*.js", "test/*.js"], - "extends": "plugin:@fui/es5" + "extends": "plugin:@fui/es5", + "rules": { + "comma-dangle": ["error", "never"] // 多行对象字面量中要求拖尾逗号 + } }, { "files": ["webpack/*.js", "types/*.ts", "typescript/*.ts","typescript/**/*.ts", "./*.js", "lib/**/*.js", "lib/*.js"], "extends": "plugin:@fui/typescript" From e3cda541c13a02ae22a13ffbd8140b86c4efa5a9 Mon Sep 17 00:00:00 2001 From: iapyang Date: Mon, 11 Oct 2021 17:13:12 +0800 Subject: [PATCH 2/3] =?UTF-8?q?BI-95299=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=BE=B9=E6=A1=86=E4=B8=8D=E9=AB=98=E4=BA=AE+=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E4=B8=8D=E5=87=86=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/dynamicdate/dynamicdate.combo.js | 407 +++++++++-------- .../dynamicdatetime/dynamicdatetime.combo.js | 426 +++++++++--------- src/widget/year/combo.year.js | 41 +- src/widget/yearmonth/combo.yearmonth.js | 40 +- src/widget/yearquarter/combo.yearquarter.js | 40 +- 5 files changed, 503 insertions(+), 451 deletions(-) diff --git a/src/widget/dynamicdate/dynamicdate.combo.js b/src/widget/dynamicdate/dynamicdate.combo.js index ca40812c6..ef010b87f 100644 --- a/src/widget/dynamicdate/dynamicdate.combo.js +++ b/src/widget/dynamicdate/dynamicdate.combo.js @@ -30,221 +30,231 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, { this.storeTriggerValue = ""; var date = BI.getDate(); this.storeValue = opts.value; + return { - type: "bi.htape", - cls: "bi-border bi-border-radius", + type: "bi.absolute", items: [{ el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-change-h-font", - width: opts.height, - height: opts.height - 2, - ref: function () { - self.changeIcon = this; - } - }, - width: opts.height - }, { - type: "bi.absolute", - items: [{ - el: { - type: "bi.combo", - container: opts.container, - ref: function () { - self.combo = this; - }, - toggle: false, - isNeedAdjustHeight: opts.isNeedAdjustHeight, - isNeedAdjustWidth: opts.isNeedAdjustWidth, - destroyWhenHide: true, + type: "bi.htape", + cls: "bi-border bi-border-radius bi-focus-shadow", + items: [{ el: { - type: "bi.dynamic_date_trigger", - min: opts.minDate, - max: opts.maxDate, - format: opts.format, - allowEdit: opts.allowEdit, - watermark: opts.watermark, + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-change-h-font", + width: opts.height - 2, height: opts.height - 2, - value: opts.value, ref: function () { - self.trigger = this; - }, - listeners: [{ - eventName: BI.DynamicDateTrigger.EVENT_KEY_DOWN, - action: function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } - self.fireEvent(BI.DynamicDateCombo.EVENT_KEY_DOWN, arguments); - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_STOP, - action: function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_FOCUS, - action: function () { - self.storeTriggerValue = self.trigger.getKey(); - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS); - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_BLUR, - action: function () { - self.fireEvent(BI.DynamicDateCombo.EVENT_BLUR); - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_ERROR, - action: function () { - self.storeValue = { - type: BI.DynamicDateCombo.Static, - value: { - year: date.getFullYear(), - month: date.getMonth() + 1 - } - }; - self.fireEvent(BI.DynamicDateCombo.EVENT_ERROR); - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_VALID, - action: function () { - self.fireEvent(BI.DynamicDateCombo.EVENT_VALID); - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicDateCombo.EVENT_CHANGE); - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_CONFIRM, - action: function () { - var dateStore = self.storeTriggerValue; - var dateObj = self.trigger.getKey(); - if (self.combo.isViewVisible() || BI.isEqual(dateObj, dateStore)) { - return; - } - if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { - self.storeValue = self.trigger.getValue(); - self.setValue(self.trigger.getValue()); - } else if (BI.isEmptyString(dateObj)) { - self.storeValue = null; - self.trigger.setValue(); - } - self._checkDynamicValue(self.storeValue); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }] + self.changeIcon = this; + } }, - adjustLength: this.constants.comboAdjustHeight, - popup: { + width: opts.height - 2 + }, { + type: "bi.absolute", + items: [{ el: { - type: "bi.dynamic_date_popup", - width: opts.isNeedAdjustWidth ? opts.width : undefined, - supportDynamic: opts.supportDynamic, - behaviors: opts.behaviors, - min: opts.minDate, - max: opts.maxDate, + type: "bi.combo", + container: opts.container, ref: function () { - self.popup = this; + self.combo = this; }, - listeners: [{ - eventName: BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE, - action: function () { - self.setValue(); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE, - action: function () { - var date = BI.getDate(); - self.setValue({ - type: BI.DynamicDateCombo.Static, - value: { - year: date.getFullYear(), - month: date.getMonth() + 1, - day: date.getDate() + toggle: false, + isNeedAdjustHeight: opts.isNeedAdjustHeight, + isNeedAdjustWidth: opts.isNeedAdjustWidth, + destroyWhenHide: true, + el: { + type: "bi.dynamic_date_trigger", + min: opts.minDate, + max: opts.maxDate, + format: opts.format, + allowEdit: opts.allowEdit, + watermark: opts.watermark, + height: opts.height - 2, + value: opts.value, + ref: function () { + self.trigger = this; + }, + listeners: [{ + eventName: BI.DynamicDateTrigger.EVENT_KEY_DOWN, + action: function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); } - }); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE, - action: function () { - var value = self.popup.getValue(); - if(self._checkValue(value)) { - self.setValue(value); + self.fireEvent(BI.DynamicDateCombo.EVENT_KEY_DOWN, arguments); } - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicDatePopup.EVENT_CHANGE, + }, { + eventName: BI.DynamicDateTrigger.EVENT_STOP, + action: function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + } + }, { + eventName: BI.DynamicDateTrigger.EVENT_FOCUS, + action: function () { + self.storeTriggerValue = self.trigger.getKey(); + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS); + } + }, { + eventName: BI.DynamicDateTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_BLUR); + } + }, { + eventName: BI.DynamicDateTrigger.EVENT_ERROR, + action: function () { + self.storeValue = { + type: BI.DynamicDateCombo.Static, + value: { + year: date.getFullYear(), + month: date.getMonth() + 1 + } + }; + self.fireEvent(BI.DynamicDateCombo.EVENT_ERROR); + } + }, { + eventName: BI.DynamicDateTrigger.EVENT_VALID, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_VALID); + } + }, { + eventName: BI.DynamicDateTrigger.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_CHANGE); + } + }, { + eventName: BI.DynamicDateTrigger.EVENT_CONFIRM, + action: function () { + var dateStore = self.storeTriggerValue; + var dateObj = self.trigger.getKey(); + if (self.combo.isViewVisible() || BI.isEqual(dateObj, dateStore)) { + return; + } + if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { + self.storeValue = self.trigger.getValue(); + self.setValue(self.trigger.getValue()); + } else if (BI.isEmptyString(dateObj)) { + self.storeValue = null; + self.trigger.setValue(); + } + self._checkDynamicValue(self.storeValue); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }] + }, + adjustLength: this.constants.comboAdjustHeight, + popup: { + el: { + type: "bi.dynamic_date_popup", + width: opts.isNeedAdjustWidth ? opts.width : undefined, + supportDynamic: opts.supportDynamic, + behaviors: opts.behaviors, + min: opts.minDate, + max: opts.maxDate, + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE, + action: function () { + self.setValue(); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE, + action: function () { + var date = BI.getDate(); + self.setValue({ + type: BI.DynamicDateCombo.Static, + value: { + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate() + } + }); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE, + action: function () { + var value = self.popup.getValue(); + if (self._checkValue(value)) { + self.setValue(value); + } + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDatePopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); + } + }] + }, + stopPropagation: false + }, + // DEC-4250 和复选下拉一样,点击triggerBtn不默认收起 + hideChecker: function (e) { + return self.triggerBtn.element.find(e.target).length === 0; + }, + listeners: [{ + eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, action: function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + self.popup.setMinDate(opts.minDate); + self.popup.setMaxDate(opts.maxDate); + self.popup.setValue(self.storeValue); + self.fireEvent(BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW); } - }, { - eventName: BI.DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, + }] + }, + top: 0, + left: 0, + right: 0, + bottom: 0 + }, { + el: { + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-font", + width: opts.height - 2, + height: opts.height - 2, + listeners: [{ + eventName: BI.IconButton.EVENT_CHANGE, action: function () { - self.fireEvent(BI.DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); + if (self.combo.isViewVisible()) { + // self.combo.hideView(); + } else { + self.combo.showView(); + } } - }] + }], + ref: function () { + self.triggerBtn = this; + } }, - stopPropagation: false - }, - // DEC-4250 和复选下拉一样,点击triggerBtn不默认收起 - hideChecker: function (e) { - return self.triggerBtn.element.find(e.target).length === 0; - }, - listeners: [{ - eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, - action: function () { - self.popup.setMinDate(opts.minDate); - self.popup.setMaxDate(opts.maxDate); - self.popup.setValue(self.storeValue); - self.fireEvent(BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW); - } + top: 0, + right: 0 }] - }, - top: 0, - left: 0, - right: 0, - bottom: 0 - }, { - el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-font", - width: opts.height, - height: opts.height, - listeners: [{ - eventName: BI.IconButton.EVENT_CHANGE, - action: function () { - if (self.combo.isViewVisible()) { - // self.combo.hideView(); - } else { - self.combo.showView(); - } - } - }], - ref: function () { - self.triggerBtn = this; - } - }, - top: 0, - right: 0 - }] - }], - ref: function (_ref) { - self.comboWrapper = _ref; - } + }], + ref: function (_ref) { + self.comboWrapper = _ref; + } + }, + top: 1, + left: 1, + right: 1, + bottom: 1 + }] }; }, @@ -261,7 +271,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, { switch (type) { case BI.DynamicDateCombo.Dynamic: this.changeIcon.setVisible(true); - this.comboWrapper.attr("items")[0].width = o.height; + this.comboWrapper.attr("items")[0].width = o.height - 2; this.comboWrapper.resize(); break; default: @@ -279,6 +289,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, { return BI.isNotEmptyObject(v.value); case BI.DynamicDateCombo.Static: var value = v.value || {}; + return !BI.checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0]; default: return true; diff --git a/src/widget/dynamicdatetime/dynamicdatetime.combo.js b/src/widget/dynamicdatetime/dynamicdatetime.combo.js index 722ab299b..bc0f71c44 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.combo.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.combo.js @@ -30,229 +30,240 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { this.storeTriggerValue = ""; var date = BI.getDate(); this.storeValue = opts.value; + return { - type: "bi.htape", - cls: "bi-border bi-border-radius", + type: "bi.absolute", items: [{ el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-change-h-font", - width: opts.height, - height: opts.height - 2, - ref: function () { - self.changeIcon = this; - } - }, - width: opts.height - }, { - type: "bi.absolute", - items: [{ - el: { - type: "bi.combo", - destroyWhenHide: true, - container: opts.container, - ref: function () { - self.combo = this; - }, - toggle: false, - isNeedAdjustHeight: opts.isNeedAdjustHeight, - isNeedAdjustWidth: opts.isNeedAdjustWidth, + type: "bi.htape", + cls: "bi-border bi-border-radius bi-focus-shadow", + items: [{ el: { - type: "bi.dynamic_date_time_trigger", - min: opts.minDate, - max: opts.maxDate, - allowEdit: opts.allowEdit, - watermark: opts.watermark, - format: opts.format, + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-change-h-font", + width: opts.height - 2, height: opts.height - 2, - value: opts.value, ref: function () { - self.trigger = this; - }, - listeners: [{ - eventName: BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN, - action: function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_KEY_DOWN, arguments); - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_STOP, - action: function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK, - action: function () { - self.combo.toggle(); - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_FOCUS, - action: function () { - self.storeTriggerValue = self.trigger.getKey(); - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR, - action: function () { - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR); - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, - action: function () { - self.storeValue = { - type: BI.DynamicDateTimeCombo.Static, - value: { - year: date.getFullYear(), - month: date.getMonth() + 1 - } - }; - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_ERROR); - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_VALID, - action: function () { - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_VALID); - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CHANGE); - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_CONFIRM, - action: function () { - var dateStore = self.storeTriggerValue; - var dateObj = self.trigger.getKey(); - if (self.combo.isViewVisible() || BI.isEqual(dateObj, dateStore)) { - return; - } - if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { - self.storeValue = self.trigger.getValue(); - self.setValue(self.trigger.getValue()); - } else if (BI.isEmptyString(dateObj)) { - self.storeValue = null; - self.trigger.setValue(); - } - self._checkDynamicValue(self.storeValue); - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); - } - }] + self.changeIcon = this; + } }, - adjustLength: this.constants.comboAdjustHeight, - popup: { + width: opts.height - 2 + }, { + type: "bi.absolute", + items: [{ el: { - type: "bi.dynamic_date_time_popup", - width: opts.isNeedAdjustWidth ? opts.width : undefined, - supportDynamic: opts.supportDynamic, - behaviors: opts.behaviors, - min: opts.minDate, - max: opts.maxDate, + type: "bi.combo", + cls: "bi-focus-shadow", + destroyWhenHide: true, + container: opts.container, ref: function () { - self.popup = this; + self.combo = this; }, - listeners: [{ - eventName: BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE, - action: function () { - self.setValue(); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE, - action: function () { - var date = BI.getDate(); - self.setValue({ - type: BI.DynamicDateTimeCombo.Static, - value: { - year: date.getFullYear(), - month: date.getMonth() + 1, - day: date.getDate(), - hour: 0, - minute: 0, - second: 0 + toggle: false, + isNeedAdjustHeight: opts.isNeedAdjustHeight, + isNeedAdjustWidth: opts.isNeedAdjustWidth, + el: { + type: "bi.dynamic_date_time_trigger", + min: opts.minDate, + max: opts.maxDate, + allowEdit: opts.allowEdit, + watermark: opts.watermark, + format: opts.format, + height: opts.height - 2, + value: opts.value, + ref: function () { + self.trigger = this; + }, + listeners: [{ + eventName: BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN, + action: function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); } - }); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE, - action: function () { - var value = self.popup.getValue(); - if(self._checkValue(value)) { - self.setValue(value); + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_KEY_DOWN, arguments); } - self.combo.hideView(); - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicDateTimePopup.EVENT_CHANGE, + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_STOP, + action: function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK, + action: function () { + self.combo.toggle(); + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_FOCUS, + action: function () { + self.storeTriggerValue = self.trigger.getKey(); + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR); + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, + action: function () { + self.storeValue = { + type: BI.DynamicDateTimeCombo.Static, + value: { + year: date.getFullYear(), + month: date.getMonth() + 1 + } + }; + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_ERROR); + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_VALID, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_VALID); + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CHANGE); + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_CONFIRM, + action: function () { + var dateStore = self.storeTriggerValue; + var dateObj = self.trigger.getKey(); + if (self.combo.isViewVisible() || BI.isEqual(dateObj, dateStore)) { + return; + } + if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { + self.storeValue = self.trigger.getValue(); + self.setValue(self.trigger.getValue()); + } else if (BI.isEmptyString(dateObj)) { + self.storeValue = null; + self.trigger.setValue(); + } + self._checkDynamicValue(self.storeValue); + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); + } + }] + }, + adjustLength: this.constants.comboAdjustHeight, + popup: { + el: { + type: "bi.dynamic_date_time_popup", + width: opts.isNeedAdjustWidth ? opts.width : undefined, + supportDynamic: opts.supportDynamic, + behaviors: opts.behaviors, + min: opts.minDate, + max: opts.maxDate, + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE, + action: function () { + self.setValue(); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE, + action: function () { + var date = BI.getDate(); + self.setValue({ + type: BI.DynamicDateTimeCombo.Static, + value: { + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate(), + hour: 0, + minute: 0, + second: 0 + } + }); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE, + action: function () { + var value = self.popup.getValue(); + if (self._checkValue(value)) { + self.setValue(value); + } + self.combo.hideView(); + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDateTimePopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); + } + }] + }, + stopPropagation: false + }, + listeners: [{ + eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, action: function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); + self.popup.setMinDate(opts.minDate); + self.popup.setMaxDate(opts.maxDate); + self.popup.setValue(self.storeValue); + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW); } - }, { - eventName: BI.DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, + }], + // DEC-4250 和复选下拉一样,点击不收起 + hideChecker: function (e) { + return self.triggerBtn.element.find(e.target).length === 0; + } + }, + top: 0, + left: 0, + right: 0, + bottom: 0 + }, { + el: { + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-font", + width: opts.height - 2, + height: opts.height - 2, + listeners: [{ + eventName: BI.IconButton.EVENT_CHANGE, action: function () { - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); + if (self.combo.isViewVisible()) { + // self.combo.hideView(); + } else { + self.combo.showView(); + } } - }] - }, - stopPropagation: false - }, - listeners: [{ - eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, - action: function () { - self.popup.setMinDate(opts.minDate); - self.popup.setMaxDate(opts.maxDate); - self.popup.setValue(self.storeValue); - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW); - } - }], - // DEC-4250 和复选下拉一样,点击不收起 - hideChecker: function (e) { - return self.triggerBtn.element.find(e.target).length === 0; - } - }, - top: 0, - left: 0, - right: 0, - bottom: 0 - }, { - el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-font", - width: opts.height, - height: opts.height, - listeners: [{ - eventName: BI.IconButton.EVENT_CHANGE, - action: function () { - if (self.combo.isViewVisible()) { - // self.combo.hideView(); - } else { - self.combo.showView(); + }], + ref: function () { + self.triggerBtn = this; } - } - }], - ref: function () { - self.triggerBtn = this; - } - }, - top: 0, - right: 0 - }] - }], - ref: function (_ref) { - self.comboWrapper = _ref; - } + }, + top: 0, + right: 0 + }] + }], + ref: function (_ref) { + self.comboWrapper = _ref; + } + }, + top: 1, + left: 1, + right: 1, + bottom: 1 + }] }; }, @@ -269,7 +280,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { switch (type) { case BI.DynamicDateTimeCombo.Dynamic: this.changeIcon.setVisible(true); - this.comboWrapper.attr("items")[0].width = o.height; + this.comboWrapper.attr("items")[0].width = o.height - 2; this.comboWrapper.resize(); break; default: @@ -287,6 +298,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { return BI.isNotEmptyObject(v.value); case BI.DynamicDateCombo.Static: var value = v.value || {}; + return !BI.checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0]; default: return true; diff --git a/src/widget/year/combo.year.js b/src/widget/year/combo.year.js index da6233f1c..b23b660e4 100644 --- a/src/widget/year/combo.year.js +++ b/src/widget/year/combo.year.js @@ -6,7 +6,7 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, { minDate: "1900-01-01", // 最小日期 maxDate: "2099-12-31", // 最大日期 height: 24, - supportDynamic: true, + supportDynamic: true }, _init: function () { @@ -92,7 +92,7 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, { eventName: BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE, action: function () { var date = BI.getDate(); - self.setValue({type: BI.DynamicYearCombo.Static, value: {year: date.getFullYear()}}); + self.setValue({ type: BI.DynamicYearCombo.Static, value: { year: date.getFullYear() } }); self.combo.hideView(); self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); } @@ -119,24 +119,33 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, { }); BI.createWidget({ - type: "bi.htape", - cls: "bi-border bi-border-radius", + type: "bi.absolute", element: this, - ref: function () { - self.comboWrapper = this; - }, items: [{ el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-change-h-font", - width: 24, - height: o.height - 2, + type: "bi.htape", + cls: "bi-border bi-border-radius bi-focus-shadow", ref: function () { - self.changeIcon = this; - } + self.comboWrapper = this; + }, + items: [{ + el: { + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-change-h-font", + width: o.height - 2, + height: o.height - 2, + ref: function () { + self.changeIcon = this; + } + }, + width: o.height - 2 + }, this.combo] }, - width: 24 - }, this.combo] + top: 1, + left: 1, + right: 1, + bottom: 1 + }] }); this._checkDynamicValue(o.value); }, @@ -149,7 +158,7 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, { switch (type) { case BI.DynamicYearCombo.Dynamic: this.changeIcon.setVisible(true); - this.comboWrapper.attr("items")[0].width = 24; + this.comboWrapper.attr("items")[0].width = this.options.height - 2, this.comboWrapper.resize(); break; default: diff --git a/src/widget/yearmonth/combo.yearmonth.js b/src/widget/yearmonth/combo.yearmonth.js index 662dcc0eb..761760e1a 100644 --- a/src/widget/yearmonth/combo.yearmonth.js +++ b/src/widget/yearmonth/combo.yearmonth.js @@ -93,7 +93,7 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, { eventName: BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE, action: function () { var date = BI.getDate(); - self.setValue({type: BI.DynamicYearMonthCombo.Static, value: {year: date.getFullYear(), month: date.getMonth() + 1}}); + self.setValue({ type: BI.DynamicYearMonthCombo.Static, value: { year: date.getFullYear(), month: date.getMonth() + 1 } }); self.combo.hideView(); self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); } @@ -123,24 +123,33 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, { }); BI.createWidget({ - type: "bi.htape", - cls: "bi-border bi-border-radius", + type: "bi.absolute", element: this, - ref: function () { - self.comboWrapper = this; - }, items: [{ el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-change-h-font", - width: 24, - height: o.height - 2, + type: "bi.htape", + cls: "bi-border bi-border-radius bi-focus-shadow", ref: function () { - self.changeIcon = this; - } + self.comboWrapper = this; + }, + items: [{ + el: { + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-change-h-font", + width: o.height - 2, + height: o.height - 2, + ref: function () { + self.changeIcon = this; + } + }, + width: o.height - 2 + }, this.combo] }, - width: 24 - }, this.combo] + top: 1, + left: 1, + right: 1, + bottom: 1 + }] }); this._checkDynamicValue(o.value); }, @@ -153,7 +162,7 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, { switch (type) { case BI.DynamicYearMonthCombo.Dynamic: this.changeIcon.setVisible(true); - this.comboWrapper.attr("items")[0].width = 24; + this.comboWrapper.attr("items")[0].width = this.options.height - 2, this.comboWrapper.resize(); break; default: @@ -171,6 +180,7 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, { return BI.isNotEmptyObject(v.value); case BI.DynamicDateCombo.Static: var value = v.value || {}; + return !BI.checkDateVoid(value.year, value.month, 1, o.minDate, o.maxDate)[0]; default: return true; diff --git a/src/widget/yearquarter/combo.yearquarter.js b/src/widget/yearquarter/combo.yearquarter.js index 129d5edf6..83c973702 100644 --- a/src/widget/yearquarter/combo.yearquarter.js +++ b/src/widget/yearquarter/combo.yearquarter.js @@ -93,7 +93,7 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, { eventName: BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE, action: function () { var date = BI.getDate(); - self.setValue({type: BI.DynamicYearMonthCombo.Static, value: {year: date.getFullYear(), quarter: BI.getQuarter(date)}}); + self.setValue({ type: BI.DynamicYearMonthCombo.Static, value: { year: date.getFullYear(), quarter: BI.getQuarter(date) } }); self.combo.hideView(); self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); } @@ -123,24 +123,33 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, { }); BI.createWidget({ - type: "bi.htape", - cls: "bi-border bi-border-radius", + type: "bi.absolute", element: this, - ref: function () { - self.comboWrapper = this; - }, items: [{ el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-change-h-font", - width: 24, - height: o.height - 2, + type: "bi.htape", + cls: "bi-border bi-border-radius bi-focus-shadow", ref: function () { - self.changeIcon = this; - } + self.comboWrapper = this; + }, + items: [{ + el: { + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-change-h-font", + width: o.height - 2, + height: o.height - 2, + ref: function () { + self.changeIcon = this; + } + }, + width: o.height - 2 + }, this.combo] }, - width: 24 - }, this.combo] + top: 1, + left: 1, + right: 1, + bottom: 1 + }] }); this._checkDynamicValue(o.value); }, @@ -153,7 +162,7 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, { switch (type) { case BI.DynamicYearQuarterCombo.Dynamic: this.changeIcon.setVisible(true); - this.comboWrapper.attr("items")[0].width = 24; + this.comboWrapper.attr("items")[0].width = this.options.height - 2; this.comboWrapper.resize(); break; default: @@ -171,6 +180,7 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, { return BI.isNotEmptyObject(v.value); case BI.DynamicDateCombo.Static: var value = v.value || {}; + return !BI.checkDateVoid(value.year, (value.quarter - 1) * 3 + 1, 1, o.minDate, o.maxDate)[0]; default: return true; From 85853e29481872c130e173733c715587313d6319 Mon Sep 17 00:00:00 2001 From: iapyang Date: Mon, 11 Oct 2021 17:13:52 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dbi-focus-shadow?= =?UTF-8?q?=E5=9C=A8=E4=B8=8B=E6=8B=89=E6=A1=86=E6=94=B6=E8=B5=B7=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E4=BC=9Ablur=E5=AF=BC=E8=87=B4focus-within=E4=BC=AA?= =?UTF-8?q?=E7=B1=BB=E4=B8=80=E7=9B=B4=E5=AD=98=E5=9C=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/combination/combo.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index fcb2690f3..7ca9267d8 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -296,14 +296,16 @@ this.popupView && this.popupView.destroy(); this.popupView = null; this._rendered = false; - - if (!e || !this.combo.element.__isMouseInBounds__(e)) { - this.element.removeClass(this.options.hoverClass); - } } else { this.popupView && this.popupView.invisible(); } + if (!e || !this.combo.element.__isMouseInBounds__(e)) { + this.element.removeClass(this.options.hoverClass); + // 应对bi-focus-shadow在收起时不失焦 + this.element.blur(); + } + this.element.removeClass(this.options.comboClass); delete needHideWhenAnotherComboOpen[this.getName()];