Guyi 4 years ago
parent
commit
0b4d3d4ece
  1. 5
      changelog.md
  2. 14
      src/base/combination/combo.js
  3. 3
      src/base/grid/grid.js
  4. 2
      src/case/calendar/calendar.js
  5. 3
      src/core/func/function.js
  6. 11
      src/core/ob.js
  7. 52
      src/widget/date/calendar/picker.date.js
  8. 1
      src/widget/downlist/combo.downlist.js
  9. 2
      src/widget/downlist/popup.downlist.js
  10. 2
      src/widget/multilayerselecttree/multilayerselecttree.leveltree.js
  11. 2
      src/widget/multilayersingletree/multilayersingletree.leveltree.js
  12. 24
      src/widget/multiselect/multiselect.combo.nobar.js
  13. 2
      src/widget/multiselect/search/multiselect.search.insert.pane.js
  14. 2
      src/widget/multiselect/search/multiselect.search.pane.js
  15. 2
      src/widget/singleselect/search/singleselect.search.pane.insert.js
  16. 2
      src/widget/singleselect/search/singleselect.search.pane.js
  17. 2
      typescript/base/combination/combo.ts
  18. 41
      typescript/core/decorator/decorator.ts
  19. 47
      typescript/core/inject.ts
  20. 2
      typescript/core/ob.ts
  21. 3
      typescript/index.ts

5
changelog.md

@ -1,5 +1,10 @@
# 更新日志
2.0(2020-07)
- 修复了日期类型控件设置一个不在minDate和maxDate之间的日期值时,面板灰化与翻页按钮状态不对的问题
- BI.OB的on方法返回一个解除监听的函数
- 修复了grid_view执行_unMount时不调用子组件的_unMount的问题
- combo新增belowMouse属性,允许popup在点击处弹出
- combo新增hideWhenAnotherComboOpen属性,开启则其他combo下拉时当前combo收起
- 修复了datePicker在setValue的时候没有动态刷新可用月份的问题
- 同步复选下拉及其面板新增getAllValue获取所有已选值
- 同步复选下拉树及其面板新增getAllValue获取完整的选中树节点

14
src/base/combination/combo.js

