Browse Source

Merge branch 'master' of ssh://code.fineres.com:7999/~claire.tang/fineui

es6
Claire 3 years ago
parent
commit
6b433c345f
  1. 15
      changelog.md
  2. 2
      package.json
  3. 45
      src/base/single/input/input.js
  4. 4
      src/case/checkbox/check.first.treenode.js
  5. 4
      src/case/checkbox/check.last.treenode.js
  6. 4
      src/case/checkbox/check.mid.treenode.js
  7. 4
      src/case/checkbox/check.treenode.js
  8. 9
      src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js
  9. 1
      src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js
  10. 29
      src/case/combo/textvaluecombo/combo.textvalue.js
  11. 2
      src/case/list/list.select.js
  12. 67
      src/case/trigger/trigger.text.js
  13. 29
      src/case/trigger/trigger.text.select.js
  14. 2
      src/core/wrapper/layout/layout.inline.js
  15. 39
      src/less/base/combo/combo.less
  16. 14
      src/less/base/combo/combo.textvalue.less
  17. 11
      src/less/base/trigger/trigger.text.less
  18. 4
      src/less/core/wrapper/flex.horizontal.less
  19. 4
      src/less/core/wrapper/flex.vertical.less
  20. 4
      src/less/core/wrapper/flex.wrapper.horizontal.less
  21. 4
      src/less/core/wrapper/flex.wrapper.vertical.less
  22. 1
      src/less/lib/theme.less
  23. 30
      src/less/widget/multilayerselecttree/multilayerselecttree.combo.less
  24. 29
      src/less/widget/multilayersingletree/multilayersingletree.combo.less
  25. 80
      src/widget/multilayerselecttree/multilayerselecttree.combo.js
  26. 59
      src/widget/multilayerselecttree/multilayerselecttree.trigger.js
  27. 36
      src/widget/multilayersingletree/multilayersingletree.combo.js
  28. 57
      src/widget/multilayersingletree/multilayersingletree.trigger.js
  29. 40
      src/widget/selecttree/selecttree.combo.js
  30. 40
      src/widget/singletree/singletree.combo.js
  31. 24
      src/widget/singletree/singletree.trigger.js
  32. 8
      src/widget/year/combo.year.js
  33. 9
      src/widget/year/trigger.year.js
  34. 2
      typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts
  35. 2
      typescript/widget/multilayersingletree/multilayersingletree.combo.ts

15
changelog.md

@ -1,4 +1,19 @@
# 更新日志 # 更新日志
3.0(2022-05)
- 下拉选择框支持清空
3.0(2022-03)
- 支持响应式
- 全面支持Typescript
- 增加JSX支持
- 布局组件支持更多动态特性
- 底层API支持动画
- 增加WebWorker支持
- 支持路由
- 插件支持版本控制
- Fix数据流支持proxy版本
2.0(2022-01) 2.0(2022-01)
- 提供自定义表单 - 提供自定义表单

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "fineui", "name": "fineui",
"version": "2.0.20220505161347", "version": "2.0.20220511141337",
"description": "fineui", "description": "fineui",
"main": "dist/fineui.min.js", "main": "dist/fineui.min.js",
"types": "dist/lib/index.d.ts", "types": "dist/lib/index.d.ts",

45
src/base/single/input/input.js

@ -206,14 +206,29 @@ BI.Input = BI.inherit(BI.Single, {
this._lastValue = this.getValue(); this._lastValue = this.getValue();
}, },
_checkValidationOnValueChange: function () { _checkValidationOnValueChange: function (callback) {
var o = this.options; var self = this, o = this.options;
var v = this.getValue(); var v = this.getValue();
this.setValid( if (o.allowBlank === true && BI.trim(v) == "") {
(o.allowBlank === true && BI.trim(v) == "") || ( this.setValid(true);
BI.isNotEmptyString(BI.trim(v)) && o.validationChecker.apply(this, [BI.trim(v)]) !== false callback && callback();
) return;
); }
if (BI.trim(v) == "") {
this.setValid(false);
callback && callback();
return;
}
var checker = o.validationChecker.apply(this, [BI.trim(v)]);
if (checker instanceof Promise) {
checker.then(function (validate) {
self.setValid(validate !== false);
callback && callback();
})
} else {
this.setValid(checker !== false);
callback && callback();
}
}, },
focus: function () { focus: function () {
@ -245,14 +260,16 @@ BI.Input = BI.inherit(BI.Single, {
}, },
setValue: function (textValue) { setValue: function (textValue) {
var self = this;
this.element.val(textValue); this.element.val(textValue);
BI.nextTick(BI.bind(function () { BI.nextTick(function () {
this._checkValidationOnValueChange(); self._checkValidationOnValueChange(function () {
this._defaultState(); self._defaultState();
if (this.isValid()) { if (self.isValid()) {
this._lastValidValue = this._lastSubmitValue = this.getValue(); self._lastValidValue = self._lastSubmitValue = self.getValue();
} }
}, this)); });
});
}, },
getValue: function () { getValue: function () {

4
src/case/checkbox/check.first.treenode.js

@ -7,8 +7,8 @@ BI.FirstTreeNodeCheckbox = BI.inherit(BI.IconButton, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend( BI.FirstTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { return BI.extend( BI.FirstTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), {
extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type2" : "tree-collapse-icon-type2", extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type2" : "tree-collapse-icon-type2",
iconWidth: 24, iconWidth: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconHeight: 24 iconHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT
}); });
}, },

4
src/case/checkbox/check.last.treenode.js

@ -7,8 +7,8 @@ BI.LastTreeNodeCheckbox = BI.inherit(BI.IconButton, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.LastTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.LastTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), {
extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type4" : "tree-collapse-icon-type4", extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type4" : "tree-collapse-icon-type4",
iconWidth: 24, iconWidth: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconHeight: 24 iconHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT
}); });
}, },

4
src/case/checkbox/check.mid.treenode.js

