Browse Source

无jira refact:widget搞完了

es6
Treecat 2 years ago
parent
commit
856291de43
  1. 4
      src/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.js
  2. 19
      src/component/form/form.field.js
  3. 11
      src/component/form/form.js
  4. 178
      src/component/treevaluechooser/combo.treevaluechooser.insert.js
  5. 2
      src/widget/date/calendar/picker.date.js
  6. 4
      src/widget/date/calendar/picker.year.js
  7. 8
      src/widget/datetimepane/card.static.datetimepane.js
  8. 20
      src/widget/dynamicdate/dynamicdate.combo.js
  9. 18
      src/widget/dynamicdatetime/dynamicdatetime.combo.js
  10. 2
      src/widget/multilayerdownlist/combo.downlist.js
  11. 3
      src/widget/multilayersingletree/multilayersingletree.leveltree.js
  12. 6
      src/widget/multitree/check/multi.tree.check.pane.js
  13. 59
      src/widget/multitree/multi.tree.combo.js
  14. 87
      src/widget/multitree/multi.tree.insert.combo.js
  15. 91
      src/widget/multitree/multi.tree.list.combo.js
  16. 10
      src/widget/multitree/multi.tree.popup.js
  17. 17
      src/widget/multitree/trigger/multi.tree.button.checkselected.js
  18. 38
      src/widget/multitree/trigger/multi.tree.search.insert.pane.js
  19. 4
      src/widget/multitree/trigger/multi.tree.search.pane.js
  20. 19
      src/widget/multitree/trigger/searcher.list.multi.tree.js
  21. 29
      src/widget/multitree/trigger/searcher.multi.tree.js
  22. 56
      src/widget/numbereditor/number.editor.js
  23. 116
      src/widget/numberinterval/numberinterval.js
  24. 46
      src/widget/numberinterval/singleeditor/single.editor.js
  25. 7
      src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js
  26. 15
      src/widget/searchmultitextvaluecombo/multitextvalue.combo.trigger.search.js
  27. 2
      src/widget/searchmultitextvaluecombo/multitextvalue.popup.view.search.js
  28. 7
      src/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue.js
  29. 12
      src/widget/selecttree/selecttree.combo.js
  30. 10
      src/widget/selecttree/selecttree.expander.js
  31. 17
      src/widget/selecttree/selecttree.popup.js
  32. 22
      src/widget/singleselect/search/singleselect.search.loader.js
  33. 12
      src/widget/singleselect/search/singleselect.search.pane.insert.js
  34. 48
      src/widget/singleselect/singleselect.combo.js
  35. 34
      src/widget/singleselect/singleselect.insert.combo.js
  36. 20
      src/widget/singleselect/singleselect.loader.js
  37. 3
      src/widget/singleselect/singleselect.popup.view.js
  38. 3
      src/widget/singleselect/singleselectlist.insert.js
  39. 12
      src/widget/singleselect/trigger/editor.singleselect.js
  40. 11
      src/widget/singleselect/trigger/searcher.singleselect.js
  41. 2
      src/widget/singleslider/button/iconbutton.slider.js
  42. 60
      src/widget/singleslider/singleslider.js
  43. 35
      src/widget/singleslider/singleslider.label.js
  44. 35
      src/widget/singleslider/singleslider.normal.js
  45. 9
      src/widget/singletree/singletree.combo.js
  46. 9
      src/widget/singletree/singletree.popup.js
  47. 10
      src/widget/singletree/singletree.trigger.js
  48. 8
      src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js
  49. 69
      src/widget/time/datetime.popup.js
  50. 100
      src/widget/time/time.combo.js
  51. 97
      src/widget/time/time.trigger.js
  52. 63
      src/widget/timeinterval/dateinterval.js
  53. 75
      src/widget/timeinterval/timeinterval.js
  54. 49
      src/widget/timeinterval/timeperiods.js
  55. 35
      src/widget/year/card.dynamic.year.js
  56. 26
      src/widget/year/card.year.js
  57. 38
      src/widget/year/combo.year.js
  58. 96
      src/widget/year/popup.year.js
  59. 38
      src/widget/year/trigger.year.js
  60. 30
      src/widget/yearinterval/yearinterval.js
  61. 42
      src/widget/yearmonth/card.dynamic.yearmonth.js
  62. 20
      src/widget/yearmonth/card.static.yearmonth.js
  63. 35
      src/widget/yearmonth/combo.yearmonth.js
  64. 79
      src/widget/yearmonth/popup.yearmonth.js
  65. 44
      src/widget/yearmonth/trigger.yearmonth.js
  66. 19
      src/widget/yearmonthinterval/yearmonthinterval.js
  67. 35
      src/widget/yearquarter/combo.yearquarter.js

4
src/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.js

@ -1,5 +1,5 @@
import { shortcut, Widget, Selection, each, contains } from "@/core";
import { SearchMultiTextValueCombo } from "@/widget"; import { SearchMultiTextValueCombo } from "@/widget";
import { shortcut, Widget, Selection, each, contains } from "@/core";
@shortcut() @shortcut()
export class AllValueMultiTextValueCombo extends Widget { export class AllValueMultiTextValueCombo extends Widget {
@ -15,7 +15,7 @@ export class AllValueMultiTextValueCombo extends Widget {
const value = this._digestValue(o.value); const value = this._digestValue(o.value);
return { return {
type: "bi.search_multi_text_value_combo", type: SearchMultiTextValueCombo.xtype,
simple: o.simple, simple: o.simple,
text: o.text, text: o.text,
height: o.height, height: o.height,

19
src/component/form/form.field.js

@ -1,5 +1,5 @@
import { AbsoluteLayout, VerticalAdaptLayout, shortcut, Widget, extend, concat, isKey, VerticalAlign } from "@/core";
import { shortcut, Widget, extend, concat, isKey, VerticalAlign } from "@/core"; import { Label } from "@/base";
@shortcut() @shortcut()
export class FormField extends Widget { export class FormField extends Widget {
@ -14,14 +14,14 @@ export class FormField extends Widget {
validate() { validate() {
return true; return true;
}, // 默认返回true }, // 默认返回true
} };
render() { render() {
const self = this, const self = this,
o = this.options; o = this.options;
const field = { const field = {
type: "bi.absolute", type: AbsoluteLayout.xtype,
items: [ items: [
{ {
el: extend({}, o.el, { el: extend({}, o.el, {
@ -52,7 +52,7 @@ export class FormField extends Widget {
}, },
{ {
el: { el: {
type: "bi.label", type: Label.xtype,
cls: "error-tip bi-error", cls: "error-tip bi-error",
ref(_ref) { ref(_ref) {
self.error = _ref; self.error = _ref;
@ -68,14 +68,14 @@ export class FormField extends Widget {
}; };
return { return {
type: "bi.vertical_adapt", type: VerticalAdaptLayout.xtype,
columnSize: ["auto", "fill"], columnSize: ["auto", "fill"],
verticalAlign: VerticalAlign.Stretch, verticalAlign: VerticalAlign.Stretch,
items: isKey(o.label) items: isKey(o.label)
? [ ? [
{ {
el: { el: {
type: "bi.label", type: Label.xtype,
textAlign: o.labelAlign, textAlign: o.labelAlign,
text: o.label, text: o.label,
width: o.labelWidth, width: o.labelWidth,
@ -95,10 +95,7 @@ export class FormField extends Widget {
validate() { validate() {
const isValid = this.validateWithNoTip(); const isValid = this.validateWithNoTip();
!isValid && !isValid && this.error.setText(this.options.tip(this.field.getValue(), this.field));
this.error.setText(
this.options.tip(this.field.getValue(), this.field)
);
this.error.setVisible(!isValid); this.error.setVisible(!isValid);
this.field.element[isValid ? "removeClass" : "addClass"]("bi-error"); this.field.element[isValid ? "removeClass" : "addClass"]("bi-error");

11
src/component/form/form.js

@ -1,4 +1,5 @@
import { shortcut, Widget, map, some, each } from "@/core"; import { VerticalLayout, shortcut, Widget, map, some, each } from "@/core";
import { FormField } from "./form.field";
import { ButtonGroup } from "@/base"; import { ButtonGroup } from "@/base";
@shortcut() @shortcut()
@ -8,7 +9,7 @@ export class Form extends Widget {
props = { props = {
baseCls: "bi-form", baseCls: "bi-form",
labelAlign: "right", labelAlign: "right",
layout: { type: "bi.vertical", vgap: 20 }, layout: { type: VerticalLayout.xtype, vgap: 20 },
items: [{ label: "", el: {} }], items: [{ label: "", el: {} }],
labelWidth: "", labelWidth: "",
headerCls: "", headerCls: "",
@ -35,7 +36,7 @@ export class Form extends Widget {
return map(o.items, (idx, item) => { return map(o.items, (idx, item) => {
return { return {
type: "bi.form_field", type: FormField.xtype,
height: item.el.height || 28, height: item.el.height || 28,
labelAlign: o.labelAlign, labelAlign: o.labelAlign,
labelWidth: o.labelWidth, labelWidth: o.labelWidth,
@ -79,8 +80,6 @@ export class Form extends Widget {
} }
getValue() { getValue() {
return !this.isAllValid() return !this.isAllValid() ? null : map(this.group.getAllButtons(), (idx, button) => button.getValue());
? null
: map(this.group.getAllButtons(), (idx, button) => button.getValue());
} }
} }

178
src/component/treevaluechooser/combo.treevaluechooser.insert.js

@ -1,31 +1,40 @@
/** import { shortcut, extend, emptyFn, isNotNull, createWidget, bind } from "@/core";
* 简单的复选下拉树控件, 适用于数据量少的情况, 可以自增值 import { AbstractTreeValueChooser } from "./abstract.treevaluechooser";
* import { MultiTreeInsertCombo, MultiTreeCombo } from "@/widget";
* Created by GUY on 2015/10/29. import { TreeValueChooserCombo } from "./combo.treevaluechooser";
* @class BI.TreeValueChooserInsertCombo
* @extends BI.Widget
*/
BI.TreeValueChooserInsertCombo = BI.inherit(BI.AbstractTreeValueChooser, {
_defaultConfig: function () { @shortcut()
return BI.extend(BI.TreeValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), { export class TreeValueChooserInsertCombo extends AbstractTreeValueChooser {
static xtype = "bi.tree_value_chooser_insert_combo";
static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR";
static EVENT_STOP = "EVENT_STOP";
static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
static EVENT_SEARCHING = "EVENT_SEARCHING";
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-tree-value-chooser-insert-combo", baseCls: "bi-tree-value-chooser-insert-combo",
width: 200, width: 200,
height: 24, height: 24,
items: null, items: null,
itemsCreator: BI.emptyFn, itemsCreator: emptyFn,
isNeedAdjustWidth: true isNeedAdjustWidth: true,
}); });
}, }
_init: function () { _init() {
BI.TreeValueChooserInsertCombo.superclass._init.apply(this, arguments); super._init(...arguments);
var self = this, o = this.options; const self = this,
if (BI.isNotNull(o.items)) { o = this.options;
if (isNotNull(o.items)) {
this._initData(o.items); this._initData(o.items);
} }
this.combo = BI.createWidget({ this.combo = createWidget({
type: "bi.multi_tree_insert_combo", type: MultiTreeInsertCombo.xtype,
simple: o.simple, simple: o.simple,
isNeedAdjustWidth: o.isNeedAdjustWidth, isNeedAdjustWidth: o.isNeedAdjustWidth,
allowEdit: o.allowEdit, allowEdit: o.allowEdit,
@ -34,94 +43,93 @@ BI.TreeValueChooserInsertCombo = BI.inherit(BI.AbstractTreeValueChooser, {
value: o.value, value: o.value,
watermark: o.watermark, watermark: o.watermark,
element: this, element: this,
itemsCreator: BI.bind(this._itemsCreator, this), itemsCreator: bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this), valueFormatter: bind(this._valueFormatter, this),
width: o.width, width: o.width,
height: o.height, height: o.height,
listeners: [{ listeners: [
eventName: BI.MultiTreeInsertCombo.EVENT_FOCUS, {
action: function () { eventName: MultiTreeInsertCombo.EVENT_FOCUS,
self.fireEvent(BI.TreeValueChooserCombo.EVENT_FOCUS); action () {
} self.fireEvent(TreeValueChooserCombo.EVENT_FOCUS);
}, { },
eventName: BI.MultiTreeInsertCombo.EVENT_BLUR, },
action: function () { {
self.fireEvent(BI.TreeValueChooserCombo.EVENT_BLUR); eventName: MultiTreeInsertCombo.EVENT_BLUR,
} action () {
}, { self.fireEvent(TreeValueChooserCombo.EVENT_BLUR);
eventName: BI.MultiTreeInsertCombo.EVENT_STOP, },
action: function () { },
self.fireEvent(BI.TreeValueChooserInsertCombo.EVENT_STOP); {
} eventName: MultiTreeInsertCombo.EVENT_STOP,
}, { action () {
eventName: BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.fireEvent(TreeValueChooserInsertCombo.EVENT_STOP);
action: function (v) { },
self.fireEvent(BI.TreeValueChooserInsertCombo.EVENT_CLICK_ITEM, v); },
} {
}, { eventName: MultiTreeInsertCombo.EVENT_CLICK_ITEM,
eventName: BI.MultiTreeInsertCombo.EVENT_SEARCHING, action (v) {
action: function () { self.fireEvent(TreeValueChooserInsertCombo.EVENT_CLICK_ITEM, v);
self.fireEvent(BI.TreeValueChooserInsertCombo.EVENT_SEARCHING); },
} },
}, { {
eventName: BI.MultiTreeInsertCombo.EVENT_CONFIRM, eventName: MultiTreeInsertCombo.EVENT_SEARCHING,
action: function () { action () {
self.fireEvent(BI.TreeValueChooserInsertCombo.EVENT_CONFIRM); self.fireEvent(TreeValueChooserInsertCombo.EVENT_SEARCHING);
} },
}, { },
eventName: BI.MultiTreeCombo.EVENT_BEFORE_POPUPVIEW, {
action: function () { eventName: MultiTreeInsertCombo.EVENT_CONFIRM,
self.fireEvent(BI.TreeValueChooserInsertCombo.EVENT_BEFORE_POPUPVIEW); action () {
self.fireEvent(TreeValueChooserInsertCombo.EVENT_CONFIRM);
},
},
{
eventName: MultiTreeCombo.EVENT_BEFORE_POPUPVIEW,
action () {
self.fireEvent(TreeValueChooserInsertCombo.EVENT_BEFORE_POPUPVIEW);
},
} }
}] ],
}); });
}, }
showView: function () { showView() {
this.combo.showView(); this.combo.showView();
}, }
hideView: function () { hideView() {
this.combo.hideView(); this.combo.hideView();
}, }
getSearcher: function () { getSearcher() {
return this.combo.getSearcher(); return this.combo.getSearcher();
}, }
setValue: function (v) { setValue(v) {
this.combo.setValue(v); this.combo.setValue(v);
}, }
getValue: function () { getValue() {
return this.combo.getValue(); return this.combo.getValue();
}, }
populate: function (items) { populate(items) {
if (BI.isNotNull(items)) { if (isNotNull(items)) {
this._initData(items); this._initData(items);
} }
this.combo.populate(); this.combo.populate();
}, }
focus: function () { focus() {
this.combo.focus(); this.combo.focus();
}, }
blur: function () { blur() {
this.combo.blur(); this.combo.blur();
}, }
setWaterMark: function (v) { setWaterMark(v) {
this.combo.setWaterMark(v); this.combo.setWaterMark(v);
} }
}); }
BI.TreeValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.TreeValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
BI.TreeValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
BI.TreeValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.TreeValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.TreeValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.TreeValueChooserInsertCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.tree_value_chooser_insert_combo", BI.TreeValueChooserInsertCombo);

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

@ -150,7 +150,7 @@ export class DatePicker extends Widget {
items: [this.right], items: [this.right],
}, },
width: 24, width: 24,
}, }
], ],
}); });
this.setValue({ this.setValue({

4
src/widget/date/calendar/picker.year.js

@ -83,7 +83,7 @@ export class YearPicker extends Widget {
items: [ items: [
{ {
el: this.year, el: this.year,
}, }
], ],
}, },
{ {
@ -92,7 +92,7 @@ export class YearPicker extends Widget {
items: [this.right], items: [this.right],
}, },
width: 25, width: 25,
}, }
], ],
}); });
this.setValue(this._year); this.setValue(this._year);

8
src/widget/datetimepane/card.static.datetimepane.js

@ -105,7 +105,7 @@ export class StaticDateTimePaneCard extends Widget {
el: { el: {
type: DynamicDateTimeSelect.xtype, type: DynamicDateTimeSelect.xtype,
cls: "bi-split-top", cls: "bi-split-top",
ref: (_ref) => { ref: _ref => {
this.timeSelect = _ref; this.timeSelect = _ref;
}, },
listeners: [ listeners: [
@ -115,11 +115,11 @@ export class StaticDateTimePaneCard extends Widget {
this.selectedTime = extend(this.calendar.getValue(), this.timeSelect.getValue()); this.selectedTime = extend(this.calendar.getValue(), this.timeSelect.getValue());
this.fireEvent("EVENT_CHANGE"); this.fireEvent("EVENT_CHANGE");
}, },
}, }
], ],
}, },
height: 40, height: 40,
}, }
], ],
}); });
@ -136,7 +136,7 @@ export class StaticDateTimePaneCard extends Widget {
top: 40, top: 40,
left: 0, left: 0,
right: 0, right: 0,
}, }
], ],
}); });
this.setValue(o.selectedTime); this.setValue(o.selectedTime);

20
src/widget/dynamicdate/dynamicdate.combo.js

@ -9,7 +9,7 @@ import {
isEmptyString, isEmptyString,
isNotNull, isNotNull,
isNotEmptyObject, isNotEmptyObject,
checkDateVoid, checkDateVoid
} from "@/core"; } from "@/core";
import { Combo, IconButton, Single } from "@/base"; import { Combo, IconButton, Single } from "@/base";
import { DynamicDateTrigger } from "./dynamicdate.trigger"; import { DynamicDateTrigger } from "./dynamicdate.trigger";
@ -75,7 +75,7 @@ export class DynamicDateCombo extends Single {
type: Combo.xtype, type: Combo.xtype,
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`,
container: opts.container, container: opts.container,
ref: (_ref) => { ref: _ref => {
this.combo = _ref; this.combo = _ref;
}, },
toggle: false, toggle: false,
@ -93,7 +93,7 @@ export class DynamicDateCombo extends Single {
cls: "bi-trigger-icon-button date-change-h-font", cls: "bi-trigger-icon-button date-change-h-font",
width: toPix(opts.height, border), width: toPix(opts.height, border),
height: toPix(opts.height, border), height: toPix(opts.height, border),
ref: (_ref) => { ref: _ref => {
this.changeIcon = _ref; this.changeIcon = _ref;
}, },
}, },
@ -109,7 +109,7 @@ export class DynamicDateCombo extends Single {
iconWidth: toPix(opts.height, border), iconWidth: toPix(opts.height, border),
height: toPix(opts.height, border), height: toPix(opts.height, border),
value: opts.value, value: opts.value,
ref: (_ref) => { ref: _ref => {
this.trigger = _ref; this.trigger = _ref;
}, },
listeners: [ listeners: [
@ -192,9 +192,9 @@ export class DynamicDateCombo extends Single {
this._checkDynamicValue(this.storeValue); this._checkDynamicValue(this.storeValue);
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM); this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
}, },
}, }
], ],
}, }
], ],
}, },
adjustLength: this.constants.comboAdjustHeight, adjustLength: this.constants.comboAdjustHeight,
@ -206,7 +206,7 @@ export class DynamicDateCombo extends Single {
behaviors: opts.behaviors, behaviors: opts.behaviors,
min: opts.minDate, min: opts.minDate,
max: opts.maxDate, max: opts.maxDate,
ref: (_ref) => { ref: _ref => {
this.popup = _ref; this.popup = _ref;
}, },
listeners: [ listeners: [
@ -258,7 +258,7 @@ export class DynamicDateCombo extends Single {
action: () => { action: () => {
this.fireEvent(DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); this.fireEvent(DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
}, },
}, }
], ],
}, },
}, },
@ -275,14 +275,14 @@ export class DynamicDateCombo extends Single {
this.popup.setValue(this.storeValue); this.popup.setValue(this.storeValue);
this.fireEvent(DynamicDateCombo.EVENT_BEFORE_POPUPVIEW); this.fireEvent(DynamicDateCombo.EVENT_BEFORE_POPUPVIEW);
}, },
}, }
], ],
}, },
top: 0, top: 0,
left: 0, left: 0,
right: 0, right: 0,
bottom: 0, bottom: 0,
}, }
], ],
}; };
} }

18
src/widget/dynamicdatetime/dynamicdatetime.combo.js

@ -76,7 +76,7 @@ export class DynamicDateTimeCombo extends Single {
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`,
destroyWhenHide: true, destroyWhenHide: true,
container: opts.container, container: opts.container,
ref: (_ref) => { ref: _ref => {
this.combo = _ref; this.combo = _ref;
}, },
toggle: false, toggle: false,
@ -93,7 +93,7 @@ export class DynamicDateTimeCombo extends Single {
cls: "bi-trigger-icon-button date-change-h-font", cls: "bi-trigger-icon-button date-change-h-font",
width: this.constants.iconWidth, width: this.constants.iconWidth,
height: toPix(opts.height, border), height: toPix(opts.height, border),
ref: (_ref) => { ref: _ref => {
this.changeIcon = _ref; this.changeIcon = _ref;
}, },
}, },
@ -109,7 +109,7 @@ export class DynamicDateTimeCombo extends Single {
iconWidth: this.constants.iconWidth, iconWidth: this.constants.iconWidth,
height: toPix(opts.height, border), height: toPix(opts.height, border),
value: opts.value, value: opts.value,
ref: (_ref) => { ref: _ref => {
this.trigger = _ref; this.trigger = _ref;
}, },
listeners: [ listeners: [
@ -198,9 +198,9 @@ export class DynamicDateTimeCombo extends Single {
this._checkDynamicValue(this.storeValue); this._checkDynamicValue(this.storeValue);
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM); this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
}, },
}, }
], ],
}, }
], ],
}, },
adjustLength: this.constants.comboAdjustHeight, adjustLength: this.constants.comboAdjustHeight,
@ -212,7 +212,7 @@ export class DynamicDateTimeCombo extends Single {
behaviors: opts.behaviors, behaviors: opts.behaviors,
min: opts.minDate, min: opts.minDate,
max: opts.maxDate, max: opts.maxDate,
ref: (_ref) => { ref: _ref => {
this.popup = _ref; this.popup = _ref;
}, },
listeners: [ listeners: [
@ -267,7 +267,7 @@ export class DynamicDateTimeCombo extends Single {
action: () => { action: () => {
this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
}, },
}, }
], ],
}, },
}, },
@ -280,7 +280,7 @@ export class DynamicDateTimeCombo extends Single {
this.popup.setValue(this.storeValue); this.popup.setValue(this.storeValue);
this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW); this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
}, },
}, }
], ],
// // DEC-4250 和复选下拉一样,点击不收起 // // DEC-4250 和复选下拉一样,点击不收起
// hideChecker: function (e) { // hideChecker: function (e) {
@ -291,7 +291,7 @@ export class DynamicDateTimeCombo extends Single {
left: 0, left: 0,
right: 0, right: 0,
bottom: 0, bottom: 0,
}, }
], ],
}; };
} }

2
src/widget/multilayerdownlist/combo.downlist.js

