Browse Source

Merge pull request #258533 in DEC/fineui from master to feature/x

* commit 'e46e7ec0164ba1f1985a65c207616c0784f5fc15':
  无jia任务 先回退
  BI-133648 feat:日期过滤控件加预览模式
  无JIRA 组件销毁的时候ref处理
  KERNEL-16950 fix: 内存泄露问题
  BI-133648 feat:日期过滤控件加预览模式
  BI-133648 fix:日期过滤控件加预览模式
research/test
superman 12 months ago
parent
commit
ad7c51a9bd
  1. 2
      packages/fineui/src/core/4.widget.js
  2. 3
      packages/fineui/src/fix/fix.js
  3. 51
      packages/fineui/src/widget/datepane/datepane.js
  4. 2
      packages/fineui/src/widget/dynamicdate/dynamicdate.combo.js
  5. 16
      packages/fineui/src/widget/dynamicdate/dynamicdate.popup.js
  6. 2
      packages/fineui/src/widget/dynamicdatetime/dynamicdatetime.combo.js
  7. 17
      packages/fineui/src/widget/dynamicdatetime/dynamicdatetime.popup.js
  8. 2
      packages/fineui/src/widget/timeinterval/dateinterval.js
  9. 2
      packages/fineui/src/widget/timeinterval/timeinterval.js
  10. 2
      packages/fineui/src/widget/year/combo.year.js
  11. 10
      packages/fineui/src/widget/year/popup.year.js
  12. 2
      packages/fineui/src/widget/yearmonth/combo.yearmonth.js
  13. 14
      packages/fineui/src/widget/yearmonth/popup.yearmonth.js
  14. 2
      packages/fineui/src/widget/yearmonthinterval/yearmonthinterval.js
  15. 2
      packages/fineui/src/widget/yearquarter/combo.yearquarter.js
  16. 15
      packages/fineui/src/widget/yearquarter/popup.yearquarter.js

2
packages/fineui/src/core/4.widget.js

@ -868,13 +868,13 @@ export class Widget extends OB {
callLifeHook(this, "destroyed"); callLifeHook(this, "destroyed");
this.destroyed = null; this.destroyed = null;
this._isDestroyed = true; this._isDestroyed = true;
// this._purgeRef(); // 清除ref的时机还是要仔细考虑一下
} }
_unMount() { _unMount() {
this._assetMounted(); this._assetMounted();
this.__destroy(); this.__destroy();
this.fireEvent(Events.UNMOUNT); this.fireEvent(Events.UNMOUNT);
// this._purgeRef(); // 子组件unmount ref置为null了,父组件拿不到ref,导致报错
this.purgeListeners(); this.purgeListeners();
} }

3
packages/fineui/src/fix/fix.js

@ -1380,10 +1380,13 @@ class Model {
}); });
}); });
this._watchers && (this._watchers = []); this._watchers && (this._watchers = []);
this._computedWatchers && (this._computedWatchers = []);
this.destroyed && this.destroyed(); this.destroyed && this.destroyed();
this.$$model = null; this.$$model = null;
this.$$computed = null; this.$$computed = null;
this.$$state = null; this.$$state = null;
this.$$context = null;
this.model = null;
this._destroyHandler && this._destroyHandler(); this._destroyHandler && this._destroyHandler();
} }
} }

51
packages/fineui/src/widget/datepane/datepane.js