@ -7,8 +7,8 @@ BI.MidTreeNodeCheckbox = BI.inherit(BI.IconButton, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend( BI.MidTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { return BI.extend( BI.MidTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), {
extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type3" : "tree-collapse-icon-type3", extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type3" : "tree-collapse-icon-type3",
iconWidth: 24, iconWidth: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconHeight: 24 iconHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT
}); });
}, },

4
src/case/checkbox/check.treenode.js

@ -7,8 +7,8 @@ BI.TreeNodeCheckbox = BI.inherit(BI.IconButton, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend( BI.TreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { return BI.extend( BI.TreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), {
extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type1" : "tree-collapse-icon-type1", extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type1" : "tree-collapse-icon-type1",
iconWidth: 24, iconWidth: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconHeight: 24 iconHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT
}); });
}, },

9
src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js

@ -11,6 +11,7 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
items: [], items: [],
tipType: "", tipType: "",
warningTitle: "", warningTitle: "",
allowClear: false,
}, },
render: function () { render: function () {
@ -48,6 +49,7 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
tipType: o.tipType, tipType: o.tipType,
warningTitle: o.warningTitle, warningTitle: o.warningTitle,
title: o.title, title: o.title,
allowClear: o.allowClear,
listeners: [{ listeners: [{
eventName: BI.SearchTextValueTrigger.EVENT_CHANGE, eventName: BI.SearchTextValueTrigger.EVENT_CHANGE,
action: function () { action: function () {
@ -55,6 +57,13 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
self.combo.hideView(); self.combo.hideView();
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE);
} }
}, {
eventName: BI.SearchTextValueTrigger.EVENT_CLEAR,
action: function () {
self.setValue();
self.combo.hideView();
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE);
}
}] }]
}, },
popup: { popup: {

1
src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js

@ -111,4 +111,5 @@ BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP"; BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP";
BI.SearchTextValueTrigger.EVENT_START = "EVENT_START"; BI.SearchTextValueTrigger.EVENT_START = "EVENT_START";
BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE"; BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.SearchTextValueTrigger.EVENT_CLEAR = "EVENT_CLEAR";
BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger); BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger);

29
src/case/combo/textvaluecombo/combo.textvalue.js

@ -12,6 +12,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
text: "", text: "",
value: "", value: "",
allowClear: false,
}); });
}, },
@ -33,7 +34,16 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
height: o.height, height: o.height,
text: o.text, text: o.text,
value: o.value, value: o.value,
warningTitle: o.warningTitle warningTitle: o.warningTitle,
allowClear: o.allowClear,
listeners: [
{
eventName: BI.SelectTextTrigger.EVENT_CLEAR,
action: function () {
self._clear();
}
}
],
}); });
this.popup = BI.createWidget({ this.popup = BI.createWidget({
type: "bi.text_value_combo_popup", type: "bi.text_value_combo_popup",
@ -62,15 +72,20 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
minHeight: 25 minHeight: 25
} }
}); });
if(BI.isKey(o.value)) { if (BI.isKey(o.value)) {
this._checkError(o.value); this._checkError(o.value);
} }
}, },
_clear: function () {
this.setValue();
},
_checkError: function (v) { _checkError: function (v) {
if(BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) {
this.trigger.options.tipType = "success"; this.trigger.options.tipType = "success";
this.element.removeClass("combo-error"); this.element.removeClass("error");
this.trigger.element.removeClass("error");
} else { } else {
v = BI.isArray(v) ? v : [v]; v = BI.isArray(v) ? v : [v];
var result = BI.find(this.options.items, function (idx, item) { var result = BI.find(this.options.items, function (idx, item) {
@ -78,10 +93,12 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
}); });
if (BI.isNull(result)) { if (BI.isNull(result)) {
this.trigger.setTipType("warning"); this.trigger.setTipType("warning");
this.element.removeClass("combo-error").addClass("combo-error"); this.element.addClass("error");
this.trigger.element.addClass("error");
} else { } else {
this.trigger.setTipType("success"); this.trigger.setTipType("success");
this.element.removeClass("combo-error"); this.element.removeClass("error");
this.trigger.element.removeClass("error");
} }
} }
}, },

2
src/case/list/list.select.js

