Browse Source

chore: 整理代码

es6
guy 3 years ago
parent
commit
fb3c102632
  1. 8
      src/less/base/colorchooser/colorchooser.trigger.less
  2. 389
      src/widget/dynamicdate/dynamicdate.combo.js
  3. 11
      src/widget/dynamicdate/dynamicdate.trigger.js
  4. 402
      src/widget/dynamicdatetime/dynamicdatetime.combo.js
  5. 12
      src/widget/dynamicdatetime/dynamicdatetime.trigger.js

8
src/less/base/colorchooser/colorchooser.trigger.less

@ -2,4 +2,10 @@
.bi-color-chooser-trigger { .bi-color-chooser-trigger {
.border-radius(2px); .border-radius(2px);
} }
.bi-combo-popup {
.bi-color-chooser-trigger {
border-color: @color-bi-border-hover-combo;
}
}

389
src/widget/dynamicdate/dynamicdate.combo.js

@ -36,223 +36,190 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
type: "bi.absolute", type: "bi.absolute",
items: [{ items: [{
el: { el: {
type: "bi.htape", type: "bi.combo",
cls: (opts.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow", cls: (opts.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow",
items: [{ container: opts.container,
el: { ref: function () {
type: "bi.icon_button", self.combo = this;
cls: "bi-trigger-icon-button date-change-h-font", },
width: opts.height - border, toggle: false,
height: opts.height - border, isNeedAdjustHeight: opts.isNeedAdjustHeight,
ref: function () { isNeedAdjustWidth: opts.isNeedAdjustWidth,
self.changeIcon = this; destroyWhenHide: true,
} el: {
}, type: "bi.horizontal_fill",
width: opts.height - border columnSize: [opts.height - border, "fill"],
}, { height: opts.height - border,
type: "bi.absolute",
items: [{ items: [{
el: {
type: "bi.combo",
container: opts.container,
ref: function () {
self.combo = this;
},
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
destroyWhenHide: true,
el: {
type: "bi.dynamic_date_trigger",
simple: opts.simple,
min: opts.minDate,
max: opts.maxDate,
format: opts.format,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
height: opts.height - border,
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.comboWrapper.element.addClass("error");
self.fireEvent(BI.DynamicDateCombo.EVENT_ERROR);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_VALID,
action: function () {
self.comboWrapper.element.removeClass("error");
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.popup.setMinDate(opts.minDate);
self.popup.setMaxDate(opts.maxDate);
self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW);
}
}]
},
top: 0,
left: 0,
right: 0,
bottom: 0
}, {
el: { el: {
type: "bi.icon_button", type: "bi.icon_button",
cls: "bi-trigger-icon-button date-font", cls: "bi-trigger-icon-button date-change-h-font",
width: opts.height - border, width: opts.height - border,
height: opts.height - border, height: opts.height - border,
listeners: [{
eventName: BI.IconButton.EVENT_CHANGE,
action: function () {
if (self.combo.isViewVisible()) {
// self.combo.hideView();
} else {
self.combo.showView();
}
}
}],
ref: function () { ref: function () {
self.triggerBtn = this; self.changeIcon = this;
} }
}, },
top: 0, }, {
right: 0 type: "bi.dynamic_date_trigger",
simple: opts.simple,
min: opts.minDate,
max: opts.maxDate,
format: opts.format,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
iconWidth: opts.height - border,
height: opts.height - border,
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.combo.element.addClass("error");
self.fireEvent(BI.DynamicDateCombo.EVENT_ERROR);
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_VALID,
action: function () {
self.combo.element.removeClass("error");
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);
}
}]
}] }]
}], },
ref: function (_ref) { adjustLength: this.constants.comboAdjustHeight,
self.comboWrapper = _ref; 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);
}
}]
},
},
// // 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, top: 0,
left: 0, left: 0,
@ -275,12 +242,12 @@ 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.options.simple ? 1 : 2; // this.comboWrapper.attr("items")[0].width = o.height - this.options.simple ? 1 : 2;
this.comboWrapper.resize(); // this.comboWrapper.resize();
break; break;
default: default:
this.comboWrapper.attr("items")[0].width = 0; // this.comboWrapper.attr("items")[0].width = 0;
this.comboWrapper.resize(); // this.comboWrapper.resize();
this.changeIcon.setVisible(false); this.changeIcon.setVisible(false);
break; break;
} }

11
src/widget/dynamicdate/dynamicdate.trigger.js

@ -13,6 +13,7 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
min: "1900-01-01", // 最小日期 min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期 max: "2099-12-31", // 最大日期
height: 24, height: 24,
iconWidth: 24,
format: "", // 显示的日期格式化方式 format: "", // 显示的日期格式化方式
allowEdit: true, // 是否允许编辑 allowEdit: true, // 是否允许编辑
watermark: "" watermark: ""
@ -122,8 +123,12 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
items: [{ items: [{
el: this.editor el: this.editor
}, { }, {
el: BI.createWidget(), el: {
width: 24 type: "bi.icon_button",
cls: "bi-trigger-icon-button date-font",
width: o.iconWidth
},
width: o.iconWidth
}] }]
}); });
!o.allowEdit && BI.createWidget({ !o.allowEdit && BI.createWidget({
@ -135,7 +140,7 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
title: BI.bind(this._getTitle, this) title: BI.bind(this._getTitle, this)
}, },
left: 0, left: 0,
right: 24, right: o.iconWidth,
top: 0, top: 0,
bottom: 0 bottom: 0
}] }]

