Browse Source

Pull request #2224: 无JIRA任务 修复边框不高亮+高度不准确问题

Merge in VISUAL/fineui from ~TELLER/fineui:master to master

* commit '217d08f70329c31057cd78916cee0118958f19e0':
  fix: 修复bi-focus-shadow在下拉框收起时不会blur导致focus-within伪类一直存在的问题
  BI-95299 fix: 修复边框不高亮+高度不准确问题
  chore: 修改eslint
es6
Teller 3 years ago
parent
commit
d95a57ade9
  1. 5
      .eslintrc
  2. 10
      src/base/combination/combo.js
  3. 407
      src/widget/dynamicdate/dynamicdate.combo.js
  4. 426
      src/widget/dynamicdatetime/dynamicdatetime.combo.js
  5. 41
      src/widget/year/combo.year.js
  6. 40
      src/widget/yearmonth/combo.yearmonth.js
  7. 40
      src/widget/yearquarter/combo.yearquarter.js

5
.eslintrc

@ -27,7 +27,10 @@
"plugins": ["@typescript-eslint/eslint-plugin"], "plugins": ["@typescript-eslint/eslint-plugin"],
"overrides": [{ "overrides": [{
"files": ["src/*.js","src/**/*.js", "demo/*.js", "demo/**/*.js", "i18n/**/*.js", "i18n/*.js", "test/**/*.js", "test/*.js"], "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"], "files": ["webpack/*.js", "types/*.ts", "typescript/*.ts","typescript/**/*.ts", "./*.js", "lib/**/*.js", "lib/*.js"],
"extends": "plugin:@fui/typescript" "extends": "plugin:@fui/typescript"

10
src/base/combination/combo.js

@ -296,14 +296,16 @@
this.popupView && this.popupView.destroy(); this.popupView && this.popupView.destroy();
this.popupView = null; this.popupView = null;
this._rendered = false; this._rendered = false;
if (!e || !this.combo.element.__isMouseInBounds__(e)) {
this.element.removeClass(this.options.hoverClass);
}
} else { } else {
this.popupView && this.popupView.invisible(); 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); this.element.removeClass(this.options.comboClass);
delete needHideWhenAnotherComboOpen[this.getName()]; delete needHideWhenAnotherComboOpen[this.getName()];

407
src/widget/dynamicdate/dynamicdate.combo.js

@ -30,221 +30,231 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
this.storeTriggerValue = ""; this.storeTriggerValue = "";
var date = BI.getDate(); var date = BI.getDate();
this.storeValue = opts.value; this.storeValue = opts.value;
return { return {
type: "bi.htape", type: "bi.absolute",
cls: "bi-border bi-border-radius",
items: [{ items: [{
el: { el: {
type: "bi.icon_button", type: "bi.htape",
cls: "bi-trigger-icon-button date-change-h-font", cls: "bi-border bi-border-radius bi-focus-shadow",
width: opts.height, items: [{
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,
el: { el: {
type: "bi.dynamic_date_trigger", type: "bi.icon_button",
min: opts.minDate, cls: "bi-trigger-icon-button date-change-h-font",
max: opts.maxDate, width: opts.height - 2,
format: opts.format,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
height: opts.height - 2, height: opts.height - 2,
value: opts.value,
ref: function () { ref: function () {
self.trigger = this; self.changeIcon = 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);
}
}]
}, },
adjustLength: this.constants.comboAdjustHeight, width: opts.height - 2
popup: { }, {
type: "bi.absolute",
items: [{
el: { el: {
type: "bi.dynamic_date_popup", type: "bi.combo",
width: opts.isNeedAdjustWidth ? opts.width : undefined, container: opts.container,
supportDynamic: opts.supportDynamic,
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
ref: function () { ref: function () {
self.popup = this; self.combo = this;
}, },
listeners: [{ toggle: false,
eventName: BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE, isNeedAdjustHeight: opts.isNeedAdjustHeight,
action: function () { isNeedAdjustWidth: opts.isNeedAdjustWidth,
self.setValue(); destroyWhenHide: true,
self.combo.hideView(); el: {
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); type: "bi.dynamic_date_trigger",
} min: opts.minDate,
}, { max: opts.maxDate,
eventName: BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE, format: opts.format,
action: function () { allowEdit: opts.allowEdit,
var date = BI.getDate(); watermark: opts.watermark,
self.setValue({ height: opts.height - 2,
type: BI.DynamicDateCombo.Static, value: opts.value,
value: { ref: function () {
year: date.getFullYear(), self.trigger = this;
month: date.getMonth() + 1, },
day: date.getDate() listeners: [{
eventName: BI.DynamicDateTrigger.EVENT_KEY_DOWN,
action: function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
} }
}); self.fireEvent(BI.DynamicDateCombo.EVENT_KEY_DOWN, arguments);
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.DynamicDateTrigger.EVENT_STOP,
} action: function () {
}, { if (!self.combo.isViewVisible()) {
eventName: BI.DynamicDatePopup.EVENT_CHANGE, 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 () { action: function () {
self.setValue(self.popup.getValue()); self.popup.setMinDate(opts.minDate);
self.combo.hideView(); self.popup.setMaxDate(opts.maxDate);
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); 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 () { 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 top: 0,
}, right: 0
// 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, ref: function (_ref) {
left: 0, self.comboWrapper = _ref;
right: 0, }
bottom: 0 },
}, { top: 1,
el: { left: 1,
type: "bi.icon_button", right: 1,
cls: "bi-trigger-icon-button date-font", bottom: 1
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;
}
}; };
}, },
@ -261,7 +271,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
switch (type) { switch (type) {
case BI.DynamicDateCombo.Dynamic: case BI.DynamicDateCombo.Dynamic:
this.changeIcon.setVisible(true); this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = o.height; this.comboWrapper.attr("items")[0].width = o.height - 2;
this.comboWrapper.resize(); this.comboWrapper.resize();
break; break;
default: default:
@ -279,6 +289,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
return BI.isNotEmptyObject(v.value); return BI.isNotEmptyObject(v.value);
case BI.DynamicDateCombo.Static: case BI.DynamicDateCombo.Static:
var value = v.value || {}; var value = v.value || {};
return !BI.checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0]; return !BI.checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default: default:
return true; return true;

426
src/widget/dynamicdatetime/dynamicdatetime.combo.js

@ -30,229 +30,240 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
this.storeTriggerValue = ""; this.storeTriggerValue = "";
var date = BI.getDate(); var date = BI.getDate();
this.storeValue = opts.value; this.storeValue = opts.value;
return { return {
type: "bi.htape", type: "bi.absolute",
cls: "bi-border bi-border-radius",
items: [{ items: [{
el: { el: {
type: "bi.icon_button", type: "bi.htape",
cls: "bi-trigger-icon-button date-change-h-font", cls: "bi-border bi-border-radius bi-focus-shadow",
width: opts.height, items: [{
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,
el: { el: {
type: "bi.dynamic_date_time_trigger", type: "bi.icon_button",
min: opts.minDate, cls: "bi-trigger-icon-button date-change-h-font",
max: opts.maxDate, width: opts.height - 2,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
format: opts.format,
height: opts.height - 2, height: opts.height - 2,
value: opts.value,
ref: function () { ref: function () {
self.trigger = this; self.changeIcon = 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);
}
}]
}, },
adjustLength: this.constants.comboAdjustHeight, width: opts.height - 2
popup: { }, {
type: "bi.absolute",
items: [{
el: { el: {
type: "bi.dynamic_date_time_popup", type: "bi.combo",
width: opts.isNeedAdjustWidth ? opts.width : undefined, cls: "bi-focus-shadow",
supportDynamic: opts.supportDynamic, destroyWhenHide: true,
behaviors: opts.behaviors, container: opts.container,
min: opts.minDate,
max: opts.maxDate,
ref: function () { ref: function () {
self.popup = this; self.combo = this;
}, },
listeners: [{ toggle: false,
eventName: BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE, isNeedAdjustHeight: opts.isNeedAdjustHeight,
action: function () { isNeedAdjustWidth: opts.isNeedAdjustWidth,
self.setValue(); el: {
self.combo.hideView(); type: "bi.dynamic_date_time_trigger",
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); min: opts.minDate,
} max: opts.maxDate,
}, { allowEdit: opts.allowEdit,
eventName: BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE, watermark: opts.watermark,
action: function () { format: opts.format,
var date = BI.getDate(); height: opts.height - 2,
self.setValue({ value: opts.value,
type: BI.DynamicDateTimeCombo.Static, ref: function () {
value: { self.trigger = this;
year: date.getFullYear(), },
month: date.getMonth() + 1, listeners: [{
day: date.getDate(), eventName: BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN,
hour: 0, action: function () {
minute: 0, if (self.combo.isViewVisible()) {
second: 0 self.combo.hideView();
} }
}); self.fireEvent(BI.DynamicDateTimeCombo.EVENT_KEY_DOWN, arguments);
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.DynamicDateTimeTrigger.EVENT_STOP,
} action: function () {
}, { if (!self.combo.isViewVisible()) {
eventName: BI.DynamicDateTimePopup.EVENT_CHANGE, 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 () { action: function () {
self.setValue(self.popup.getValue()); self.popup.setMinDate(opts.minDate);
self.combo.hideView(); self.popup.setMaxDate(opts.maxDate);
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); 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 () { action: function () {
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); if (self.combo.isViewVisible()) {
// self.combo.hideView();
} else {
self.combo.showView();
}
} }
}] }],
}, ref: function () {
stopPropagation: false self.triggerBtn = this;
},
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();
} }
} },
}], top: 0,
ref: function () { right: 0
self.triggerBtn = this; }]
} }],
}, ref: function (_ref) {
top: 0, self.comboWrapper = _ref;
right: 0 }
}] },
}], top: 1,
ref: function (_ref) { left: 1,
self.comboWrapper = _ref; right: 1,
} bottom: 1
}]
}; };
}, },
@ -269,7 +280,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
switch (type) { switch (type) {
case BI.DynamicDateTimeCombo.Dynamic: case BI.DynamicDateTimeCombo.Dynamic:
this.changeIcon.setVisible(true); this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = o.height; this.comboWrapper.attr("items")[0].width = o.height - 2;
this.comboWrapper.resize(); this.comboWrapper.resize();
break; break;
default: default:
@ -287,6 +298,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
return BI.isNotEmptyObject(v.value); return BI.isNotEmptyObject(v.value);
case BI.DynamicDateCombo.Static: case BI.DynamicDateCombo.Static:
var value = v.value || {}; var value = v.value || {};
return !BI.checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0]; return !BI.checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default: default:
return true; return true;

41
src/widget/year/combo.year.js

@ -6,7 +6,7 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
minDate: "1900-01-01", // 最小日期 minDate: "1900-01-01", // 最小日期
maxDate: "2099-12-31", // 最大日期 maxDate: "2099-12-31", // 最大日期
height: 24, height: 24,
supportDynamic: true, supportDynamic: true
}, },
_init: function () { _init: function () {
@ -92,7 +92,7 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
eventName: BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE, eventName: BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () { action: function () {
var date = BI.getDate(); 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.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
} }
@ -119,24 +119,33 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
}); });
BI.createWidget({ BI.createWidget({
type: "bi.htape", type: "bi.absolute",
cls: "bi-border bi-border-radius",
element: this, element: this,
ref: function () {
self.comboWrapper = this;
},
items: [{ items: [{
el: { el: {
type: "bi.icon_button", type: "bi.htape",
cls: "bi-trigger-icon-button date-change-h-font", cls: "bi-border bi-border-radius bi-focus-shadow",
width: 24,
height: o.height - 2,
ref: function () { 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 top: 1,
}, this.combo] left: 1,
right: 1,
bottom: 1
}]
}); });
this._checkDynamicValue(o.value); this._checkDynamicValue(o.value);
}, },
@ -149,7 +158,7 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
switch (type) { switch (type) {
case BI.DynamicYearCombo.Dynamic: case BI.DynamicYearCombo.Dynamic:
this.changeIcon.setVisible(true); this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = 24; this.comboWrapper.attr("items")[0].width = this.options.height - 2,
this.comboWrapper.resize(); this.comboWrapper.resize();
break; break;
default: default:

40
src/widget/yearmonth/combo.yearmonth.js

@ -93,7 +93,7 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
eventName: BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE, eventName: BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () { action: function () {
var date = BI.getDate(); 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.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
} }
@ -123,24 +123,33 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
}); });
BI.createWidget({ BI.createWidget({
type: "bi.htape", type: "bi.absolute",
cls: "bi-border bi-border-radius",
element: this, element: this,
ref: function () {
self.comboWrapper = this;
},
items: [{ items: [{
el: { el: {
type: "bi.icon_button", type: "bi.htape",
cls: "bi-trigger-icon-button date-change-h-font", cls: "bi-border bi-border-radius bi-focus-shadow",
width: 24,
height: o.height - 2,
ref: function () { 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 top: 1,
}, this.combo] left: 1,
right: 1,
bottom: 1
}]
}); });
this._checkDynamicValue(o.value); this._checkDynamicValue(o.value);
}, },
@ -153,7 +162,7 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
switch (type) { switch (type) {
case BI.DynamicYearMonthCombo.Dynamic: case BI.DynamicYearMonthCombo.Dynamic:
this.changeIcon.setVisible(true); this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = 24; this.comboWrapper.attr("items")[0].width = this.options.height - 2,
this.comboWrapper.resize(); this.comboWrapper.resize();
break; break;
default: default:
@ -171,6 +180,7 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
return BI.isNotEmptyObject(v.value); return BI.isNotEmptyObject(v.value);
case BI.DynamicDateCombo.Static: case BI.DynamicDateCombo.Static:
var value = v.value || {}; var value = v.value || {};
return !BI.checkDateVoid(value.year, value.month, 1, o.minDate, o.maxDate)[0]; return !BI.checkDateVoid(value.year, value.month, 1, o.minDate, o.maxDate)[0];
default: default:
return true; return true;

40
src/widget/yearquarter/combo.yearquarter.js

@ -93,7 +93,7 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
eventName: BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE, eventName: BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE,
action: function () { action: function () {
var date = BI.getDate(); 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.combo.hideView();
self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
} }
@ -123,24 +123,33 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
}); });
BI.createWidget({ BI.createWidget({
type: "bi.htape", type: "bi.absolute",
cls: "bi-border bi-border-radius",
element: this, element: this,
ref: function () {
self.comboWrapper = this;
},
items: [{ items: [{
el: { el: {
type: "bi.icon_button", type: "bi.htape",
cls: "bi-trigger-icon-button date-change-h-font", cls: "bi-border bi-border-radius bi-focus-shadow",
width: 24,
height: o.height - 2,
ref: function () { 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 top: 1,
}, this.combo] left: 1,
right: 1,
bottom: 1
}]
}); });
this._checkDynamicValue(o.value); this._checkDynamicValue(o.value);
}, },
@ -153,7 +162,7 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
switch (type) { switch (type) {
case BI.DynamicYearQuarterCombo.Dynamic: case BI.DynamicYearQuarterCombo.Dynamic:
this.changeIcon.setVisible(true); this.changeIcon.setVisible(true);
this.comboWrapper.attr("items")[0].width = 24; this.comboWrapper.attr("items")[0].width = this.options.height - 2;
this.comboWrapper.resize(); this.comboWrapper.resize();
break; break;
default: default:
@ -171,6 +180,7 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
return BI.isNotEmptyObject(v.value); return BI.isNotEmptyObject(v.value);
case BI.DynamicDateCombo.Static: case BI.DynamicDateCombo.Static:
var value = v.value || {}; var value = v.value || {};
return !BI.checkDateVoid(value.year, (value.quarter - 1) * 3 + 1, 1, o.minDate, o.maxDate)[0]; return !BI.checkDateVoid(value.year, (value.quarter - 1) * 3 + 1, 1, o.minDate, o.maxDate)[0];
default: default:
return true; return true;

Loading…
Cancel
Save