@ -94,7 +94,7 @@ BI.SelectList = BI.inherit(BI.Widget, {
var hasNext = this.list.hasNext(); var hasNext = this.list.hasNext();
var isAlreadyAllSelected = this.toolbar.isSelected(); var isAlreadyAllSelected = this.toolbar.isSelected();
var isHalf = selectLength > 0 && notSelectLength > 0; var isHalf = selectLength > 0 && notSelectLength > 0;
var allSelected = isAlreadyAllSelected; var allSelected = selectLength > 0 && notSelectLength <= 0 && (!hasNext || isAlreadyAllSelected);
if (this.isAllSelected() === false) { if (this.isAllSelected() === false) {
hasNext && (isHalf = selectLength > 0); hasNext && (isHalf = selectLength > 0);

67
src/case/trigger/trigger.text.js

@ -7,25 +7,27 @@
*/ */
BI.TextTrigger = BI.inherit(BI.Trigger, { BI.TextTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () { props: function () {
var self = this; var self = this;
var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments); return {
return BI.extend(conf, { baseCls: "bi-text-trigger",
baseCls: (conf.baseCls || "") + " bi-text-trigger",
height: 24, height: 24,
textHgap: 6, textHgap: 6,
textCls: "", textCls: "",
allowClear: false,
title: function () { title: function () {
return self.text.getText(); return self.text.getText();
} }
}); };
}, },
_init: function () { render: function () {
BI.TextTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const; var self = this, o = this.options, c = this._const;
this.text = BI.createWidget({ var text = {
type: "bi.label", type: "bi.label",
ref: function (_ref) {
self.text = _ref;
},
cls: "select-text-label" + (BI.isKey(o.textCls) ? (" " + o.textCls) : ""), cls: "select-text-label" + (BI.isKey(o.textCls) ? (" " + o.textCls) : ""),
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
@ -39,32 +41,56 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
tgap: o.textTgap, tgap: o.textTgap,
bgap: o.textBgap, bgap: o.textBgap,
readonly: o.readonly readonly: o.readonly
}); };
this.trigerButton = BI.createWidget({
var triggerButton = {
type: "bi.trigger_icon_button", type: "bi.trigger_icon_button",
ref: function (_ref) {
self.triggerButton = _ref;
},
width: o.triggerWidth || o.height width: o.triggerWidth || o.height
}); };
BI.createWidget({ return ({
element: this,
type: "bi.horizontal_fill", type: "bi.horizontal_fill",
columnSize: ["fill", o.triggerWidth || o.height],
items: [ items: [
{ {
el: this.text, el: text,
width: "fill" width: "fill"
}, { }, {
el: this.trigerButton, el: o.allowClear ? {
width: o.triggerWidth || o.height type: "bi.vertical_adapt",
horizontalAlign: "left",
scrollable: false,
items: [
{
el: {
type: "bi.icon_button",
ref: function (_ref) {
self.clearBtn = _ref;
},
cls: "close-h-font " + (o.allowClear ? "clear-button" : ""),
stopPropagation: true,
handler: function () {
self.fireEvent(BI.TextTrigger.EVENT_CLEAR);
},
},
}, {
el: triggerButton,
}
]
} : triggerButton,
} }
] ]
}); });
}, },
getTextor: function() { getTextor: function () {
return this.text; return this.text;
}, },
setTextCls: function(cls) { setTextCls: function (cls) {
var o = this.options; var o = this.options;
var oldCls = o.textCls; var oldCls = o.textCls;
o.textCls = cls; o.textCls = cls;
@ -73,6 +99,9 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
setText: function (text) { setText: function (text) {
this.text.setText(text); this.text.setText(text);
if (this.options.allowClear) {
this.clearBtn.setVisible(BI.isNotEmptyString(text));
}
}, },
setTipType: function (v) { setTipType: function (v) {
@ -80,4 +109,6 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
this.options.tipType = v; this.options.tipType = v;
} }
}); });
BI.TextTrigger.EVENT_CLEAR = "EVENT_CLEAR";
BI.shortcut("bi.text_trigger", BI.TextTrigger); BI.shortcut("bi.text_trigger", BI.TextTrigger);

29
src/case/trigger/trigger.text.select.js

@ -11,6 +11,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
return BI.extend(BI.SelectTextTrigger.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.SelectTextTrigger.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-select-text-trigger", baseCls: "bi-select-text-trigger",
height: 24, height: 24,
allowClear: false,
}); });
}, },
@ -32,11 +33,21 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
textTgap: o.textTgap, textTgap: o.textTgap,
textBgap: o.textBgap, textBgap: o.textBgap,
tipType: o.tipType, tipType: o.tipType,
warningTitle: o.warningTitle warningTitle: o.warningTitle,
allowClear: o.allowClear,
listeners: [
{
eventName: BI.TextTrigger.EVENT_CLEAR,
action: function () {
self.setText("");
self.fireEvent(BI.SelectTextTrigger.EVENT_CLEAR);
}
}
]
}); });
}, },
_digest: function(vals, items){ _digest: function (vals, items) {
var o = this.options; var o = this.options;
vals = BI.isArray(vals) ? vals : [vals]; vals = BI.isArray(vals) ? vals : [vals];
var result = []; var result = [];
@ -51,15 +62,20 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
return { return {
textCls: "", textCls: "",
text: result.join(",") text: result.join(",")
} };
} else { } else {
return { return {
textCls: "bi-water-mark", textCls: "bi-water-mark",
text: BI.isFunction(o.text) ? o.text() : o.text text: BI.isFunction(o.text) ? o.text() : o.text
} };
} }
}, },
setText: function (text) {
this.options.text = text;
this.trigger.setText(text);
},
setValue: function (vals) { setValue: function (vals) {
var formatValue = this._digest(vals, this.options.items); var formatValue = this._digest(vals, this.options.items);
this.trigger.setTextCls(formatValue.textCls); this.trigger.setTextCls(formatValue.textCls);
@ -67,10 +83,11 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
}, },
setTipType: function (v) { setTipType: function (v) {
this.options.tipType = v;
this.trigger.setTipType(v); this.trigger.setTipType(v);
}, },
getTextor: function() { getTextor: function () {
return this.trigger.getTextor(); return this.trigger.getTextor();
}, },
@ -78,4 +95,6 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
this.options.items = items; this.options.items = items;
} }
}); });
BI.SelectTextTrigger.EVENT_CLEAR = "EVENT_CLEAR";
BI.shortcut("bi.select_text_trigger", BI.SelectTextTrigger); BI.shortcut("bi.select_text_trigger", BI.SelectTextTrigger);

2
src/core/wrapper/layout/layout.inline.js