402
src/widget/dynamicdatetime/dynamicdatetime.combo.js

@ -36,232 +36,198 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
type: "bi.absolute", type: "bi.absolute",
items: [{ items: [{
el: { el: {
type: "bi.htape", type: "bi.combo",
cls: (opts.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow", cls: (opts.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow",
items: [{ destroyWhenHide: true,
el: { container: opts.container,
type: "bi.icon_button", ref: function () {
cls: "bi-trigger-icon-button date-change-h-font", self.combo = this;
width: opts.height - border, },
height: opts.height - border, toggle: false,
ref: function () { isNeedAdjustHeight: opts.isNeedAdjustHeight,
self.changeIcon = this; isNeedAdjustWidth: opts.isNeedAdjustWidth,
} el: {
}, type: "bi.horizontal_fill",
width: opts.height - border columnSize: [opts.height - border, "fill"],
}, { height: opts.height - border,
type: "bi.absolute",
items: [{ items: [{
el: { el: {
type: "bi.combo", type: "bi.icon_button",
cls: "bi-focus-shadow", cls: "bi-trigger-icon-button date-change-h-font",
destroyWhenHide: true, width: opts.height - border,
container: opts.container, height: opts.height - border,
ref: function () { ref: function () {
self.combo = this; self.changeIcon = this;
},
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
el: {
type: "bi.dynamic_date_time_trigger",
simple: opts.simple,
min: opts.minDate,
max: opts.maxDate,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
format: opts.format,
height: opts.height - border,
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.comboWrapper.element.addClass("error");
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_ERROR);
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_VALID,
action: function () {
self.comboWrapper.element.removeClass("error");
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.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.dynamic_date_time_trigger",
type: "bi.icon_button", simple: opts.simple,
cls: "bi-trigger-icon-button date-font", min: opts.minDate,
width: opts.height - border, max: opts.maxDate,
height: opts.height - border, allowEdit: opts.allowEdit,
listeners: [{ watermark: opts.watermark,
eventName: BI.IconButton.EVENT_CHANGE, format: opts.format,
action: function () { iconWidth: opts.height - border,
if (self.combo.isViewVisible()) { height: opts.height - border,
// self.combo.hideView(); value: opts.value,
} else { ref: function () {
self.combo.showView(); 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.combo.element.addClass("error");
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_ERROR);
}
}, {
eventName: BI.DynamicDateTimeTrigger.EVENT_VALID,
action: function () {
self.combo.element.removeClass("error");
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)) {
ref: function () { self.storeValue = self.trigger.getValue();
self.triggerBtn = this; 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);
} }
}, }]
top: 0,
right: 0
}] }]
},
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);
}
}]
},
},
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);
}
}], }],
ref: function (_ref) { // // DEC-4250 和复选下拉一样,点击不收起
self.comboWrapper = _ref; // hideChecker: function (e) {
} // return self.triggerBtn.element.find(e.target).length === 0;
// }
}, },
top: 0, top: 0,
left: 0, left: 0,
@ -284,12 +250,12 @@ 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.options.simple ? 1 : 2; // this.comboWrapper.attr("items")[0].width = o.height - (this.options.simple ? 1 : 2);
this.comboWrapper.resize(); // this.comboWrapper.resize();
break; break;
default: default:
this.comboWrapper.attr("items")[0].width = 0; // this.comboWrapper.attr("items")[0].width = 0;
this.comboWrapper.resize(); // this.comboWrapper.resize();
this.changeIcon.setVisible(false); this.changeIcon.setVisible(false);
break; break;
} }

12
src/widget/dynamicdatetime/dynamicdatetime.trigger.js

@ -13,6 +13,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
min: "1900-01-01", // 最小日期 min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期 max: "2099-12-31", // 最大日期
height: 24, height: 24,
iconWidth: 24,
format: "", // 显示的日期格式化方式 format: "", // 显示的日期格式化方式
allowEdit: true, // 是否允许编辑 allowEdit: true, // 是否允许编辑
watermark: "" watermark: ""
@ -120,8 +121,11 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
items: [{ items: [{
el: this.editor el: this.editor
}, { }, {
el: BI.createWidget(), el: {
width: 24 type: "bi.icon_button",
cls: "bi-trigger-icon-button date-font",
},
width: o.iconWidth
}] }]
}); });
@ -134,7 +138,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
title: BI.bind(this._getTitle, this) title: BI.bind(this._getTitle, this)
}, },
left: 0, left: 0,
right: 24, right: o.iconWidth,
top: 0, top: 0,
bottom: 0 bottom: 0
}] }]
@ -389,4 +393,4 @@ BI.DynamicDateTimeTrigger.EVENT_VALID = "EVENT_VALID";
BI.DynamicDateTimeTrigger.EVENT_ERROR = "EVENT_ERROR"; BI.DynamicDateTimeTrigger.EVENT_ERROR = "EVENT_ERROR";
BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
BI.shortcut("bi.dynamic_date_time_trigger", BI.DynamicDateTimeTrigger); BI.shortcut("bi.dynamic_date_time_trigger", BI.DynamicDateTimeTrigger);

Loading…
Cancel
Save