@ -31,7 +31,8 @@
el: {},
popup: {},
comboClass: "bi-combo-popup",
hoverClass: "bi-combo-hover"
hoverClass: "bi-combo-hover",
belowMouse: false
});
},
@ -266,7 +267,7 @@
// return;
// }
// BI-10290 公式combo双击公式内容会收起
if (e && ((!skipTriggerChecker && this.element.find(e.target).length > 0)
if (e && ((skipTriggerChecker !== true && this.element.find(e.target).length > 0)
|| (this.popupView && this.popupView.element.find(e.target).length > 0)
|| e.target.className === "CodeMirror-cursor" || BI.Widget._renderEngine.createElement(e.target).closest(".CodeMirror-hints").length > 0)) {// BI-9887 CodeMirror的公式弹框需要特殊处理下
var directions = this.options.direction.split(",");
@ -275,11 +276,12 @@
this.adjustWidth();
this.adjustHeight();
}
return false;
return;
}
var isHide = this.options.hideChecker.apply(this, [e]);
if (isHide === false) {
return false;
return;
}
this._hideView();
return true;
@ -309,7 +311,7 @@
this.popupView.visible();
BI.each(needHideWhenAnotherComboOpen, function (i, combo) {
if (i !== self.getName()) {
if (combo && combo._hideIf(e, true)) {
if (combo && combo._hideIf(e, true) === true) {
delete needHideWhenAnotherComboOpen[i];
}
}
@ -349,7 +351,7 @@
}
var isVisible = this.popupView.isVisible();
this.popupView.visible();
var combo = BI.isNotNull(e) ? {
var combo = (o.belowMouse && BI.isNotNull(e)) ? {
element: {
offset: function () {
return {

3
src/base/grid/grid.js

@ -150,7 +150,8 @@ BI.GridView = BI.inherit(BI.Widget, {
if (this.renderedCells[index]._top !== rowDatum.offset + verticalOffsetAdjustment) {
this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) + "px");
}
renderedCells.push(child = this.renderedCells[index]);
child = this.renderedCells[index].el;
renderedCells.push(this.renderedCells[index]);
} else {
child = BI.createWidget(BI.extend({
type: "bi.label",

2
src/case/calendar/calendar.js

@ -23,8 +23,6 @@ BI.Calendar = BI.inherit(BI.Widget, {
var self = this, o = this.options, log = {}, De = BI.getDate();
var mins = o.min.match(/\d+/g);
var maxs = o.max.match(/\d+/g);
Y < (mins[0] | 0) && (Y = (mins[0] | 0));
Y > (maxs[0] | 0) && (Y = (maxs[0] | 0));
De.setFullYear(Y, M, D);
log.ymd = [De.getFullYear(), De.getMonth(), De.getDate()];

3
src/core/func/function.js

@ -135,7 +135,8 @@ _.extend(BI.Func, {
var char1 = str1[i];
var char2 = str2[i];
if (char1 !== char2) {
return BI.CODE_INDEX[char1] - BI.CODE_INDEX[char2]
// 找不到的字符都往后面放
return (BI.isNull(BI.CODE_INDEX[char1]) ? BI.MAX : BI.CODE_INDEX[char1]) - (BI.isNull(BI.CODE_INDEX[char2]) ? BI.MAX : BI.CODE_INDEX[char2]);
}
}
return len1 - len2;

11
src/core/ob.js

@ -86,8 +86,8 @@
},
_getEvents: function () {
if (!_.isArray(this.events)) {
this.events = [];
if (!_.isObject(this.events)) {
this.events = {};
}
return this.events;
},
@ -98,6 +98,7 @@
* @param {Function} fn 事件对应的执行函数
*/
on: function (eventName, fn) {
var self = this;
eventName = eventName.toLowerCase();
var fns = this._getEvents()[eventName];
if (!_.isArray(fns)) {
@ -105,6 +106,10 @@
this._getEvents()[eventName] = fns;
}
fns.push(fn);
return function () {
self.un(eventName, fn);
};
},
/**
@ -148,7 +153,7 @@
*/
purgeListeners: function () {
/* alex:清空events*/
this.events = [];
this.events = {};
},
/**
* 触发绑定过的事件

52
src/widget/date/calendar/picker.date.js

@ -35,7 +35,7 @@ BI.DatePicker = BI.inherit(BI.Widget, {
} else {
self.setValue({
year: self.year.getValue(),
month: self.month.getValue() - 1,
month: (self.month.getValue() - 1) || BI.getDate().getMonth(),
});
}
self.fireEvent(BI.DatePicker.EVENT_CHANGE);
@ -59,7 +59,7 @@ BI.DatePicker = BI.inherit(BI.Widget, {
} else {
self.setValue({
year: self.year.getValue(),
month: self.month.getValue() + 1,
month: (self.month.getValue() + 1) || (BI.getDate().getMonth() + 2),
});
}
self.fireEvent(BI.DatePicker.EVENT_CHANGE);
@ -87,7 +87,7 @@ BI.DatePicker = BI.inherit(BI.Widget, {
});
this.month.on(BI.MonthDateCombo.EVENT_CHANGE, function () {
self.setValue({
year: self.year.getValue(),
year: self.year.getValue() || self._year,
month: self.month.getValue(),
});
self.fireEvent(BI.DatePicker.EVENT_CHANGE);
@ -136,40 +136,68 @@ BI.DatePicker = BI.inherit(BI.Widget, {
if (!BI.contains(allowMonth, month)) {
month = allowMonth[0];
}
return month;
},
_getAllowMonths: function () {
var self = this, o = this.options;
var obj = this._getCheckMinMaxDate();
var year = this.year.getValue() || this._year;
return BI.filter(BI.range(1, 13), function (idx, v) {
return !BI.checkDateVoid(self.year.getValue(), v, 1, o.min, o.max)[0];
})
return !BI.checkDateVoid(year, v, 1, obj.min, obj.max)[0];
});
},
// 上一年月不合法则灰化
_checkLeftValid: function () {
var o = this.options;
var minDate = BI.parseDateTime(o.min, "%Y-%X-%d");
var valid = !(this._month <= (minDate.getMonth() + 1) && this._year <= minDate.getFullYear());
var obj = this._getCheckMinMaxDate();
var year = this._month === 1 ? this._year - 1 : this._year;
var month = this._month === 1 ? 12 : this.month - 1;
var valid = BI.isNull(BI.checkDateVoid(year, month, 1, obj.min, obj.max)[0]);
this.left.setEnable(valid);
return valid;
},
// 下一年月不合法则灰化
_checkRightValid: function () {
var o = this.options;
var maxDate = BI.parseDateTime(o.max, "%Y-%X-%d");
var valid = !(this._month >= (maxDate.getMonth() + 1) && this._year >= maxDate.getFullYear());
var obj = this._getCheckMinMaxDate();
var year = this._month === 12 ? this._year + 1 : this._year;
var month = this._month === 12 ? 1 : this.month + 1;
var valid = BI.isNull(BI.checkDateVoid(year, month, 1, obj.min, obj.max)[0]);
this.right.setEnable(valid);
return valid;
},
_getCheckMinMaxDate: function() {
var o = this.options;
var minDate = BI.parseDateTime(o.min, "%Y-%X-%d");
var maxDate = BI.parseDateTime(o.max, "%Y-%X-%d");
minDate.setDate(1);
maxDate.setDate(1);
return {
min: BI.print(minDate, "%Y-%X-%d"),
max: BI.print(maxDate, "%Y-%X-%d")
};
},
setMinDate: function (minDate) {
this.options.min = minDate;
this.year.setMinDate(minDate);
this._refreshMonth();
this._checkLeftValid();
this._checkRightValid();
},
setMaxDate: function (maxDate) {
this.options.max = maxDate;
this.year.setMaxDate(maxDate);
this._refreshMonth();
this._checkLeftValid();
this._checkRightValid();
},
setValue: function (ob) {

1
src/widget/downlist/combo.downlist.js

@ -45,6 +45,7 @@ BI.DownListCombo = BI.inherit(BI.Widget, {
container: o.container,
adjustLength: o.adjustLength,
direction: o.direction,
belowMouse: o.belowMouse,
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",

2
src/widget/downlist/popup.downlist.js

@ -118,7 +118,7 @@ BI.DownListPopup = BI.inherit(BI.Pane, {
var fatherValue = BI.deepClone(item.el.value);
var childValue = BI.deepClone(child.value);
self.singleValues.push(child.value);
child.type = "bi.down_list_item";
child.type = child.type || "bi.down_list_item";
child.extraCls = " child-down-list-item";
child.title = child.title || child.text;
child.textRgap = 10;

2
src/widget/multilayerselecttree/multilayerselecttree.leveltree.js

@ -113,7 +113,7 @@ BI.MultiLayerSelectLevelTree = BI.inherit(BI.Pane, {
isDefaultInit: o.itemsCreator !== BI.emptyFn,
el: {
type: "bi.button_tree",
chooseType: BI.Selection.Default, // 不使用buttontree内部getValue逻辑
chooseType: o.chooseType === BI.Selection.None ? BI.Selection.None : BI.Selection.Default, // 不使用buttontree内部getValue逻辑
behaviors: o.behaviors,
layouts: [{
type: "bi.vertical"

2
src/widget/multilayersingletree/multilayersingletree.leveltree.js

@ -112,7 +112,7 @@ BI.MultiLayerSingleLevelTree = BI.inherit(BI.Pane, {
isDefaultInit: o.itemsCreator !== BI.emptyFn,
el: {
type: "bi.button_tree",
chooseType: BI.Selection.Default, // 不使用buttontree内部getValue逻辑
chooseType: o.chooseType === BI.Selection.None ? BI.Selection.None : BI.Selection.Default, // 不使用buttontree内部getValue逻辑
behaviors: o.behaviors,
layouts: [{
type: "bi.vertical"

24
src/widget/multiselect/multiselect.combo.nobar.js

@ -78,6 +78,11 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
self._setStartValue("");
self.fireEvent(BI.MultiSelectNoBarCombo.EVENT_STOP);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
self._addItem(assertShowValue);
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
var last = BI.last(keywords);
@ -272,6 +277,25 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
});
},
_addItem: function (assertShowValue) {
var self = this;
var keyword = this.trigger.getSearcher().getKeyword();
this._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
// 如果在不选的状态下直接把该值添加进来
if (self.storeValue.type === BI.Selection.Multi) {
BI.pushDistinct(self.storeValue.value, keyword);
}
self.combo.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self.populate();
self._setStartValue("");
});
},
_itemsCreator4Trigger: function (op, callback) {
var self = this, o = this.options;
o.itemsCreator(op, function (res) {

2
src/widget/multiselect/search/multiselect.search.insert.pane.js

@ -78,7 +78,7 @@ BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, {
setKeyword: function (keyword) {
var o = this.options;
var hasSameValue = BI.some(this.loader.getAllButtons(), function (idx, btn) {
return keyword === (o.valueFormatter(btn.getValue()) || btn.getValue());
return keyword === btn.getValue();
});
var isMatchTipVisible = this.loader.getAllButtons().length > 0 && hasSameValue;
this.tooltipClick.setVisible(isMatchTipVisible);

2
src/widget/multiselect/search/multiselect.search.pane.js

@ -65,7 +65,7 @@ BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
setKeyword: function (keyword) {
var btn, o = this.options;
var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === (o.valueFormatter(btn.getValue()) || btn.getValue()));
var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && keyword === btn.getValue();
if (isVisible !== this.tooltipClick.isVisible()) {
this.tooltipClick.setVisible(isVisible);
this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0);

2
src/widget/singleselect/search/singleselect.search.pane.insert.js

@ -80,7 +80,7 @@ BI.SingleSelectSearchInsertPane = BI.inherit(BI.Widget, {
setKeyword: function (keyword) {
var o = this.options;
var hasSameValue = BI.some(this.loader.getAllButtons(), function (idx, btn) {
return keyword === (o.valueFormatter(btn.getValue()) || btn.getValue());
return keyword === btn.getValue();
});
var isMatchTipVisible = this.loader.getAllButtons().length > 0 && hasSameValue;
this.tooltipClick.setVisible(isMatchTipVisible);

2
src/widget/singleselect/search/singleselect.search.pane.js

@ -67,7 +67,7 @@ BI.SingleSelectSearchPane = BI.inherit(BI.Widget, {
setKeyword: function (keyword) {
var btn, o = this.options;
var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === (o.valueFormatter(btn.getValue()) || btn.getValue()));
var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && keyword === btn.getValue();
if (isVisible !== this.tooltipClick.isVisible()) {
this.tooltipClick.setVisible(isVisible);
this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0);

2
typescript/base/combination/combo.ts

@ -1,7 +1,7 @@
import { _Widget } from "../../core/widget";
export interface _Combo extends _Widget {
populate(items: any): void;
populate(...args: any[]): void;
_setEnable(v: boolean): void;

41
typescript/core/decorator/decorator.ts

@ -44,6 +44,47 @@ export function store<T>(Model: Constructor<T> & {xtype: string}, opts: { props?
};
}
/**
* mixin
* ie8下不能使用
*/
export function mixin<T>() {
return function decorator(Target: Constructor<T> & { xtype: string }): void {
const mixin: {
[key: string]: Function;
} = {};
Object.getOwnPropertyNames(Target.prototype).forEach(name => {
if (name === 'constructor') {
return;
}
mixin[name] = Target.prototype[name];
});
Fix.mixin(Target.xtype, mixin);
};
}
/**
* mixins属性
* ie8下不能使用
* @param Mixins
*/
export function mixins(...Mixins: ({ new (...args: any[]): {} } & { xtype: string })[]) {
return function classDecorator<U extends { new (...args: any[]): {} }>(constructor: U) {
const mixins: string[] = [];
Mixins.forEach(mixin => {
mixin.xtype && mixins.push(mixin.xtype);
});
return class extends constructor {
mixins = mixins;
};
};
}
/**
* Model基类
*/

47
typescript/core/inject.ts

@ -0,0 +1,47 @@
type _module = (xtype: string, cls: any) => void;
type _constant = (xtype: string, cls: any) => void;
type _model = (xtype: string, cls: any) => void;
type _store = (xtype: string, cls: any) => void;
type _service = (xtype: string, cls: any) => void;
type _provider = (xtype: string, cls: any) => void;
interface _modules {
getModule: (type: string) => any;
getAllModules: () => any;
}
interface _constants {
getConstant: (type: string) => any;
}
interface _models {
getModel: (type: string, options?: any) => any;
}
interface _stores {
getStore: (type: string, options?: any) => any;
}
interface _providers {
getProvider: (type: string, options?: any) => any;
}
interface _services {
getService: (type: string, options?: any) => any;
}
export type _inject = {
module: _module;
constant: _constant;
model: _model;
store: _store;
provider: _provider;
service: _service;
Modules: _modules;
Constants: _constants;
Models: _models;
Stores: _stores;
Providers: _providers;
Services: _services;
}

2
typescript/core/ob.ts

@ -19,7 +19,7 @@ export interface _OB {
_getEvents(): { [eventName: string]: Function[] };
on(eventName: string, fn: Function): void;
on(eventName: string, fn: Function): Function;
once(eventName: string, fn: Function): void;

3
typescript/index.ts

@ -36,6 +36,7 @@ import { _i18n } from "./core/i18n";
import { _Plugin } from "./core/plugin";
import { _OB } from "./core/ob";
import { _Widget, _WidgetStatic } from "./core/widget";
import { _inject } from "./core/inject";
import { _Layout } from "./core/wrapper/layout";
import { _AbsoluteLayout } from "./core/wrapper/layout/layout.absolute";
import { _HTapeLayout, _VTapeLayout } from "./core/wrapper/layout/layout.tape";
@ -49,7 +50,7 @@ type ClassConstructor<T extends {}> = T & {
readonly prototype: T;
}
export interface BI extends _func, _i18n, _base {
export interface BI extends _func, _i18n, _base, _inject {
OB: ClassConstructor<_OB>;
Plugin: _Plugin;
Widget: ClassConstructor<_Widget> & _WidgetStatic;

Loading…
Cancel
Save