@ -40,7 +40,7 @@ BI.InlineLayout = BI.inherit(BI.Layout, {
_addElement: function (i, item) { _addElement: function (i, item) {
var o = this.options; var o = this.options;
var w = BI.InlineLayout.superclass._addElement.apply(this, arguments); var w = BI.InlineLayout.superclass._addElement.apply(this, arguments);
var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width >= 1 ? null : item.width; var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width;
if (o.columnSize.length > 0) { if (o.columnSize.length > 0) {
if (item.width >= 1 && o.columnSize[i] >= 1 && o.columnSize[i] !== item.width) { if (item.width >= 1 && o.columnSize[i] >= 1 && o.columnSize[i] !== item.width) {
columnSize = null; columnSize = null;

39
src/less/base/combo/combo.less

@ -1,19 +1,22 @@
@import "../../index.less"; @import "../../index.less";
@val: transform .3s ease; @val: transform .3s ease;
.bi-combo { .bi-combo {
& > .bi-trigger { & > .bi-trigger {
& .bi-trigger-icon-button{ & .bi-trigger-icon-button {
& .x-icon { & .x-icon {
.rotate(0deg); .rotate(0deg);
.transition(@val); .transition(@val);
} }
} }
} }
&.bi-combo-popup { &.bi-combo-popup {
display: block !important; display: block !important;
visibility: visible !important; visibility: visible !important;
& > .bi-trigger { & > .bi-trigger {
& .bi-trigger-icon-button{ & .bi-trigger-icon-button {
& .x-icon { & .x-icon {
.rotate(180deg); .rotate(180deg);
.transition(@val); .transition(@val);
@ -21,11 +24,13 @@
} }
} }
} }
&.bi-combo-popup, &.bi-combo-hover, &:hover { &.bi-combo-popup, &.bi-combo-hover, &:hover {
&.bi-border, &.bi-border-bottom { &.bi-border, &.bi-border-bottom {
border-color: @color-bi-border-hover-combo; border-color: @color-bi-border-hover-combo;
} }
} }
&.disabled { &.disabled {
&.bi-combo-hover, &:hover { &.bi-combo-hover, &:hover {
&.bi-border, &.bi-border-bottom { &.bi-border, &.bi-border-bottom {
@ -33,6 +38,36 @@
} }
} }
} }
&.error {
&.bi-combo-hover, &:hover {
&.bi-border, &.bi-border-bottom {
border-color: @border-color-negative;
}
}
}
// 将来统一变成combo的特性
//&.status-error {
// &.bi-border, &.bi-border-bottom {
// border-color: @border-color-negative;
// }
//
// .bi-trigger .select-text-label {
// color: @color-bi-text-error-text-trigger;
// }
//}
//
//&.status-warning {
// &.bi-border, &.bi-border-bottom {
// border-color: @border-color-warning;
// }
//
// .bi-trigger .select-text-label {
// color: @font-color-warning;
// }
//}
} }
.bi-theme-dark { .bi-theme-dark {

14
src/less/base/combo/combo.textvalue.less

@ -1,14 +0,0 @@
@import "../../index.less";
.bi-text-value-combo {
&.combo-error {
& .bi-select-text-trigger {
& .select-text-label {
color: @color-bi-text-error-hover-text-value-combo;
}
}
&.bi-border, &.bi-border-bottom {
border-color: @border-color-negative;
}
}
}

11
src/less/base/trigger/trigger.text.less

@ -0,0 +1,11 @@
@import "../../index.less";
.bi-text-trigger {
&.error .select-text-label {
color: @color-bi-text-error-text-trigger;
}
&:where(:not(&:hover)) .clear-button {
display: none;
}
}

4
src/less/core/wrapper/flex.horizontal.less

@ -169,7 +169,9 @@
} }
> .f-f { > .f-f {
min-width: 0; &:not(.f-s-n) {
min-width: 0;
}
-webkit-flex-grow: 1; -webkit-flex-grow: 1;
-moz-flex-grow: 1; -moz-flex-grow: 1;
-ms-flex-grow: 1; -ms-flex-grow: 1;

4
src/less/core/wrapper/flex.vertical.less

@ -168,7 +168,9 @@
} }
> .f-f { > .f-f {
min-height: 0; &:not(.f-s-n) {
min-height: 0;
}
-webkit-flex-grow: 1; -webkit-flex-grow: 1;
-moz-flex-grow: 1; -moz-flex-grow: 1;
-ms-flex-grow: 1; -ms-flex-grow: 1;

4
src/less/core/wrapper/flex.wrapper.horizontal.less

@ -265,7 +265,9 @@
} }
> .f-f { > .f-f {
min-width: 0; &:not(.f-s-n) {
min-width: 0;
}
-webkit-flex-grow: 1; -webkit-flex-grow: 1;
-moz-flex-grow: 1; -moz-flex-grow: 1;
-ms-flex-grow: 1; -ms-flex-grow: 1;

4
src/less/core/wrapper/flex.wrapper.vertical.less

@ -259,7 +259,9 @@
} }
> .f-f { > .f-f {
min-height: 0; &:not(.f-s-n) {
min-height: 0;
}
-webkit-flex-grow: 1; -webkit-flex-grow: 1;
-moz-flex-grow: 1; -moz-flex-grow: 1;
-ms-flex-grow: 1; -ms-flex-grow: 1;

1
src/less/lib/theme.less

@ -179,6 +179,7 @@
@color-bi-border-hover-text-value-down-list-combo: @color-bi-border-highlight; @color-bi-border-hover-text-value-down-list-combo: @color-bi-border-highlight;
@color-bi-border-hover-text-value-check-combo: @color-bi-border-highlight; @color-bi-border-hover-text-value-check-combo: @color-bi-border-highlight;
@color-bi-text-error-hover-text-value-combo: @color-bi-text-failure; @color-bi-text-error-hover-text-value-combo: @color-bi-text-failure;
@color-bi-text-error-text-trigger: @color-bi-text-failure;
@color-bi-text-error-hover-text-value-icon-combo: @color-bi-text-failure; @color-bi-text-error-hover-text-value-icon-combo: @color-bi-text-failure;
@color-bi-text-error-hover-search-text-value-combo: @color-bi-text-failure; @color-bi-text-error-hover-search-text-value-combo: @color-bi-text-failure;
@color-bi-background-bubble-combo-triangle: @color-bi-background-default; @color-bi-background-bubble-combo-triangle: @color-bi-background-default;

30
src/less/widget/multilayerselecttree/multilayerselecttree.combo.less

@ -1,20 +1,24 @@
@import "../../index.less"; @import "../../index.less";
@val: transform .3s ease;
.bi-multilayer-select-tree-combo { .bi-multilayer-select-tree-combo {
& .trigger-icon-button{
font-size: @font-size-16; &.status-error {
} &.bi-border, &.bi-border-bottom {
// 此combo的trigger_button是absolute上去的,与bi-combo在同一层级,独立写一下 border-color: @border-color-negative;
& .bi-combo.bi-combo-popup + .bi-trigger-icon-button { }
& .x-icon {
.rotate(180deg); .bi-trigger .select-text-label {
.transition(@val); color: @color-bi-text-error-text-trigger;
} }
} }
& .bi-combo + .bi-trigger-icon-button {
& .x-icon { &.status-warning {
.rotate(0deg); &.bi-border, &.bi-border-bottom {
.transition(@val); border-color: @border-color-warning;
}
.bi-trigger .select-text-label {
color: @font-color-warning;
} }
} }
} }

29
src/less/widget/multilayersingletree/multilayersingletree.combo.less

@ -1,20 +1,23 @@
@import "../../index.less"; @import "../../index.less";
@val: transform .3s ease;
.bi-multilayer-single-tree-combo { .bi-multilayer-single-tree-combo {
& .trigger-icon-button{ &.status-error {
font-size: @font-size-16; &.bi-border, &.bi-border-bottom {
} border-color: @border-color-negative;
// 此combo的trigger_button是absolute上去的,与bi-combo在同一层级,独立写一下 }
& .bi-combo.bi-combo-popup + .bi-trigger-icon-button {
& .x-icon { .bi-trigger .select-text-label {
.rotate(180deg); color: @color-bi-text-error-text-trigger;
.transition(@val);
} }
} }
& .bi-combo + .bi-trigger-icon-button {
& .x-icon { &.status-warning {
.rotate(0deg); &.bi-border, &.bi-border-bottom {
.transition(@val); border-color: @border-color-warning;
}
.bi-trigger .select-text-label {
color: @font-color-warning;
} }
} }
} }

80
src/widget/multilayerselecttree/multilayerselecttree.combo.js

@ -16,66 +16,29 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
allowEdit: false, allowEdit: false,
allowSearchValue: false, allowSearchValue: false,
allowInsertValue: false, allowInsertValue: false,
isNeedAdjustWidth: true isNeedAdjustWidth: true,
status: "", // "error","warning"
}); });
}, },
_init: function () { _init: function () {
var o = this.options; var o = this.options;
if (this._shouldWrapper()) { BI.isNumeric(o.width) && (o.width -= 2);
o.height -= 2; BI.isNumeric(o.height) && (o.height -= 2);
BI.isNumeric(o.width) && (o.width -= 2);
}
BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments); BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments);
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
var combo = (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); return (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig();
return this._shouldWrapper() ? combo : {
type: "bi.absolute",
items: [{
el: combo,
left: 0,
right: 0,
top: 0,
bottom: 0
}, {
el: {
type: "bi.trigger_icon_button",
cls: "trigger-icon-button",
ref: function (_ref) {
self.triggerBtn = _ref;
},
width: o.height,
height: o.height,
handler: function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
}
},
right: 0,
bottom: 0,
top: 0
}]
};
},
_shouldWrapper: function () {
var o = this.options;
return !o.allowEdit && o.itemsCreator === BI.emptyFn;
}, },
_getBaseConfig: function () { _getBaseConfig: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
type: "bi.combo", type: "bi.combo",
cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius " + (BI.isKey(o.status) ? ("status-" + o.status) : ""),
container: o.container, container: o.container,
destroyWhenHide: o.destroyWhenHide, destroyWhenHide: o.destroyWhenHide,
adjustLength: 2, adjustLength: 2,
@ -122,7 +85,7 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
}; };
}, },
_getSearchConfig: function() { _getSearchConfig: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
el: { el: {
@ -139,7 +102,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
watermark: o.watermark, watermark: o.watermark,
height: o.height - (o.simple ? 1 : 2), // height: o.height - (o.simple ? 1 : 2),
height: o.height,
text: o.text, text: o.text,
value: o.value, value: o.value,
tipType: o.tipType, tipType: o.tipType,
@ -184,7 +148,7 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
// IE11下,popover(position: fixed)下放置下拉控件(position: fixed), 滚动的时候会异常卡顿 // IE11下,popover(position: fixed)下放置下拉控件(position: fixed), 滚动的时候会异常卡顿
// 通过container参数将popup放置于popover之外解决此问题, 其他下拉控件由于元素少或者有分页,所以 // 通过container参数将popup放置于popover之外解决此问题, 其他下拉控件由于元素少或者有分页,所以
// 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪 // 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪
return (o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0) ? false : self.triggerBtn.element.find(e.target).length === 0; return !(o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0);
}, },
listeners: [{ listeners: [{
@ -198,7 +162,7 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW); self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW);
} }
}] }]
} };
}, },
_getSyncConfig: function () { _getSyncConfig: function () {
@ -207,13 +171,15 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
return BI.extend(baseConfig, o.allowEdit ? this._getSearchConfig() : { return BI.extend(baseConfig, o.allowEdit ? this._getSearchConfig() : {
el: { el: {
type: "bi.single_tree_trigger", type: "bi.single_tree_trigger",
ref: function(_ref) { ref: function (_ref) {
self.textTrigger = _ref; self.textTrigger = _ref;
}, },
text: o.text, text: o.text,
height: o.height, height: o.height,
items: o.items, items: o.items,
value: o.value value: o.value,
tipType: o.tipType,
warningTitle: o.warningTitle,
} }
}); });
}, },
@ -236,6 +202,22 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
return this.trigger ? this.trigger.getSearcher() : this.textTrigger.getTextor(); return this.trigger ? this.trigger.getSearcher() : this.textTrigger.getTextor();
}, },
clear: function () {
// do some work
},
setStatus: function (status) {
if (BI.isKey(this.options.status)) {
this.element.removeClass("status-" + this.options.status);
}
this.element.addClass("status-" + status);
this.options.status = status;
},
setTipType: function (v) {
this.trigger ? this.trigger.setTipType(v) : this.textTrigger.setTipType(v);
},
populate: function (items) { populate: function (items) {
this.combo.populate(items); this.combo.populate(items);
}, },