@ -30,6 +30,7 @@ export class DynamicDatePane extends Widget {
minDate: "1900-01-01", minDate: "1900-01-01",
maxDate: "2099-12-31", maxDate: "2099-12-31",
supportDynamic: true, supportDynamic: true,
isPreview: false, // 是否是预览状态
}; };
render() { render() {
@ -63,17 +64,11 @@ export class DynamicDatePane extends Widget {
{ {
eventName: ButtonGroup.EVENT_CHANGE, eventName: ButtonGroup.EVENT_CHANGE,
action: () => { action: () => {
let date;
const value = this.switcher.getValue()[0]; const value = this.switcher.getValue()[0];
this.dateTab.setSelect(value); this.dateTab.setSelect(value);
switch (value) { switch (value) {
case DynamicDatePane.Static: case DynamicDatePane.Static:
date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); this._setStaticValueByDynamicValue(this.dynamicPane.getValue());
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
break; break;
case DynamicDatePane.Dynamic: case DynamicDatePane.Dynamic:
this.dynamicPane.setValue({ this.dynamicPane.setValue({
@ -195,7 +190,7 @@ export class DynamicDatePane extends Widget {
} }
created() { created() {
this.setValue(this.options.value); this._initValue(this.options.value);
} }
_checkValueValid(value) { _checkValueValid(value) {
@ -212,6 +207,31 @@ export class DynamicDatePane extends Widget {
} }
} }
_initValue(v) {
v = v || {};
const type = v.type || DynamicDateCombo.Static;
const value = v.value || v;
const { isPreview } = this.options;
// 如果是初始化且是预览状态 直接打开静态页面
this.switcher.setValue(isPreview ? DynamicDateCombo.Static : type);
this.dateTab.setSelect(isPreview ? DynamicDateCombo.Static : type);
switch (type) {
case DynamicDateCombo.Dynamic:
if (isPreview) {
this._setStaticValueByDynamicValue(value);
} else {
this.dynamicPane.setValue(value);
}
break;
case DynamicDateCombo.Static:
default:
this._setStaticValue(value);
break;
}
}
setMinDate(minDate) { setMinDate(minDate) {
if (this.options.minDate !== minDate) { if (this.options.minDate !== minDate) {
this.options.minDate = minDate; this.options.minDate = minDate;
@ -238,6 +258,12 @@ export class DynamicDatePane extends Widget {
break; break;
case DynamicDateCombo.Static: case DynamicDateCombo.Static:
default: default:
this._setStaticValue(value);
break;
}
}
_setStaticValue(value) {
if (this._checkValueValid(value)) { if (this._checkValueValid(value)) {
const date = getDate(); const date = getDate();
this.ymd.setValue({ this.ymd.setValue({
@ -247,8 +273,15 @@ export class DynamicDatePane extends Widget {
} else { } else {
this.ymd.setValue(value); this.ymd.setValue(value);
} }
break;
} }
_setStaticValueByDynamicValue(value) {
const date = DynamicDateHelper.getCalculation(value);
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
} }
getValue() { getValue() {

2
packages/fineui/src/widget/dynamicdate/dynamicdate.combo.js

@ -53,6 +53,7 @@ export class DynamicDateCombo extends Single {
}, },
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
isPreview: false, // 是否是预览状态
}; };
_init() { _init() {
@ -200,6 +201,7 @@ export class DynamicDateCombo extends Single {
popup: { popup: {
el: { el: {
type: DynamicDatePopup.xtype, type: DynamicDatePopup.xtype,
isPreview: opts.isPreview,
width: opts.isNeedAdjustWidth ? opts.width : undefined, width: opts.isNeedAdjustWidth ? opts.width : undefined,
supportDynamic: opts.supportDynamic, supportDynamic: opts.supportDynamic,
behaviors: opts.behaviors, behaviors: opts.behaviors,

16
packages/fineui/src/widget/dynamicdate/dynamicdate.popup.js

@ -34,6 +34,7 @@ export class DynamicDatePopup extends Widget {
baseCls: "bi-dynamic-date-popup", baseCls: "bi-dynamic-date-popup",
width: 272, width: 272,
supportDynamic: true, supportDynamic: true,
isPreview: false, // 是否是预览状态
}; };
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
@ -282,10 +283,23 @@ export class DynamicDatePopup extends Widget {
v = v || {}; v = v || {};
const type = v.type || DynamicDateCombo.Static; const type = v.type || DynamicDateCombo.Static;
const value = v.value || v; const value = v.value || v;
this.dateTab.setSelect(type); const { isPreview } = this.options;
let date;
// 如果是预览状态 直接打开静态页面
this.dateTab.setSelect(isPreview ? DynamicDateCombo.Static : type);
switch (type) { switch (type) {
case DynamicDateCombo.Dynamic: case DynamicDateCombo.Dynamic:
if (isPreview) {
date = DynamicDateHelper.getCalculation(value);
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
} else {
this.dynamicPane.setValue(value); this.dynamicPane.setValue(value);
}
this._setInnerValue(); this._setInnerValue();
break; break;
case DynamicDateCombo.Static: case DynamicDateCombo.Static:

2
packages/fineui/src/widget/dynamicdatetime/dynamicdatetime.combo.js

@ -44,6 +44,7 @@ export class DynamicDateTimeCombo extends Single {
}, },
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
isPreview: false, // 是否是预览状态
}; };
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
@ -207,6 +208,7 @@ export class DynamicDateTimeCombo extends Single {
popup: { popup: {
el: { el: {
type: DynamicDateTimePopup.xtype, type: DynamicDateTimePopup.xtype,
isPreview: opts.isPreview,
timeSelectTypes: opts.timeSelectTypes, timeSelectTypes: opts.timeSelectTypes,
width: opts.isNeedAdjustWidth ? opts.width : undefined, width: opts.isNeedAdjustWidth ? opts.width : undefined,
supportDynamic: opts.supportDynamic, supportDynamic: opts.supportDynamic,

17
packages/fineui/src/widget/dynamicdatetime/dynamicdatetime.popup.js

@ -36,6 +36,7 @@ export class DynamicDateTimePopup extends Widget {
baseCls: "bi-dynamic-date-time-popup", baseCls: "bi-dynamic-date-time-popup",
width: 272, width: 272,
supportDynamic: true, supportDynamic: true,
isPreview: false, // 是否是预览状态
}; };
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
@ -292,10 +293,24 @@ export class DynamicDateTimePopup extends Widget {
v = v || {}; v = v || {};
const type = v.type || DynamicDateCombo.Static; const type = v.type || DynamicDateCombo.Static;
const value = v.value || v; const value = v.value || v;
this.dateTab.setSelect(type); const { isPreview } = this.options;
let date;
// 如果是预览状态 直接打开静态页面
this.dateTab.setSelect(isPreview ? DynamicDateCombo.Static : type);
switch (type) { switch (type) {
case DynamicDateCombo.Dynamic: case DynamicDateCombo.Dynamic:
if (isPreview) {
date = DynamicDateHelper.getCalculation(value);
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
this.timeSelect.setValue();
} else {
this.dynamicPane.setValue(value); this.dynamicPane.setValue(value);
}
this._setInnerValue(); this._setInnerValue();
break; break;
case DynamicDateCombo.Static: case DynamicDateCombo.Static:

2
packages/fineui/src/widget/timeinterval/dateinterval.js

@ -23,6 +23,7 @@ export class DateInterval extends Single {
lgap: 15, lgap: 15,
offset: 0, offset: 0,
timeErrorCls: "time-error", timeErrorCls: "time-error",
isPreview: false, // 是否是预览状态
}; };
static EVENT_VALID = "EVENT_VALID"; static EVENT_VALID = "EVENT_VALID";
@ -78,6 +79,7 @@ export class DateInterval extends Single {
const o = this.options; const o = this.options;
const combo = createWidget({ const combo = createWidget({
type: DynamicDateCombo.xtype, type: DynamicDateCombo.xtype,
isPreview: o.isPreview,
supportDynamic: o.supportDynamic, supportDynamic: o.supportDynamic,
minDate: o.minDate, minDate: o.minDate,
maxDate: o.maxDate, maxDate: o.maxDate,

2
packages/fineui/src/widget/timeinterval/timeinterval.js

@ -23,6 +23,7 @@ export class TimeInterval extends Single {
lgap: 15, lgap: 15,
offset: 0, offset: 0,
timeErrorCls: "time-error", timeErrorCls: "time-error",
isPreview: false, // 是否是预览状态
}; };
static EVENT_VALID = "EVENT_VALID"; static EVENT_VALID = "EVENT_VALID";
@ -76,6 +77,7 @@ export class TimeInterval extends Single {
const o = this.options; const o = this.options;
const combo = createWidget({ const combo = createWidget({
type: DynamicDateTimeCombo.xtype, type: DynamicDateTimeCombo.xtype,
isPreview: o.isPreview,
timeSelectTypes: o.timeSelectTypes, timeSelectTypes: o.timeSelectTypes,
simple: o.simple, simple: o.simple,
supportDynamic: o.supportDynamic, supportDynamic: o.supportDynamic,

2
packages/fineui/src/widget/year/combo.year.js

@ -27,6 +27,7 @@ export class DynamicYearCombo extends Widget {
maxDate: "2099-12-31", // 最大日期 maxDate: "2099-12-31", // 最大日期
height: 24, height: 24,
supportDynamic: true, supportDynamic: true,
isPreview: false, // 是否是预览状态
}; };
_init() { _init() {
@ -95,6 +96,7 @@ export class DynamicYearCombo extends Widget {
el: { el: {
type: DynamicYearPopup.xtype, type: DynamicYearPopup.xtype,
supportDynamic: o.supportDynamic, supportDynamic: o.supportDynamic,
isPreview: o.isPreview,
ref: _ref => { ref: _ref => {
this.popup = _ref; this.popup = _ref;
}, },

10
packages/fineui/src/widget/year/popup.year.js

@ -30,6 +30,7 @@ export class DynamicYearPopup extends Widget {
max: "2099-12-31", max: "2099-12-31",
width: 180, width: 180,
supportDynamic: true, supportDynamic: true,
isPreview: false, // 是否是预览状态
}; };
constants = { constants = {
tabHeight: 40, tabHeight: 40,
@ -266,10 +267,15 @@ export class DynamicYearPopup extends Widget {
v = v || {}; v = v || {};
const type = v.type || DynamicDateCombo.Static; const type = v.type || DynamicDateCombo.Static;
const value = v.value || v; const value = v.value || v;
this.dateTab.setSelect(type); const { isPreview } = this.options;
// 如果是预览状态 直接打开静态页面
this.dateTab.setSelect(isPreview ? DynamicDateCombo.Static : type);
switch (type) { switch (type) {
case DynamicDateCombo.Dynamic: case DynamicDateCombo.Dynamic:
this.dynamicPane.setValue(value); isPreview
? this.year.setValue({ year: DynamicDateHelper.getCalculation(value).getFullYear() })
: this.dynamicPane.setValue(value);
this._setInnerValue(); this._setInnerValue();
break; break;
case DynamicDateCombo.Static: case DynamicDateCombo.Static:

2
packages/fineui/src/widget/yearmonth/combo.yearmonth.js

@ -38,6 +38,7 @@ export class DynamicYearMonthCombo extends Single {
supportDynamic: true, supportDynamic: true,
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
isPreview: false, // 是否是预览状态
}; };
_init() { _init() {
@ -106,6 +107,7 @@ export class DynamicYearMonthCombo extends Single {
type: DynamicYearMonthPopup.xtype, type: DynamicYearMonthPopup.xtype,
width: o.isNeedAdjustWidth ? o.width : undefined, width: o.isNeedAdjustWidth ? o.width : undefined,
supportDynamic: o.supportDynamic, supportDynamic: o.supportDynamic,
isPreview: o.isPreview,
ref: _ref => { ref: _ref => {
this.popup = _ref; this.popup = _ref;
}, },

14
packages/fineui/src/widget/yearmonth/popup.yearmonth.js

@ -31,6 +31,7 @@ export class DynamicYearMonthPopup extends Widget {
max: "2099-12-31", max: "2099-12-31",
width: 180, width: 180,
supportDynamic: true, supportDynamic: true,
isPreview: false, // 是否是预览状态
}; };
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
@ -262,11 +263,22 @@ export class DynamicYearMonthPopup extends Widget {
v = v || {}; v = v || {};
const type = v.type || DynamicDateCombo.Static; const type = v.type || DynamicDateCombo.Static;
const value = v.value || v; const value = v.value || v;
const { isPreview } = this.options;
let date;
this.dateTab.setSelect(type); // 如果是预览状态 直接打开静态页面
this.dateTab.setSelect(isPreview ? DynamicDateCombo.Static : type);
switch (type) { switch (type) {
case DynamicDateCombo.Dynamic: case DynamicDateCombo.Dynamic:
if (isPreview) {
date = DynamicDateHelper.getCalculation(value);
this.year.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
});
} else {
this.dynamicPane.setValue(value); this.dynamicPane.setValue(value);
}
this._setInnerValue(); this._setInnerValue();
break; break;
case DynamicDateCombo.Static: case DynamicDateCombo.Static:

2
packages/fineui/src/widget/yearmonthinterval/yearmonthinterval.js

@ -34,6 +34,7 @@ export class YearMonthInterval extends Single {
supportDynamic: true, supportDynamic: true,
height: 24, height: 24,
simple: false, simple: false,
isPreview: false, // 是否是预览状态
}; };
render() { render() {
@ -71,6 +72,7 @@ export class YearMonthInterval extends Single {
const o = this.options; const o = this.options;
const combo = createWidget({ const combo = createWidget({
type: DynamicYearMonthCombo.xtype, type: DynamicYearMonthCombo.xtype,
isPreview: o.isPreview,
simple: o.simple, simple: o.simple,
supportDynamic: o.supportDynamic, supportDynamic: o.supportDynamic,
height: o.height, height: o.height,

2
packages/fineui/src/widget/yearquarter/combo.yearquarter.js

@ -33,6 +33,7 @@ export class DynamicYearQuarterCombo extends Widget {
supportDynamic: true, supportDynamic: true,
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
isPreview: false, // 是否是预览状态
}; };
static EVENT_CONFIRM = "EVENT_CONFIRM"; static EVENT_CONFIRM = "EVENT_CONFIRM";
@ -109,6 +110,7 @@ export class DynamicYearQuarterCombo extends Widget {
type: DynamicYearQuarterPopup.xtype, type: DynamicYearQuarterPopup.xtype,
width: o.isNeedAdjustWidth ? o.width : undefined, width: o.isNeedAdjustWidth ? o.width : undefined,
supportDynamic: o.supportDynamic, supportDynamic: o.supportDynamic,
isPreview: o.isPreview,
ref: _ref => { ref: _ref => {
this.popup = _ref; this.popup = _ref;
}, },

15
packages/fineui/src/widget/yearquarter/popup.yearquarter.js

@ -32,6 +32,7 @@ export class DynamicYearQuarterPopup extends Widget {
max: "2099-12-31", max: "2099-12-31",
width: 180, width: 180,
supportDynamic: true, supportDynamic: true,
isPreview: false, // 是否是预览状态
}; };
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
@ -304,10 +305,22 @@ export class DynamicYearQuarterPopup extends Widget {
v = v || {}; v = v || {};
const type = v.type || DynamicDateCombo.Static; const type = v.type || DynamicDateCombo.Static;
const value = v.value || v; const value = v.value || v;
this.dateTab.setSelect(type); const { isPreview } = this.options;
let date;
// 如果是预览状态 直接打开静态页面
this.dateTab.setSelect(isPreview ? DynamicDateCombo.Static : type);
switch (type) { switch (type) {
case DynamicDateCombo.Dynamic: case DynamicDateCombo.Dynamic:
if (isPreview) {
date = DynamicDateHelper.getCalculation(value);
this.year.setValue({
year: date.getFullYear(),
quarter: getQuarter(date),
});
} else {
this.dynamicPane.setValue(value); this.dynamicPane.setValue(value);
}
this._setInnerValue(); this._setInnerValue();
break; break;
case DynamicDateCombo.Static: case DynamicDateCombo.Static:

Loading…
Cancel
Save