@ -35,7 +35,7 @@ export class MultiLayerDownListCombo extends Widget {
value: o.value, value: o.value,
}); });
this.popupview.on(MultiLayerDownListPopup.EVENT_CHANGE, (value) => { this.popupview.on(MultiLayerDownListPopup.EVENT_CHANGE, value => {
this.fireEvent(MultiLayerDownListCombo.EVENT_CHANGE, value); this.fireEvent(MultiLayerDownListCombo.EVENT_CHANGE, value);
this.downlistcombo.hideView(); this.downlistcombo.hideView();
}); });

3
src/widget/multilayersingletree/multilayersingletree.leveltree.js

@ -178,8 +178,7 @@ export class MultiLayerSingleLevelTree extends Pane {
setValue(v) { setValue(v) {
// getValue依赖于storeValue, 那么不选的时候就不要更新storeValue了 // getValue依赖于storeValue, 那么不选的时候就不要更新storeValue了
if (this.options.chooseType === Selection.None) { if (this.options.chooseType !== Selection.None) {
} else {
this.storeValue = v; this.storeValue = v;
this.tree.setValue(v); this.tree.setValue(v);
} }

6
src/widget/multitree/check/multi.tree.check.pane.js

@ -6,7 +6,8 @@ import {
i18nText, i18nText,
nextTick, nextTick,
Events, Events,
VerticalAdaptLayout, VTapeLayout VerticalAdaptLayout,
VTapeLayout
} from "@/core"; } from "@/core";
import { Pane, TextButton, Label } from "@/base"; import { Pane, TextButton, Label } from "@/base";
import { DisplayTree, TreeView } from "@/case"; import { DisplayTree, TreeView } from "@/case";
@ -123,6 +124,5 @@ export class MultiTreeCheckPane extends Pane {
this.display.setSelectedValue(v.value); this.display.setSelectedValue(v.value);
} }
getValue() { getValue() {}
}
} }

59
src/widget/multitree/multi.tree.combo.js