59
src/widget/multilayerselecttree/multilayerselecttree.trigger.js

@ -3,7 +3,7 @@
*/ */
BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
props: function() { props: function () {
return { return {
extraCls: "bi-multi-layer-select-tree-trigger", extraCls: "bi-multi-layer-select-tree-trigger",
height: 24, height: 24,
@ -16,11 +16,12 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) { if (o.itemsCreator === BI.emptyFn) {
this._initData(); this._initData();
} }
var content = {
type: "bi.htape", return {
type: "bi.horizontal_fill",
items: [ items: [
{ {
el: { el: {
@ -86,7 +87,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
}, },
onSearch: function (obj, callback) { onSearch: function (obj, callback) {
var keyword = obj.keyword; var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) { if (o.itemsCreator === BI.emptyFn) {
callback(self._getSearchItems(keyword)); callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword); o.allowInsertValue && self.popup.setKeyword(keyword);
} else { } else {
@ -99,51 +100,37 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE); self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE);
} }
}] }]
} },
width: "fill",
}, { }, {
el: { el: {
type: "bi.layout", type: "bi.trigger_icon_button",
width: 24 cls: "trigger-icon-button",
ref: function (_ref) {
self.triggerBtn = _ref;
},
width: 24,
}, },
width: 24 width: 24,
} }
] ]
}; };
return o.allowEdit ? content : {
type: "bi.absolute",
items: [{
el: content,
left: 0,
right: 0,
top: 0,
bottom: 0
}, {
el: {
type: "bi.layout"
},
left: 0,
right: 24,
top: 0,
bottom: 0
}]
};
}, },
_initData: function() { _initData: function () {
var o = this.options; var o = this.options;
this.tree = new BI.Tree(); this.tree = new BI.Tree();
this.nodes = BI.Tree.treeFormat(BI.deepClone(o.items)); this.nodes = BI.Tree.treeFormat(BI.deepClone(o.items));
this.tree.initTree(this.nodes); this.tree.initTree(this.nodes);
}, },
_getSearchItems: function(keyword) { _getSearchItems: function (keyword) {
var self = this, o = this.options; var self = this, o = this.options;
// 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索
var items = []; var items = [];
this.tree.traverse(function (node) { this.tree.traverse(function (node) {
var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword);
if(find.find.length > 0 || find.match.length > 0) { if (find.find.length > 0 || find.match.length > 0) {
items.push(node); items.push(node);
return true; return true;
} }
@ -151,7 +138,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
return this._fillTreeStructure4Search(items, "id"); return this._fillTreeStructure4Search(items, "id");
}, },
_createJson: function(node, open) { _createJson: function (node, open) {
return { return {
id: node.id, id: node.id,
pId: node.pId, pId: node.pId,
@ -159,10 +146,10 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
value: node.value, value: node.value,
isParent: BI.isNotEmptyArray(node.children), isParent: BI.isNotEmptyArray(node.children),
open: open open: open
} };
}, },
_getChildren: function(node) { _getChildren: function (node) {
var self = this; var self = this;
node.children = node.children || []; node.children = node.children || [];
var nodes = []; var nodes = [];
@ -179,7 +166,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
var result = []; var result = [];
var queue = []; var queue = [];
BI.each(leaves, function (idx, node) { BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId}); queue.push({ pId: node.pId });
result.push(node); result.push(node);
result = result.concat(self._getChildren(node)); result = result.concat(self._getChildren(node));
}); });
@ -188,7 +175,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id"); var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) { if (pNode != null) {
pNode.open = true; pNode.open = true;
queue.push({pId: pNode.pId}); queue.push({ pId: pNode.pId });
result.push(pNode); result.push(pNode);
} }
} }

36
src/widget/multilayersingletree/multilayersingletree.combo.js

@ -25,17 +25,15 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
_init: function () { _init: function () {
var o = this.options; var o = this.options;
if (this._shouldWrapper()) { BI.isNumeric(o.width) && (o.width -= 2);
o.height -= 2; BI.isNumeric(o.height) && (o.height -= 2);
BI.isNumeric(o.width) && (o.width -= 2);
}
BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments); BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments);
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
var combo = (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); return (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig();
return this._shouldWrapper() ? combo : { return this._shouldWrapper() ? combo : {
type: "bi.absolute", type: "bi.absolute",
@ -79,7 +77,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
type: "bi.combo", type: "bi.combo",
cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius " + (BI.isKey(o.status) ? ("status-" + o.status) : ""),
container: o.container, container: o.container,
destroyWhenHide: o.destroyWhenHide, destroyWhenHide: o.destroyWhenHide,
adjustLength: 2, adjustLength: 2,
@ -125,7 +123,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
}; };
}, },
_getSearchConfig: function() { _getSearchConfig: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
el: { el: {
@ -142,7 +140,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
items: o.items, items: o.items,
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
height: o.height - (o.simple ? 1 : 2), height: o.height,
text: o.text, text: o.text,
value: o.value, value: o.value,
tipType: o.tipType, tipType: o.tipType,
@ -186,7 +184,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
// IE11下,popover(position: fixed)下放置下拉控件(position: fixed), 滚动的时候会异常卡顿 // IE11下,popover(position: fixed)下放置下拉控件(position: fixed), 滚动的时候会异常卡顿
// 通过container参数将popup放置于popover之外解决此问题, 其他下拉控件由于元素少或者有分页,所以 // 通过container参数将popup放置于popover之外解决此问题, 其他下拉控件由于元素少或者有分页,所以
// 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪 // 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪
return (o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0) ? false : self.triggerBtn.element.find(e.target).length === 0 return !(o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0);
}, },
listeners: [{ listeners: [{
eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, eventName: BI.Combo.EVENT_AFTER_HIDEVIEW,
@ -199,7 +197,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW); self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW);
} }
}] }]
} };
}, },
_getSyncConfig: function () { _getSyncConfig: function () {
@ -208,13 +206,15 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
return BI.extend(baseConfig, o.allowEdit ? this._getSearchConfig() : { return BI.extend(baseConfig, o.allowEdit ? this._getSearchConfig() : {
el: { el: {
type: "bi.single_tree_trigger", type: "bi.single_tree_trigger",
ref: function(_ref) { ref: function (_ref) {
self.textTrigger = _ref; self.textTrigger = _ref;
}, },
text: o.text, text: o.text,
height: o.height, height: o.height,
items: o.items, items: o.items,
value: o.value value: o.value,
tipType: o.tipType,
warningTitle: o.warningTitle,
} }
}); });
}, },
@ -237,6 +237,18 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
return this.combo.getValue(); return this.combo.getValue();
}, },
setStatus: function (status) {
if (BI.isKey(this.options.status)) {
this.element.removeClass("status-" + this.options.status);
}
this.element.addClass("status-" + status);
this.options.status = status;
},
setTipType: function (v) {
this.trigger ? this.trigger.setTipType(v) : this.textTrigger.setTipType(v);
},
populate: function (items) { populate: function (items) {
this.combo.populate(items); this.combo.populate(items);
}, },