@ -1,3 +1,5 @@
import { MultiTreeCheckSelectedButton } from "./trigger/multi.tree.button.checkselected";
import { MultiTreeCheckPane } from "./check/multi.tree.check.pane";
import { import {
shortcut, shortcut,
extend, extend,
@ -59,7 +61,7 @@ export class MultiTreeCombo extends Single {
this.storeValue = { value: o.value || {} }; this.storeValue = { value: o.value || {} };
this.trigger = createWidget({ this.trigger = createWidget({
type: "bi.multi_select_trigger", type: MultiSelectTrigger.xtype,
allowEdit: o.allowEdit, allowEdit: o.allowEdit,
height: toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
@ -75,7 +77,7 @@ export class MultiTreeCombo extends Single {
}, },
}, },
searcher: { searcher: {
type: "bi.multi_tree_searcher", type: MultiTreeSearcher.xtype,
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
listeners: [ listeners: [
{ {
@ -97,7 +99,7 @@ export class MultiTreeCombo extends Single {
el: this.trigger, el: this.trigger,
adjustLength: 1, adjustLength: 1,
popup: { popup: {
type: "bi.multi_tree_popup_view", type: MultiTreePopup.xtype,
ref() { ref() {
self.popup = this; self.popup = this;
self.trigger.setAdapter(this); self.trigger.setAdapter(this);
@ -125,10 +127,7 @@ export class MultiTreeCombo extends Single {
self.trigger.getSearcher().setState(val); self.trigger.getSearcher().setState(val);
self.numberCounter.setButtonChecked(val); self.numberCounter.setButtonChecked(val);
self.storeValue = { value: self.combo.getValue() }; self.storeValue = { value: self.combo.getValue() };
self.fireEvent( self.fireEvent(MultiTreeCombo.EVENT_CLICK_ITEM, self.combo.getValue());
MultiTreeCombo.EVENT_CLICK_ITEM,
self.combo.getValue()
);
self._dataChange = true; self._dataChange = true;
}, },
}, },
@ -231,14 +230,9 @@ export class MultiTreeCombo extends Single {
type: BI.Selection.Multi, type: BI.Selection.Multi,
value: checked ? { 1: 1 } : {}, value: checked ? { 1: 1 } : {},
}; };
this.getSearcher().setState( this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
checked ? BI.Selection.Multi : BI.Selection.None
);
self.numberCounter.setButtonChecked(val); self.numberCounter.setButtonChecked(val);
self.fireEvent( self.fireEvent(MultiTreeCombo.EVENT_CLICK_ITEM, self.combo.getValue());
MultiTreeCombo.EVENT_CLICK_ITEM,
self.combo.getValue()
);
self._dataChange = true; self._dataChange = true;
}); });
@ -261,8 +255,7 @@ export class MultiTreeCombo extends Single {
this.combo.on(Combo.EVENT_BEFORE_HIDEVIEW, () => { this.combo.on(Combo.EVENT_BEFORE_HIDEVIEW, () => {
if (isSearching()) { if (isSearching()) {
self._stopEditing(); self._stopEditing();
self._dataChange && self._dataChange && self.fireEvent(MultiTreeCombo.EVENT_CONFIRM);
self.fireEvent(MultiTreeCombo.EVENT_CONFIRM);
} else { } else {
if (isPopupView()) { if (isPopupView()) {
self._stopEditing(); self._stopEditing();
@ -270,8 +263,7 @@ export class MultiTreeCombo extends Single {
if (clear === true) { if (clear === true) {
self.storeValue = { value: {} }; self.storeValue = { value: {} };
} }
self._dataChange && self._dataChange && self.fireEvent(MultiTreeCombo.EVENT_CONFIRM);
self.fireEvent(MultiTreeCombo.EVENT_CONFIRM);
} }
} }
clear = false; clear = false;
@ -291,12 +283,12 @@ export class MultiTreeCombo extends Single {
}); });
this.numberCounter = createWidget({ this.numberCounter = createWidget({
type: "bi.multi_select_check_selected_switcher", type: MultiSelectCheckSelectedSwitcher.xtype,
el: { el: {
type: "bi.multi_tree_check_selected_button", type: MultiTreeCheckSelectedButton.xtype,
}, },
popup: { popup: {
type: "bi.multi_tree_check_pane", type: MultiTreeCheckPane.xtype,
}, },
masker: { masker: {
offset: { offset: {
@ -310,17 +302,12 @@ export class MultiTreeCombo extends Single {
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
value: { value: o.value || {} }, value: { value: o.value || {} },
}); });
this.numberCounter.on( this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
() => {
if (!self.combo.isViewVisible()) { if (!self.combo.isViewVisible()) {
self.combo.showView(); self.combo.showView();
} }
} });
); this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, () => {
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
() => {
if (want2showCounter === false) { if (want2showCounter === false) {
want2showCounter = true; want2showCounter = true;
} }
@ -328,27 +315,21 @@ export class MultiTreeCombo extends Single {
want2showCounter = null; want2showCounter = null;
showCounter(); showCounter();
} }
} });
);
this.numberCounter.on(Events.VIEW, b => { this.numberCounter.on(Events.VIEW, b => {
nextTick(() => { nextTick(() => {
// 自动调整宽度 // 自动调整宽度
self.trigger.refreshPlaceHolderWidth( self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
b === true ? self.numberCounter.element.outerWidth() + 8 : 0
);
}); });
}); });
this.numberCounter.on( this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
() => {
nextTick(() => { nextTick(() => {
// 收起时自动调整宽度 // 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0); self.trigger.refreshPlaceHolderWidth(0);
}); });
} });
);
this.trigger.element.click(e => { this.trigger.element.click(e => {
if (self.trigger.element.find(e.target).length > 0) { if (self.trigger.element.find(e.target).length > 0) {

87
src/widget/multitree/multi.tree.insert.combo.js

@ -1,3 +1,8 @@
import { MultiTreeSearcher } from "./trigger/searcher.multi.tree";
import { MultiTreeSearchInsertPane } from "./trigger/multi.tree.search.insert.pane";
import { MultiTreePopup } from "./multi.tree.popup";
import { MultiTreeCheckSelectedButton } from "./trigger/multi.tree.button.checkselected";
import { MultiTreeCheckPane } from "./check/multi.tree.check.pane";
import { import {
shortcut, shortcut,
extend, extend,
@ -11,8 +16,6 @@ import {
deepClone deepClone
} from "@/core"; } from "@/core";
import { Single, Combo } from "@/base"; import { Single, Combo } from "@/base";
import { MultiTreeSearchInsertPane } from "./trigger/multi.tree.search.insert.pane";
import { MultiTreePopup } from "./multi.tree.popup";
import { MultiSelectTrigger } from "../multiselect/multiselect.trigger"; import { MultiSelectTrigger } from "../multiselect/multiselect.trigger";
import { TriggerIconButton } from "@/case"; import { TriggerIconButton } from "@/case";
import { MultiSelectCheckSelectedSwitcher } from "../multiselect/trigger/switcher.checkselected"; import { MultiSelectCheckSelectedSwitcher } from "../multiselect/trigger/switcher.checkselected";
@ -50,7 +53,7 @@ export class MultiTreeInsertCombo extends Single {
this.storeValue = { value: o.value || {} }; this.storeValue = { value: o.value || {} };
this.trigger = createWidget({ this.trigger = createWidget({
type: "bi.multi_select_trigger", type: MultiSelectTrigger.xtype,
allowEdit: o.allowEdit, allowEdit: o.allowEdit,
height: toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
@ -66,18 +69,16 @@ export class MultiTreeInsertCombo extends Single {
}, },
}, },
searcher: { searcher: {
type: "bi.multi_tree_searcher", type: MultiTreeSearcher.xtype,
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
popup: { popup: {
type: "bi.multi_tree_search_insert_pane", type: MultiTreeSearchInsertPane.xtype,
listeners: [ listeners: [
{ {
eventName: MultiTreeSearchInsertPane.EVENT_ADD_ITEM, eventName: MultiTreeSearchInsertPane.EVENT_ADD_ITEM,
action() { action() {
self.storeValue.value[ self.storeValue.value[self.trigger.getSearcher().getKeyword()] = {};
self.trigger.getSearcher().getKeyword()
] = {};
self._assertShowValue(); self._assertShowValue();
// setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了 // setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了
self.combo.setValue(self.storeValue); self.combo.setValue(self.storeValue);
@ -87,8 +88,7 @@ export class MultiTreeInsertCombo extends Single {
}, },
}, },
{ {
eventName: eventName: MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE,
MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE,
action() { action() {
self._dataChange = true; self._dataChange = true;
}, },
@ -107,7 +107,7 @@ export class MultiTreeInsertCombo extends Single {
el: this.trigger, el: this.trigger,
adjustLength: 1, adjustLength: 1,
popup: { popup: {
type: "bi.multi_tree_popup_view", type: MultiTreePopup.xtype,
ref() { ref() {
self.popup = this; self.popup = this;
self.trigger.setAdapter(this); self.trigger.setAdapter(this);
@ -135,10 +135,7 @@ export class MultiTreeInsertCombo extends Single {
self.trigger.getSearcher().setState(val); self.trigger.getSearcher().setState(val);
self.numberCounter.setButtonChecked(val); self.numberCounter.setButtonChecked(val);
self.storeValue = { value: self.combo.getValue() }; self.storeValue = { value: self.combo.getValue() };
self.fireEvent( self.fireEvent(MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.getValue());
MultiTreeInsertCombo.EVENT_CLICK_ITEM,
self.getValue()
);
self._dataChange = true; self._dataChange = true;
}, },
}, },
@ -177,16 +174,12 @@ export class MultiTreeInsertCombo extends Single {
}, },
}); });
var change = false; let change = false;
var clear = false; // 标识当前是否点击了清空 let clear = false; // 标识当前是否点击了清空
const isSearching = function () { const isSearching = () => self.trigger.getSearcher().isSearching();
return self.trigger.getSearcher().isSearching();
};
const isPopupView = function () { const isPopupView = () => self.combo.isViewVisible();
return self.combo.isViewVisible();
};
this.trigger.on(MultiSelectTrigger.EVENT_FOCUS, () => { this.trigger.on(MultiSelectTrigger.EVENT_FOCUS, () => {
self.fireEvent(MultiTreeInsertCombo.EVENT_FOCUS); self.fireEvent(MultiTreeInsertCombo.EVENT_FOCUS);
@ -236,14 +229,9 @@ export class MultiTreeInsertCombo extends Single {
type: BI.Selection.Multi, type: BI.Selection.Multi,
value: checked ? { 1: 1 } : {}, value: checked ? { 1: 1 } : {},
}; };
this.getSearcher().setState( this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
checked ? BI.Selection.Multi : BI.Selection.None
);
self.numberCounter.setButtonChecked(val); self.numberCounter.setButtonChecked(val);
self.fireEvent( self.fireEvent(MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
MultiTreeInsertCombo.EVENT_CLICK_ITEM,
self.combo.getValue()
);
self._dataChange = true; self._dataChange = true;
}); });
@ -266,8 +254,7 @@ export class MultiTreeInsertCombo extends Single {
this.combo.on(Combo.EVENT_BEFORE_HIDEVIEW, () => { this.combo.on(Combo.EVENT_BEFORE_HIDEVIEW, () => {
if (isSearching()) { if (isSearching()) {
self._stopEditing(); self._stopEditing();
self._dataChange && self._dataChange && self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
} else { } else {
if (isPopupView()) { if (isPopupView()) {
self._stopEditing(); self._stopEditing();
@ -275,15 +262,14 @@ export class MultiTreeInsertCombo extends Single {
if (clear === true) { if (clear === true) {
self.storeValue = { value: {} }; self.storeValue = { value: {} };
} }
self._dataChange && self._dataChange && self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
} }
} }
clear = false; clear = false;
change = false; change = false;
}); });
var triggerBtn = createWidget({ const triggerBtn = createWidget({
type: TriggerIconButton.xtype, type: TriggerIconButton.xtype,
width: o.height, width: o.height,
height: o.height, height: o.height,
@ -299,12 +285,12 @@ export class MultiTreeInsertCombo extends Single {
}); });
this.numberCounter = createWidget({ this.numberCounter = createWidget({
type: "bi.multi_select_check_selected_switcher", type: MultiSelectCheckSelectedSwitcher.xtype,
el: { el: {
type: "bi.multi_tree_check_selected_button", type: MultiTreeCheckSelectedButton.xtype,
}, },
popup: { popup: {
type: "bi.multi_tree_check_pane", type: MultiTreeCheckPane.xtype,
}, },
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
masker: { masker: {
@ -318,17 +304,12 @@ export class MultiTreeInsertCombo extends Single {
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
value: o.value, value: o.value,
}); });
this.numberCounter.on( this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
() => {
if (!self.combo.isViewVisible()) { if (!self.combo.isViewVisible()) {
self.combo.showView(); self.combo.showView();
} }
} });
); this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, () => {
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
() => {
if (want2showCounter === false) { if (want2showCounter === false) {
want2showCounter = true; want2showCounter = true;
} }
@ -336,25 +317,19 @@ export class MultiTreeInsertCombo extends Single {
want2showCounter = null; want2showCounter = null;
showCounter(); showCounter();
} }
} });
);
this.numberCounter.on( this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
() => {
nextTick(() => { nextTick(() => {
// 收起时自动调整宽度 // 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0); self.trigger.refreshPlaceHolderWidth(0);
}); });
} });
);
this.numberCounter.on(Events.VIEW, b => { this.numberCounter.on(Events.VIEW, b => {
nextTick(() => { nextTick(() => {
// 自动调整宽度 // 自动调整宽度
self.trigger.refreshPlaceHolderWidth( self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
b === true ? self.numberCounter.element.outerWidth() + 8 : 0
);
}); });
}); });

91
src/widget/multitree/multi.tree.list.combo.js

@ -1,3 +1,6 @@
import { MultiListTreeSearcher } from "./trigger/searcher.list.multi.tree";
import { MultiTreeCheckSelectedButton } from "./trigger/multi.tree.button.checkselected";
import { MultiTreeCheckPane } from "./check/multi.tree.check.pane";
import { import {
shortcut, shortcut,
extend, extend,
@ -14,12 +17,7 @@ import { Single, Combo } from "@/base";
import { MultiTreeSearchInsertPane } from "./trigger/multi.tree.search.insert.pane"; import { MultiTreeSearchInsertPane } from "./trigger/multi.tree.search.insert.pane";
import { MultiTreePopup } from "./multi.tree.popup"; import { MultiTreePopup } from "./multi.tree.popup";
import { MultiSelectTrigger } from "../multiselect/multiselect.trigger"; import { MultiSelectTrigger } from "../multiselect/multiselect.trigger";
import { import { TriggerIconButton, ListPartTree, ListDisplayTree, Listasynctree } from "@/case";
TriggerIconButton,
ListPartTree,
ListDisplayTree,
Listasynctree
} from "@/case";
import { MultiSelectCheckSelectedSwitcher } from "../multiselect/trigger/switcher.checkselected"; import { MultiSelectCheckSelectedSwitcher } from "../multiselect/trigger/switcher.checkselected";
@shortcut() @shortcut()
@ -57,7 +55,7 @@ export class MultiTreeListCombo extends Single {
this.storeValue = { value: o.value || [] }; this.storeValue = { value: o.value || [] };
this.trigger = createWidget({ this.trigger = createWidget({
type: "bi.multi_select_trigger", type: MultiSelectTrigger.xtype,
allowEdit: o.allowEdit, allowEdit: o.allowEdit,
text: o.text, text: o.text,
defaultText: o.defaultText, defaultText: o.defaultText,
@ -73,12 +71,10 @@ export class MultiTreeListCombo extends Single {
}, },
}, },
searcher: { searcher: {
type: "bi.multi_list_tree_searcher", type: MultiListTreeSearcher.xtype,
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
popup: { popup: {
type: o.allowInsertValue type: o.allowInsertValue ? "bi.multi_tree_search_insert_pane" : "bi.multi_tree_search_pane",
? "bi.multi_tree_search_insert_pane"
: "bi.multi_tree_search_pane",
el: { el: {
type: ListPartTree.xtype, type: ListPartTree.xtype,
}, },
@ -86,9 +82,7 @@ export class MultiTreeListCombo extends Single {
{ {
eventName: MultiTreeSearchInsertPane.EVENT_ADD_ITEM, eventName: MultiTreeSearchInsertPane.EVENT_ADD_ITEM,
action() { action() {
self.storeValue.value.unshift([ self.storeValue.value.unshift([self.trigger.getSearcher().getKeyword()]);
self.trigger.getSearcher().getKeyword()
]);
self._assertShowValue(); self._assertShowValue();
// setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了 // setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了
self.combo.setValue(self.storeValue); self.combo.setValue(self.storeValue);
@ -102,10 +96,10 @@ export class MultiTreeListCombo extends Single {
}, },
switcher: { switcher: {
el: { el: {
type: "bi.multi_tree_check_selected_button", type: MultiTreeCheckSelectedButton.xtype,
}, },
popup: { popup: {
type: "bi.multi_tree_check_pane", type: MultiTreeCheckPane.xtype,
el: { el: {
type: ListDisplayTree.xtype, type: ListDisplayTree.xtype,
}, },
@ -154,10 +148,7 @@ export class MultiTreeListCombo extends Single {
self.trigger.getSearcher().setState(val); self.trigger.getSearcher().setState(val);
self.numberCounter.setButtonChecked(val); self.numberCounter.setButtonChecked(val);
self.storeValue = { value: self.combo.getValue() }; self.storeValue = { value: self.combo.getValue() };
self.fireEvent( self.fireEvent(MultiTreeListCombo.EVENT_CLICK_ITEM, self.getValue());
MultiTreeListCombo.EVENT_CLICK_ITEM,
self.getValue()
);
self._dataChange = true; self._dataChange = true;
}, },
}, },
@ -196,16 +187,12 @@ export class MultiTreeListCombo extends Single {
}, },
}); });
var change = false; let change = false;
var clear = false; // 标识当前是否点击了清空 let clear = false; // 标识当前是否点击了清空
const isSearching = function () { const isSearching = () => self.trigger.getSearcher().isSearching();
return self.trigger.getSearcher().isSearching();
};
const isPopupView = function () { const isPopupView = () => self.combo.isViewVisible();
return self.combo.isViewVisible();
};
this.trigger.on(MultiSelectTrigger.EVENT_FOCUS, () => { this.trigger.on(MultiSelectTrigger.EVENT_FOCUS, () => {
self.fireEvent(MultiTreeListCombo.EVENT_FOCUS); self.fireEvent(MultiTreeListCombo.EVENT_FOCUS);
@ -255,14 +242,9 @@ export class MultiTreeListCombo extends Single {
type: BI.Selection.Multi, type: BI.Selection.Multi,
value: checked ? { 1: 1 } : {}, value: checked ? { 1: 1 } : {},
}; };
this.getSearcher().setState( this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
checked ? BI.Selection.Multi : BI.Selection.None
);
self.numberCounter.setButtonChecked(val); self.numberCounter.setButtonChecked(val);
self.fireEvent( self.fireEvent(MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
MultiTreeListCombo.EVENT_CLICK_ITEM,
self.combo.getValue()
);
self._dataChange = true; self._dataChange = true;
}); });
@ -285,8 +267,7 @@ export class MultiTreeListCombo extends Single {
this.combo.on(Combo.EVENT_BEFORE_HIDEVIEW, () => { this.combo.on(Combo.EVENT_BEFORE_HIDEVIEW, () => {
if (isSearching()) { if (isSearching()) {
self.trigger.stopEditing(); self.trigger.stopEditing();
self._dataChange && self._dataChange && self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
} else { } else {
if (isPopupView()) { if (isPopupView()) {
self._stopEditing(); self._stopEditing();
@ -294,15 +275,14 @@ export class MultiTreeListCombo extends Single {
if (clear === true) { if (clear === true) {
self.storeValue = { value: [] }; self.storeValue = { value: [] };
} }
self._dataChange && self._dataChange && self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
} }
} }
clear = false; clear = false;
change = false; change = false;
}); });
var triggerBtn = createWidget({ const triggerBtn = createWidget({
type: TriggerIconButton.xtype, type: TriggerIconButton.xtype,
width: o.height, width: o.height,
height: o.height, height: o.height,
@ -318,12 +298,12 @@ export class MultiTreeListCombo extends Single {
}); });
this.numberCounter = createWidget({ this.numberCounter = createWidget({
type: "bi.multi_select_check_selected_switcher", type: MultiSelectCheckSelectedSwitcher.xtype,
el: { el: {
type: "bi.multi_tree_check_selected_button", type: MultiTreeCheckSelectedButton.xtype,
}, },
popup: { popup: {
type: "bi.multi_tree_check_pane", type: MultiTreeCheckPane.xtype,
}, },
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
masker: { masker: {
@ -337,17 +317,12 @@ export class MultiTreeListCombo extends Single {
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
value: o.value, value: o.value,
}); });
this.numberCounter.on( this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
() => {
if (!self.combo.isViewVisible()) { if (!self.combo.isViewVisible()) {
self.combo.showView(); self.combo.showView();
} }
} });
); this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, () => {
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
() => {
if (want2showCounter === false) { if (want2showCounter === false) {
want2showCounter = true; want2showCounter = true;
} }
@ -355,27 +330,21 @@ export class MultiTreeListCombo extends Single {
want2showCounter = null; want2showCounter = null;
showCounter(); showCounter();
} }
} });
);
this.numberCounter.on(Events.VIEW, b => { this.numberCounter.on(Events.VIEW, b => {
nextTick(() => { nextTick(() => {
// 自动调整宽度 // 自动调整宽度
self.trigger.refreshPlaceHolderWidth( self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
b === true ? self.numberCounter.element.outerWidth() + 8 : 0
);
}); });
}); });
this.numberCounter.on( this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
() => {
nextTick(() => { nextTick(() => {
// 收起时自动调整宽度 // 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0); self.trigger.refreshPlaceHolderWidth(0);
}); });
} });
);
this.trigger.element.click(e => { this.trigger.element.click(e => {
if (self.trigger.element.find(e.target).length > 0) { if (self.trigger.element.find(e.target).length > 0) {

10
src/widget/multitree/multi.tree.popup.js

@ -54,9 +54,7 @@ export class MultiTreePopup extends Pane {
el: this.tree, el: this.tree,
}); });
this.popupView.on( this.popupView.on(MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, index => {
MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON,
index => {
switch (index) { switch (index) {
case 0: case 0:
self.fireEvent(MultiTreePopup.EVENT_CLICK_CLEAR); self.fireEvent(MultiTreePopup.EVENT_CLICK_CLEAR);
@ -64,9 +62,11 @@ export class MultiTreePopup extends Pane {
case 1: case 1:
self.fireEvent(MultiTreePopup.EVENT_CLICK_CONFIRM); self.fireEvent(MultiTreePopup.EVENT_CLICK_CONFIRM);
break; break;
default:
break;
} }
} });
);
this.tree.on(TreeView.EVENT_CHANGE, () => { this.tree.on(TreeView.EVENT_CHANGE, () => {
self.fireEvent(MultiTreePopup.EVENT_CHANGE); self.fireEvent(MultiTreePopup.EVENT_CHANGE);

17
src/widget/multitree/trigger/multi.tree.button.checkselected.js

@ -1,12 +1,4 @@
import { import { HorizontalLayout, shortcut, extend, emptyFn, createWidget, i18nText, Controller, size } from "@/core";
shortcut,
extend,
emptyFn,
createWidget,
i18nText,
Controller,
size
} from "@/core";
import { Single, TextButton, IconButton } from "@/base"; import { Single, TextButton, IconButton } from "@/base";
import { MultiSelectCheckSelectedButton } from "../../multiselect/trigger/button.checkselected"; import { MultiSelectCheckSelectedButton } from "../../multiselect/trigger/button.checkselected";
@ -47,14 +39,11 @@ export class MultiTreeCheckSelectedButton extends Single {
}); });
this.checkSelected.on(TextButton.EVENT_CHANGE, function () { this.checkSelected.on(TextButton.EVENT_CHANGE, function () {
self.fireEvent( self.fireEvent(MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
MultiSelectCheckSelectedButton.EVENT_CHANGE,
arguments
);
}); });
createWidget({ createWidget({
type: "bi.horizontal", type: HorizontalLayout.xtype,
element: this, element: this,
items: [this.indicator, this.checkSelected], items: [this.indicator, this.checkSelected],
}); });

38
src/widget/multitree/trigger/multi.tree.search.insert.pane.js

@ -1,12 +1,4 @@
import { import { shortcut, Widget, i18nText, extend, Controller, AbsoluteLayout, isEmptyArray } from "@/core";
shortcut,
Widget,
i18nText,
extend,
Controller,
AbsoluteLayout,
isEmptyArray
} from "@/core";
import { TreeView, PartTree } from "@/case"; import { TreeView, PartTree } from "@/case";
import { TextButton } from "@/base"; import { TextButton } from "@/base";
@ -43,10 +35,7 @@ export class MultiTreeSearchInsertPane extends Widget {
height: this.constants.height, height: this.constants.height,
cls: "bi-high-light", cls: "bi-high-light",
handler() { handler() {
self.fireEvent( self.fireEvent(MultiTreeSearchInsertPane.EVENT_ADD_ITEM, opts.keywordGetter());
MultiTreeSearchInsertPane.EVENT_ADD_ITEM,
opts.keywordGetter()
);
}, },
}, },
top: 5, top: 5,
@ -62,10 +51,7 @@ export class MultiTreeSearchInsertPane extends Widget {
op.keyword = opts.keywordGetter(); op.keyword = opts.keywordGetter();
opts.itemsCreator(op, res => { opts.itemsCreator(op, res => {
callback(res); callback(res);
self.setKeyword( self.setKeyword(opts.keywordGetter(), res.items);
opts.keywordGetter(),
res.items
);
}); });
}, },
ref(_ref) { ref(_ref) {
@ -76,26 +62,19 @@ export class MultiTreeSearchInsertPane extends Widget {
{ {
eventName: Controller.EVENT_CHANGE, eventName: Controller.EVENT_CHANGE,
action() { action() {
self.fireEvent( self.fireEvent(Controller.EVENT_CHANGE, arguments);
Controller.EVENT_CHANGE,
arguments
);
}, },
}, },
{ {
eventName: TreeView.EVENT_CHANGE, eventName: TreeView.EVENT_CHANGE,
action() { action() {
self.fireEvent( self.fireEvent(MultiTreeSearchInsertPane.EVENT_CHANGE);
MultiTreeSearchInsertPane.EVENT_CHANGE
);
}, },
}, },
{ {
eventName: PartTree.EVENT_CLICK_TREE_NODE, eventName: PartTree.EVENT_CLICK_TREE_NODE,
action() { action() {
self.fireEvent( self.fireEvent(MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE);
MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE
);
}, },
} }
], ],
@ -115,10 +94,7 @@ export class MultiTreeSearchInsertPane extends Widget {
const isAddTipVisible = isEmptyArray(nodes); const isAddTipVisible = isEmptyArray(nodes);
this.addTip.setVisible(isAddTipVisible); this.addTip.setVisible(isAddTipVisible);
this.partTree.setVisible(!isAddTipVisible); this.partTree.setVisible(!isAddTipVisible);
isAddTipVisible && isAddTipVisible && this.addTip.setText(i18nText("BI-Basic_Click_To_Add_Text", keyword));
this.addTip.setText(
i18nText("BI-Basic_Click_To_Add_Text", keyword)
);
} }
hasChecked() { hasChecked() {

4
src/widget/multitree/trigger/multi.tree.search.pane.js

@ -43,9 +43,7 @@ export class MultiTreeSearchPane extends Pane {
{ {
eventName: PartTree.EVENT_CLICK_TREE_NODE, eventName: PartTree.EVENT_CLICK_TREE_NODE,
action() { action() {
self.fireEvent( self.fireEvent(MultiTreeSearchPane.EVENT_CLICK_TREE_NODE);
MultiTreeSearchPane.EVENT_CLICK_TREE_NODE
);
}, },
} }
], ],

19
src/widget/multitree/trigger/searcher.list.multi.tree.js

@ -1,15 +1,4 @@
import { import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, isNumber, size, each, last } from "@/core";
shortcut,
Widget,
extend,
emptyFn,
createWidget,
isNotNull,
isNumber,
size,
each,
last
} from "@/core";
import { MultiSelectEditor } from "../../multiselect/trigger/editor.multiselect"; import { MultiSelectEditor } from "../../multiselect/trigger/editor.multiselect";
import { MultiSelectSearcher } from "../../multiselect/trigger/searcher.multiselect"; import { MultiSelectSearcher } from "../../multiselect/trigger/searcher.multiselect";
import { Searcher } from "@/base"; import { Searcher } from "@/base";
@ -158,11 +147,7 @@ export class MultiListTreeSearcher extends Widget {
let text = ""; let text = "";
each(ob.value, (idx, path) => { each(ob.value, (idx, path) => {
const childValue = last(path); const childValue = last(path);
text += text += path === "null" ? "" : `${o.valueFormatter(`${childValue}`) || childValue}; `;
path === "null"
? ""
: `${o.valueFormatter(`${childValue}`) || childValue
}; `;
count++; count++;
}); });

29
src/widget/multitree/trigger/searcher.multi.tree.js

@ -9,7 +9,8 @@ import {
size, size,
keys, keys,
each, each,
isEmptyObject, Func isEmptyObject,
Func
} from "@/core"; } from "@/core";
import { MultiSelectEditor } from "../../multiselect/trigger/editor.multiselect"; import { MultiSelectEditor } from "../../multiselect/trigger/editor.multiselect";
import { MultiSelectSearcher } from "../../multiselect/trigger/searcher.multiselect"; import { MultiSelectSearcher } from "../../multiselect/trigger/searcher.multiselect";
@ -48,7 +49,7 @@ export class MultiTreeSearcher extends Widget {
const self = this, const self = this,
o = this.options; o = this.options;
this.editor = createWidget({ this.editor = createWidget({
type: "bi.multi_select_editor", type: MultiSelectEditor.xtype,
watermark: o.watermark, watermark: o.watermark,
height: o.height, height: o.height,
el: { el: {
@ -97,13 +98,9 @@ export class MultiTreeSearcher extends Widget {
}, },
listeners: [ listeners: [
{ {
eventName: eventName: MultiTreeSearchPane.EVENT_CLICK_TREE_NODE,
MultiTreeSearchPane.EVENT_CLICK_TREE_NODE,
action() { action() {
self.fireEvent( self.fireEvent(MultiTreeSearcher.EVENT_CLICK_TREE_NODE, arguments);
MultiTreeSearcher.EVENT_CLICK_TREE_NODE,
arguments
);
}, },
} }
], ],
@ -179,15 +176,9 @@ export class MultiTreeSearcher extends Widget {
const names = BI.Func.getSortedResult(keys(value)); const names = BI.Func.getSortedResult(keys(value));
each(names, (idx, name) => { each(names, (idx, name) => {
const childNodes = getChildrenNode(value[name]); const childNodes = getChildrenNode(value[name]);
text += text += `${
`${(name === "null" (name === "null" ? "" : o.valueFormatter(`${name}`) || name) +
? "" (childNodes === "" ? (isEmptyObject(value[name]) ? "" : ":") : `:${childNodes}`)
: o.valueFormatter(`${name}`) || name) +
(childNodes === ""
? isEmptyObject(value[name])
? ""
: ":"
: `:${childNodes}`)
}; `; }; `;
if (childNodes === "") { if (childNodes === "") {
count++; count++;
@ -211,9 +202,7 @@ export class MultiTreeSearcher extends Widget {
index++; index++;
const childNodes = getChildrenNode(ob[name]); const childNodes = getChildrenNode(ob[name]);
text += text +=
(name === "null" (name === "null" ? "" : o.valueFormatter(`${name}`) || name) +
? ""
: o.valueFormatter(`${name}`) || name) +
(childNodes === "" ? "" : `:${childNodes}`) + (childNodes === "" ? "" : `:${childNodes}`) +
(index === _size ? "" : ","); (index === _size ? "" : ",");
if (childNodes === "") { if (childNodes === "") {

56
src/widget/numbereditor/number.editor.js

@ -1,18 +1,36 @@
import { shortcut, Widget, extend, emptyFn, createWidget, toPix, parseFloat, HTapeLayout, GridLayout, isNumeric, clamp, MIN, MAX, KeyCode, add } from "@/core"; import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
toPix,
parseFloat,
HTapeLayout,
GridLayout,
isNumeric,
clamp,
MIN,
MAX,
KeyCode,
add
} from "@/core";
import { SignEditor } from "@/case"; import { SignEditor } from "@/case";
import { TextEditor } from "../editor"; import { TextEditor } from "../editor";
import { IconButton } from "@/base"; import { IconButton } from "@/base";
@shortcut() @shortcut()
export class NumberEditor extends Widget { export class NumberEditor extends Widget {
static xtype = "bi.number_editor" static xtype = "bi.number_editor";
static EVENT_CONFIRM = "EVENT_CONFIRM" static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig(conf) { _defaultConfig(conf) {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
baseCls: `bi-number-editor bi-focus-shadow ${conf.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`, baseCls: `bi-number-editor bi-focus-shadow ${
conf.simple ? "bi-border-bottom" : "bi-border bi-border-radius"
}`,
validationChecker: emptyFn, validationChecker: emptyFn,
valueFormatter(v) { valueFormatter(v) {
return v; return v;
@ -50,7 +68,8 @@ export class NumberEditor extends Widget {
return o.validationChecker(parsedValue); return o.validationChecker(parsedValue);
}, },
errorText: o.errorText, errorText: o.errorText,
listeners: [{ listeners: [
{
eventName: SignEditor.EVENT_QUICK_DOWN, eventName: SignEditor.EVENT_QUICK_DOWN,
action: e => { action: e => {
if ([KeyCode.UP, KeyCode.DOWN].includes(e.keyCode)) { if ([KeyCode.UP, KeyCode.DOWN].includes(e.keyCode)) {
@ -98,7 +117,9 @@ export class NumberEditor extends Widget {
forceNotSelected: true, forceNotSelected: true,
trigger: "lclick,", trigger: "lclick,",
debounce: false, debounce: false,
cls: `${o.simple ? "solid-triangle-top-font " : "add-up-font bi-border-left "}top-button bi-list-item-active2 icon-size-12`, cls: `${
o.simple ? "solid-triangle-top-font " : "add-up-font bi-border-left "
}top-button bi-list-item-active2 icon-size-12`,
}); });
this.topBtn.on(IconButton.EVENT_CHANGE, () => { this.topBtn.on(IconButton.EVENT_CHANGE, () => {
this._finetuning(o.step); this._finetuning(o.step);
@ -110,7 +131,9 @@ export class NumberEditor extends Widget {
trigger: "lclick,", trigger: "lclick,",
forceNotSelected: true, forceNotSelected: true,
debounce: false, debounce: false,
cls: `${o.simple ? "solid-triangle-bottom-font " : "minus-down-font bi-border-left "}bottom-button bi-list-item-active2 icon-size-12`, cls: `${
o.simple ? "solid-triangle-bottom-font " : "minus-down-font bi-border-left "
}bottom-button bi-list-item-active2 icon-size-12`,
}); });
this.bottomBtn.on(IconButton.EVENT_CHANGE, () => { this.bottomBtn.on(IconButton.EVENT_CHANGE, () => {
this._finetuning(-o.step); this._finetuning(-o.step);
@ -122,20 +145,24 @@ export class NumberEditor extends Widget {
height: toPix(o.height, 2), height: toPix(o.height, 2),
element: this, element: this,
items: [ items: [
this.editor, { this.editor,
{
el: { el: {
type: GridLayout.xtype, type: GridLayout.xtype,
columns: 1, columns: 1,
rows: 2, rows: 2,
items: [{ items: [
{
column: 0, column: 0,
row: 0, row: 0,
el: this.topBtn, el: this.topBtn,
}, { },
{
column: 0, column: 0,
row: 1, row: 1,
el: this.bottomBtn, el: this.bottomBtn,
}], }
],
}, },
width: 23, width: 23,
} }
@ -165,10 +192,7 @@ export class NumberEditor extends Widget {
} }
_finetuning(addValue) { _finetuning(addValue) {
const { const { max, min } = this.options;
max,
min,
} = this.options;
let v = parseFloat(this.getValue()); let v = parseFloat(this.getValue());
v = add(v, addValue); v = add(v, addValue);
v = clamp(v, min, max); v = clamp(v, min, max);

116
src/widget/numberinterval/numberinterval.js

@ -1,11 +1,26 @@
import { shortcut, extend, i18nText, createWidget, toPix, isNumeric, AbsoluteLayout, isEmptyString, isNotNull, isNull, isIE, getIEVersion } from "@/core"; import { NumberIntervalSingleEidtor } from "./singleeditor/single.editor";
import {
HorizontalFillLayout,
shortcut,
extend,
i18nText,
createWidget,
toPix,
isNumeric,
AbsoluteLayout,
isEmptyString,
isNotNull,
isNull,
isIE,
getIEVersion,
} from "@/core";
import { Single, Label, Bubbles } from "@/base"; import { Single, Label, Bubbles } from "@/base";
import { IconCombo } from "@/case"; import { IconCombo } from "@/case";
import { NumberIntervalSingleEidtor } from "./singleeditor/single.editor"; import { NumberIntervalSingleEidtor } from "./singleeditor/single.editor";
@shortcut() @shortcut()
export class NumberInterval extends Single { export class NumberInterval extends Single {
static xtype = "bi.number_interval" static xtype = "bi.number_interval";
constants = { constants = {
typeError: "typeBubble", typeError: "typeBubble",
@ -23,16 +38,16 @@ export class NumberInterval extends Single {
adjustYOffset: 2, adjustYOffset: 2,
}; };
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_CONFIRM = "EVENT_CONFIRM" static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_VALID = "EVENT_VALID" static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR" static EVENT_ERROR = "EVENT_ERROR";
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
return extend(conf, { return extend(conf, {
extraCls: `bi-number-interval${(isIE() && getIEVersion() < 10) ? " hack" : ""}`, extraCls: `bi-number-interval${isIE() && getIEVersion() < 10 ? " hack" : ""}`,
height: 24, height: 24,
validation: "valid", validation: "valid",
closeMin: true, closeMin: true,
@ -47,7 +62,7 @@ export class NumberInterval extends Single {
o = this.options; o = this.options;
super._init(...arguments); super._init(...arguments);
this.smallEditor = createWidget({ this.smallEditor = createWidget({
type: "bi.number_interval_single_editor", type: NumberIntervalSingleEidtor.xtype,
height: toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
watermark: o.watermark, watermark: o.watermark,
allowBlank: o.allowBlank, allowBlank: o.allowBlank,
@ -69,7 +84,9 @@ export class NumberInterval extends Single {
return true; return true;
}, },
cls: `number-interval-small-editor bi-focus-shadow ${o.simple ? "bi-border-bottom" : "bi-border bi-border-corner-left-radius"}`, cls: `number-interval-small-editor bi-focus-shadow ${
o.simple ? "bi-border-bottom" : "bi-border bi-border-corner-left-radius"
}`,
}); });
this.smallTip = createWidget({ this.smallTip = createWidget({
@ -81,15 +98,17 @@ export class NumberInterval extends Single {
createWidget({ createWidget({
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
element: this.smallEditor, element: this.smallEditor,
items: [{ items: [
{
el: this.smallTip, el: this.smallTip,
top: 0, top: 0,
right: 5, right: 5,
}], },
],
}); });
this.bigEditor = createWidget({ this.bigEditor = createWidget({
type: "bi.number_interval_single_editor", type: NumberIntervalSingleEidtor.xtype,
height: toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
watermark: o.watermark, watermark: o.watermark,
allowBlank: o.allowBlank, allowBlank: o.allowBlank,
@ -109,7 +128,9 @@ export class NumberInterval extends Single {
return true; return true;
}, },
cls: `number-interval-big-editor bi-focus-shadow${o.simple ? " bi-border-bottom" : " bi-border bi-border-corner-right-radius"}`, cls: `number-interval-big-editor bi-focus-shadow${
o.simple ? " bi-border-bottom" : " bi-border bi-border-corner-right-radius"
}`,
}); });
this.bigTip = createWidget({ this.bigTip = createWidget({
@ -121,26 +142,33 @@ export class NumberInterval extends Single {
createWidget({ createWidget({
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
element: this.bigEditor, element: this.bigEditor,
items: [{ items: [
{
el: this.bigTip, el: this.bigTip,
top: 0, top: 0,
right: 5, right: 5,
}], },
],
}); });
this.smallCombo = createWidget({ this.smallCombo = createWidget({
type: IconCombo.xtype, type: IconCombo.xtype,
cls: `number-interval-small-combo${o.simple ? "" : " bi-border-top bi-border-bottom bi-border-right bi-border-corner-right-radius"}`, cls: `number-interval-small-combo${
o.simple ? "" : " bi-border-top bi-border-bottom bi-border-right bi-border-corner-right-radius"
}`,
height: toPix(o.height, o.simple ? 0 : 2), height: toPix(o.height, o.simple ? 0 : 2),
width: toPix(c.width, c.border), width: toPix(c.width, c.border),
items: [{ items: [
{
text: `(${i18nText("BI-Less_Than")})`, text: `(${i18nText("BI-Less_Than")})`,
iconCls: "less-font", iconCls: "less-font",
value: 0, value: 0,
}, { },
{
text: `(${i18nText("BI-Less_And_Equal")})`, text: `(${i18nText("BI-Less_And_Equal")})`,
value: 1, value: 1,
iconCls: "less-equal-font", iconCls: "less-equal-font",
}], },
],
}); });
if (o.closeMin === true) { if (o.closeMin === true) {
this.smallCombo.setValue(1); this.smallCombo.setValue(1);
@ -149,18 +177,23 @@ export class NumberInterval extends Single {
} }
this.bigCombo = createWidget({ this.bigCombo = createWidget({
type: IconCombo.xtype, type: IconCombo.xtype,
cls: `number-interval-big-combo${o.simple ? "" : " bi-border-top bi-border-bottom bi-border-left bi-border-corner-left-radius"}`, cls: `number-interval-big-combo${
o.simple ? "" : " bi-border-top bi-border-bottom bi-border-left bi-border-corner-left-radius"
}`,
height: toPix(o.height, o.simple ? 0 : 2), height: toPix(o.height, o.simple ? 0 : 2),
width: toPix(c.width, c.border), width: toPix(c.width, c.border),
items: [{ items: [
{
text: `(${i18nText("BI-Less_Than")})`, text: `(${i18nText("BI-Less_Than")})`,
iconCls: "less-font", iconCls: "less-font",
value: 0, value: 0,
}, { },
{
text: `(${i18nText("BI-Less_And_Equal")})`, text: `(${i18nText("BI-Less_And_Equal")})`,
value: 1, value: 1,
iconCls: "less-equal-font", iconCls: "less-equal-font",
}], },
],
}); });
if (o.closeMax === true) { if (o.closeMax === true) {
this.bigCombo.setValue(1); this.bigCombo.setValue(1);
@ -178,38 +211,47 @@ export class NumberInterval extends Single {
tipType: "warning", tipType: "warning",
}); });
this.left = createWidget({ this.left = createWidget({
type: "bi.horizontal_fill", type: HorizontalFillLayout.xtype,
columnSize: ["fill", ""], columnSize: ["fill", ""],
items: [{ items: [
{
el: self.smallEditor, el: self.smallEditor,
}, { },
{
el: self.smallCombo, el: self.smallCombo,
}], },
],
}); });
this.right = createWidget({ this.right = createWidget({
type: "bi.horizontal_fill", type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"], columnSize: ["", "fill"],
items: [{ items: [
{
el: self.bigCombo, el: self.bigCombo,
}, { },
{
el: self.bigEditor, el: self.bigEditor,
// BI-23883 间距考虑边框 // BI-23883 间距考虑边框
// lgap: 1 // lgap: 1
}], },
],
}); });
createWidget({ createWidget({
element: self, element: self,
type: "bi.horizontal_fill", type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"], columnSize: ["fill", "", "fill"],
items: [{ items: [
{
el: self.left, el: self.left,
}, { },
{
el: self.label, el: self.label,
}, { },
{
el: self.right, el: self.right,
}], },
],
}); });
// createWidget({ // createWidget({

46
src/widget/numberinterval/singleeditor/single.editor.js

@ -3,15 +3,15 @@ import { Single, Editor } from "@/base";
@shortcut() @shortcut()
export class NumberIntervalSingleEidtor extends Single { export class NumberIntervalSingleEidtor extends Single {
static xtype = "bi.number_interval_single_editor" static xtype = "bi.number_interval_single_editor";
static EVENT_FOCUS = "EVENT_FOCUS" static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR" static EVENT_BLUR = "EVENT_BLUR";
static EVENT_ERROR = "EVENT_ERROR" static EVENT_ERROR = "EVENT_ERROR";
static EVENT_VALID = "EVENT_VALID" static EVENT_VALID = "EVENT_VALID";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM" static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
static EVENT_CONFIRM = "EVENT_CONFIRM" static EVENT_CONFIRM = "EVENT_CONFIRM";
props = { props = {
baseCls: "bi-number-interval-single-editor", baseCls: "bi-number-interval-single-editor",
@ -25,7 +25,8 @@ export class NumberIntervalSingleEidtor extends Single {
return { return {
type: VerticalLayout.xtype, type: VerticalLayout.xtype,
items: [{ items: [
{
type: Editor.xtype, type: Editor.xtype,
simple: o.simple, simple: o.simple,
ref(_ref) { ref(_ref) {
@ -37,43 +38,52 @@ export class NumberIntervalSingleEidtor extends Single {
value: o.value, value: o.value,
quitChecker: o.quitChecker, quitChecker: o.quitChecker,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
listeners: [{ listeners: [
{
eventName: Editor.EVENT_ERROR, eventName: Editor.EVENT_ERROR,
action() { action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_ERROR, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_ERROR, arguments);
}, },
}, { },
{
eventName: Editor.EVENT_FOCUS, eventName: Editor.EVENT_FOCUS,
action() { action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_FOCUS, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_FOCUS, arguments);
}, },
}, { },
{
eventName: Editor.EVENT_BLUR, eventName: Editor.EVENT_BLUR,
action() { action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_BLUR, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_BLUR, arguments);
}, },
}, { },
{
eventName: Editor.EVENT_VALID, eventName: Editor.EVENT_VALID,
action() { action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_VALID, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_VALID, arguments);
}, },
}, { },
{
eventName: Editor.EVENT_CHANGE, eventName: Editor.EVENT_CHANGE,
action() { action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE, arguments);
}, },
}, { },
{
eventName: Editor.EVENT_CONFIRM, eventName: Editor.EVENT_CONFIRM,
action() { action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_CONFIRM, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_CONFIRM, arguments);
}, },
}, { },
{
eventName: Editor.EVENT_CHANGE_CONFIRM, eventName: Editor.EVENT_CHANGE_CONFIRM,
action() { action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE_CONFIRM, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE_CONFIRM, arguments);
}, },
}], }
}], ],
}
],
}; };
} }

7
src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js

@ -29,8 +29,12 @@ import {
BlankSplitChar BlankSplitChar
} from "@/core"; } from "@/core";
import { Single, Combo } from "@/base"; import { Single, Combo } from "@/base";
import { MultiSelectTrigger, MultiSelectPopupView, MultiSelectCombo, SearchMultiSelectTrigger, SearchMultiSelectPopupView } from "@/widget";
import { MultiSelectBar, TriggerIconButton } from "@/case"; import { MultiSelectBar, TriggerIconButton } from "@/case";
import { MultiSelectTrigger } from "@/widget/multiselect/multiselect.trigger";
import { MultiSelectPopupView } from "@/widget/multiselect/multiselect.popup.view";
import { MultiSelectCombo } from "@/widget/multiselect/multiselect.combo";
import { SearchMultiSelectTrigger } from "@/widget/searchmultitextvaluecombo/multitextvalue.combo.trigger.search";
import { SearchMultiSelectPopupView } from "@/widget/searchmultitextvaluecombo/multitextvalue.popup.view.search";
@shortcut() @shortcut()
export class SearchMultiTextValueCombo extends Single { export class SearchMultiTextValueCombo extends Single {
@ -231,7 +235,6 @@ export class SearchMultiTextValueCombo extends Single {
} }
}); });
triggerBtn.on(TriggerIconButton.EVENT_CHANGE, () => { triggerBtn.on(TriggerIconButton.EVENT_CHANGE, () => {
this.trigger.getCounter().hideView(); this.trigger.getCounter().hideView();
if (this.combo.isViewVisible()) { if (this.combo.isViewVisible()) {

15
src/widget/searchmultitextvaluecombo/multitextvalue.combo.trigger.search.js

@ -1,6 +1,17 @@
import { shortcut, extend, emptyFn, createWidget, Events, nextTick, HTapeLayout, RightVerticalAdaptLayout } from "@/core"; import {
shortcut,
extend,
emptyFn,
createWidget,
Events,
nextTick,
HTapeLayout,
RightVerticalAdaptLayout
} from "@/core";
import { Trigger } from "@/base"; import { Trigger } from "@/base";
import { MultiSelectCheckSelectedSwitcher, MultiSelectSearcher, SearchMultiSelectSearcher } from "@/widget"; import { MultiSelectCheckSelectedSwitcher } from "@/widget/multiselect/trigger/switcher.checkselected";
import { MultiSelectSearcher } from "@/widget/multiselect/trigger/searcher.multiselect";
import { SearchMultiSelectSearcher } from "@/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue";
@shortcut() @shortcut()
export class SearchMultiSelectTrigger extends Trigger { export class SearchMultiSelectTrigger extends Trigger {

2
src/widget/searchmultitextvaluecombo/multitextvalue.popup.view.search.js

@ -1,6 +1,6 @@
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText } from "@/core"; import { shortcut, Widget, extend, emptyFn, createWidget, i18nText } from "@/core";
import { MultiPopupView } from "@/case"; import { MultiPopupView } from "@/case";
import { SearchMultiSelectLoader } from "@/widget"; import { SearchMultiSelectLoader } from "@/widget/searchmultitextvaluecombo/multitextvalue.loader.search";
@shortcut() @shortcut()
export class SearchMultiSelectPopupView extends Widget { export class SearchMultiSelectPopupView extends Widget {

7
src/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue.js

@ -1,6 +1,7 @@
import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, Selection, size, each } from "@/core"; import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, Selection, size, each } from "@/core";
import { Searcher } from "@/base"; import { Searcher } from "@/base";
import { MultiSelectEditor, MultiSelectSearchPane } from "@/widget"; import { MultiSelectEditor } from "@/widget/multiselect/trigger/editor.multiselect";
import { MultiSelectSearchPane } from "@/widget/multiselect/search/multiselect.search.pane";
@shortcut() @shortcut()
export class SearchMultiSelectSearcher extends Widget { export class SearchMultiSelectSearcher extends Widget {
@ -173,7 +174,7 @@ export class SearchMultiSelectSearcher extends Widget {
return this.searcher.getValue(); return this.searcher.getValue();
} }
populate(items) { populate(...items) {
this.searcher.populate.apply(this.searcher, arguments); this.searcher.populate(items);
} }
} }

12
src/widget/selecttree/selecttree.combo.js

@ -1,7 +1,3 @@
/**
* @class SelectTreeCombo
* @extends Widget
*/
import { import {
shortcut, shortcut,
Widget, Widget,
@ -21,6 +17,11 @@ import { Combo } from "@/base";
import { SingleTreeTrigger } from "@/widget/singletree/singletree.trigger"; import { SingleTreeTrigger } from "@/widget/singletree/singletree.trigger";
import { SelectTreePopup } from "./selecttree.popup"; import { SelectTreePopup } from "./selecttree.popup";
/**
* @class SelectTreeCombo
* @extends Widget
*/
@shortcut() @shortcut()
export class SelectTreeCombo extends Widget { export class SelectTreeCombo extends Widget {
static xtype = "bi.select_tree_combo"; static xtype = "bi.select_tree_combo";
@ -37,7 +38,8 @@ export class SelectTreeCombo extends Widget {
} }
_init() { _init() {
const self = this, o = this.options; const self = this,
o = this.options;
super._init(...arguments); super._init(...arguments);
this.trigger = createWidget({ this.trigger = createWidget({

10
src/widget/selecttree/selecttree.expander.js

@ -1,12 +1,4 @@
import { import { shortcut, Widget, extend, createWidget, Controller, Events, contains } from "@/core";
shortcut,
Widget,
extend,
createWidget,
Controller,
Events,
contains
} from "@/core";
import { Expander } from "@/base"; import { Expander } from "@/base";
@shortcut() @shortcut()

17
src/widget/selecttree/selecttree.popup.js

@ -5,7 +5,12 @@ import {
each, each,
createWidget, createWidget,
Controller, Controller,
isArray, isNotEmptyArray, UUID, defaults, Tree, VerticalLayout isArray,
isNotEmptyArray,
UUID,
defaults,
Tree,
VerticalLayout
} from "@/core"; } from "@/core";
import { Pane } from "@/base"; import { Pane } from "@/base";
import { BasicTreeItem, BasicTreeNode, LevelTree, TreeExpander } from "@/case"; import { BasicTreeItem, BasicTreeNode, LevelTree, TreeExpander } from "@/case";
@ -37,11 +42,7 @@ export class SelectTreePopup extends Pane {
}; };
node.id = node.id || UUID(); node.id = node.id || UUID();
if ( if (node.isParent === true || node.parent === true || isNotEmptyArray(node.children)) {
node.isParent === true ||
node.parent === true ||
isNotEmptyArray(node.children)
) {
extend.type = BasicTreeNode.xtype; extend.type = BasicTreeNode.xtype;
extend.selectable = true; extend.selectable = true;
defaults(node, extend); defaults(node, extend);
@ -102,8 +103,6 @@ export class SelectTreePopup extends Pane {
populate(items) { populate(items) {
super.populate(...arguments); super.populate(...arguments);
this.tree.populate( this.tree.populate(this._formatItems(Tree.transformToTreeFormat(items)));
this._formatItems(Tree.transformToTreeFormat(items))
);
} }
} }

22
src/widget/singleselect/search/singleselect.search.loader.js

@ -1,4 +1,18 @@
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText, isUndefined, Controller, VerticalLayout, map, isArray, isKey, Func } from "@/core"; import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
i18nText,
isUndefined,
Controller,
VerticalLayout,
map,
isArray,
isKey,
Func
} from "@/core";
import { ButtonGroup, Loader } from "@/base"; import { ButtonGroup, Loader } from "@/base";
import { SingleSelectList } from "../singleselect.list"; import { SingleSelectList } from "../singleselect.list";
import { SingleSelectItem, SingleSelectRadioItem } from "@/case"; import { SingleSelectItem, SingleSelectRadioItem } from "@/case";
@ -98,7 +112,8 @@ export class SingleSelectSearchLoader extends Widget {
_createItems(items) { _createItems(items) {
const o = this.options; const o = this.options;
return map(items, (i, item) => extend( return map(items, (i, item) =>
extend(
{ {
type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype, type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
logic: o.logic, logic: o.logic,
@ -110,7 +125,8 @@ export class SingleSelectSearchLoader extends Widget {
title: item.title || item.text, title: item.title || item.text,
}, },
item item
)); )
);
} }
_filterValues(src) { _filterValues(src) {

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

@ -1,4 +1,14 @@
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText, Controller, VerticalFillLayout, VerticalLayout } from "@/core"; import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
i18nText,
Controller,
VerticalFillLayout,
VerticalLayout
} from "@/core";
import { Label } from "@/base"; import { Label } from "@/base";
import { SingleSelectSearchLoader } from "./singleselect.search.loader"; import { SingleSelectSearchLoader } from "./singleselect.search.loader";

48
src/widget/singleselect/singleselect.combo.js

@ -1,4 +1,18 @@
import { shortcut, extend, emptyFn, isKey, createWidget, toPix, isNotNull, nextTick, AbsoluteLayout, makeObject, map, each, remove } from "@/core"; import {
shortcut,
extend,
emptyFn,
isKey,
createWidget,
toPix,
isNotNull,
nextTick,
AbsoluteLayout,
makeObject,
map,
each,
remove
} from "@/core";
import { Single, Combo } from "@/base"; import { Single, Combo } from "@/base";
import { SingleSelectTrigger } from "./singleselect.trigger"; import { SingleSelectTrigger } from "./singleselect.trigger";
import { SingleSelectPopupView } from "./singleselect.popup.view"; import { SingleSelectPopupView } from "./singleselect.popup.view";
@ -42,7 +56,7 @@ export class SingleSelectCombo extends Single {
this.requesting = false; this.requesting = false;
this.trigger = createWidget({ this.trigger = createWidget({
type: "bi.single_select_trigger", type: SingleSelectTrigger.xtype,
height: toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
// adapter: this.popup, // adapter: this.popup,
allowNoSelect: o.allowNoSelect, allowNoSelect: o.allowNoSelect,
@ -81,15 +95,12 @@ export class SingleSelectCombo extends Single {
this.fireEvent(SingleSelectCombo.EVENT_SEARCHING); this.fireEvent(SingleSelectCombo.EVENT_SEARCHING);
}); });
this.trigger.on( this.trigger.on(SingleSelectTrigger.EVENT_CHANGE, (value, obj) => {
SingleSelectTrigger.EVENT_CHANGE,
(value, obj) => {
this.storeValue = this.trigger.getValue(); this.storeValue = this.trigger.getValue();
assertShowValue(); assertShowValue();
this._defaultState(); this._defaultState();
this._dataChange = true; this._dataChange = true;
} });
);
this.trigger.on(SingleSelectTrigger.EVENT_COUNTER_CLICK, () => { this.trigger.on(SingleSelectTrigger.EVENT_COUNTER_CLICK, () => {
if (!this.combo.isViewVisible()) { if (!this.combo.isViewVisible()) {
this.combo.showView(); this.combo.showView();
@ -104,13 +115,14 @@ export class SingleSelectCombo extends Single {
el: this.trigger, el: this.trigger,
adjustLength: 1, adjustLength: 1,
popup: { popup: {
type: "bi.single_select_popup_view", type: SingleSelectPopupView.xtype,
allowNoSelect: o.allowNoSelect, allowNoSelect: o.allowNoSelect,
ref: _ref => { ref: _ref => {
this.popup = _ref; this.popup = _ref;
this.trigger.setAdapter(_ref); this.trigger.setAdapter(_ref);
}, },
listeners: [{ listeners: [
{
eventName: SingleSelectPopupView.EVENT_CHANGE, eventName: SingleSelectPopupView.EVENT_CHANGE,
action: () => { action: () => {
this._dataChange = true; this._dataChange = true;
@ -121,7 +133,8 @@ export class SingleSelectCombo extends Single {
}); });
this.fireEvent(SingleSelectCombo.EVENT_CLICK_ITEM); this.fireEvent(SingleSelectCombo.EVENT_CLICK_ITEM);
}, },
}], }
],
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
itemWrapper: o.itemWrapper, itemWrapper: o.itemWrapper,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
@ -156,8 +169,7 @@ export class SingleSelectCombo extends Single {
if (this.requesting === true) { if (this.requesting === true) {
this.wants2Quit = true; this.wants2Quit = true;
} else { } else {
this._dataChange && this._dataChange && this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
} }
}); });
@ -177,7 +189,8 @@ export class SingleSelectCombo extends Single {
createWidget({ createWidget({
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
element: this, element: this,
items: [{ items: [
{
el: this.combo, el: this.combo,
left: 0, left: 0,
right: 0, right: 0,
@ -209,7 +222,8 @@ export class SingleSelectCombo extends Single {
const o = this.options; const o = this.options;
this._assertValue(this.storeValue); this._assertValue(this.storeValue);
this.requesting = true; this.requesting = true;
o.itemsCreator({ o.itemsCreator(
{
type: SingleSelectCombo.REQ_GET_ALL_DATA, type: SingleSelectCombo.REQ_GET_ALL_DATA,
keywords, keywords,
}, },
@ -233,8 +247,7 @@ export class SingleSelectCombo extends Single {
_adjust(callback) { _adjust(callback) {
const adjust = () => { const adjust = () => {
if (this.wants2Quit === true) { if (this.wants2Quit === true) {
this._dataChange && this._dataChange && this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
this.wants2Quit = false; this.wants2Quit = false;
} }
this.requesting = false; this.requesting = false;
@ -242,7 +255,8 @@ export class SingleSelectCombo extends Single {
const o = this.options; const o = this.options;
if (!this._count) { if (!this._count) {
o.itemsCreator({ o.itemsCreator(
{
type: SingleSelectCombo.REQ_GET_DATA_LENGTH, type: SingleSelectCombo.REQ_GET_DATA_LENGTH,
}, },
res => { res => {

34
src/widget/singleselect/singleselect.insert.combo.js

@ -1,4 +1,17 @@
import { shortcut, extend, emptyFn, i18nText, isKey, createWidget, toPix, isNotNull, nextTick, AbsoluteLayout, makeObject } from "@/core"; import { SingleSelectSearchInsertPane } from "./search";
import {
shortcut,
extend,
emptyFn,
i18nText,
isKey,
createWidget,
toPix,
isNotNull,
nextTick,
AbsoluteLayout,
makeObject
} from "@/core";
import { Single, Combo } from "@/base"; import { Single, Combo } from "@/base";
import { SingleSelectTrigger } from "./singleselect.trigger"; import { SingleSelectTrigger } from "./singleselect.trigger";
import { SingleSelectPopupView } from "./singleselect.popup.view"; import { SingleSelectPopupView } from "./singleselect.popup.view";
@ -63,7 +76,7 @@ export class SingleSelectInsertCombo extends Single {
value: this.storeValue, value: this.storeValue,
searcher: { searcher: {
popup: { popup: {
type: "bi.single_select_search_insert_pane", type: SingleSelectSearchInsertPane.xtype,
}, },
}, },
}); });
@ -93,15 +106,12 @@ export class SingleSelectInsertCombo extends Single {
self.fireEvent(SingleSelectInsertCombo.EVENT_SEARCHING); self.fireEvent(SingleSelectInsertCombo.EVENT_SEARCHING);
}); });
this.trigger.on( this.trigger.on(SingleSelectTrigger.EVENT_CHANGE, function (value, obj) {
SingleSelectTrigger.EVENT_CHANGE,
function (value, obj) {
self.storeValue = this.getValue(); self.storeValue = this.getValue();
assertShowValue(); assertShowValue();
self._defaultState(); self._defaultState();
self._dataChange = true; self._dataChange = true;
} });
);
this.trigger.on(SingleSelectTrigger.EVENT_COUNTER_CLICK, () => { this.trigger.on(SingleSelectTrigger.EVENT_COUNTER_CLICK, () => {
if (!self.combo.isViewVisible()) { if (!self.combo.isViewVisible()) {
self.combo.showView(); self.combo.showView();
@ -132,9 +142,7 @@ export class SingleSelectInsertCombo extends Single {
assertShowValue(); assertShowValue();
self._defaultState(); self._defaultState();
}); });
self.fireEvent( self.fireEvent(SingleSelectInsertCombo.EVENT_CLICK_ITEM);
SingleSelectInsertCombo.EVENT_CLICK_ITEM
);
}, },
} }
], ],
@ -172,8 +180,7 @@ export class SingleSelectInsertCombo extends Single {
if (self.requesting === true) { if (self.requesting === true) {
self.wants2Quit = true; self.wants2Quit = true;
} else { } else {
self._dataChange && self._dataChange && self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
} }
}); });
@ -229,8 +236,7 @@ export class SingleSelectInsertCombo extends Single {
function adjust() { function adjust() {
if (self.wants2Quit === true) { if (self.wants2Quit === true) {
self._dataChange && self._dataChange && self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
self.wants2Quit = false; self.wants2Quit = false;
} }
self.requesting = false; self.requesting = false;

20
src/widget/singleselect/singleselect.loader.js

@ -1,4 +1,16 @@
import { shortcut, Widget, extend, emptyFn, createWidget, isUndefined, map, isKey, Controller, VerticalLayout, delay } from "@/core"; import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
isUndefined,
map,
isKey,
Controller,
VerticalLayout,
delay
} from "@/core";
import { ButtonGroup, Loader } from "@/base"; import { ButtonGroup, Loader } from "@/base";
import { SingleSelectList } from "./singleselect.list"; import { SingleSelectList } from "./singleselect.list";
import { SingleSelectItem, SingleSelectRadioItem } from "@/case"; import { SingleSelectItem, SingleSelectRadioItem } from "@/case";
@ -127,7 +139,8 @@ export class SingleSelectLoader extends Widget {
_createItems(items) { _createItems(items) {
const o = this.options; const o = this.options;
return map(items, (i, item) => extend( return map(items, (i, item) =>
extend(
{ {
type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype, type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
logic: o.logic, logic: o.logic,
@ -139,7 +152,8 @@ export class SingleSelectLoader extends Widget {
title: item.title || item.text, title: item.title || item.text,
}, },
item item
)); )
);
} }
_scrollToTop() { _scrollToTop() {

3
src/widget/singleselect/singleselect.popup.view.js

@ -1,3 +1,4 @@
import { SingleSelectLoader } from "./singleselect.loader";
import { shortcut, Widget, extend, emptyFn, createWidget } from "@/core"; import { shortcut, Widget, extend, emptyFn, createWidget } from "@/core";
import { MultiPopupView } from "@/case"; import { MultiPopupView } from "@/case";
import { PopupView } from "@/base"; import { PopupView } from "@/base";
@ -27,7 +28,7 @@ export class SingleSelectPopupView extends Widget {
const opts = this.options; const opts = this.options;
this.loader = createWidget({ this.loader = createWidget({
type: "bi.single_select_loader", type: SingleSelectLoader.xtype,
allowNoSelect: opts.allowNoSelect, allowNoSelect: opts.allowNoSelect,
itemsCreator: opts.itemsCreator, itemsCreator: opts.itemsCreator,
itemWrapper: opts.itemWrapper, itemWrapper: opts.itemWrapper,

3
src/widget/singleselect/singleselectlist.insert.js

@ -1,3 +1,4 @@
import { SingleSelectSearchInsertPane } from "./search";
import { import {
shortcut, shortcut,
extend, extend,
@ -68,7 +69,7 @@ export class SingleSelectInsertList extends Single {
}); });
this.searcherPane = createWidget({ this.searcherPane = createWidget({
type: "bi.single_select_search_insert_pane", type: SingleSelectSearchInsertPane.xtype,
allowNoSelect: o.allowNoSelect, allowNoSelect: o.allowNoSelect,
cls: "bi-border-left bi-border-right bi-border-bottom", cls: "bi-border-left bi-border-right bi-border-bottom",
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,

12
src/widget/singleselect/trigger/editor.singleselect.js

@ -1,4 +1,14 @@
import { shortcut, Widget, extend, i18nText, createWidget, Controller, isEmptyString, isEmptyArray, BlankSplitChar } from "@/core"; import {
shortcut,
Widget,
extend,
i18nText,
createWidget,
Controller,
isEmptyString,
isEmptyArray,
BlankSplitChar
} from "@/core";
import { StateEditor } from "@/case"; import { StateEditor } from "@/case";
import { SelectPatchEditor } from "../../multiselect"; import { SelectPatchEditor } from "../../multiselect";

11
src/widget/singleselect/trigger/searcher.singleselect.js

@ -1,3 +1,4 @@
import { SingleSelectSearchPane } from "../search";
import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, isUndefined, Selection } from "@/core"; import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, isUndefined, Selection } from "@/core";
import { SingleSelectEditor } from "./editor.singleselect"; import { SingleSelectEditor } from "./editor.singleselect";
import { Searcher } from "@/base"; import { Searcher } from "@/base";
@ -33,11 +34,12 @@ export class SingleSelectSearcher extends Widget {
const self = this, const self = this,
o = this.options; o = this.options;
this.editor = createWidget(o.el, { this.editor = createWidget(o.el, {
type: "bi.single_select_editor", type: SingleSelectEditor.xtype,
height: o.height, height: o.height,
watermark: o.watermark, watermark: o.watermark,
text: o.text, text: o.text,
listeners: [{ listeners: [
{
eventName: SingleSelectEditor.EVENT_FOCUS, eventName: SingleSelectEditor.EVENT_FOCUS,
action: () => { action: () => {
this.fireEvent(SingleSelectSearcher.EVENT_FOCUS); this.fireEvent(SingleSelectSearcher.EVENT_FOCUS);
@ -63,8 +65,9 @@ export class SingleSelectSearcher extends Widget {
}, },
el: this.editor, el: this.editor,
popup: extend({ popup: extend(
type: "bi.single_select_search_pane", {
type: SingleSelectSearchPane.xtype,
allowNoSelect: o.allowNoSelect, allowNoSelect: o.allowNoSelect,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
keywordGetter: () => this.editor.getValue(), keywordGetter: () => this.editor.getValue(),

2
src/widget/singleslider/button/iconbutton.slider.js

@ -8,7 +8,7 @@ export class SliderIconButton extends Widget {
baseCls: "bi-single-slider-button slider-button bi-high-light-border", baseCls: "bi-single-slider-button slider-button bi-high-light-border",
height: 8, height: 8,
width: 8, width: 8,
} };
constants = { constants = {
LARGE_SIZE: 16, LARGE_SIZE: 16,
NORMAL_SIZE: 12, NORMAL_SIZE: 12,

60
src/widget/singleslider/singleslider.js

@ -1,3 +1,5 @@
import { SliderIconButton } from "./button/iconbutton.slider";
import { SignTextEditor } from "./button/editor.sign.text";
import { import {
shortcut, shortcut,
createWidget, createWidget,
@ -32,7 +34,7 @@ export class SingleSlider extends Single {
TRACK_HEIGHT: 24, TRACK_HEIGHT: 24,
TRACK_GAP_HALF: 7, TRACK_GAP_HALF: 7,
TRACK_GAP: 14, TRACK_GAP: 14,
} };
props = { props = {
baseCls: "bi-single-slider bi-slider-track", baseCls: "bi-single-slider bi-slider-track",
@ -74,7 +76,7 @@ export class SingleSlider extends Single {
this.track = this._createTrackWrapper(); this.track = this._createTrackWrapper();
this.slider = createWidget({ this.slider = createWidget({
type: "bi.single_slider_button", type: SliderIconButton.xtype,
}); });
this._draggable(this.slider); this._draggable(this.slider);
const sliderVertical = createWidget({ const sliderVertical = createWidget({
@ -98,17 +100,9 @@ export class SingleSlider extends Single {
}); });
// 这边其实是有问题的,拖拽区域是个圆,在圆的边缘拖拽后放开,这边计算出来的蓝条宽度实际上会比放开时长一点或者短一点 // 这边其实是有问题的,拖拽区域是个圆,在圆的边缘拖拽后放开,这边计算出来的蓝条宽度实际上会比放开时长一点或者短一点
sliderVertical.element.click(e => { sliderVertical.element.click(e => {
if ( if (this.enable && this.isEnabled() && sliderVertical.element[0] === e.originalEvent.target) {
this.enable && const offset = e.clientX - this.element.offset().left - c.SLIDER_WIDTH_HALF;
this.isEnabled() && const trackLength = this.track.element[0].scrollWidth - c.TRACK_GAP;
sliderVertical.element[0] === e.originalEvent.target
) {
const offset =
e.clientX -
this.element.offset().left -
c.SLIDER_WIDTH_HALF;
const trackLength =
this.track.element[0].scrollWidth - c.TRACK_GAP;
let percent = 0; let percent = 0;
if (offset < 0) { if (offset < 0) {
percent = 0; percent = 0;
@ -129,7 +123,7 @@ export class SingleSlider extends Single {
} }
}); });
this.label = createWidget({ this.label = createWidget({
type: "bi.sign_text_editor", type: SignTextEditor.xtype,
cls: "slider-editor-button", cls: "slider-editor-button",
text: o.unit, text: o.unit,
width: toPix(c.EDITOR_WIDTH, 2), width: toPix(c.EDITOR_WIDTH, 2),
@ -140,9 +134,7 @@ export class SingleSlider extends Single {
}); });
this.label.element.hover( this.label.element.hover(
() => { () => {
this.label.element this.label.element.removeClass("bi-border").addClass("bi-border");
.removeClass("bi-border")
.addClass("bi-border");
}, },
() => { () => {
this.label.element.removeClass("bi-border"); this.label.element.removeClass("bi-border");
@ -216,7 +208,7 @@ export class SingleSlider extends Single {
offset = 0, offset = 0,
defaultSize = 0; defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker( const mouseMoveTracker = new MouseMoveTracker(
(deltaX => { deltaX => {
if (mouseMoveTracker.isDragging()) { if (mouseMoveTracker.isDragging()) {
startDrag = true; startDrag = true;
offset += deltaX; offset += deltaX;
@ -232,8 +224,8 @@ export class SingleSlider extends Single {
this.label.setValue(v); this.label.setValue(v);
this.value = v; this.value = v;
} }
}), },
(() => { () => {
if (startDrag === true) { if (startDrag === true) {
size = optimizeSize(size); size = optimizeSize(size);
const percent = (size * 100) / this._getGrayTrackLength(); const percent = (size * 100) / this._getGrayTrackLength();
@ -247,7 +239,7 @@ export class SingleSlider extends Single {
widget.element.removeClass("dragging"); widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves(); mouseMoveTracker.releaseMouseMoves();
this.fireEvent(SingleSlider.EVENT_CHANGE); this.fireEvent(SingleSlider.EVENT_CHANGE);
}), },
window window
); );
widget.element.on("mousedown", function (event) { widget.element.on("mousedown", function (event) {
@ -306,7 +298,7 @@ export class SingleSlider extends Single {
if (o.digit === false) { if (o.digit === false) {
valid = true; valid = true;
} else { } else {
const dotText = (`${v}`).split(".")[1] || ""; const dotText = `${v}`.split(".")[1] || "";
valid = dotText.length === o.digit; valid = dotText.length === o.digit;
} }
} }
@ -375,13 +367,9 @@ export class SingleSlider extends Single {
_setEnable(b) { _setEnable(b) {
super._setEnable.apply(this, [b]); super._setEnable.apply(this, [b]);
if (b) { if (b) {
this.blueTrack.element this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
.removeClass("disabled-blue-track")
.addClass("blue-track");
} else { } else {
this.blueTrack.element this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
.removeClass("blue-track")
.addClass("disabled-blue-track");
} }
} }
@ -409,21 +397,9 @@ export class SingleSlider extends Single {
this._setVisible(true); this._setVisible(true);
this.enable = true; this.enable = true;
if (o.digit) { if (o.digit) {
this.label.setErrorText( this.label.setErrorText(i18nText("BI-Basic_Please_Enter_Number_Between", this.min, this.max));
i18nText(
"BI-Basic_Please_Enter_Number_Between",
this.min,
this.max
)
);
} else { } else {
this.label.setErrorText( this.label.setErrorText(i18nText("BI-Basic_Please_Enter_Integer_Number_Between", this.min, this.max));
i18nText(
"BI-Basic_Please_Enter_Integer_Number_Between",
this.min,
this.max
)
);
} }
if (isNumeric(this.value) || isNotEmptyString(this.value)) { if (isNumeric(this.value) || isNotEmptyString(this.value)) {

35
src/widget/singleslider/singleslider.label.js

@ -1,3 +1,4 @@
import { SliderIconButton } from "./button/iconbutton.slider";
import { import {
shortcut, shortcut,
createWidget, createWidget,
@ -30,7 +31,7 @@ export class SingleSliderLabel extends Single {
TRACK_HEIGHT: 24, TRACK_HEIGHT: 24,
TRACK_GAP_HALF: 7, TRACK_GAP_HALF: 7,
TRACK_GAP: 14, TRACK_GAP: 14,
} };
props = { props = {
baseCls: "bi-single-slider-label bi-slider-track", baseCls: "bi-single-slider-label bi-slider-track",
digit: false, digit: false,
@ -71,7 +72,7 @@ export class SingleSliderLabel extends Single {
this.track = this._createTrackWrapper(); this.track = this._createTrackWrapper();
this.slider = createWidget({ this.slider = createWidget({
type: "bi.single_slider_button", type: SliderIconButton.xtype,
}); });
this._draggable(this.slider); this._draggable(this.slider);
const sliderVertical = createWidget({ const sliderVertical = createWidget({
@ -93,17 +94,9 @@ export class SingleSliderLabel extends Single {
height: c.SLIDER_HEIGHT, height: c.SLIDER_HEIGHT,
}); });
sliderVertical.element.click(e => { sliderVertical.element.click(e => {
if ( if (this.enable && this.isEnabled() && sliderVertical.element[0] === e.originalEvent.target) {
this.enable && const offset = e.clientX - this.element.offset().left - c.SLIDER_WIDTH_HALF;
this.isEnabled() && const trackLength = this.track.element[0].scrollWidth - c.TRACK_GAP;
sliderVertical.element[0] === e.originalEvent.target
) {
const offset =
e.clientX -
this.element.offset().left -
c.SLIDER_WIDTH_HALF;
const trackLength =
this.track.element[0].scrollWidth - c.TRACK_GAP;
let percent = 0; let percent = 0;
if (offset < 0) { if (offset < 0) {
percent = 0; percent = 0;
@ -188,7 +181,7 @@ export class SingleSliderLabel extends Single {
offset = 0, offset = 0,
defaultSize = 0; defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker( const mouseMoveTracker = new MouseMoveTracker(
(deltaX => { deltaX => {
if (mouseMoveTracker.isDragging()) { if (mouseMoveTracker.isDragging()) {
startDrag = true; startDrag = true;
offset += deltaX; offset += deltaX;
@ -205,8 +198,8 @@ export class SingleSliderLabel extends Single {
this.value = v; this.value = v;
this.fireEvent(SingleSliderLabel.EVENT_CHANGE); this.fireEvent(SingleSliderLabel.EVENT_CHANGE);
} }
}), },
(() => { () => {
if (startDrag === true) { if (startDrag === true) {
size = optimizeSize(size); size = optimizeSize(size);
const percent = (size * 100) / this._getGrayTrackLength(); const percent = (size * 100) / this._getGrayTrackLength();
@ -220,7 +213,7 @@ export class SingleSliderLabel extends Single {
widget.element.removeClass("dragging"); widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves(); mouseMoveTracker.releaseMouseMoves();
this.fireEvent(SingleSliderLabel.EVENT_CHANGE); this.fireEvent(SingleSliderLabel.EVENT_CHANGE);
}), },
window window
); );
widget.element.on("mousedown", function (event) { widget.element.on("mousedown", function (event) {
@ -316,13 +309,9 @@ export class SingleSliderLabel extends Single {
_setEnable(b) { _setEnable(b) {
super._setEnable.apply(this, [b]); super._setEnable.apply(this, [b]);
if (b) { if (b) {
this.blueTrack.element this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
.removeClass("disabled-blue-track")
.addClass("blue-track");
} else { } else {
this.blueTrack.element this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
.removeClass("blue-track")
.addClass("disabled-blue-track");
} }
} }

35
src/widget/singleslider/singleslider.normal.js

@ -1,3 +1,4 @@
import { SliderIconButton } from "./button/iconbutton.slider";
import { import {
shortcut, shortcut,
createWidget, createWidget,
@ -27,7 +28,7 @@ export class SingleSliderNormal extends Single {
TRACK_HEIGHT: 24, TRACK_HEIGHT: 24,
TRACK_GAP_HALF: 7, TRACK_GAP_HALF: 7,
TRACK_GAP: 14, TRACK_GAP: 14,
} };
props = { props = {
baseCls: "bi-single-slider-normal bi-slider-track", baseCls: "bi-single-slider-normal bi-slider-track",
min: 0, min: 0,
@ -52,7 +53,7 @@ export class SingleSliderNormal extends Single {
const track = this._createTrack(); const track = this._createTrack();
this.slider = createWidget({ this.slider = createWidget({
type: "bi.single_slider_button", type: SliderIconButton.xtype,
}); });
this._draggable(this.slider); this._draggable(this.slider);
@ -75,17 +76,9 @@ export class SingleSliderNormal extends Single {
height: c.SLIDER_HEIGHT, height: c.SLIDER_HEIGHT,
}); });
sliderVertical.element.click(e => { sliderVertical.element.click(e => {
if ( if (this.enable && this.isEnabled() && sliderVertical.element[0] === e.originalEvent.target) {
this.enable && const offset = e.clientX - this.element.offset().left - c.SLIDER_WIDTH_HALF;
this.isEnabled() && const trackLength = this.track.element[0].scrollWidth - c.TRACK_GAP;
sliderVertical.element[0] === e.originalEvent.target
) {
const offset =
e.clientX -
this.element.offset().left -
c.SLIDER_WIDTH_HALF;
const trackLength =
this.track.element[0].scrollWidth - c.TRACK_GAP;
let percent = 0; let percent = 0;
if (offset < 0) { if (offset < 0) {
percent = 0; percent = 0;
@ -147,7 +140,7 @@ export class SingleSliderNormal extends Single {
offset = 0, offset = 0,
defaultSize = 0; defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker( const mouseMoveTracker = new MouseMoveTracker(
(deltaX => { deltaX => {
if (mouseMoveTracker.isDragging()) { if (mouseMoveTracker.isDragging()) {
startDrag = true; startDrag = true;
offset += deltaX; offset += deltaX;
@ -162,8 +155,8 @@ export class SingleSliderNormal extends Single {
this.value = v; this.value = v;
this.fireEvent(SingleSliderNormal.EVENT_DRAG, v); this.fireEvent(SingleSliderNormal.EVENT_DRAG, v);
} }
}), },
(() => { () => {
if (startDrag === true) { if (startDrag === true) {
size = optimizeSize(size); size = optimizeSize(size);
const percent = (size * 100) / this._getGrayTrackLength(); const percent = (size * 100) / this._getGrayTrackLength();
@ -177,7 +170,7 @@ export class SingleSliderNormal extends Single {
widget.element.removeClass("dragging"); widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves(); mouseMoveTracker.releaseMouseMoves();
this.fireEvent(SingleSlider.EVENT_CHANGE); this.fireEvent(SingleSlider.EVENT_CHANGE);
}), },
window window
); );
widget.element.on("mousedown", function (event) { widget.element.on("mousedown", function (event) {
@ -286,13 +279,9 @@ export class SingleSliderNormal extends Single {
_setEnable(b) { _setEnable(b) {
super._setEnable.apply(this, [b]); super._setEnable.apply(this, [b]);
if (b) { if (b) {
this.blueTrack.element this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
.removeClass("disabled-blue-track")
.addClass("blue-track");
} else { } else {
this.blueTrack.element this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
.removeClass("blue-track")
.addClass("disabled-blue-track");
} }
} }

9
src/widget/singletree/singletree.combo.js

@ -10,7 +10,8 @@ import {
isEmptyArray, isEmptyArray,
isEmptyString, isEmptyString,
isArray, isArray,
contains, find contains,
find
} from "@/core"; } from "@/core";
import { Combo } from "@/base"; import { Combo } from "@/base";
import { SingleTreeTrigger } from "./singletree.trigger"; import { SingleTreeTrigger } from "./singletree.trigger";
@ -25,11 +26,7 @@ export class SingleTreeCombo extends Widget {
_defaultConfig(config) { _defaultConfig(config) {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
baseCls: baseCls: `bi-single-tree-combo ${config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`,
`bi-single-tree-combo ${
config.simple
? "bi-border-bottom"
: "bi-border bi-border-radius"}`,
trigger: {}, trigger: {},
height: 24, height: 24,
text: "", text: "",

9
src/widget/singletree/singletree.popup.js

@ -1,11 +1,4 @@
import { import { shortcut, extend, i18nText, createWidget, Controller, isArray, VerticalLayout } from "@/core";
shortcut,
extend,
i18nText,
createWidget,
Controller,
isArray, VerticalLayout
} from "@/core";
import { Pane } from "@/base"; import { Pane } from "@/base";
import { LevelTree } from "@/case"; import { LevelTree } from "@/case";

10
src/widget/singletree/singletree.trigger.js

@ -1,12 +1,4 @@
import { import { shortcut, extend, emptyFn, createWidget, contains, isArray, some } from "@/core";
shortcut,
extend,
emptyFn,
createWidget,
contains,
isArray,
some
} from "@/core";
import { Trigger } from "@/base"; import { Trigger } from "@/base";
import { SelectTextTrigger } from "@/case"; import { SelectTextTrigger } from "@/case";

8
src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js

@ -1,3 +1,4 @@
import { DownListSelectTextTrigger } from "./trigger.textvaluedownlist";
import { import {
shortcut, shortcut,
Widget, Widget,
@ -22,8 +23,9 @@ export class TextValueDownListCombo extends Widget {
_defaultConfig(config) { _defaultConfig(config) {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
baseCls: baseCls: `bi-text-value-down-list-combo bi-border-radius ${
`bi-text-value-down-list-combo bi-border-radius ${config.simple ? "bi-border-bottom" : "bi-border"}`, config.simple ? "bi-border-bottom" : "bi-border"
}`,
height: 24, height: 24,
}); });
} }
@ -46,7 +48,7 @@ export class TextValueDownListCombo extends Widget {
width: toPix(o.width, 2), width: toPix(o.width, 2),
height: toPix(o.height, 2), height: toPix(o.height, 2),
el: { el: {
type: "bi.down_list_select_text_trigger", type: DownListSelectTextTrigger.xtype,
ref: _ref => { ref: _ref => {
this.trigger = _ref; this.trigger = _ref;
}, },

69
src/widget/time/datetime.popup.js

@ -1,82 +1,107 @@
import { shortcut, Widget, i18nText, CenterAdaptLayout, GridLayout, isNull, isEmptyObject, isEmptyString } from "@/core"; import {
VTapeLayout,
shortcut,
Widget,
i18nText,
CenterAdaptLayout,
GridLayout,
isNull,
isEmptyObject,
isEmptyString
} from "@/core";
import { TextButton } from "@/base"; import { TextButton } from "@/base";
import { DynamicDateTimeSelect } from "../dynamicdatetime"; import { DynamicDateTimeSelect } from "../dynamicdatetime";
@shortcut() @shortcut()
export class TimePopup extends Widget { export class TimePopup extends Widget {
static xtype = "bi.time_popup" static xtype = "bi.time_popup";
props = { props = {
baseCls: "bi-date-time-popup", baseCls: "bi-date-time-popup",
height: 68, height: 68,
}; };
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE" static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE" static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
static BUTTON_NOW_EVENT_CHANGE = "BUTTON_NOW_EVENT_CHANGE" static BUTTON_NOW_EVENT_CHANGE = "BUTTON_NOW_EVENT_CHANGE";
static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE" static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
render() { render() {
const o = this.options; const o = this.options;
return { return {
type: "bi.vtape", type: VTapeLayout.xtype,
items: [{ items: [
{
el: { el: {
type: CenterAdaptLayout.xtype, type: CenterAdaptLayout.xtype,
cls: "bi-split-top", cls: "bi-split-top",
items: [{ items: [
{
type: DynamicDateTimeSelect.xtype, type: DynamicDateTimeSelect.xtype,
value: o.value, value: o.value,
ref: _ref => { ref: _ref => {
this.timeSelect = _ref; this.timeSelect = _ref;
}, },
}], }
],
}, },
hgap: 10, hgap: 10,
height: 44, height: 44,
}, { },
{
el: { el: {
type: GridLayout.xtype, type: GridLayout.xtype,
items: [ items: [
[{ [
{
type: TextButton.xtype, type: TextButton.xtype,
cls: "bi-high-light bi-split-top", cls: "bi-high-light bi-split-top",
shadow: true, shadow: true,
text: i18nText("BI-Basic_Clears"), text: i18nText("BI-Basic_Clears"),
listeners: [{ listeners: [
{
eventName: TextButton.EVENT_CHANGE, eventName: TextButton.EVENT_CHANGE,
action: () => { action: () => {
this.fireEvent(TimePopup.BUTTON_CLEAR_EVENT_CHANGE); this.fireEvent(TimePopup.BUTTON_CLEAR_EVENT_CHANGE);
}, },
}], }
}, { ],
},
{
type: TextButton.xtype, type: TextButton.xtype,
cls: "bi-split-left bi-split-right bi-high-light bi-split-top", cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
shadow: true, shadow: true,
text: i18nText("BI-Basic_Now"), text: i18nText("BI-Basic_Now"),
listeners: [{ listeners: [
{
eventName: TextButton.EVENT_CHANGE, eventName: TextButton.EVENT_CHANGE,
action: () => { action: () => {
this.fireEvent(TimePopup.BUTTON_NOW_EVENT_CHANGE); this.fireEvent(TimePopup.BUTTON_NOW_EVENT_CHANGE);
}, },
}], }
}, { ],
},
{
type: TextButton.xtype, type: TextButton.xtype,
cls: "bi-high-light bi-split-top", cls: "bi-high-light bi-split-top",
shadow: true, shadow: true,
text: i18nText("BI-Basic_OK"), text: i18nText("BI-Basic_OK"),
listeners: [{ listeners: [
{
eventName: TextButton.EVENT_CHANGE, eventName: TextButton.EVENT_CHANGE,
action: () => { action: () => {
this.fireEvent(TimePopup.BUTTON_OK_EVENT_CHANGE); this.fireEvent(TimePopup.BUTTON_OK_EVENT_CHANGE);
}, },
}], }
}] ],
}
]
], ],
}, },
height: 24, height: 24,
}], }
],
}; };
} }

100
src/widget/time/time.combo.js

@ -1,17 +1,27 @@
import { shortcut, toPix, getDate, isNotEmptyString, isEqual, isEmptyString, AbsoluteLayout } from "@/core"; import {
HorizontalFillLayout,
shortcut,
toPix,
getDate,
isNotEmptyString,
isEqual,
isEmptyString,
AbsoluteLayout
} from "@/core";
import { TimeTrigger } from "./time.trigger";
import { Single, IconButton, Combo } from "@/base"; import { Single, IconButton, Combo } from "@/base";
import { TimePopup } from "./datetime.popup"; import { TimePopup } from "./datetime.popup";
@shortcut() @shortcut()
export class TimeCombo extends Single { export class TimeCombo extends Single {
static xtype = "bi.time_combo" static xtype = "bi.time_combo";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN" static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
static EVENT_CONFIRM = "EVENT_CONFIRM" static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_VALID = "EVENT_VALID" static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR" static EVENT_ERROR = "EVENT_ERROR";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW" static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
constants = { constants = {
popupHeight: 80, popupHeight: 80,
@ -19,7 +29,7 @@ export class TimeCombo extends Single {
comboAdjustHeight: 1, comboAdjustHeight: 1,
border: 1, border: 1,
iconWidth: 24, iconWidth: 24,
} };
props = { props = {
baseCls: "bi-time-combo", baseCls: "bi-time-combo",
@ -40,28 +50,32 @@ export class TimeCombo extends Single {
this.storeValue = opts.value; this.storeValue = opts.value;
const popup = { const popup = {
type: "bi.time_popup", type: TimePopup.xtype,
value: opts.value, value: opts.value,
listeners: [{ listeners: [
{
eventName: TimePopup.BUTTON_CLEAR_EVENT_CHANGE, eventName: TimePopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => { action: () => {
this.setValue(); this.setValue();
this.hidePopupView(); this.hidePopupView();
this.fireEvent(TimeCombo.EVENT_CONFIRM); this.fireEvent(TimeCombo.EVENT_CONFIRM);
}, },
}, { },
{
eventName: TimePopup.BUTTON_OK_EVENT_CHANGE, eventName: TimePopup.BUTTON_OK_EVENT_CHANGE,
action: () => { action: () => {
this.setValue(this.popup.getValue()); this.setValue(this.popup.getValue());
this.hidePopupView(); this.hidePopupView();
this.fireEvent(TimeCombo.EVENT_CONFIRM); this.fireEvent(TimeCombo.EVENT_CONFIRM);
}, },
}, { },
{
eventName: TimePopup.BUTTON_NOW_EVENT_CHANGE, eventName: TimePopup.BUTTON_NOW_EVENT_CHANGE,
action: () => { action: () => {
this._setNowTime(); this._setNowTime();
}, },
}], }
],
ref: _ref => { ref: _ref => {
this.popup = _ref; this.popup = _ref;
}, },
@ -69,7 +83,8 @@ export class TimeCombo extends Single {
return { return {
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
items: [{ items: [
{
el: { el: {
type: Combo.xtype, type: Combo.xtype,
cls: "bi-border bi-border-radius", cls: "bi-border bi-border-radius",
@ -78,11 +93,12 @@ export class TimeCombo extends Single {
isNeedAdjustHeight: opts.isNeedAdjustHeight, isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth, isNeedAdjustWidth: opts.isNeedAdjustWidth,
el: { el: {
type: "bi.horizontal_fill", type: HorizontalFillLayout.xtype,
columnSize: ["fill", this.constants.iconWidth], columnSize: ["fill", this.constants.iconWidth],
height: toPix(opts.height, 2), height: toPix(opts.height, 2),
items: [{ items: [
type: "bi.time_trigger", {
type: TimeTrigger.xtype,
height: toPix(opts.height, 2), height: toPix(opts.height, 2),
allowEdit: opts.allowEdit, allowEdit: opts.allowEdit,
watermark: opts.watermark, watermark: opts.watermark,
@ -91,7 +107,8 @@ export class TimeCombo extends Single {
ref: _ref => { ref: _ref => {
this.trigger = _ref; this.trigger = _ref;
}, },
listeners: [{ listeners: [
{
eventName: "EVENT_KEY_DOWN", eventName: "EVENT_KEY_DOWN",
action: () => { action: () => {
if (this.combo.isViewVisible()) { if (this.combo.isViewVisible()) {
@ -99,14 +116,16 @@ export class TimeCombo extends Single {
} }
this.fireEvent(TimeCombo.EVENT_KEY_DOWN, arguments); this.fireEvent(TimeCombo.EVENT_KEY_DOWN, arguments);
}, },
}, { },
{
eventName: "EVENT_STOP", eventName: "EVENT_STOP",
action: () => { action: () => {
if (!this.combo.isViewVisible()) { if (!this.combo.isViewVisible()) {
this.combo.showView(); this.combo.showView();
} }
}, },
}, { },
{
eventName: "EVENT_FOCUS", eventName: "EVENT_FOCUS",
action: () => { action: () => {
this.storeTriggerValue = this.trigger.getKey(); this.storeTriggerValue = this.trigger.getKey();
@ -115,12 +134,14 @@ export class TimeCombo extends Single {
} }
this.fireEvent("EVENT_FOCUS"); this.fireEvent("EVENT_FOCUS");
}, },
}, { },
{
eventName: "EVENT_BLUR", eventName: "EVENT_BLUR",
action: () => { action: () => {
this.fireEvent("EVENT_BLUR"); this.fireEvent("EVENT_BLUR");
}, },
}, { },
{
eventName: "EVENT_ERROR", eventName: "EVENT_ERROR",
action: () => { action: () => {
const date = getDate(); const date = getDate();
@ -131,17 +152,20 @@ export class TimeCombo extends Single {
}; };
this.fireEvent("EVENT_ERROR"); this.fireEvent("EVENT_ERROR");
}, },
}, { },
{
eventName: "EVENT_VALID", eventName: "EVENT_VALID",
action: () => { action: () => {
this.fireEvent("EVENT_VALID"); this.fireEvent("EVENT_VALID");
}, },
}, { },
{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: () => { action: () => {
this.fireEvent("EVENT_CHANGE"); this.fireEvent("EVENT_CHANGE");
}, },
}, { },
{
eventName: "EVENT_CONFIRM", eventName: "EVENT_CONFIRM",
action: () => { action: () => {
if (this.combo.isViewVisible()) { if (this.combo.isViewVisible()) {
@ -158,13 +182,16 @@ export class TimeCombo extends Single {
} }
this.fireEvent("EVENT_CONFIRM"); this.fireEvent("EVENT_CONFIRM");
}, },
}], }
}, { ],
},
{
el: { el: {
type: IconButton.xtype, type: IconButton.xtype,
cls: "bi-trigger-icon-button time-font", cls: "bi-trigger-icon-button time-font",
width: this.constants.iconWidth, width: this.constants.iconWidth,
listeners: [{ listeners: [
{
eventName: IconButton.EVENT_CHANGE, eventName: IconButton.EVENT_CHANGE,
action: () => { action: () => {
if (this.combo.isViewVisible()) { if (this.combo.isViewVisible()) {
@ -173,12 +200,14 @@ export class TimeCombo extends Single {
this.combo.showView(); this.combo.showView();
} }
}, },
}], }
],
ref: _ref => { ref: _ref => {
this.triggerBtn = _ref; this.triggerBtn = _ref;
}, },
}, },
}], }
],
}, },
adjustLength: this.constants.comboAdjustHeight, adjustLength: this.constants.comboAdjustHeight,
popup: { popup: {
@ -187,13 +216,15 @@ export class TimeCombo extends Single {
stopPropagation: false, stopPropagation: false,
}, },
hideChecker: e => this.triggerBtn.element.find(e.target).length === 0, hideChecker: e => this.triggerBtn.element.find(e.target).length === 0,
listeners: [{ listeners: [
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW, eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => { action: () => {
this.popup.setValue(this.storeValue); this.popup.setValue(this.storeValue);
this.fireEvent(TimeCombo.EVENT_BEFORE_POPUPVIEW); this.fireEvent(TimeCombo.EVENT_BEFORE_POPUPVIEW);
}, },
}], }
],
ref: _ref => { ref: _ref => {
this.combo = _ref; this.combo = _ref;
}, },
@ -202,7 +233,8 @@ export class TimeCombo extends Single {
left: 0, left: 0,
right: 0, right: 0,
bottom: 0, bottom: 0,
}], }
],
}; };
} }

97
src/widget/time/time.trigger.js

@ -1,15 +1,43 @@
import { shortcut, i18nText, bind, isNotNull, isNotEmptyString, isEqual, AbsoluteLayout, any, print, parseDateTime, isEmptyObject, getDate, isNotEmptyObject } from "@/core"; import {
shortcut,
i18nText,
bind,
isNotNull,
isNotEmptyString,
isEqual,
AbsoluteLayout,
any,
print,
parseDateTime,
isEmptyObject,
getDate,
isNotEmptyObject
} from "@/core";
import { Trigger, Text } from "@/base"; import { Trigger, Text } from "@/base";
import { SignEditor } from "@/case"; import { SignEditor } from "@/case";
@shortcut() @shortcut()
export class TimeTrigger extends Trigger { export class TimeTrigger extends Trigger {
static xtype = "bi.time_trigger" static xtype = "bi.time_trigger";
_const = { _const = {
COMPARE_FORMAT: "%H:%M:%S", COMPARE_FORMAT: "%H:%M:%S",
COMPLETE_COMPARE_FORMAT: "%Y-%M-%d %H:%M:%S %P", COMPLETE_COMPARE_FORMAT: "%Y-%M-%d %H:%M:%S %P",
FORMAT_ARRAY: ["%H:%M:%S", "%I:%M:%S", "%l:%M:%S", "%k:%M:%S", "%l:%M:%S %p", "%l:%M:%S %P", "%H:%M:%S %p", "%H:%M:%S %P", "%l:%M", "%k:%M", "%I:%M", "%H:%M", "%M:%S"], FORMAT_ARRAY: [
"%H:%M:%S",
"%I:%M:%S",
"%l:%M:%S",
"%k:%M:%S",
"%l:%M:%S %p",
"%l:%M:%S %P",
"%H:%M:%S %p",
"%H:%M:%S %P",
"%l:%M",
"%k:%M",
"%I:%M",
"%H:%M",
"%M:%S"
],
DEFAULT_DATE_STRING: "2000-01-01", DEFAULT_DATE_STRING: "2000-01-01",
DEFAULT_HOUR: "00", DEFAULT_HOUR: "00",
}; };
@ -31,7 +59,8 @@ export class TimeTrigger extends Trigger {
return { return {
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
items: [{ items: [
{
el: { el: {
type: SignEditor.xtype, type: SignEditor.xtype,
height: o.height, height: o.height,
@ -47,38 +76,45 @@ export class TimeTrigger extends Trigger {
allowBlank: true, allowBlank: true,
watermark: o.watermark, watermark: o.watermark,
title: bind(this._getTitle, this), title: bind(this._getTitle, this),
listeners: [{ listeners: [
{
eventName: "EVENT_KEY_DOWN", eventName: "EVENT_KEY_DOWN",
action: (...args) => { action: (...args) => {
this.fireEvent("EVENT_KEY_DOWN", ...args); this.fireEvent("EVENT_KEY_DOWN", ...args);
}, },
}, { },
{
eventName: "EVENT_FOCUS", eventName: "EVENT_FOCUS",
action: () => { action: () => {
this.storeTriggerValue = this.getKey(); this.storeTriggerValue = this.getKey();
this.fireEvent("EVENT_FOCUS"); this.fireEvent("EVENT_FOCUS");
}, },
}, { },
{
eventName: "EVENT_BLUR", eventName: "EVENT_BLUR",
action: () => { action: () => {
this.fireEvent("EVENT_BLUR"); this.fireEvent("EVENT_BLUR");
}, },
}, { },
{
eventName: "EVENT_STOP", eventName: "EVENT_STOP",
action: () => { action: () => {
this.fireEvent("EVENT_STOP"); this.fireEvent("EVENT_STOP");
}, },
}, { },
{
eventName: "EVENT_VALID", eventName: "EVENT_VALID",
action: () => { action: () => {
this.fireEvent("EVENT_VALID"); this.fireEvent("EVENT_VALID");
}, },
}, { },
{
eventName: "EVENT_ERROR", eventName: "EVENT_ERROR",
action: () => { action: () => {
this.fireEvent("EVENT_ERROR"); this.fireEvent("EVENT_ERROR");
}, },
}, { },
{
eventName: "EVENT_CONFIRM", eventName: "EVENT_CONFIRM",
action: () => { action: () => {
const value = this.editor.getValue(); const value = this.editor.getValue();
@ -95,23 +131,27 @@ export class TimeTrigger extends Trigger {
} }
this.fireEvent("EVENT_CONFIRM"); this.fireEvent("EVENT_CONFIRM");
}, },
}, { },
{
eventName: "EVENT_START", eventName: "EVENT_START",
action: () => { action: () => {
this.fireEvent("EVENT_START"); this.fireEvent("EVENT_START");
}, },
}, { },
{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: () => { action: () => {
this.fireEvent("EVENT_CHANGE"); this.fireEvent("EVENT_CHANGE");
}, },
}], }
],
}, },
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}, { },
{
el: { el: {
type: Text.xtype, type: Text.xtype,
invisible: o.allowEdit, invisible: o.allowEdit,
@ -123,14 +163,25 @@ export class TimeTrigger extends Trigger {
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}], }
],
}; };
} }
_dateCheck(date) { _dateCheck(date) {
const c = this._const; const c = this._const;
return any(c.FORMAT_ARRAY, (idx, format) => print(parseDateTime(`${c.DEFAULT_DATE_STRING} ${this._getCompleteHMS(date, format)}`, c.COMPLETE_COMPARE_FORMAT), format) === date); return any(
c.FORMAT_ARRAY,
(idx, format) =>
print(
parseDateTime(
`${c.DEFAULT_DATE_STRING} ${this._getCompleteHMS(date, format)}`,
c.COMPLETE_COMPARE_FORMAT
),
format
) === date
);
} }
_getCompleteHMS(str, format) { _getCompleteHMS(str, format) {
@ -153,7 +204,10 @@ export class TimeTrigger extends Trigger {
} }
const date = getDate(); const date = getDate();
return print(getDate(date.getFullYear(), 0, 1, storeValue.hour, storeValue.minute, storeValue.second), this._getFormatString()); return print(
getDate(date.getFullYear(), 0, 1, storeValue.hour, storeValue.minute, storeValue.second),
this._getFormatString()
);
} }
_getFormatString() { _getFormatString() {
@ -163,7 +217,12 @@ export class TimeTrigger extends Trigger {
_formatValue(v) { _formatValue(v) {
const now = getDate(); const now = getDate();
return isNotEmptyObject(v) ? print(getDate(now.getFullYear(), now.getMonth(), now.getDay(), v.hour, v.minute, v.second), this._getFormatString()) : ""; return isNotEmptyObject(v)
? print(
getDate(now.getFullYear(), now.getMonth(), now.getDay(), v.hour, v.minute, v.second),
this._getFormatString()
)
: "";
} }
getKey() { getKey() {

63
src/widget/timeinterval/dateinterval.js

@ -1,10 +1,21 @@
import { shortcut, extend, createWidget, i18nText, print, parseDateTime, checkDateVoid, checkDateLegal, isNotNull } from "@/core"; import {
HorizontalFillLayout,
shortcut,
extend,
createWidget,
i18nText,
print,
parseDateTime,
checkDateVoid,
checkDateLegal,
isNotNull
} from "@/core";
import { Single, Label, Bubbles } from "@/base"; import { Single, Label, Bubbles } from "@/base";
import { DynamicDateCombo } from "../dynamicdate"; import { DynamicDateCombo } from "../dynamicdate";
@shortcut() @shortcut()
export class DateInterval extends Single { export class DateInterval extends Single {
static xtype = "bi.date_interval" static xtype = "bi.date_interval";
constants = { constants = {
height: 24, height: 24,
@ -14,11 +25,10 @@ export class DateInterval extends Single {
timeErrorCls: "time-error", timeErrorCls: "time-error",
}; };
static EVENT_VALID = "EVENT_VALID" static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR" static EVENT_ERROR = "EVENT_ERROR";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW" static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
@ -39,11 +49,13 @@ export class DateInterval extends Single {
this.right = this._createCombo(o.value.end, o.watermark?.end); this.right = this._createCombo(o.value.end, o.watermark?.end);
return { return {
type: "bi.horizontal_fill", type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"], columnSize: ["fill", "", "fill"],
items: [{ items: [
{
el: this.left, el: this.left,
}, { },
{
el: { el: {
type: Label.xtype, type: Label.xtype,
height: o.height, height: o.height,
@ -53,9 +65,11 @@ export class DateInterval extends Single {
this.label = _ref; this.label = _ref;
}, },
}, },
}, { },
{
el: this.right, el: this.right,
}], }
],
}; };
} }
@ -71,12 +85,14 @@ export class DateInterval extends Single {
watermark, watermark,
value: v, value: v,
height: o.height, height: o.height,
listeners: [{ listeners: [
{
eventName: DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, eventName: DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
action: () => { action: () => {
this.fireEvent(DateInterval.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); this.fireEvent(DateInterval.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
}, },
}], }
],
}); });
combo.on(DynamicDateCombo.EVENT_ERROR, () => { combo.on(DynamicDateCombo.EVENT_ERROR, () => {
this._clearTitle(); this._clearTitle();
@ -143,10 +159,12 @@ export class DateInterval extends Single {
} }
_dateCheck(date) { _dateCheck(date) {
return print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date || return (
print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
print(parseDateTime(date, "%Y-%X-%d"), "%Y-%X-%d") === date || print(parseDateTime(date, "%Y-%X-%d"), "%Y-%X-%d") === date ||
print(parseDateTime(date, "%Y-%x-%e"), "%Y-%x-%e") === date || print(parseDateTime(date, "%Y-%x-%e"), "%Y-%x-%e") === date ||
print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date; print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date
);
} }
_checkVoid(obj) { _checkVoid(obj) {
@ -159,15 +177,22 @@ export class DateInterval extends Single {
const smallObj = smallDate.match(/\d+/g), const smallObj = smallDate.match(/\d+/g),
bigObj = bigDate.match(/\d+/g); bigObj = bigDate.match(/\d+/g);
return this._dateCheck(smallDate) && checkDateLegal(smallDate) && this._checkVoid({ return (
this._dateCheck(smallDate) &&
checkDateLegal(smallDate) &&
this._checkVoid({
year: smallObj[0], year: smallObj[0],
month: smallObj[1], month: smallObj[1],
day: smallObj[2], day: smallObj[2],
}) && this._dateCheck(bigDate) && checkDateLegal(bigDate) && this._checkVoid({ }) &&
this._dateCheck(bigDate) &&
checkDateLegal(bigDate) &&
this._checkVoid({
year: bigObj[0], year: bigObj[0],
month: bigObj[1], month: bigObj[1],
day: bigObj[2], day: bigObj[2],
}); })
);
} }
_compare(smallDate, bigDate) { _compare(smallDate, bigDate) {

75
src/widget/timeinterval/timeinterval.js

@ -1,10 +1,21 @@
import { shortcut, extend, createWidget, i18nText, print, parseDateTime, checkDateVoid, checkDateLegal, isNotNull } from "@/core"; import {
HorizontalFillLayout,
shortcut,
extend,
createWidget,
i18nText,
print,
parseDateTime,
checkDateVoid,
checkDateLegal,
isNotNull
} from "@/core";
import { Single, Label, Bubbles } from "@/base"; import { Single, Label, Bubbles } from "@/base";
import { DynamicDateTimeCombo } from "../dynamicdatetime"; import { DynamicDateTimeCombo } from "../dynamicdatetime";
@shortcut() @shortcut()
export class TimeInterval extends Single { export class TimeInterval extends Single {
static xtype = "bi.time_interval" static xtype = "bi.time_interval";
constants = { constants = {
height: 24, height: 24,
@ -14,9 +25,9 @@ export class TimeInterval extends Single {
timeErrorCls: "time-error", timeErrorCls: "time-error",
}; };
static EVENT_VALID = "EVENT_VALID" static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR" static EVENT_ERROR = "EVENT_ERROR";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
@ -37,11 +48,13 @@ export class TimeInterval extends Single {
this.right = this._createCombo(o.value.end, o.watermark?.end); this.right = this._createCombo(o.value.end, o.watermark?.end);
return { return {
type: "bi.horizontal_fill", type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"], columnSize: ["fill", "", "fill"],
items: [{ items: [
{
el: this.left, el: this.left,
}, { },
{
el: { el: {
type: Label.xtype, type: Label.xtype,
height: o.height, height: o.height,
@ -51,9 +64,11 @@ export class TimeInterval extends Single {
this.label = _ref; this.label = _ref;
}, },
}, },
}, { },
{
el: this.right, el: this.right,
}], }
],
}; };
} }
@ -81,7 +96,12 @@ export class TimeInterval extends Single {
Bubbles.hide("error"); Bubbles.hide("error");
const smallDate = this.left.getKey(), const smallDate = this.left.getKey(),
bigDate = this.right.getKey(); bigDate = this.right.getKey();
if (this.left.isValid() && this.right.isValid() && this._check(smallDate, bigDate) && this._compare(smallDate, bigDate)) { if (
this.left.isValid() &&
this.right.isValid() &&
this._check(smallDate, bigDate) &&
this._compare(smallDate, bigDate)
) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text")); this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls); this.element.addClass(this.constants.timeErrorCls);
Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, { Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
@ -98,7 +118,12 @@ export class TimeInterval extends Single {
Bubbles.hide("error"); Bubbles.hide("error");
const smallDate = this.left.getKey(), const smallDate = this.left.getKey(),
bigDate = this.right.getKey(); bigDate = this.right.getKey();
if (this.left.isValid() && this.right.isValid() && this._check(smallDate, bigDate) && this._compare(smallDate, bigDate)) { if (
this.left.isValid() &&
this.right.isValid() &&
this._check(smallDate, bigDate) &&
this._compare(smallDate, bigDate)
) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text")); this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls); this.element.addClass(this.constants.timeErrorCls);
Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, { Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
@ -121,7 +146,12 @@ export class TimeInterval extends Single {
Bubbles.hide("error"); Bubbles.hide("error");
const smallDate = this.left.getKey(), const smallDate = this.left.getKey(),
bigDate = this.right.getKey(); bigDate = this.right.getKey();
if (this.left.isValid() && this.right.isValid() && this._check(smallDate, bigDate) && this._compare(smallDate, bigDate)) { if (
this.left.isValid() &&
this.right.isValid() &&
this._check(smallDate, bigDate) &&
this._compare(smallDate, bigDate)
) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text")); this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls); this.element.addClass(this.constants.timeErrorCls);
this.fireEvent(TimeInterval.EVENT_ERROR); this.fireEvent(TimeInterval.EVENT_ERROR);
@ -136,10 +166,12 @@ export class TimeInterval extends Single {
} }
_dateCheck(date) { _dateCheck(date) {
return print(parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date || return (
print(parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S") === date || print(parseDateTime(date, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%x-%e %H:%M:%S"), "%Y-%x-%e %H:%M:%S") === date || print(parseDateTime(date, "%Y-%x-%e %H:%M:%S"), "%Y-%x-%e %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%X-%e %H:%M:%S"), "%Y-%X-%e %H:%M:%S") === date; print(parseDateTime(date, "%Y-%X-%e %H:%M:%S"), "%Y-%X-%e %H:%M:%S") === date
);
} }
_checkVoid(obj) { _checkVoid(obj) {
@ -152,15 +184,22 @@ export class TimeInterval extends Single {
const smallObj = smallDate.match(/\d+/g), const smallObj = smallDate.match(/\d+/g),
bigObj = bigDate.match(/\d+/g); bigObj = bigDate.match(/\d+/g);
return this._dateCheck(smallDate) && checkDateLegal(smallDate) && this._checkVoid({ return (
this._dateCheck(smallDate) &&
checkDateLegal(smallDate) &&
this._checkVoid({
year: smallObj[0], year: smallObj[0],
month: smallObj[1], month: smallObj[1],
day: smallObj[2], day: smallObj[2],
}) && this._dateCheck(bigDate) && checkDateLegal(bigDate) && this._checkVoid({ }) &&
this._dateCheck(bigDate) &&
checkDateLegal(bigDate) &&
this._checkVoid({
year: bigObj[0], year: bigObj[0],
month: bigObj[1], month: bigObj[1],
day: bigObj[2], day: bigObj[2],
}); })
);
} }
_compare(smallDate, bigDate) { _compare(smallDate, bigDate) {

49
src/widget/timeinterval/timeperiods.js

@ -1,33 +1,37 @@
import { shortcut, extend } from "@/core"; import { HorizontalFillLayout, shortcut, extend } from "@/core";
import { Single, Label } from "@/base"; import { Single, Label } from "@/base";
import { TimeCombo } from "../time"; import { TimeCombo } from "../time";
@shortcut() @shortcut()
export class TimePeriods extends Single { export class TimePeriods extends Single {
static xtype = "bi.time_periods" static xtype = "bi.time_periods";
props = { props = {
extraCls: "bi-time-interval", extraCls: "bi-time-interval",
value: {}, value: {},
}; };
static EVENT_CONFIRM = "EVENT_CONFIRM" static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
render() { render() {
const o = this.options; const o = this.options;
return { return {
type: "bi.horizontal_fill", type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"], columnSize: ["fill", "", "fill"],
items: [{ items: [
el: extend({ {
el: extend(
{
ref: _ref => { ref: _ref => {
this.left = _ref; this.left = _ref;
}, },
}, this._createCombo(o.value.start, o.watermark?.start)), },
}, { this._createCombo(o.value.start, o.watermark?.start)
),
},
{
el: { el: {
type: Label.xtype, type: Label.xtype,
height: o.height, height: o.height,
@ -37,13 +41,18 @@ export class TimePeriods extends Single {
this.label = _ref; this.label = _ref;
}, },
}, },
}, { },
el: extend({ {
el: extend(
{
ref: _ref => { ref: _ref => {
this.right = _ref; this.right = _ref;
}, },
}, this._createCombo(o.value.end, o.watermark?.end)), },
}], this._createCombo(o.value.end, o.watermark?.end)
),
}
],
}; };
} }
@ -55,23 +64,27 @@ export class TimePeriods extends Single {
value: v, value: v,
height: o.height, height: o.height,
watermark, watermark,
listeners: [{ listeners: [
{
eventName: TimeCombo.EVENT_BEFORE_POPUPVIEW, eventName: TimeCombo.EVENT_BEFORE_POPUPVIEW,
action: () => { action: () => {
this.left.hidePopupView(); this.left.hidePopupView();
this.right.hidePopupView(); this.right.hidePopupView();
}, },
}, { },
{
eventName: TimeCombo.EVENT_CHANGE, eventName: TimeCombo.EVENT_CHANGE,
action: () => { action: () => {
this.fireEvent(TimePeriods.EVENT_CHANGE); this.fireEvent(TimePeriods.EVENT_CHANGE);
}, },
}, { },
{
eventName: TimeCombo.EVENT_CONFIRM, eventName: TimeCombo.EVENT_CONFIRM,
action: () => { action: () => {
this.fireEvent(TimePeriods.EVENT_CONFIRM); this.fireEvent(TimePeriods.EVENT_CONFIRM);
}, },
}], }
],
}; };
} }

35
src/widget/year/card.dynamic.year.js

@ -1,3 +1,9 @@
import { checkDateVoid, i18nText, isNotEmptyString, parseDateTime, shortcut, VerticalLayout, Widget } from "@/core";
import { Bubbles, Label } from "@/base";
import { DynamicDateCard } from "@/widget/dynamicdate/dynamicdate.card";
import { DynamicDateHelper } from "@/widget/dynamicdate/dynamicdate.caculate";
import { DynamicDateParamItem } from "@/widget/dynamicdate/dynamicdate.param.item";
/** /**
* 年份展示面板 * 年份展示面板
* *
@ -5,9 +11,6 @@
* @class BI.YearCard * @class BI.YearCard
* @extends BI.Trigger * @extends BI.Trigger
*/ */
import { checkDateVoid, i18nText, isNotEmptyString, parseDateTime, shortcut, VerticalLayout, Widget } from "@/core";
import { Bubbles, Label } from "@/base";
import { DynamicDateCard, DynamicDateHelper, DynamicDateParamItem } from "@/widget";
@shortcut() @shortcut()
export class DynamicYearCard extends Widget { export class DynamicYearCard extends Widget {
@ -15,35 +18,41 @@ export class DynamicYearCard extends Widget {
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
props = { props = {
baseCls: "bi-year-card", baseCls: "bi-year-card",
} };
render() { render() {
return { return {
type: VerticalLayout.xtype, type: VerticalLayout.xtype,
ref: _ref => { ref: _ref => {
this.wrapper = _ref; this.wrapper = _ref;
}, },
items: [{ items: [
{
type: Label.xtype, type: Label.xtype,
text: i18nText("BI-Multi_Date_Relative_Current_Time"), text: i18nText("BI-Multi_Date_Relative_Current_Time"),
textAlign: "left", textAlign: "left",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
}, { },
{
type: DynamicDateParamItem.xtype, type: DynamicDateParamItem.xtype,
ref: _ref => { ref: _ref => {
this.item = _ref; this.item = _ref;
}, },
listeners: [{ listeners: [
{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: () => { action: () => {
this.fireEvent("EVENT_CHANGE"); this.fireEvent("EVENT_CHANGE");
}, },
}, { },
{
eventName: "EVENT_INPUT_CHANGE", eventName: "EVENT_INPUT_CHANGE",
action: () => { action: () => {
Bubbles.hide("dynamic-year-error"); Bubbles.hide("dynamic-year-error");
}, },
}], }
}], ],
}
],
vgap: 10, vgap: 10,
hgap: 10, hgap: 10,
}; };
@ -68,9 +77,7 @@ export class DynamicYearCard extends Widget {
const start = parseDateTime(o.min, "%Y-%X-%d"); const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d"); const end = parseDateTime(o.max, "%Y-%X-%d");
return i18nText("BI-Basic_Year_Range_Error", return i18nText("BI-Basic_Year_Range_Error", start.getFullYear(), end.getFullYear());
start.getFullYear(),
end.getFullYear());
} }
setMinDate(minDate) { setMinDate(minDate) {
@ -94,7 +101,7 @@ export class DynamicYearCard extends Widget {
const value = this.item.getValue(); const value = this.item.getValue();
return { return {
year: (value.offset === 0 ? -value.value : +value.value), year: value.offset === 0 ? -value.value : +value.value,
}; };
} }

26
src/widget/year/card.year.js

@ -1,4 +1,20 @@
import { shortcut, Widget, extend, createWidget, getDate, bind, Controller, isKey, HTapeLayout, CenterAdaptLayout, Layout, each, isNotEmptyString, checkDateVoid, parseInt } from "@/core"; import {
shortcut,
Widget,
extend,
createWidget,
getDate,
bind,
Controller,
isKey,
HTapeLayout,
CenterAdaptLayout,
Layout,
each,
isNotEmptyString,
checkDateVoid,
parseInt
} from "@/core";
import { YearCalendar } from "@/case"; import { YearCalendar } from "@/case";
import { IconButton, Navigation } from "@/base"; import { IconButton, Navigation } from "@/base";
@ -50,9 +66,7 @@ export class StaticYearCard extends Widget {
{ {
eventName: IconButton.EVENT_CHANGE, eventName: IconButton.EVENT_CHANGE,
action: () => { action: () => {
this.navigation.setSelect( this.navigation.setSelect(this.navigation.getSelect() - 1);
this.navigation.getSelect() - 1
);
this._checkLeftValid(); this._checkLeftValid();
this._checkRightValid(); this._checkRightValid();
}, },
@ -70,9 +84,7 @@ export class StaticYearCard extends Widget {
{ {
eventName: IconButton.EVENT_CHANGE, eventName: IconButton.EVENT_CHANGE,
action: () => { action: () => {
this.navigation.setSelect( this.navigation.setSelect(this.navigation.getSelect() + 1);
this.navigation.getSelect() + 1
);
this._checkLeftValid(); this._checkLeftValid();
this._checkRightValid(); this._checkRightValid();
}, },

38
src/widget/year/combo.year.js

@ -1,8 +1,8 @@
import { IconButton, Combo } from "@/base";
import { shortcut, Widget, toPix, getDate, isNotNull, AbsoluteLayout, HorizontalFillLayout, extend } from "@/core"; import { shortcut, Widget, toPix, getDate, isNotNull, AbsoluteLayout, HorizontalFillLayout, extend } from "@/core";
import { DynamicYearTrigger } from "@/widget/year/trigger.year"; import { DynamicYearTrigger } from "@/widget/year/trigger.year";
import { DynamicDateCombo } from "@/widget";
import { Combo } from "@/base";
import { DynamicYearPopup } from "@/widget/year/popup.year"; import { DynamicYearPopup } from "@/widget/year/popup.year";
import { DynamicDateCombo } from "@/widget/dynamicdate/dynamicdate.combo";
@shortcut() @shortcut()
export class DynamicYearCombo extends Widget { export class DynamicYearCombo extends Widget {
@ -14,7 +14,7 @@ export class DynamicYearCombo extends Widget {
static EVENT_FOCUS = "EVENT_FOCUS"; static EVENT_FOCUS = "EVENT_FOCUS";
_const = { _const = {
iconWidth: 24, iconWidth: 24,
} };
props = { props = {
baseCls: "bi-year-combo", baseCls: "bi-year-combo",
@ -23,7 +23,7 @@ export class DynamicYearCombo extends Widget {
maxDate: "2099-12-31", // 最大日期 maxDate: "2099-12-31", // 最大日期
height: 24, height: 24,
supportDynamic: true, supportDynamic: true,
} };
_init() { _init() {
const o = this.options; const o = this.options;
@ -94,21 +94,24 @@ export class DynamicYearCombo extends Widget {
ref: _ref => { ref: _ref => {
this.popup = _ref; this.popup = _ref;
}, },
listeners: [{ listeners: [
{
eventName: DynamicYearPopup.EVENT_CHANGE, eventName: DynamicYearPopup.EVENT_CHANGE,
action: () => { action: () => {
this.setValue(this.popup.getValue()); this.setValue(this.popup.getValue());
this.combo.hideView(); this.combo.hideView();
this.fireEvent(DynamicYearCombo.EVENT_CONFIRM); this.fireEvent(DynamicYearCombo.EVENT_CONFIRM);
}, },
}, { },
{
eventName: DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE, eventName: DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => { action: () => {
this.setValue(); this.setValue();
this.combo.hideView(); this.combo.hideView();
this.fireEvent(DynamicYearCombo.EVENT_CONFIRM); this.fireEvent(DynamicYearCombo.EVENT_CONFIRM);
}, },
}, { },
{
eventName: DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE, eventName: DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE,
action: () => { action: () => {
const date = getDate(); const date = getDate();
@ -116,14 +119,16 @@ export class DynamicYearCombo extends Widget {
this.combo.hideView(); this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM); this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
}, },
}, { },
{
eventName: DynamicYearPopup.BUTTON_OK_EVENT_CHANGE, eventName: DynamicYearPopup.BUTTON_OK_EVENT_CHANGE,
action: () => { action: () => {
this.setValue(this.popup.getValue()); this.setValue(this.popup.getValue());
this.combo.hideView(); this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM); this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
}, },
}], }
],
behaviors: o.behaviors, behaviors: o.behaviors,
min: o.minDate, min: o.minDate,
max: o.maxDate, max: o.maxDate,
@ -141,7 +146,8 @@ export class DynamicYearCombo extends Widget {
BI.createWidget({ BI.createWidget({
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
element: this, element: this,
items: [{ items: [
{
el: { el: {
type: HorizontalFillLayout.xtype, type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"], columnSize: ["", "fill"],
@ -149,9 +155,10 @@ export class DynamicYearCombo extends Widget {
ref: _ref => { ref: _ref => {
this.comboWrapper = _ref; this.comboWrapper = _ref;
}, },
items: [{ items: [
{
el: { el: {
type: "bi.icon_button", type: IconButton.xtype,
cls: "bi-trigger-icon-button date-change-h-font", cls: "bi-trigger-icon-button date-change-h-font",
width: this._const.iconWidth, width: this._const.iconWidth,
height: toPix(o.height, border), height: toPix(o.height, border),
@ -159,13 +166,16 @@ export class DynamicYearCombo extends Widget {
this.changeIcon = _ref; this.changeIcon = _ref;
}, },
}, },
}, this.combo], },
this.combo
],
}, },
top: 0, top: 0,
left: 0, left: 0,
right: 0, right: 0,
bottom: 0, bottom: 0,
}], }
],
}); });
this._checkDynamicValue(o.value); this._checkDynamicValue(o.value);
} }

96
src/widget/year/popup.year.js

@ -1,7 +1,22 @@
import { shortcut, Widget, toPix, i18nText, VerticalLayout, GridLayout, print, getDate, checkDateVoid, createItems } from "@/core"; import {
shortcut,
Widget,
toPix,
i18nText,
VerticalLayout,
GridLayout,
print,
getDate,
checkDateVoid,
createItems
} from "@/core";
import { TextButton, Tab } from "@/base"; import { TextButton, Tab } from "@/base";
import { DynamicDateCombo, DynamicDateHelper, DynamicYearCard, DynamicYearCombo, StaticYearCard } from "@/widget";
import { LinearSegment } from "@/case"; import { LinearSegment } from "@/case";
import { DynamicDateCombo } from "@/widget/dynamicdate/dynamicdate.combo";
import { DynamicDateHelper } from "@/widget/dynamicdate/dynamicdate.caculate";
import { DynamicYearCard } from "@/widget/year/card.dynamic.year";
import { DynamicYearCombo } from "@/widget/year/combo.year";
import { StaticYearCard } from "@/widget/year/card.year";
@shortcut() @shortcut()
export class DynamicYearPopup extends Widget { export class DynamicYearPopup extends Widget {
@ -39,29 +54,21 @@ export class DynamicYearPopup extends Widget {
{ {
type: TextButton.xtype, type: TextButton.xtype,
cls: "bi-split-top bi-high-light", cls: "bi-split-top bi-high-light",
textHeight: toPix( textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
shadow: true, shadow: true,
text: i18nText("BI-Basic_Clear"), text: i18nText("BI-Basic_Clear"),
listeners: [ listeners: [
{ {
eventName: TextButton.EVENT_CHANGE, eventName: TextButton.EVENT_CHANGE,
action: () => { action: () => {
this.fireEvent( this.fireEvent(DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE);
DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE
);
}, },
} }
], ],
}, },
{ {
type: TextButton.xtype, type: TextButton.xtype,
textHeight: toPix( textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
cls: "bi-split-left bi-split-right bi-high-light bi-split-top", cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
shadow: true, shadow: true,
text: i18nText("BI-Basic_Current_Year"), text: i18nText("BI-Basic_Current_Year"),
@ -73,9 +80,7 @@ export class DynamicYearPopup extends Widget {
{ {
eventName: TextButton.EVENT_CHANGE, eventName: TextButton.EVENT_CHANGE,
action: () => { action: () => {
this.fireEvent( this.fireEvent(DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE);
DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE
);
}, },
} }
], ],
@ -83,32 +88,19 @@ export class DynamicYearPopup extends Widget {
{ {
type: TextButton.xtype, type: TextButton.xtype,
cls: "bi-split-top bi-high-light", cls: "bi-split-top bi-high-light",
textHeight: toPix( textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
shadow: true, shadow: true,
text: i18nText("BI-Basic_OK"), text: i18nText("BI-Basic_OK"),
listeners: [ listeners: [
{ {
eventName: TextButton.EVENT_CHANGE, eventName: TextButton.EVENT_CHANGE,
action: () => { action: () => {
const type = const type = this.dateTab.getSelect();
this.dateTab.getSelect(); if (type === DynamicDateCombo.Dynamic) {
if ( this.dynamicPane.checkValidation(true) &&
type === this.fireEvent(BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE);
DynamicDateCombo.Dynamic
) {
this.dynamicPane.checkValidation(
true
) &&
this.fireEvent(
BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE
);
} else { } else {
this.fireEvent( this.fireEvent(DynamicYearPopup.BUTTON_OK_EVENT_CHANGE);
DynamicYearPopup.BUTTON_OK_EVENT_CHANGE
);
} }
}, },
} }
@ -128,9 +120,7 @@ export class DynamicYearPopup extends Widget {
this.yearButton.setValue(i18nText("BI-Basic_Current_Year")); this.yearButton.setValue(i18nText("BI-Basic_Current_Year"));
this.yearButton.setEnable(!this._checkYearValid()); this.yearButton.setEnable(!this._checkYearValid());
} else { } else {
let date = DynamicDateHelper.getCalculation( let date = DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue());
this.dynamicPane.getInputValue()
);
date = print(date, "%Y"); date = print(date, "%Y");
this.yearButton.setValue(date); this.yearButton.setValue(date);
this.yearButton.setEnable(false); this.yearButton.setEnable(false);
@ -141,13 +131,7 @@ export class DynamicYearPopup extends Widget {
const o = this.options; const o = this.options;
const today = getDate(); const today = getDate();
return !!checkDateVoid( return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
today.getFullYear(),
today.getMonth() + 1,
today.getDate(),
o.min,
o.max
)[0];
} }
_getTabJson() { _getTabJson() {
@ -212,9 +196,7 @@ export class DynamicYearPopup extends Widget {
{ {
eventName: StaticYearCard.EVENT_CHANGE, eventName: StaticYearCard.EVENT_CHANGE,
action: () => { action: () => {
this.fireEvent( this.fireEvent(DynamicYearPopup.EVENT_CHANGE);
DynamicYearPopup.EVENT_CHANGE
);
}, },
} }
], ],
@ -238,14 +220,8 @@ export class DynamicYearPopup extends Widget {
} }
case DynamicYearCombo.Dynamic: case DynamicYearCombo.Dynamic:
default: default:
if ( if (this.storeValue && this.storeValue.type === DynamicYearCombo.Dynamic) {
this.storeValue && this.dynamicPane.setValue(this.storeValue.value);
this.storeValue.type ===
DynamicYearCombo.Dynamic
) {
this.dynamicPane.setValue(
this.storeValue.value
);
} else { } else {
this.dynamicPane.setValue({ this.dynamicPane.setValue({
year: 0, year: 0,
@ -264,13 +240,7 @@ export class DynamicYearPopup extends Widget {
const o = this.options; const o = this.options;
const today = getDate(); const today = getDate();
return !!checkDateVoid( return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
today.getFullYear(),
today.getMonth() + 1,
today.getDate(),
o.min,
o.max
)[0];
} }
setMinDate(minDate) { setMinDate(minDate) {

38
src/widget/year/trigger.year.js

@ -1,7 +1,23 @@
import { shortcut, extend, i18nText, bind, createWidget, isPositiveInteger, checkDateVoid, parseDateTime, isNotNull, isNotEmptyString, parseInt, print, getDate, HorizontalFillLayout } from "@/core"; import {
shortcut,
extend,
i18nText,
bind,
createWidget,
isPositiveInteger,
checkDateVoid,
parseDateTime,
isNotNull,
isNotEmptyString,
parseInt,
print,
getDate,
HorizontalFillLayout
} from "@/core";
import { Trigger, TextButton } from "@/base"; import { Trigger, TextButton } from "@/base";
import { SignEditor, TriggerIconButton } from "@/case"; import { SignEditor, TriggerIconButton } from "@/case";
import { DynamicDateCombo, DynamicDateHelper } from "@/widget"; import { DynamicDateCombo } from "@/widget/dynamicdate/dynamicdate.combo";
import { DynamicDateHelper } from "@/widget/dynamicdate/dynamicdate.caculate";
@shortcut() @shortcut()
export class DynamicYearTrigger extends Trigger { export class DynamicYearTrigger extends Trigger {
@ -41,11 +57,7 @@ export class DynamicYearTrigger extends Trigger {
type: SignEditor.xtype, type: SignEditor.xtype,
simple: o.simple, simple: o.simple,
height: o.height, height: o.height,
validationChecker: v => ( validationChecker: v => v === "" || (isPositiveInteger(v) && !checkDateVoid(v, 1, 1, o.min, o.max)[0]),
v === "" ||
(isPositiveInteger(v) &&
!checkDateVoid(v, 1, 1, o.min, o.max)[0])
),
quitChecker: () => false, quitChecker: () => false,
hgap: c.hgap, hgap: c.hgap,
vgap: c.vgap, vgap: c.vgap,
@ -56,11 +68,7 @@ export class DynamicYearTrigger extends Trigger {
const start = parseDateTime(o.min, "%Y-%X-%d"); const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d"); const end = parseDateTime(o.max, "%Y-%X-%d");
return i18nText( return i18nText("BI-Basic_Year_Range_Error", start.getFullYear(), end.getFullYear());
"BI-Basic_Year_Range_Error",
start.getFullYear(),
end.getFullYear()
);
} }
return i18nText("BI-Year_Trigger_Invalid_Text"); return i18nText("BI-Year_Trigger_Invalid_Text");
@ -137,9 +145,7 @@ export class DynamicYearTrigger extends Trigger {
value += value +=
Math.abs(obj.year) + Math.abs(obj.year) +
i18nText("BI-Basic_Year") + i18nText("BI-Basic_Year") +
(obj.year < 0 (obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
? i18nText("BI-Basic_Front")
: i18nText("BI-Basic_Behind"));
} }
return value; return value;
@ -166,7 +172,7 @@ export class DynamicYearTrigger extends Trigger {
date = DynamicDateHelper.getCalculation(value); date = DynamicDateHelper.getCalculation(value);
const dateStr = BI.print(date, "%Y"); const dateStr = BI.print(date, "%Y");
return BI.isEmptyString(text) ? dateStr : (`${text}:${dateStr}`); return BI.isEmptyString(text) ? dateStr : `${text}:${dateStr}`;
} }
case DynamicDateCombo.Static: case DynamicDateCombo.Static:

30
src/widget/yearinterval/yearinterval.js

@ -1,4 +1,14 @@
import { shortcut, HorizontalFillLayout, createWidget, i18nText, print, parseDateTime, checkDateVoid, isNotNull, checkDateLegal } from "@/core"; import {
shortcut,
HorizontalFillLayout,
createWidget,
i18nText,
print,
parseDateTime,
checkDateVoid,
isNotNull,
checkDateLegal
} from "@/core";
import { Single, Label, Bubbles } from "@/base"; import { Single, Label, Bubbles } from "@/base";
import { DynamicYearCombo } from "../year"; import { DynamicYearCombo } from "../year";
@ -116,10 +126,7 @@ export class YearInterval extends Single {
} }
_dateCheck(date) { _dateCheck(date) {
return ( return print(parseDateTime(date, "%Y"), "%Y") === date || print(parseDateTime(date, "%Y"), "%Y") === date;
print(parseDateTime(date, "%Y"), "%Y") === date ||
print(parseDateTime(date, "%Y"), "%Y") === date
);
} }
_checkVoid(obj) { _checkVoid(obj) {
@ -164,9 +171,7 @@ export class YearInterval extends Single {
smallDate = print(parseDateTime(smallDate, "%Y"), "%Y"); smallDate = print(parseDateTime(smallDate, "%Y"), "%Y");
bigDate = print(parseDateTime(bigDate, "%Y"), "%Y"); bigDate = print(parseDateTime(bigDate, "%Y"), "%Y");
return ( return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate;
isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate
);
} }
_setTitle(v) { _setTitle(v) {
@ -189,14 +194,9 @@ export class YearInterval extends Single {
) { ) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text")); this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls); this.element.addClass(this.constants.timeErrorCls);
Bubbles.show( Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
"error",
i18nText("BI-Time_Interval_Error_Text"),
this,
{
offsetStyle: "center", offsetStyle: "center",
} });
);
this.fireEvent(YearInterval.EVENT_ERROR); this.fireEvent(YearInterval.EVENT_ERROR);
} else { } else {
this._clearTitle(); this._clearTitle();

42
src/widget/yearmonth/card.dynamic.yearmonth.js

@ -53,9 +53,7 @@ export class DynamicYearMonthCard extends Widget {
{ {
eventName: "EVENT_INPUT_CHANGE", eventName: "EVENT_INPUT_CHANGE",
action: () => { action: () => {
Bubbles.hide( Bubbles.hide("dynamic-year-month-error");
"dynamic-year-month-error"
);
}, },
} }
], ],
@ -78,9 +76,7 @@ export class DynamicYearMonthCard extends Widget {
{ {
eventName: "EVENT_INPUT_CHANGE", eventName: "EVENT_INPUT_CHANGE",
action: () => { action: () => {
Bubbles.hide( Bubbles.hide("dynamic-year-month-error");
"dynamic-year-month-error"
);
}, },
} }
], ],
@ -109,29 +105,19 @@ export class DynamicYearMonthCard extends Widget {
_checkDate(obj) { _checkDate(obj) {
const o = this.options; const o = this.options;
const date = DynamicDateHelper.getCalculation( const date = DynamicDateHelper.getCalculation(extend(this._getValue(), this._digestDateTypeValue(obj)));
extend(this._getValue(), this._digestDateTypeValue(obj))
);
return !checkDateVoid( return !checkDateVoid(date.getFullYear(), date.getMonth() + 1, date.getDate(), o.min, o.max)[0];
date.getFullYear(),
date.getMonth() + 1,
date.getDate(),
o.min,
o.max
)[0];
} }
_digestDateTypeValue(value) { _digestDateTypeValue(value) {
const valueMap = {}; const valueMap = {};
switch (value.dateType) { switch (value.dateType) {
case DynamicDateCard.TYPE.YEAR: case DynamicDateCard.TYPE.YEAR:
valueMap.year = valueMap.year = value.offset === 0 ? -value.value : +value.value;
value.offset === 0 ? -value.value : +value.value;
break; break;
case DynamicDateCard.TYPE.MONTH: case DynamicDateCard.TYPE.MONTH:
valueMap.month = valueMap.month = value.offset === 0 ? -value.value : +value.value;
value.offset === 0 ? -value.value : +value.value;
break; break;
default: default:
break; break;
@ -162,12 +148,8 @@ export class DynamicYearMonthCard extends Widget {
setValue(v) { setValue(v) {
v = v || { year: 0, month: 0 }; v = v || { year: 0, month: 0 };
this.year.setValue( this.year.setValue(this._createValue(DynamicDateCard.TYPE.YEAR, v.year));
this._createValue(DynamicDateCard.TYPE.YEAR, v.year) this.month.setValue(this._createValue(DynamicDateCard.TYPE.MONTH, v.month));
);
this.month.setValue(
this._createValue(DynamicDateCard.TYPE.MONTH, v.month)
);
} }
_getValue() { _getValue() {
@ -199,13 +181,7 @@ export class DynamicYearMonthCard extends Widget {
invalid = !this._checkDate(this._getValue()); invalid = !this._checkDate(this._getValue());
errorText = this._getErrorText(); errorText = this._getErrorText();
} }
invalid && invalid && show && Bubbles.show("dynamic-year-month-error", errorText, this.wrapper);
show &&
Bubbles.show(
"dynamic-year-month-error",
errorText,
this.wrapper
);
return !invalid; return !invalid;
} }

20
src/widget/yearmonth/card.static.yearmonth.js

@ -30,7 +30,8 @@ export class StaticYearMonthCard extends Widget {
const month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12]; const month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12];
const items = chunk(month, 2); const items = chunk(month, 2);
return map(items, (i, item) => map(item, (j, td) => { return map(items, (i, item) =>
map(item, (j, td) => {
return { return {
type: TextItem.xtype, type: TextItem.xtype,
cls: "bi-list-item-select", cls: "bi-list-item-select",
@ -46,7 +47,8 @@ export class StaticYearMonthCard extends Widget {
this.monthMap[j === 0 ? i : i + 6] = _ref; this.monthMap[j === 0 ? i : i + 6] = _ref;
}, },
}; };
})); })
);
} }
render() { render() {
@ -96,9 +98,7 @@ export class StaticYearMonthCard extends Widget {
columns: 2, columns: 2,
rows: 6, rows: 6,
columnSize: [1 / 2, 1 / 2], columnSize: [1 / 2, 1 / 2],
rowSize: rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1,
BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT +
1,
} }
) )
), ),
@ -115,9 +115,7 @@ export class StaticYearMonthCard extends Widget {
action: () => { action: () => {
this.selectedYear = this.yearPicker.getValue(); this.selectedYear = this.yearPicker.getValue();
this.selectedMonth = this.month.getValue()[0]; this.selectedMonth = this.month.getValue()[0];
this.fireEvent( this.fireEvent(StaticYearMonthCard.EVENT_CHANGE);
StaticYearMonthCard.EVENT_CHANGE
);
}, },
} }
], ],
@ -194,11 +192,7 @@ export class StaticYearMonthCard extends Widget {
const newObj = {}; const newObj = {};
newObj.year = obj.year || 0; newObj.year = obj.year || 0;
newObj.month = obj.month || 0; newObj.month = obj.month || 0;
if ( if (newObj.year === 0 || newObj.month === 0 || checkDateVoid(newObj.year, newObj.month, 1, o.min, o.max)[0]) {
newObj.year === 0 ||
newObj.month === 0 ||
checkDateVoid(newObj.year, newObj.month, 1, o.min, o.max)[0]
) {
const year = newObj.year || getDate().getFullYear(); const year = newObj.year || getDate().getFullYear();
this.selectedYear = year; this.selectedYear = year;
this.selectedMonth = ""; this.selectedMonth = "";

35
src/widget/yearmonth/combo.yearmonth.js

@ -47,7 +47,7 @@ export class DynamicYearMonthCombo extends Single {
this.storeTriggerValue = ""; this.storeTriggerValue = "";
const border = o.simple ? 1 : 2; const border = o.simple ? 1 : 2;
this.trigger = createWidget({ this.trigger = createWidget({
type: "bi.dynamic_year_month_trigger", type: DynamicYearMonthTrigger.xtype,
simple: o.simple, simple: o.simple,
min: o.minDate, min: o.minDate,
max: o.maxDate, max: o.maxDate,
@ -103,7 +103,7 @@ export class DynamicYearMonthCombo extends Single {
minWidth: 100, minWidth: 100,
stopPropagation: false, stopPropagation: false,
el: { el: {
type: "bi.dynamic_year_month_popup", type: DynamicYearMonthPopup.xtype,
width: o.isNeedAdjustWidth ? o.width : undefined, width: o.isNeedAdjustWidth ? o.width : undefined,
supportDynamic: o.supportDynamic, supportDynamic: o.supportDynamic,
ref: _ref => { ref: _ref => {
@ -115,26 +115,20 @@ export class DynamicYearMonthCombo extends Single {
action: () => { action: () => {
this.setValue(this.popup.getValue()); this.setValue(this.popup.getValue());
this.combo.hideView(); this.combo.hideView();
this.fireEvent( this.fireEvent(DynamicYearMonthCombo.EVENT_CONFIRM);
DynamicYearMonthCombo.EVENT_CONFIRM
);
}, },
}, },
{ {
eventName: eventName: DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE,
DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => { action: () => {
this.setValue(); this.setValue();
this.comboWrapper.element.removeClass("error"); this.comboWrapper.element.removeClass("error");
this.combo.hideView(); this.combo.hideView();
this.fireEvent( this.fireEvent(DynamicYearMonthCombo.EVENT_CONFIRM);
DynamicYearMonthCombo.EVENT_CONFIRM
);
}, },
}, },
{ {
eventName: eventName: DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE,
DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE,
action: () => { action: () => {
const date = getDate(); const date = getDate();
this.setValue({ this.setValue({
@ -149,8 +143,7 @@ export class DynamicYearMonthCombo extends Single {
}, },
}, },
{ {
eventName: eventName: DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE,
DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE,
action: () => { action: () => {
const value = this.popup.getValue(); const value = this.popup.getValue();
if (this._checkValue(value)) { if (this._checkValue(value)) {
@ -183,11 +176,7 @@ export class DynamicYearMonthCombo extends Single {
el: { el: {
type: HorizontalFillLayout.xtype, type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"], columnSize: ["", "fill"],
cls: cls: `${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
`${o.simple
? "bi-border-bottom"
: "bi-border bi-border-radius"
} bi-focus-shadow`,
ref: _ref => { ref: _ref => {
this.comboWrapper = _ref; this.comboWrapper = _ref;
}, },
@ -239,13 +228,7 @@ export class DynamicYearMonthCombo extends Single {
case DynamicDateCombo.Static: { case DynamicDateCombo.Static: {
const value = v.value || {}; const value = v.value || {};
return !checkDateVoid( return !checkDateVoid(value.year, value.month, 1, o.minDate, o.maxDate)[0];
value.year,
value.month,
1,
o.minDate,
o.maxDate
)[0];
} }
default: default:
return true; return true;

79
src/widget/yearmonth/popup.yearmonth.js

@ -13,11 +13,13 @@ import {
import { DynamicYearMonthCombo } from "./combo.yearmonth"; import { DynamicYearMonthCombo } from "./combo.yearmonth";
import { TextButton, Tab } from "@/base"; import { TextButton, Tab } from "@/base";
import { DynamicDateCombo, DynamicDateHelper } from "../dynamicdate"; import { DynamicDateCombo, DynamicDateHelper } from "../dynamicdate";
// import { DynamicYearCombo } from "../year/combo.year"; import { DynamicYearCombo } from "../year/combo.year";
import { StaticYearMonthCard } from "./card.static.yearmonth"; import { StaticYearMonthCard } from "./card.static.yearmonth";
import { LinearSegment } from "@/case"; import { LinearSegment } from "@/case";
import { DynamicYearMonthCard } from "./card.dynamic.yearmonth"; import { DynamicYearMonthCard } from "./card.dynamic.yearmonth";
//
@shortcut() @shortcut()
export class DynamicYearMonthPopup extends Widget { export class DynamicYearMonthPopup extends Widget {
static xtype = "bi.dynamic_year_month_popup"; static xtype = "bi.dynamic_year_month_popup";
@ -54,19 +56,14 @@ export class DynamicYearMonthPopup extends Widget {
{ {
type: TextButton.xtype, type: TextButton.xtype,
cls: "bi-split-top bi-high-light", cls: "bi-split-top bi-high-light",
textHeight: toPix( textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
shadow: true, shadow: true,
text: i18nText("BI-Basic_Clear"), text: i18nText("BI-Basic_Clear"),
listeners: [ listeners: [
{ {
eventName: TextButton.EVENT_CHANGE, eventName: TextButton.EVENT_CHANGE,
action: () => { action: () => {
this.fireEvent( this.fireEvent(DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE);
DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE
);
}, },
} }
], ],
@ -74,10 +71,7 @@ export class DynamicYearMonthPopup extends Widget {
{ {
type: TextButton.xtype, type: TextButton.xtype,
cls: "bi-split-left bi-split-right bi-high-light bi-split-top", cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
textHeight: toPix( textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
shadow: true, shadow: true,
text: i18nText("BI-Basic_Current_Month"), text: i18nText("BI-Basic_Current_Month"),
disabled: this._checkTodayValid(), disabled: this._checkTodayValid(),
@ -88,9 +82,7 @@ export class DynamicYearMonthPopup extends Widget {
{ {
eventName: TextButton.EVENT_CHANGE, eventName: TextButton.EVENT_CHANGE,
action: () => { action: () => {
this.fireEvent( this.fireEvent(DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE);
DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE
);
}, },
} }
], ],
@ -98,32 +90,19 @@ export class DynamicYearMonthPopup extends Widget {
{ {
type: TextButton.xtype, type: TextButton.xtype,
cls: "bi-split-top bi-high-light", cls: "bi-split-top bi-high-light",
textHeight: toPix( textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
shadow: true, shadow: true,
text: i18nText("BI-Basic_OK"), text: i18nText("BI-Basic_OK"),
listeners: [ listeners: [
{ {
eventName: TextButton.EVENT_CHANGE, eventName: TextButton.EVENT_CHANGE,
action: () => { action: () => {
const type = const type = this.dateTab.getSelect();
this.dateTab.getSelect(); if (type === DynamicDateCombo.Dynamic) {
if ( this.dynamicPane.checkValidation(true) &&
type === this.fireEvent(DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE);
DynamicDateCombo.Dynamic
) {
this.dynamicPane.checkValidation(
true
) &&
this.fireEvent(
DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE
);
} else { } else {
this.fireEvent( this.fireEvent(DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE);
DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE
);
} }
}, },
} }
@ -143,9 +122,7 @@ export class DynamicYearMonthPopup extends Widget {
this.textButton.setValue(i18nText("BI-Basic_Current_Month")); this.textButton.setValue(i18nText("BI-Basic_Current_Month"));
this.textButton.setEnable(!this._checkTodayValid()); this.textButton.setEnable(!this._checkTodayValid());
} else { } else {
let date = DynamicDateHelper.getCalculation( let date = DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue());
this.dynamicPane.getInputValue()
);
date = print(date, "%Y-%x"); date = print(date, "%Y-%x");
this.textButton.setValue(date); this.textButton.setValue(date);
this.textButton.setEnable(false); this.textButton.setEnable(false);
@ -156,13 +133,7 @@ export class DynamicYearMonthPopup extends Widget {
const o = this.options; const o = this.options;
const today = getDate(); const today = getDate();
return !!checkDateVoid( return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
today.getFullYear(),
today.getMonth() + 1,
today.getDate(),
o.min,
o.max
)[0];
} }
_getTabJson() { _getTabJson() {
@ -228,9 +199,7 @@ export class DynamicYearMonthPopup extends Widget {
{ {
eventName: StaticYearMonthCard.EVENT_CHANGE, eventName: StaticYearMonthCard.EVENT_CHANGE,
action: () => { action: () => {
this.fireEvent( this.fireEvent(DynamicYearMonthPopup.EVENT_CHANGE);
DynamicYearMonthPopup.EVENT_CHANGE
);
}, },
} }
], ],
@ -247,9 +216,7 @@ export class DynamicYearMonthPopup extends Widget {
const v = this.dateTab.getSelect(); const v = this.dateTab.getSelect();
switch (v) { switch (v) {
case BI.DynamicYearCombo.Static: { case BI.DynamicYearCombo.Static: {
const date = DynamicDateHelper.getCalculation( const date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
this.dynamicPane.getValue()
);
this.year.setValue({ this.year.setValue({
year: date.getFullYear(), year: date.getFullYear(),
month: date.getMonth() + 1, month: date.getMonth() + 1,
@ -259,14 +226,8 @@ export class DynamicYearMonthPopup extends Widget {
} }
case BI.DynamicYearCombo.Dynamic: case BI.DynamicYearCombo.Dynamic:
default: default:
if ( if (this.storeValue && this.storeValue.type === BI.DynamicYearCombo.Dynamic) {
this.storeValue && this.dynamicPane.setValue(this.storeValue.value);
this.storeValue.type ===
BI.DynamicYearCombo.Dynamic
) {
this.dynamicPane.setValue(
this.storeValue.value
);
} else { } else {
this.dynamicPane.setValue({ this.dynamicPane.setValue({
year: 0, year: 0,
@ -303,8 +264,6 @@ export class DynamicYearMonthPopup extends Widget {
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); this.dateTab.setSelect(type);
switch (type) { switch (type) {
case DynamicDateCombo.Dynamic: case DynamicDateCombo.Dynamic:

44
src/widget/yearmonth/trigger.yearmonth.js

@ -120,18 +120,12 @@ export class DynamicYearMonthTrigger extends Trigger {
let month = this.monthEditor.getValue(); let month = this.monthEditor.getValue();
if (isEmptyString(month)) { if (isEmptyString(month)) {
month = month =
parseInt(v, 10) === parseInt(v, 10) === parseDateTime(o.min, "%Y-%X-%d").getFullYear()
parseDateTime(o.min, "%Y-%X-%d").getFullYear() ? parseDateTime(o.min, "%Y-%X-%d").getMonth() + 1
? parseDateTime(o.min, "%Y-%X-%d").getMonth() +
1
: 1; : 1;
} }
return ( return v === "" || (isPositiveInteger(v) && !checkDateVoid(v, month, 1, o.min, o.max)[0]);
v === "" ||
(isPositiveInteger(v) &&
!checkDateVoid(v, month, 1, o.min, o.max)[0])
);
} }
const year = this.yearEditor.getValue(); const year = this.yearEditor.getValue();
@ -142,13 +136,7 @@ export class DynamicYearMonthTrigger extends Trigger {
v <= 12 && v <= 12 &&
(isEmptyString(year) (isEmptyString(year)
? true ? true
: !checkDateVoid( : !checkDateVoid(this.yearEditor.getValue(), v, 1, o.min, o.max)[0]))
this.yearEditor.getValue(),
v,
1,
o.min,
o.max
)[0]))
); );
}, },
quitChecker: () => false, quitChecker: () => false,
@ -156,11 +144,7 @@ export class DynamicYearMonthTrigger extends Trigger {
errorText: v => { errorText: v => {
const year = isYear ? v : this.yearEditor.getValue(); const year = isYear ? v : this.yearEditor.getValue();
const month = isYear ? this.monthEditor.getValue() : v; const month = isYear ? this.monthEditor.getValue() : v;
if ( if (!isPositiveInteger(year) || !isPositiveInteger(month) || month > 12) {
!isPositiveInteger(year) ||
!isPositiveInteger(month) ||
month > 12
) {
return i18nText("BI-Year_Trigger_Invalid_Text"); return i18nText("BI-Year_Trigger_Invalid_Text");
} }
@ -260,9 +244,7 @@ export class DynamicYearMonthTrigger extends Trigger {
type: DynamicDateCombo.Static, type: DynamicDateCombo.Static,
value: { value: {
year: this.yearEditor.getValue(), year: this.yearEditor.getValue(),
month: isEmptyString(this.monthEditor.getValue()) month: isEmptyString(this.monthEditor.getValue()) ? "" : monthValue,
? ""
: monthValue,
}, },
}; };
} }
@ -270,11 +252,7 @@ export class DynamicYearMonthTrigger extends Trigger {
_yearCheck(v) { _yearCheck(v) {
const date = print(parseDateTime(v, "%Y-%X-%d"), "%Y-%X-%d"); const date = print(parseDateTime(v, "%Y-%X-%d"), "%Y-%X-%d");
return ( return print(parseDateTime(v, "%Y"), "%Y") === v && date >= this.options.min && date <= this.options.max;
print(parseDateTime(v, "%Y"), "%Y") === v &&
date >= this.options.min &&
date <= this.options.max
);
} }
_autoSwitch(editor) { _autoSwitch(editor) {
@ -294,17 +272,13 @@ export class DynamicYearMonthTrigger extends Trigger {
value += value +=
Math.abs(obj.year) + Math.abs(obj.year) +
i18nText("BI-Basic_Year") + i18nText("BI-Basic_Year") +
(obj.year < 0 (obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
? i18nText("BI-Basic_Front")
: i18nText("BI-Basic_Behind"));
} }
if (isNotNull(obj.month) && parseInt(obj.month) !== 0) { if (isNotNull(obj.month) && parseInt(obj.month) !== 0) {
value += value +=
Math.abs(obj.month) + Math.abs(obj.month) +
i18nText("BI-Basic_Month") + i18nText("BI-Basic_Month") +
(obj.month < 0 (obj.month < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
? i18nText("BI-Basic_Front")
: i18nText("BI-Basic_Behind"));
} }
return value; return value;

19
src/widget/yearmonthinterval/yearmonthinterval.js

@ -69,7 +69,7 @@ export class YearMonthInterval extends Single {
_createCombo(v, watermark) { _createCombo(v, watermark) {
const o = this.options; const o = this.options;
const combo = createWidget({ const combo = createWidget({
type: "bi.dynamic_year_month_combo", type: DynamicYearMonthCombo.xtype,
supportDynamic: o.supportDynamic, supportDynamic: o.supportDynamic,
height: o.height, height: o.height,
minDate: o.minDate, minDate: o.minDate,
@ -81,9 +81,7 @@ export class YearMonthInterval extends Single {
{ {
eventName: DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW, eventName: DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW,
action: () => { action: () => {
this.fireEvent( this.fireEvent(YearMonthInterval.EVENT_BEFORE_POPUPVIEW);
YearMonthInterval.EVENT_BEFORE_POPUPVIEW
);
}, },
} }
], ],
@ -175,9 +173,7 @@ export class YearMonthInterval extends Single {
smallDate = print(parseDateTime(smallDate, "%Y-%X"), "%Y-%X"); smallDate = print(parseDateTime(smallDate, "%Y-%X"), "%Y-%X");
bigDate = print(parseDateTime(bigDate, "%Y-%X"), "%Y-%X"); bigDate = print(parseDateTime(bigDate, "%Y-%X"), "%Y-%X");
return ( return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate;
isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate
);
} }
_setTitle(v) { _setTitle(v) {
@ -200,14 +196,9 @@ export class YearMonthInterval extends Single {
) { ) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text")); this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls); this.element.addClass(this.constants.timeErrorCls);
Bubbles.show( Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
"error",
i18nText("BI-Time_Interval_Error_Text"),
this,
{
offsetStyle: "center", offsetStyle: "center",
} });
);
this.fireEvent(YearMonthInterval.EVENT_ERROR); this.fireEvent(YearMonthInterval.EVENT_ERROR);
} else { } else {
this._clearTitle(); this._clearTitle();

35
src/widget/yearquarter/combo.yearquarter.js

@ -50,7 +50,7 @@ export class DynamicYearQuarterCombo extends Widget {
const border = o.simple ? 1 : 2; const border = o.simple ? 1 : 2;
this.storeTriggerValue = ""; this.storeTriggerValue = "";
this.trigger = createWidget({ this.trigger = createWidget({
type: "bi.dynamic_year_quarter_trigger", type: DynamicYearQuarterTrigger.xtype,
simple: o.simple, simple: o.simple,
min: o.minDate, min: o.minDate,
max: o.maxDate, max: o.maxDate,
@ -106,7 +106,7 @@ export class DynamicYearQuarterCombo extends Widget {
minWidth: 85, minWidth: 85,
stopPropagation: false, stopPropagation: false,
el: { el: {
type: "bi.dynamic_year_quarter_popup", type: DynamicYearQuarterPopup.xtype,
width: o.isNeedAdjustWidth ? o.width : undefined, width: o.isNeedAdjustWidth ? o.width : undefined,
supportDynamic: o.supportDynamic, supportDynamic: o.supportDynamic,
ref: _ref => { ref: _ref => {
@ -118,26 +118,20 @@ export class DynamicYearQuarterCombo extends Widget {
action: () => { action: () => {
this.setValue(this.popup.getValue()); this.setValue(this.popup.getValue());
this.combo.hideView(); this.combo.hideView();
this.fireEvent( this.fireEvent(DynamicYearQuarterCombo.EVENT_CONFIRM);
DynamicYearQuarterCombo.EVENT_CONFIRM
);
}, },
}, },
{ {
eventName: eventName: DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE,
DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => { action: () => {
this.setValue(); this.setValue();
this.comboWrapper.element.removeClass("error"); this.comboWrapper.element.removeClass("error");
this.combo.hideView(); this.combo.hideView();
this.fireEvent( this.fireEvent(DynamicYearQuarterCombo.EVENT_CONFIRM);
DynamicYearQuarterCombo.EVENT_CONFIRM
);
}, },
}, },
{ {
eventName: eventName: DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE,
DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE,
action: () => { action: () => {
const date = getDate(); const date = getDate();
this.setValue({ this.setValue({
@ -152,8 +146,7 @@ export class DynamicYearQuarterCombo extends Widget {
}, },
}, },
{ {
eventName: eventName: DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE,
DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE,
action: () => { action: () => {
const value = this.popup.getValue(); const value = this.popup.getValue();
if (this._checkValue(value)) { if (this._checkValue(value)) {
@ -186,11 +179,7 @@ export class DynamicYearQuarterCombo extends Widget {
el: { el: {
type: HorizontalFillLayout.xtype, type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"], columnSize: ["", "fill"],
cls: cls: `${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
`${o.simple
? "bi-border-bottom"
: "bi-border bi-border-radius"
} bi-focus-shadow`,
ref: _ref => { ref: _ref => {
this.comboWrapper = _ref; this.comboWrapper = _ref;
}, },
@ -243,13 +232,7 @@ export class DynamicYearQuarterCombo extends Widget {
case DynamicDateCombo.Static: case DynamicDateCombo.Static:
value = v.value || {}; value = v.value || {};
return !checkDateVoid( return !checkDateVoid(value.year, (value.quarter - 1) * 3 + 1, 1, o.minDate, o.maxDate)[0];
value.year,
(value.quarter - 1) * 3 + 1,
1,
o.minDate,
o.maxDate
)[0];
default: default:
return true; return true;
} }

Loading…
Cancel
Save