57
src/widget/multilayersingletree/multilayersingletree.trigger.js

@ -3,7 +3,7 @@
*/ */
BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
props: function() { props: function () {
return { return {
extraCls: "bi-multi-layer-single-tree-trigger", extraCls: "bi-multi-layer-single-tree-trigger",
height: 24, height: 24,
@ -16,11 +16,12 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) { if (o.itemsCreator === BI.emptyFn) {
this._initData(); this._initData();
} }
var content = {
type: "bi.htape", return {
type: "bi.horizontal_fill",
items: [ items: [
{ {
el: { el: {
@ -86,7 +87,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
}, },
onSearch: function (obj, callback) { onSearch: function (obj, callback) {
var keyword = obj.keyword; var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) { if (o.itemsCreator === BI.emptyFn) {
callback(self._getSearchItems(keyword)); callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword); o.allowInsertValue && self.popup.setKeyword(keyword);
} else { } else {
@ -99,51 +100,37 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE); self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE);
} }
}] }]
} },
width: "fill",
}, { }, {
el: { el: {
type: "bi.layout", type: "bi.trigger_icon_button",
width: 24 cls: "trigger-icon-button",
ref: function (_ref) {
self.triggerBtn = _ref;
},
width: 24,
}, },
width: 24 width: 24
} }
] ]
}; };
return o.allowEdit ? content : {
type: "bi.absolute",
items: [{
el: content,
left: 0,
right: 0,
top: 0,
bottom: 0
}, {
el: {
type: "bi.layout"
},
left: 0,
right: 24,
top: 0,
bottom: 0
}]
};
}, },
_initData: function() { _initData: function () {
var o = this.options; var o = this.options;
this.tree = new BI.Tree(); this.tree = new BI.Tree();
this.nodes = BI.Tree.treeFormat(BI.deepClone(o.items)); this.nodes = BI.Tree.treeFormat(BI.deepClone(o.items));
this.tree.initTree(this.nodes); this.tree.initTree(this.nodes);
}, },
_getSearchItems: function(keyword) { _getSearchItems: function (keyword) {
var self = this, o = this.options; var self = this, o = this.options;
// 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索
var items = []; var items = [];
this.tree.traverse(function (node) { this.tree.traverse(function (node) {
var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword);
if(find.find.length > 0 || find.match.length > 0) { if (find.find.length > 0 || find.match.length > 0) {
items.push(node); items.push(node);
return true; return true;
} }
@ -151,7 +138,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
return this._fillTreeStructure4Search(items, "id"); return this._fillTreeStructure4Search(items, "id");
}, },
_createJson: function(node, open) { _createJson: function (node, open) {
return { return {
id: node.id, id: node.id,
pId: node.pId, pId: node.pId,
@ -159,10 +146,10 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
value: node.value, value: node.value,
isParent: BI.isNotEmptyArray(node.children), isParent: BI.isNotEmptyArray(node.children),
open: open open: open
} };
}, },
_getChildren: function(node) { _getChildren: function (node) {
var self = this; var self = this;
node.children = node.children || []; node.children = node.children || [];
var nodes = []; var nodes = [];
@ -179,7 +166,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
var result = []; var result = [];
var queue = []; var queue = [];
BI.each(leaves, function (idx, node) { BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId}); queue.push({ pId: node.pId });
result.push(node); result.push(node);
result = result.concat(self._getChildren(node)); result = result.concat(self._getChildren(node));
}); });
@ -188,7 +175,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id"); var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) { if (pNode != null) {
pNode.open = true; pNode.open = true;
queue.push({pId: pNode.pId}); queue.push({ pId: pNode.pId });
result.push(pNode); result.push(pNode);
} }
} }

40
src/widget/selecttree/selecttree.combo.js

@ -11,6 +11,7 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, {
text: "", text: "",
items: [], items: [],
value: "", value: "",
allowClear: false,
}); });
}, },
@ -25,7 +26,13 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, {
text: o.text, text: o.text,
height: o.height, height: o.height,
items: o.items, items: o.items,
value: o.value value: o.value,
allowClear: o.allowClear,
warningTitle: o.warningTitle,
});
this.trigger.on(BI.SingleTreeTrigger.EVENT_CLEAR, function () {
self._clear();
}); });
this.popup = BI.createWidget({ this.popup = BI.createWidget({
@ -53,12 +60,43 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, {
self.setValue(self.popup.getValue()); self.setValue(self.popup.getValue());
self.combo.hideView(); self.combo.hideView();
}); });
if (BI.isKey(o.value)) {
this._checkError(o.value);
}
},
_checkError: function (v) {
if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) {
this.trigger.options.tipType = "success";
this.trigger.element.removeClass("error");
this.element.removeClass("error");
} else {
v = BI.isArray(v) ? v : [v];
var result = BI.find(this.options.items, function (idx, item) {
return BI.contains(v, item.value);
});
if (BI.isNull(result)) {
this.trigger.setTipType("warning");
this.element.removeClass("error").addClass("error");
this.trigger.element.removeClass("error").addClass("error");
} else {
this.trigger.setTipType("success");
this.trigger.element.removeClass("error");
this.element.removeClass("error");
}
}
},
_clear: function () {
this.setValue([]);
}, },
setValue: function (v) { setValue: function (v) {
v = BI.isArray(v) ? v : [v]; v = BI.isArray(v) ? v : [v];
this.trigger.setValue(v); this.trigger.setValue(v);
this.popup.setValue(v); this.popup.setValue(v);
this._checkError(v);
}, },
getValue: function () { getValue: function () {

40
src/widget/singletree/singletree.combo.js

@ -12,6 +12,7 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, {
text: "", text: "",
items: [], items: [],
value: "", value: "",
allowClear: false,
}); });
}, },
@ -26,9 +27,15 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, {
text: o.text, text: o.text,
height: o.height, height: o.height,
items: o.items, items: o.items,
value: o.value value: o.value,
allowClear: o.allowClear,
warningTitle: o.warningTitle,
}, o.trigger)); }, o.trigger));
this.trigger.on(BI.SingleTreeTrigger.EVENT_CLEAR, function () {
self._clear();
});
this.popup = BI.createWidget({ this.popup = BI.createWidget({
type: "bi.single_level_tree", type: "bi.single_level_tree",
items: o.items, items: o.items,
@ -58,6 +65,36 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, {
self.combo.hideView(); self.combo.hideView();
self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE); self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE);
}); });
if (BI.isKey(o.value)) {
this._checkError(o.value);
}
},
_checkError: function (v) {
if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) {
this.trigger.options.tipType = "success";
this.trigger.element.removeClass("error");
this.element.removeClass("error");
} else {
v = BI.isArray(v) ? v : [v];
var result = BI.find(this.options.items, function (idx, item) {
return BI.contains(v, item.value);
});
if (BI.isNull(result)) {
this.trigger.setTipType("warning");
this.element.removeClass("error").addClass("error");
this.trigger.element.removeClass("error").addClass("error");
} else {
this.trigger.setTipType("success");
this.trigger.element.removeClass("error");
this.element.removeClass("error");
}
}
},
_clear: function () {
this.setValue([]);
}, },
populate: function (items) { populate: function (items) {
@ -68,6 +105,7 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, {
v = BI.isArray(v) ? v : [v]; v = BI.isArray(v) ? v : [v];
this.trigger.setValue(v); this.trigger.setValue(v);
this.popup.setValue(v); this.popup.setValue(v);
this._checkError(v);
}, },
getValue: function () { getValue: function () {

24
src/widget/singletree/singletree.trigger.js

@ -11,7 +11,8 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, {
height: 24, height: 24,
text: "", text: "",
items: [], items: [],
value: "" value: "",
allowClear: false,
}); });
}, },
@ -26,7 +27,18 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, {
text: o.text, text: o.text,
items: o.items, items: o.items,
height: o.height, height: o.height,
value: o.value warningTitle: o.warningTitle,
tipType: o.tipType,
value: o.value,
allowClear: o.allowClear,
listeners: [
{
eventName: BI.SelectTextTrigger.EVENT_CLEAR,
action: function () {
self.fireEvent(BI.SingleTreeTrigger.EVENT_CLEAR);
}
}
]
}); });
}, },
@ -47,11 +59,16 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, {
this._checkTitle(); this._checkTitle();
}, },
setTipType: function (v) {
this.options.tipType = v;
this.trigger.setTipType(v);
},
getValue: function () { getValue: function () {
return this.options.value || []; return this.options.value || [];
}, },
getTextor: function() { getTextor: function () {
return this.trigger.getTextor(); return this.trigger.getTextor();
}, },
@ -61,4 +78,5 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, {
}); });
BI.SingleTreeTrigger.EVENT_CLEAR = "EVENT_CLEAR";
BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger); BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);

8
src/widget/year/combo.year.js

@ -24,7 +24,8 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
min: o.minDate, min: o.minDate,
max: o.maxDate, max: o.maxDate,
height: o.height - border, height: o.height - border,
value: o.value || "" value: o.value || "",
watermark: o.watermark
}); });
this.trigger.on(BI.DynamicYearTrigger.EVENT_KEY_DOWN, function () { this.trigger.on(BI.DynamicYearTrigger.EVENT_KEY_DOWN, function () {
if (self.combo.isViewVisible()) { if (self.combo.isViewVisible()) {
@ -211,8 +212,11 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
isStateValid: function () { isStateValid: function () {
return this.trigger.isValid(); return this.trigger.isValid();
} },
setWaterMark: function (v) {
this.trigger.setWaterMark(v);
}
}); });
BI.DynamicYearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicYearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";

9
src/widget/year/trigger.year.js

@ -10,7 +10,8 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, {
extraCls: "bi-year-trigger", extraCls: "bi-year-trigger",
min: "1900-01-01", // 最小日期 min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期 max: "2099-12-31", // 最大日期
height: 24 height: 24,
watermark: BI.i18nText("BI-Basic_Unrestricted")
}); });
}, },
@ -35,7 +36,7 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, {
}, },
hgap: c.hgap, hgap: c.hgap,
vgap: c.vgap, vgap: c.vgap,
watermark: BI.i18nText("BI-Basic_Unrestricted"), watermark: o.watermark,
allowBlank: true, allowBlank: true,
errorText: function (v) { errorText: function (v) {
if (BI.isPositiveInteger(v)) { if (BI.isPositiveInteger(v)) {
@ -188,6 +189,10 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, {
getKey: function () { getKey: function () {
return this.editor.getValue() | 0; return this.editor.getValue() | 0;
},
setWaterMark: function (v) {
this.editor.setWaterMark(v);
} }
}); });
BI.DynamicYearTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicYearTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";

2
typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts

@ -21,4 +21,6 @@ export declare class MultiLayerSelectTreeCombo extends Widget {
blur(): void; blur(): void;
showView(): void; showView(): void;
setStatus(status: "error" | "warning"): void;
} }

2
typescript/widget/multilayersingletree/multilayersingletree.combo.ts

@ -21,4 +21,6 @@ export declare class MultiLayerSingleTreeCombo extends Widget {
blur(): void; blur(): void;
showView(): void; showView(): void;
setStatus(status: "error" | "warning"): void;
} }

Loading…
Cancel
Save