Browse Source

Pull request #3412: 无jira refact:widget搞完了

Merge in VISUAL/fineui from ~TREECAT/fineui:es6 to es6

* commit '12a77ed9bcd9e484f3d8c0578e3582122b170cdb':
  无jira refact:多了个import
  无jira refact:widget搞完了
es6
treecat-罗群 1 year ago
parent
commit
84520732a9
  1. 14
      src/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.js
  2. 37
      src/component/form/form.field.js
  3. 13
      src/component/form/form.js
  4. 2
      src/widget/date/calendar/picker.date.js
  5. 4
      src/widget/date/calendar/picker.year.js
  6. 14
      src/widget/datetime/datetime.combo.js
  7. 8
      src/widget/datetimepane/card.static.datetimepane.js
  8. 54
      src/widget/dynamicdate/dynamicdate.combo.js
  9. 50
      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. 111
      src/widget/multitree/multi.tree.insert.combo.js
  14. 117
      src/widget/multitree/multi.tree.list.combo.js
  15. 24
      src/widget/multitree/multi.tree.popup.js
  16. 17
      src/widget/multitree/trigger/multi.tree.button.checkselected.js
  17. 38
      src/widget/multitree/trigger/multi.tree.search.insert.pane.js
  18. 4
      src/widget/multitree/trigger/multi.tree.search.pane.js
  19. 19
      src/widget/multitree/trigger/searcher.list.multi.tree.js
  20. 31
      src/widget/multitree/trigger/searcher.multi.tree.js
  21. 110
      src/widget/numbereditor/number.editor.js
  22. 373
      src/widget/numberinterval/numberinterval.js
  23. 122
      src/widget/numberinterval/singleeditor/single.editor.js
  24. 10
      src/widget/searchmultitextvaluecombo/index.js
  25. 17
      src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js
  26. 15
      src/widget/searchmultitextvaluecombo/multitextvalue.combo.trigger.search.js
  27. 2
      src/widget/searchmultitextvaluecombo/multitextvalue.loader.search.js
  28. 2
      src/widget/searchmultitextvaluecombo/multitextvalue.popup.view.search.js
  29. 7
      src/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue.js
  30. 12
      src/widget/selecttree/selecttree.combo.js
  31. 10
      src/widget/selecttree/selecttree.expander.js
  32. 17
      src/widget/selecttree/selecttree.popup.js
  33. 54
      src/widget/singleselect/search/singleselect.search.loader.js
  34. 14
      src/widget/singleselect/search/singleselect.search.pane.insert.js
  35. 2
      src/widget/singleselect/search/singleselect.search.pane.js
  36. 128
      src/widget/singleselect/singleselect.combo.js
  37. 52
      src/widget/singleselect/singleselect.insert.combo.js
  38. 6
      src/widget/singleselect/singleselect.list.js
  39. 52
      src/widget/singleselect/singleselect.loader.js
  40. 3
      src/widget/singleselect/singleselect.popup.view.js
  41. 19
      src/widget/singleselect/singleselectlist.insert.js
  42. 12
      src/widget/singleselect/trigger/editor.singleselect.js
  43. 53
      src/widget/singleselect/trigger/searcher.singleselect.js
  44. 2
      src/widget/singleslider/button/editor.sign.text.js
  45. 2
      src/widget/singleslider/button/iconbutton.slider.js
  46. 10
      src/widget/singleslider/index.js
  47. 66
      src/widget/singleslider/singleslider.js
  48. 39
      src/widget/singleslider/singleslider.label.js
  49. 37
      src/widget/singleslider/singleslider.normal.js
  50. 9
      src/widget/singletree/singletree.combo.js
  51. 9
      src/widget/singletree/singletree.popup.js
  52. 10
      src/widget/singletree/singletree.trigger.js
  53. 12
      src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js
  54. 4
      src/widget/textvaluedownlistcombo/index.js
  55. 2
      src/widget/textvaluedownlistcombo/trigger.textvaluedownlist.js
  56. 145
      src/widget/time/datetime.popup.js
  57. 344
      src/widget/time/time.combo.js
  58. 259
      src/widget/time/time.trigger.js
  59. 111
      src/widget/timeinterval/dateinterval.js
  60. 115
      src/widget/timeinterval/timeinterval.js
  61. 99
      src/widget/timeinterval/timeperiods.js
  62. 67
      src/widget/year/card.dynamic.year.js
  63. 36
      src/widget/year/card.year.js
  64. 124
      src/widget/year/combo.year.js
  65. 10
      src/widget/year/index.js
  66. 114
      src/widget/year/popup.year.js
  67. 48
      src/widget/year/trigger.year.js
  68. 38
      src/widget/yearinterval/yearinterval.js
  69. 46
      src/widget/yearmonth/card.dynamic.yearmonth.js
  70. 56
      src/widget/yearmonth/card.static.yearmonth.js
  71. 37
      src/widget/yearmonth/combo.yearmonth.js
  72. 10
      src/widget/yearmonth/index.js
  73. 87
      src/widget/yearmonth/popup.yearmonth.js
  74. 54
      src/widget/yearmonth/trigger.yearmonth.js
  75. 27
      src/widget/yearmonthinterval/yearmonthinterval.js
  76. 35
      src/widget/yearquarter/combo.yearquarter.js

14
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 {
@ -13,9 +13,9 @@ export class AllValueMultiTextValueCombo extends Widget {
const self = this, const self = this,
o = this.options; o = this.options;
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,
@ -27,12 +27,12 @@ export class AllValueMultiTextValueCombo extends Widget {
listeners: [ listeners: [
{ {
eventName: SearchMultiTextValueCombo.EVENT_CONFIRM, eventName: SearchMultiTextValueCombo.EVENT_CONFIRM,
action () { action() {
self.fireEvent(AllValueMultiTextValueCombo.EVENT_CONFIRM); self.fireEvent(AllValueMultiTextValueCombo.EVENT_CONFIRM);
}, },
} }
], ],
ref () { ref() {
self.combo = this; self.combo = this;
}, },
}; };
@ -51,10 +51,10 @@ export class AllValueMultiTextValueCombo extends Widget {
each(this.options.items, (idx, item) => { each(this.options.items, (idx, item) => {
!contains(obj.value, item.value) && values.push(item.value); !contains(obj.value, item.value) && values.push(item.value);
}); });
return values; return values;
} }
return obj.value || []; return obj.value || [];
} }

37
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 {
@ -11,21 +11,21 @@ export class FormField extends Widget {
el: {}, el: {},
headerCls: "", headerCls: "",
labelAlign: "right", // 文字默认右对齐 labelAlign: "right", // 文字默认右对齐
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, {
ref (_ref) { ref(_ref) {
self.field = _ref; self.field = _ref;
o.el.ref && o.el.ref.call(this, _ref); o.el.ref && o.el.ref.call(this, _ref);
}, },
@ -33,13 +33,13 @@ export class FormField extends Widget {
listeners: concat(o.el.listeners, [ listeners: concat(o.el.listeners, [
{ {
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action () { action() {
self.fireEvent("EVENT_CHANGE"); self.fireEvent("EVENT_CHANGE");
}, },
}, },
{ {
eventName: "EVENT_CONFIRM", eventName: "EVENT_CONFIRM",
action () { action() {
self.fireEvent("EVENT_CONFIRM"); self.fireEvent("EVENT_CONFIRM");
}, },
} }
@ -52,9 +52,9 @@ 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;
}, },
invisible: true, invisible: true,
@ -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,
@ -89,23 +89,20 @@ export class FormField extends Widget {
}; };
} }
getValue () { getValue() {
return this.field.getValue(); return this.field.getValue();
} }
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");
return isValid; return isValid;
} }
validateWithNoTip () { validateWithNoTip() {
return this.options.validate(this.field.getValue(), this.field); return this.options.validate(this.field.getValue(), this.field);
} }
} }

13
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,
@ -47,7 +48,7 @@ export class Form extends Widget {
listeners: [ listeners: [
{ {
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action () { action() {
self.fireEvent(Form.EVENT_CHANGE, this.validate()); self.fireEvent(Form.EVENT_CHANGE, this.validate());
}, },
} }
@ -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());
} }
} }

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);

14
src/widget/datetime/datetime.combo.js

@ -39,13 +39,13 @@ export class DateTimeCombo extends Single {
this.storeValue = isNotNull(opts.value) this.storeValue = isNotNull(opts.value)
? opts.value ? opts.value
: { : {
year: date.getFullYear(), year: date.getFullYear(),
month: date.getMonth() + 1, month: date.getMonth() + 1,
day: date.getDate(), day: date.getDate(),
hour: date.getHours(), hour: date.getHours(),
minute: date.getMinutes(), minute: date.getMinutes(),
second: date.getSeconds(), second: date.getSeconds(),
}; };
this.trigger = createWidget({ this.trigger = createWidget({
type: DateTimeTrigger.xtype, type: DateTimeTrigger.xtype,
height: opts.height, height: opts.height,

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);

54
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,
}, }
], ],
}; };
} }
@ -297,16 +297,16 @@ export class DynamicDateCombo extends Single {
type = v.type; type = v.type;
} }
switch (type) { switch (type) {
case DynamicDateCombo.Dynamic: case DynamicDateCombo.Dynamic:
this.changeIcon.setVisible(true); this.changeIcon.setVisible(true);
// this.comboWrapper.attr("items")[0].width = o.height - this.options.simple ? 1 : 2; // this.comboWrapper.attr("items")[0].width = o.height - this.options.simple ? 1 : 2;
// this.comboWrapper.resize(); // this.comboWrapper.resize();
break; break;
default: default:
// this.comboWrapper.attr("items")[0].width = 0; // this.comboWrapper.attr("items")[0].width = 0;
// this.comboWrapper.resize(); // this.comboWrapper.resize();
this.changeIcon.setVisible(false); this.changeIcon.setVisible(false);
break; break;
} }
} }
@ -314,14 +314,14 @@ export class DynamicDateCombo extends Single {
const o = this.options; const o = this.options;
let value; let value;
switch (v.type) { switch (v.type) {
case DynamicDateCombo.Dynamic: case DynamicDateCombo.Dynamic:
return isNotEmptyObject(v.value); return isNotEmptyObject(v.value);
case DynamicDateCombo.Static: case DynamicDateCombo.Static:
value = v.value || {}; value = v.value || {};
return !checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0]; return !checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default: default:
return true; return true;
} }
} }

50
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,
}, }
], ],
}; };
} }
@ -306,16 +306,16 @@ export class DynamicDateTimeCombo extends Single {
type = v.type; type = v.type;
} }
switch (type) { switch (type) {
case DynamicDateTimeCombo.Dynamic: case DynamicDateTimeCombo.Dynamic:
this.changeIcon.setVisible(true); this.changeIcon.setVisible(true);
// this.comboWrapper.attr("items")[0].width = o.height - (this.options.simple ? 1 : 2); // this.comboWrapper.attr("items")[0].width = o.height - (this.options.simple ? 1 : 2);
// this.comboWrapper.resize(); // this.comboWrapper.resize();
break; break;
default: default:
// this.comboWrapper.attr("items")[0].width = 0; // this.comboWrapper.attr("items")[0].width = 0;
// this.comboWrapper.resize(); // this.comboWrapper.resize();
this.changeIcon.setVisible(false); this.changeIcon.setVisible(false);
break; break;
} }
} }
@ -323,12 +323,12 @@ export class DynamicDateTimeCombo extends Single {
const o = this.options; const o = this.options;
const value = v.value || {}; const value = v.value || {};
switch (v.type) { switch (v.type) {
case DynamicDateCombo.Dynamic: case DynamicDateCombo.Dynamic:
return isNotEmptyObject(v.value); return isNotEmptyObject(v.value);
case DynamicDateCombo.Static: case DynamicDateCombo.Static:
return !checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0]; return !checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default: default:
return true; return true;
} }
} }

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() {}
}
} }

111
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,43 +304,32 @@ 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()) {
() => { self.combo.showView();
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
} }
); });
this.numberCounter.on( this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, () => {
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, if (want2showCounter === false) {
() => { want2showCounter = true;
if (want2showCounter === false) {
want2showCounter = true;
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}
} }
); if (isInit === true) {
want2showCounter = null;
this.numberCounter.on( showCounter();
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
() => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
} }
); });
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
nextTick(() => {
// 收起时自动调整宽度
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
);
}); });
}); });

117
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,17 +187,13 @@ export class MultiTreeListCombo extends Single {
}, },
}); });
var change = false; let change = false;
var clear = false; // 标识当前是否点击了清空 let clear = false; // 标识当前是否点击了清空
const isSearching = function () {
return self.trigger.getSearcher().isSearching();
};
const isPopupView = function () { const isSearching = () => self.trigger.getSearcher().isSearching();
return self.combo.isViewVisible();
};
const isPopupView = () => 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,45 +317,34 @@ 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()) {
() => { self.combo.showView();
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
} }
); });
this.numberCounter.on( this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, () => {
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, if (want2showCounter === false) {
() => { want2showCounter = true;
if (want2showCounter === false) {
want2showCounter = true;
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}
} }
); if (isInit === true) {
want2showCounter = null;
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) {

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

@ -54,19 +54,19 @@ 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, switch (index) {
index => { case 0:
switch (index) { self.fireEvent(MultiTreePopup.EVENT_CLICK_CLEAR);
case 0: break;
self.fireEvent(MultiTreePopup.EVENT_CLICK_CLEAR); case 1:
break; self.fireEvent(MultiTreePopup.EVENT_CLICK_CONFIRM);
case 1: break;
self.fireEvent(MultiTreePopup.EVENT_CLICK_CONFIRM);
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++;
}); });

31
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,16 +176,10 @@ 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 === "") {

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

@ -1,23 +1,41 @@
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;
}, },
valueParser (v) { valueParser(v) {
return v; return v;
}, },
value: 0, value: 0,
@ -50,27 +68,28 @@ 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, {
action: e => { eventName: SignEditor.EVENT_QUICK_DOWN,
if ([KeyCode.UP, KeyCode.DOWN].includes(e.keyCode)) { action: e => {
e.preventDefault(); if ([KeyCode.UP, KeyCode.DOWN].includes(e.keyCode)) {
} e.preventDefault();
}, }
}, },
{
eventName: SignEditor.EVENT_KEY_DOWN,
action: keycode => {
if (keycode === KeyCode.UP) {
this._finetuning(o.step);
return;
}
if (keycode === KeyCode.DOWN) {
this._finetuning(-o.step);
}
}, },
} {
eventName: SignEditor.EVENT_KEY_DOWN,
action: keycode => {
if (keycode === KeyCode.UP) {
this._finetuning(o.step);
return;
}
if (keycode === KeyCode.DOWN) {
this._finetuning(-o.step);
}
},
}
], ],
}); });
this.editor.on(TextEditor.EVENT_CHANGE, () => { this.editor.on(TextEditor.EVENT_CHANGE, () => {
@ -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, {
row: 0, column: 0,
el: this.topBtn, row: 0,
}, { el: this.topBtn,
column: 0, },
row: 1, {
el: this.bottomBtn, column: 0,
}], row: 1,
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);

373
src/widget/numberinterval/numberinterval.js

@ -1,11 +1,25 @@
import { shortcut, extend, i18nText, createWidget, toPix, isNumeric, AbsoluteLayout, isEmptyString, isNotNull, isNull, isIE, getIEVersion } from "@/core"; 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 +37,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,29 +61,31 @@ 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,
value: o.min, value: o.min,
level: "warning", level: "warning",
tipType: "success", tipType: "success",
title () { title() {
return self.smallEditor && self.smallEditor.getValue(); return self.smallEditor && self.smallEditor.getValue();
}, },
quitChecker () { quitChecker() {
return false; return false;
}, },
validationChecker (v) { validationChecker(v) {
if (!isNumeric(v)) { if (!isNumeric(v)) {
self.smallEditorBubbleType = c.typeError; self.smallEditorBubbleType = c.typeError;
return false; return false;
} }
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,35 +97,39 @@ export class NumberInterval extends Single {
createWidget({ createWidget({
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
element: this.smallEditor, element: this.smallEditor,
items: [{ items: [
el: this.smallTip, {
top: 0, el: this.smallTip,
right: 5, top: 0,
}], 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,
value: o.max, value: o.max,
title () { title() {
return self.bigEditor && self.bigEditor.getValue(); return self.bigEditor && self.bigEditor.getValue();
}, },
quitChecker () { quitChecker() {
return false; return false;
}, },
validationChecker (v) { validationChecker(v) {
if (!isNumeric(v)) { if (!isNumeric(v)) {
self.bigEditorBubbleType = c.typeError; self.bigEditorBubbleType = c.typeError;
return false; return false;
} }
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 +141,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, {
top: 0, el: this.bigTip,
right: 5, top: 0,
}], 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")})`, {
iconCls: "less-font", text: `(${i18nText("BI-Less_Than")})`,
value: 0, iconCls: "less-font",
}, { value: 0,
text: `(${i18nText("BI-Less_And_Equal")})`, },
value: 1, {
iconCls: "less-equal-font", text: `(${i18nText("BI-Less_And_Equal")})`,
}], value: 1,
iconCls: "less-equal-font",
},
],
}); });
if (o.closeMin === true) { if (o.closeMin === true) {
this.smallCombo.setValue(1); this.smallCombo.setValue(1);
@ -149,18 +176,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")})`, {
iconCls: "less-font", text: `(${i18nText("BI-Less_Than")})`,
value: 0, iconCls: "less-font",
}, { value: 0,
text: `(${i18nText("BI-Less_And_Equal")})`, },
value: 1, {
iconCls: "less-equal-font", text: `(${i18nText("BI-Less_And_Equal")})`,
}], value: 1,
iconCls: "less-equal-font",
},
],
}); });
if (o.closeMax === true) { if (o.closeMax === true) {
this.bigCombo.setValue(1); this.bigCombo.setValue(1);
@ -178,38 +210,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, },
// BI-23883 间距考虑边框 {
// lgap: 1 el: self.bigEditor,
}], // BI-23883 间距考虑边框
// 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.right, el: self.label,
}], },
{
el: self.right,
},
],
}); });
// createWidget({ // createWidget({
@ -275,13 +316,13 @@ export class NumberInterval extends Single {
if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) { if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) {
self.element.removeClass("number-error"); self.element.removeClass("number-error");
o.validation = "invalid"; o.validation = "invalid";
return c.typeError; return c.typeError;
} }
if (isEmptyString(self.smallEditor.getValue()) || isEmptyString(self.bigEditor.getValue())) { if (isEmptyString(self.smallEditor.getValue()) || isEmptyString(self.bigEditor.getValue())) {
self.element.removeClass("number-error"); self.element.removeClass("number-error");
o.validation = "valid"; o.validation = "valid";
return ""; return "";
} }
const smallValue = parseFloat(self.smallEditor.getValue()), const smallValue = parseFloat(self.smallEditor.getValue()),
@ -292,28 +333,28 @@ export class NumberInterval extends Single {
if (smallValue > bigValue) { if (smallValue > bigValue) {
self.element.addClass("number-error"); self.element.addClass("number-error");
o.validation = "invalid"; o.validation = "invalid";
return c.numberError; return c.numberError;
} }
self.element.removeClass("number-error"); self.element.removeClass("number-error");
o.validation = "valid"; o.validation = "valid";
return ""; return "";
} }
if (smallValue > bigValue) { if (smallValue > bigValue) {
self.element.addClass("number-error"); self.element.addClass("number-error");
o.validation = "invalid"; o.validation = "invalid";
return c.numberError; return c.numberError;
} else if (smallValue === bigValue) { } else if (smallValue === bigValue) {
self.element.addClass("number-error"); self.element.addClass("number-error");
o.validation = "invalid"; o.validation = "invalid";
return c.signalError; return c.signalError;
} }
self.element.removeClass("number-error"); self.element.removeClass("number-error");
o.validation = "valid"; o.validation = "valid";
return ""; return "";
} }
@ -327,26 +368,26 @@ export class NumberInterval extends Single {
w.on(NumberIntervalSingleEidtor.EVENT_FOCUS, () => { w.on(NumberIntervalSingleEidtor.EVENT_FOCUS, () => {
self._setTitle(""); self._setTitle("");
switch (self._checkValidation()) { switch (self._checkValidation()) {
case c.typeError: case c.typeError:
Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, { Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset, adjustYOffset: c.adjustYOffset,
}); });
break; break;
case c.numberError: case c.numberError:
Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, { Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset, adjustYOffset: c.adjustYOffset,
}); });
break; break;
case c.signalError: case c.signalError:
Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, { Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset, adjustYOffset: c.adjustYOffset,
}); });
break; break;
default: default:
return; return;
} }
}); });
} }
@ -359,17 +400,17 @@ export class NumberInterval extends Single {
Bubbles.hide(c.numberError); Bubbles.hide(c.numberError);
Bubbles.hide(c.signalError); Bubbles.hide(c.signalError);
switch (self._checkValidation()) { switch (self._checkValidation()) {
case c.typeError: case c.typeError:
self._setTitle(i18nText("BI-Numerical_Interval_Input_Data")); self._setTitle(i18nText("BI-Numerical_Interval_Input_Data"));
break; break;
case c.numberError: case c.numberError:
self._setTitle(i18nText("BI-Numerical_Interval_Number_Value")); self._setTitle(i18nText("BI-Numerical_Interval_Number_Value"));
break; break;
case c.signalError: case c.signalError:
self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value")); self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value"));
break; break;
default: default:
self._setTitle(""); self._setTitle("");
} }
}); });
} }
@ -392,22 +433,22 @@ export class NumberInterval extends Single {
c = this.constants; c = this.constants;
w.on(NumberIntervalSingleEidtor.EVENT_VALID, () => { w.on(NumberIntervalSingleEidtor.EVENT_VALID, () => {
switch (self._checkValidation()) { switch (self._checkValidation()) {
case c.numberError: case c.numberError:
Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, { Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset, adjustYOffset: c.adjustYOffset,
}); });
self.fireEvent(NumberInterval.EVENT_ERROR); self.fireEvent(NumberInterval.EVENT_ERROR);
break; break;
case c.signalError: case c.signalError:
Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, { Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset, adjustYOffset: c.adjustYOffset,
}); });
self.fireEvent(NumberInterval.EVENT_ERROR); self.fireEvent(NumberInterval.EVENT_ERROR);
break; break;
default: default:
self.fireEvent(NumberInterval.EVENT_VALID); self.fireEvent(NumberInterval.EVENT_VALID);
} }
}); });
} }
@ -417,26 +458,26 @@ export class NumberInterval extends Single {
c = this.constants; c = this.constants;
w.on(NumberIntervalSingleEidtor.EVENT_CHANGE, () => { w.on(NumberIntervalSingleEidtor.EVENT_CHANGE, () => {
switch (self._checkValidation()) { switch (self._checkValidation()) {
case c.typeError: case c.typeError:
Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, { Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset, adjustYOffset: c.adjustYOffset,
}); });
break; break;
case c.numberError: case c.numberError:
Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, { Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset, adjustYOffset: c.adjustYOffset,
}); });
break; break;
case c.signalError: case c.signalError:
Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, { Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset, adjustYOffset: c.adjustYOffset,
}); });
break; break;
default: default:
break; break;
} }
self.fireEvent(NumberInterval.EVENT_CHANGE); self.fireEvent(NumberInterval.EVENT_CHANGE);
}); });
@ -450,22 +491,22 @@ export class NumberInterval extends Single {
c = this.constants; c = this.constants;
w.on(IconCombo.EVENT_CHANGE, () => { w.on(IconCombo.EVENT_CHANGE, () => {
switch (self._checkValidation()) { switch (self._checkValidation()) {
case c.typeError: case c.typeError:
self._setTitle(i18nText("BI-Numerical_Interval_Input_Data")); self._setTitle(i18nText("BI-Numerical_Interval_Input_Data"));
self.fireEvent(NumberInterval.EVENT_ERROR); self.fireEvent(NumberInterval.EVENT_ERROR);
break; break;
case c.numberError: case c.numberError:
self._setTitle(i18nText("BI-Numerical_Interval_Number_Value")); self._setTitle(i18nText("BI-Numerical_Interval_Number_Value"));
self.fireEvent(NumberInterval.EVENT_ERROR); self.fireEvent(NumberInterval.EVENT_ERROR);
break; break;
case c.signalError: case c.signalError:
self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value")); self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value"));
self.fireEvent(NumberInterval.EVENT_ERROR); self.fireEvent(NumberInterval.EVENT_ERROR);
break; break;
default: default:
self.fireEvent(NumberInterval.EVENT_CHANGE); self.fireEvent(NumberInterval.EVENT_CHANGE);
self.fireEvent(NumberInterval.EVENT_CONFIRM); self.fireEvent(NumberInterval.EVENT_CONFIRM);
self.fireEvent(NumberInterval.EVENT_VALID); self.fireEvent(NumberInterval.EVENT_VALID);
} }
}); });
} }
@ -568,7 +609,7 @@ export class NumberInterval extends Single {
} else { } else {
value.closeMax = true; value.closeMax = true;
} }
return value; return value;
} }

122
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,55 +25,65 @@ export class NumberIntervalSingleEidtor extends Single {
return { return {
type: VerticalLayout.xtype, type: VerticalLayout.xtype,
items: [{ items: [
type: Editor.xtype, {
simple: o.simple, type: Editor.xtype,
ref (_ref) { simple: o.simple,
self.editor = _ref; ref(_ref) {
}, self.editor = _ref;
height: o.height,
watermark: o.watermark,
allowBlank: o.allowBlank,
value: o.value,
quitChecker: o.quitChecker,
validationChecker: o.validationChecker,
listeners: [{
eventName: Editor.EVENT_ERROR,
action () {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_ERROR, arguments);
}, },
}, { height: o.height,
eventName: Editor.EVENT_FOCUS, watermark: o.watermark,
action () { allowBlank: o.allowBlank,
self.fireEvent(NumberIntervalSingleEidtor.EVENT_FOCUS, arguments); value: o.value,
}, quitChecker: o.quitChecker,
}, { validationChecker: o.validationChecker,
eventName: Editor.EVENT_BLUR, listeners: [
action () { {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_BLUR, arguments); eventName: Editor.EVENT_ERROR,
}, action() {
}, { self.fireEvent(NumberIntervalSingleEidtor.EVENT_ERROR, arguments);
eventName: Editor.EVENT_VALID, },
action () { },
self.fireEvent(NumberIntervalSingleEidtor.EVENT_VALID, arguments); {
}, eventName: Editor.EVENT_FOCUS,
}, { action() {
eventName: Editor.EVENT_CHANGE, self.fireEvent(NumberIntervalSingleEidtor.EVENT_FOCUS, arguments);
action () { },
self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE, arguments); },
}, {
}, { eventName: Editor.EVENT_BLUR,
eventName: Editor.EVENT_CONFIRM, action() {
action () { self.fireEvent(NumberIntervalSingleEidtor.EVENT_BLUR, arguments);
self.fireEvent(NumberIntervalSingleEidtor.EVENT_CONFIRM, arguments); },
}, },
}, { {
eventName: Editor.EVENT_CHANGE_CONFIRM, eventName: Editor.EVENT_VALID,
action () { action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE_CONFIRM, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_VALID, arguments);
}, },
}], },
}], {
eventName: Editor.EVENT_CHANGE,
action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE, arguments);
},
},
{
eventName: Editor.EVENT_CONFIRM,
action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_CONFIRM, arguments);
},
},
{
eventName: Editor.EVENT_CHANGE_CONFIRM,
action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE_CONFIRM, arguments);
},
}
],
}
],
}; };
} }

10
src/widget/searchmultitextvaluecombo/index.js

@ -1,5 +1,5 @@
export { SearchMultiTextValueCombo } from "./multitextvalue.combo.search"; export { SearchMultiTextValueCombo } from "./multitextvalue.combo.search";
export { SearchMultiSelectPopupView } from "./multitextvalue.popup.view.search"; export { SearchMultiSelectPopupView } from "./multitextvalue.popup.view.search";
export { SearchMultiSelectTrigger } from "./multitextvalue.combo.trigger.search"; export { SearchMultiSelectTrigger } from "./multitextvalue.combo.trigger.search";
export { SearchMultiSelectLoader } from "./multitextvalue.loader.search"; export { SearchMultiSelectLoader } from "./multitextvalue.loader.search";
export { SearchMultiSelectSearcher } from "./trigger/searcher.multitextvalue"; export { SearchMultiSelectSearcher } from "./trigger/searcher.multitextvalue";

17
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()) {
@ -328,7 +331,7 @@ export class SearchMultiTextValueCombo extends Single {
}); });
change && (this.storeValue.value = values(_map)); change && (this.storeValue.value = values(_map));
this._adjust(callback); this._adjust(callback);
return; return;
} }
const selectedMap = this._makeMap(this.storeValue.value); const selectedMap = this._makeMap(this.storeValue.value);
@ -410,7 +413,7 @@ export class SearchMultiTextValueCombo extends Single {
}); });
change && (this.storeValue.value = values(map)); change && (this.storeValue.value = values(map));
this._adjust(callback); this._adjust(callback);
return; return;
} }
this._joinAll(res, callback); this._joinAll(res, callback);
@ -426,7 +429,7 @@ export class SearchMultiTextValueCombo extends Single {
for (let i = (times - 1) * 100; items[i] && i < times * 100; i++) { for (let i = (times - 1) * 100; items[i] && i < times * 100; i++) {
res.push(items[i]); res.push(items[i]);
} }
return res; return res;
} }
@ -454,12 +457,12 @@ export class SearchMultiTextValueCombo extends Single {
callback({ callback({
items, items,
}); });
return; return;
} }
if (options.type == MultiSelectCombo.REQ_GET_DATA_LENGTH) { if (options.type == MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({ count: items.length }); callback({ count: items.length });
return; return;
} }
callback({ callback({

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.loader.search.js

@ -100,7 +100,7 @@ export class SearchMultiSelectLoader extends Widget {
if (op.times === 1 && this.storeValue) { if (op.times === 1 && this.storeValue) {
const json = map(this.storeValue.value, (i, v) => { const json = map(this.storeValue.value, (i, v) => {
const txt = opts.valueFormatter(v) || v; const txt = opts.valueFormatter(v) || v;
return { return {
text: txt, text: txt,
value: v, value: v,

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))
);
} }
} }

54
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";
@ -49,7 +63,7 @@ export class SingleSelectSearchLoader extends Widget {
el: { el: {
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
behaviors: { behaviors: {
redmark () { redmark() {
return true; return true;
}, },
}, },
@ -61,7 +75,7 @@ export class SingleSelectSearchLoader extends Widget {
}, },
}, },
}, },
itemsCreator (op, callback) { itemsCreator(op, callback) {
self.storeValue && self.storeValue &&
(op = extend(op || {}, { (op = extend(op || {}, {
selectedValues: [self.storeValue], selectedValues: [self.storeValue],
@ -83,7 +97,7 @@ export class SingleSelectSearchLoader extends Widget {
} }
}); });
}, },
hasNext () { hasNext() {
return hasNext; return hasNext;
}, },
}); });
@ -97,20 +111,22 @@ 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, {
logic: o.logic, type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
cls: "bi-list-item-active", logic: o.logic,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, cls: "bi-list-item-active",
selected: false, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconWrapperWidth: 26, selected: false,
hgap: o.allowNoSelect ? 10 : 0, iconWrapperWidth: 26,
title: item.title || item.text, hgap: o.allowNoSelect ? 10 : 0,
}, title: item.title || item.text,
item },
)); item
)
);
} }
_filterValues(src) { _filterValues(src) {
@ -127,7 +143,7 @@ export class SingleSelectSearchLoader extends Widget {
const search = Func.getSearchResult(newValues, keyword); const search = Func.getSearchResult(newValues, keyword);
values = search.match.concat(search.find); values = search.match.concat(search.find);
} }
return map(values, (i, v) => { return map(values, (i, v) => {
return { return {
text: v.text, text: v.text,

14
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";
@ -38,7 +48,7 @@ export class SingleSelectSearchInsertPane extends Widget {
allowNoSelect: o.allowNoSelect, allowNoSelect: o.allowNoSelect,
keywordGetter: o.keywordGetter, keywordGetter: o.keywordGetter,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemsCreator (op, callback) { itemsCreator(op, callback) {
o.itemsCreator.apply(self, [ o.itemsCreator.apply(self, [
op, op,
function (res) { function (res) {

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

@ -38,7 +38,7 @@ export class SingleSelectSearchPane extends Widget {
allowNoSelect: o.allowNoSelect, allowNoSelect: o.allowNoSelect,
keywordGetter: o.keywordGetter, keywordGetter: o.keywordGetter,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemsCreator (op, callback) { itemsCreator(op, callback) {
o.itemsCreator.apply(self, [ o.itemsCreator.apply(self, [
op, op,
function (res) { function (res) {

128
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, this.storeValue = this.trigger.getValue();
(value, obj) => { assertShowValue();
this.storeValue = this.trigger.getValue(); this._defaultState();
assertShowValue(); this._dataChange = true;
this._defaultState(); });
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,24 +115,26 @@ 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, {
action: () => { eventName: SingleSelectPopupView.EVENT_CHANGE,
this._dataChange = true; action: () => {
this.storeValue = this.popup.getValue(); this._dataChange = true;
this._adjust(() => { this.storeValue = this.popup.getValue();
assertShowValue(); this._adjust(() => {
this._defaultState(); assertShowValue();
}); this._defaultState();
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,19 +189,20 @@ export class SingleSelectCombo extends Single {
createWidget({ createWidget({
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
element: this, element: this,
items: [{ items: [
el: this.combo, {
left: 0, el: this.combo,
right: 0, left: 0,
top: 0, right: 0,
bottom: 0, top: 0,
}, bottom: 0,
{ },
el: triggerBtn, {
right: 0, el: triggerBtn,
top: 0, right: 0,
bottom: 0, top: 0,
} bottom: 0,
}
], ],
}); });
} }
@ -209,14 +222,15 @@ 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, {
keywords, type: SingleSelectCombo.REQ_GET_ALL_DATA,
}, keywords,
ob => { },
const values = map(ob.items, "value"); ob => {
digest(values); const values = map(ob.items, "value");
} digest(values);
}
); );
const digest = items => { const digest = items => {
@ -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,14 +255,15 @@ 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 => { },
this._count = res.count; res => {
adjust(); this._count = res.count;
callback(); adjust();
} callback();
}
); );
} else { } else {
adjust(); adjust();

52
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";
@ -50,7 +63,7 @@ export class SingleSelectInsertCombo extends Single {
allowEdit: o.allowEdit, allowEdit: o.allowEdit,
// adapter: this.popup, // adapter: this.popup,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemsCreator (op, callback) { itemsCreator(op, callback) {
o.itemsCreator(op, function (res) { o.itemsCreator(op, function (res) {
if (op.times === 1 && isNotNull(op.keywords)) { if (op.times === 1 && isNotNull(op.keywords)) {
// 预防trigger内部把当前的storeValue改掉 // 预防trigger内部把当前的storeValue改掉
@ -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, self.storeValue = this.getValue();
function (value, obj) { assertShowValue();
self.storeValue = this.getValue(); self._defaultState();
assertShowValue(); self._dataChange = true;
self._defaultState(); });
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();
@ -118,30 +128,28 @@ export class SingleSelectInsertCombo extends Single {
popup: { popup: {
type: SingleSelectPopupView.xtype, type: SingleSelectPopupView.xtype,
allowNoSelect: o.allowNoSelect, allowNoSelect: o.allowNoSelect,
ref () { ref() {
self.popup = this; self.popup = this;
self.trigger.setAdapter(this); self.trigger.setAdapter(this);
}, },
listeners: [ listeners: [
{ {
eventName: SingleSelectPopupView.EVENT_CHANGE, eventName: SingleSelectPopupView.EVENT_CHANGE,
action () { action() {
self._dataChange = true; self._dataChange = true;
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self._adjust(() => { self._adjust(() => {
assertShowValue(); assertShowValue();
self._defaultState(); self._defaultState();
}); });
self.fireEvent( self.fireEvent(SingleSelectInsertCombo.EVENT_CLICK_ITEM);
SingleSelectInsertCombo.EVENT_CLICK_ITEM
);
}, },
} }
], ],
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
itemWrapper: o.itemWrapper, itemWrapper: o.itemWrapper,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
onLoaded () { onLoaded() {
nextTick(() => { nextTick(() => {
self.combo.adjustWidth(); self.combo.adjustWidth();
self.combo.adjustHeight(); self.combo.adjustHeight();
@ -149,7 +157,7 @@ export class SingleSelectInsertCombo extends Single {
}); });
}, },
}, },
hideChecker (e) { hideChecker(e) {
return triggerBtn.element.find(e.target).length === 0; return triggerBtn.element.find(e.target).length === 0;
}, },
value: o.value, value: o.value,
@ -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;

6
src/widget/singleselect/singleselect.list.js

@ -35,7 +35,7 @@ export class SingleSelectList extends Widget {
this.list = createWidget(o.el, { this.list = createWidget(o.el, {
type: ListPane.xtype, type: ListPane.xtype,
items: o.items, items: o.items,
itemsCreator (op, callback) { itemsCreator(op, callback) {
op.times === 1 && self.toolbar && self.toolbar.setVisible(false); op.times === 1 && self.toolbar && self.toolbar.setVisible(false);
o.itemsCreator(op, function (items) { o.itemsCreator(op, function (items) {
callback.apply(self, arguments); callback.apply(self, arguments);
@ -79,13 +79,13 @@ export class SingleSelectList extends Widget {
height: this._constants.itemHeight, height: this._constants.itemHeight,
forceNotSelected: true, forceNotSelected: true,
text: i18nText("BI-Basic_No_Select"), text: i18nText("BI-Basic_No_Select"),
ref (_ref) { ref(_ref) {
self.toolbar = _ref; self.toolbar = _ref;
}, },
listeners: [ listeners: [
{ {
eventName: Controller.EVENT_CHANGE, eventName: Controller.EVENT_CHANGE,
action (type) { action(type) {
if (type === Events.CLICK) { if (type === Events.CLICK) {
self.list.setValue(); self.list.setValue();
self.fireEvent(SingleSelectList.EVENT_CHANGE); self.fireEvent(SingleSelectList.EVENT_CHANGE);

52
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";
@ -52,7 +64,7 @@ export class SingleSelectLoader extends Widget {
el: { el: {
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
behaviors: { behaviors: {
redmark () { redmark() {
return true; return true;
}, },
}, },
@ -66,7 +78,7 @@ export class SingleSelectLoader extends Widget {
}, },
opts.el opts.el
), ),
itemsCreator (op, callback) { itemsCreator(op, callback) {
const startValue = self._startValue; const startValue = self._startValue;
!isUndefined(self.storeValue) && !isUndefined(self.storeValue) &&
(op = extend(op || {}, { (op = extend(op || {}, {
@ -78,7 +90,7 @@ export class SingleSelectLoader extends Widget {
if (op.times === 1 && !isUndefined(self.storeValue)) { if (op.times === 1 && !isUndefined(self.storeValue)) {
const json = map([self.storeValue], (i, v) => { const json = map([self.storeValue], (i, v) => {
const txt = opts.valueFormatter(v) || v; const txt = opts.valueFormatter(v) || v;
return ( return (
opts.itemWrapper({ opts.itemWrapper({
text: txt, text: txt,
@ -103,7 +115,7 @@ export class SingleSelectLoader extends Widget {
op.times === 1 && self._scrollToTop(); op.times === 1 && self._scrollToTop();
}); });
}, },
hasNext () { hasNext() {
return hasNext; return hasNext;
}, },
value: this.storeValue, value: this.storeValue,
@ -126,20 +138,22 @@ 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, {
logic: o.logic, type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
cls: "bi-list-item-active", logic: o.logic,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, cls: "bi-list-item-active",
selected: false, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconWrapperWidth: 26, selected: false,
textHgap: o.allowNoSelect ? 10 : 0, iconWrapperWidth: 26,
title: item.title || item.text, textHgap: o.allowNoSelect ? 10 : 0,
}, 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,

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

@ -1,3 +1,4 @@
import { SingleSelectSearchInsertPane } from "./search";
import { import {
shortcut, shortcut,
extend, extend,
@ -68,14 +69,14 @@ 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,
keywordGetter () { keywordGetter() {
return self.trigger.getKeyword(); return self.trigger.getKeyword();
}, },
itemsCreator (op, callback) { itemsCreator(op, callback) {
op.keywords = [self.trigger.getKeyword()]; op.keywords = [self.trigger.getKeyword()];
if (isNotEmptyString(op.keywords[0])) { if (isNotEmptyString(op.keywords[0])) {
this.setKeyword(op.keywords[0]); this.setKeyword(op.keywords[0]);
@ -93,14 +94,14 @@ export class SingleSelectInsertList extends Single {
type: SearchEditor.xtype, type: SearchEditor.xtype,
watermark: i18nText("BI-Basic_Search_And_Patch_Paste"), watermark: i18nText("BI-Basic_Search_And_Patch_Paste"),
}, },
ref (ref) { ref(ref) {
self.editor = ref; self.editor = ref;
}, },
height: o.searcherHeight, height: o.searcherHeight,
}, },
isAutoSearch: false, isAutoSearch: false,
isAutoSync: false, isAutoSync: false,
onSearch (op, callback) { onSearch(op, callback) {
callback(); callback();
}, },
adapter: this.adapter, adapter: this.adapter,
@ -110,7 +111,7 @@ export class SingleSelectInsertList extends Single {
listeners: [ listeners: [
{ {
eventName: Searcher.EVENT_START, eventName: Searcher.EVENT_START,
action () { action() {
self._showSearcherPane(); self._showSearcherPane();
self._setStartValue(); self._setStartValue();
this.setValue(deepClone(self.storeValue)); this.setValue(deepClone(self.storeValue));
@ -118,7 +119,7 @@ export class SingleSelectInsertList extends Single {
}, },
{ {
eventName: Searcher.EVENT_STOP, eventName: Searcher.EVENT_STOP,
action () { action() {
self._showAdapter(); self._showAdapter();
self._setStartValue(); self._setStartValue();
self.adapter.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
@ -128,7 +129,7 @@ export class SingleSelectInsertList extends Single {
}, },
{ {
eventName: Searcher.EVENT_PAUSE, eventName: Searcher.EVENT_PAUSE,
action () { action() {
const keyword = this.getKeyword(); const keyword = this.getKeyword();
self.storeValue = keyword; self.storeValue = keyword;
self._showAdapter(); self._showAdapter();
@ -142,7 +143,7 @@ export class SingleSelectInsertList extends Single {
}, },
{ {
eventName: Searcher.EVENT_CHANGE, eventName: Searcher.EVENT_CHANGE,
action () { action() {
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self.fireEvent(SingleSelectInsertList.EVENT_CHANGE); self.fireEvent(SingleSelectInsertList.EVENT_CHANGE);
}, },

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";

53
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,22 +34,23 @@ 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, {
action: () => { eventName: SingleSelectEditor.EVENT_FOCUS,
this.fireEvent(SingleSelectSearcher.EVENT_FOCUS); action: () => {
this.fireEvent(SingleSelectSearcher.EVENT_FOCUS);
},
}, },
}, {
{ eventName: SingleSelectEditor.EVENT_BLUR,
eventName: SingleSelectEditor.EVENT_BLUR, action: () => {
action: () => { this.fireEvent(SingleSelectSearcher.EVENT_BLUR);
this.fireEvent(SingleSelectSearcher.EVENT_BLUR); },
}, }
}
], ],
}); });
@ -63,20 +65,21 @@ export class SingleSelectSearcher extends Widget {
}, },
el: this.editor, el: this.editor,
popup: extend({ popup: extend(
type: "bi.single_select_search_pane", {
allowNoSelect: o.allowNoSelect, type: SingleSelectSearchPane.xtype,
valueFormatter: o.valueFormatter, allowNoSelect: o.allowNoSelect,
keywordGetter: () => this.editor.getValue(), valueFormatter: o.valueFormatter,
itemsCreator(op, callback) { keywordGetter: () => this.editor.getValue(),
const keyword = self.editor.getValue(); itemsCreator(op, callback) {
op.keywords = [keyword]; const keyword = self.editor.getValue();
this.setKeyword(keyword); op.keywords = [keyword];
o.itemsCreator(op, callback); this.setKeyword(keyword);
o.itemsCreator(op, callback);
},
value: o.value,
}, },
value: o.value, o.popup
},
o.popup
), ),
adapter: o.adapter, adapter: o.adapter,

2
src/widget/singleslider/button/editor.sign.text.js

@ -24,7 +24,7 @@ export class SignTextEditor extends Widget {
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
return extend(conf, { return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-sign-initial-editor`, baseCls: `${conf.baseCls || ""} bi-sign-initial-editor`,
validationChecker: emptyFn, validationChecker: emptyFn,

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,

10
src/widget/singleslider/index.js

@ -1,5 +1,5 @@
export { SingleSlider } from "./singleslider"; export { SingleSlider } from "./singleslider";
export { SingleSliderLabel } from "./singleslider.label"; export { SingleSliderLabel } from "./singleslider.label";
export { SingleSliderNormal } from "./singleslider.normal"; export { SingleSliderNormal } from "./singleslider.normal";
export { SignTextEditor } from "./button/editor.sign.text"; export { SignTextEditor } from "./button/editor.sign.text";
export { SliderIconButton } from "./button/iconbutton.slider"; export { SliderIconButton } from "./button/iconbutton.slider";

66
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");
@ -158,7 +150,7 @@ export class SingleSlider extends Single {
this.fireEvent(SingleSlider.EVENT_CHANGE); this.fireEvent(SingleSlider.EVENT_CHANGE);
}); });
this._setVisible(false); this._setVisible(false);
return { return {
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
items: [ items: [
@ -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,11 +298,11 @@ 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;
} }
} }
return valid; return valid;
} }
@ -343,7 +335,7 @@ export class SingleSlider extends Single {
_getValueByPercent(percent) { _getValueByPercent(percent) {
const thousandth = parseInt(percent * 10); const thousandth = parseInt(percent * 10);
return ((this.max - this.min) * thousandth) / 1000 + this.min; return ((this.max - this.min) * thousandth) / 1000 + this.min;
} }
@ -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)) {

39
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;
@ -130,7 +123,7 @@ export class SingleSliderLabel extends Single {
}); });
this._setVisible(false); this._setVisible(false);
return { return {
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
items: [ items: [
@ -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) {
@ -305,7 +298,7 @@ export class SingleSliderLabel extends Single {
_getValueByPercent(percent) { _getValueByPercent(percent) {
const thousandth = parseInt(percent * 10); const thousandth = parseInt(percent * 10);
return ((this.max - this.min) * thousandth) / 1000 + this.min; return ((this.max - this.min) * thousandth) / 1000 + this.min;
} }
@ -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");
} }
} }

37
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) {
@ -275,7 +268,7 @@ export class SingleSliderNormal extends Single {
_getValueByPercent(percent) { _getValueByPercent(percent) {
const thousandth = parseInt(percent * 10); const thousandth = parseInt(percent * 10);
return ((this.max - this.min) * thousandth) / 1000 + this.min; return ((this.max - this.min) * thousandth) / 1000 + this.min;
} }
@ -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";

12
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;
}, },
@ -92,7 +94,7 @@ export class TextValueDownListCombo extends Widget {
_digest(v) { _digest(v) {
this.value = v; this.value = v;
return this.valueMap[v]; return this.valueMap[v];
} }
@ -104,7 +106,7 @@ export class TextValueDownListCombo extends Widget {
getValue() { getValue() {
const v = this.combo.getValue()[0]; const v = this.combo.getValue()[0];
return [v.childValue || v.value]; return [v.childValue || v.value];
} }

4
src/widget/textvaluedownlistcombo/index.js

@ -1,2 +1,2 @@
export { TextValueDownListCombo } from "./combo.textvaluedownlist"; export { TextValueDownListCombo } from "./combo.textvaluedownlist";
export { DownListSelectTextTrigger } from "./trigger.textvaluedownlist"; export { DownListSelectTextTrigger } from "./trigger.textvaluedownlist";

2
src/widget/textvaluedownlistcombo/trigger.textvaluedownlist.js

@ -40,7 +40,7 @@ export class DownListSelectTextTrigger extends Trigger {
targetArray.push(item); targetArray.push(item);
} }
}); });
return targetArray; return targetArray;
} }

145
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: { {
type: CenterAdaptLayout.xtype, el: {
cls: "bi-split-top", type: CenterAdaptLayout.xtype,
items: [{ cls: "bi-split-top",
type: DynamicDateTimeSelect.xtype, items: [
value: o.value, {
ref: _ref => { type: DynamicDateTimeSelect.xtype,
this.timeSelect = _ref; value: o.value,
}, ref: _ref => {
}], this.timeSelect = _ref;
},
hgap: 10,
height: 44,
}, {
el: {
type: GridLayout.xtype,
items: [
[{
type: TextButton.xtype,
cls: "bi-high-light bi-split-top",
shadow: true,
text: i18nText("BI-Basic_Clears"),
listeners: [{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(TimePopup.BUTTON_CLEAR_EVENT_CHANGE);
}, },
}], }
}, { ],
type: TextButton.xtype, },
cls: "bi-split-left bi-split-right bi-high-light bi-split-top", hgap: 10,
shadow: true, height: 44,
text: i18nText("BI-Basic_Now"), },
listeners: [{ {
eventName: TextButton.EVENT_CHANGE, el: {
action: () => { type: GridLayout.xtype,
this.fireEvent(TimePopup.BUTTON_NOW_EVENT_CHANGE); items: [
[
{
type: TextButton.xtype,
cls: "bi-high-light bi-split-top",
shadow: true,
text: i18nText("BI-Basic_Clears"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
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-high-light bi-split-top", shadow: true,
shadow: true, text: i18nText("BI-Basic_Now"),
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_NOW_EVENT_CHANGE);
},
}
],
}, },
}], {
}] type: TextButton.xtype,
], cls: "bi-high-light bi-split-top",
}, shadow: true,
height: 24, text: i18nText("BI-Basic_OK"),
}], listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(TimePopup.BUTTON_OK_EVENT_CHANGE);
},
}
],
}
]
],
},
height: 24,
}
],
}; };
} }

344
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,169 +50,191 @@ 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, {
action: () => { eventName: TimePopup.BUTTON_CLEAR_EVENT_CHANGE,
this.setValue(); action: () => {
this.hidePopupView(); this.setValue();
this.fireEvent(TimeCombo.EVENT_CONFIRM); this.hidePopupView();
}, this.fireEvent(TimeCombo.EVENT_CONFIRM);
}, { },
eventName: TimePopup.BUTTON_OK_EVENT_CHANGE,
action: () => {
this.setValue(this.popup.getValue());
this.hidePopupView();
this.fireEvent(TimeCombo.EVENT_CONFIRM);
}, },
}, { {
eventName: TimePopup.BUTTON_NOW_EVENT_CHANGE, eventName: TimePopup.BUTTON_OK_EVENT_CHANGE,
action: () => { action: () => {
this._setNowTime(); this.setValue(this.popup.getValue());
this.hidePopupView();
this.fireEvent(TimeCombo.EVENT_CONFIRM);
},
}, },
}], {
eventName: TimePopup.BUTTON_NOW_EVENT_CHANGE,
action: () => {
this._setNowTime();
},
}
],
ref: _ref => { ref: _ref => {
this.popup = _ref; this.popup = _ref;
}, },
}; };
return { return {
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
items: [{ items: [
el: { {
type: Combo.xtype,
cls: "bi-border bi-border-radius",
container: opts.container,
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
el: { el: {
type: "bi.horizontal_fill", type: Combo.xtype,
columnSize: ["fill", this.constants.iconWidth], cls: "bi-border bi-border-radius",
height: toPix(opts.height, 2), container: opts.container,
items: [{ toggle: false,
type: "bi.time_trigger", isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
el: {
type: HorizontalFillLayout.xtype,
columnSize: ["fill", this.constants.iconWidth],
height: toPix(opts.height, 2), height: toPix(opts.height, 2),
allowEdit: opts.allowEdit, items: [
watermark: opts.watermark, {
format: opts.format, type: TimeTrigger.xtype,
value: opts.value, height: toPix(opts.height, 2),
ref: _ref => { allowEdit: opts.allowEdit,
this.trigger = _ref; watermark: opts.watermark,
}, format: opts.format,
listeners: [{ value: opts.value,
eventName: "EVENT_KEY_DOWN", ref: _ref => {
action: () => { this.trigger = _ref;
if (this.combo.isViewVisible()) { },
this.combo.hideView(); listeners: [
} {
this.fireEvent(TimeCombo.EVENT_KEY_DOWN, arguments); eventName: "EVENT_KEY_DOWN",
}, action: () => {
}, { if (this.combo.isViewVisible()) {
eventName: "EVENT_STOP", this.combo.hideView();
action: () => { }
if (!this.combo.isViewVisible()) { this.fireEvent(TimeCombo.EVENT_KEY_DOWN, arguments);
this.combo.showView(); },
} },
}, {
}, { eventName: "EVENT_STOP",
eventName: "EVENT_FOCUS", action: () => {
action: () => { if (!this.combo.isViewVisible()) {
this.storeTriggerValue = this.trigger.getKey(); this.combo.showView();
if (!this.combo.isViewVisible()) { }
this.combo.showView(); },
} },
this.fireEvent("EVENT_FOCUS"); {
}, eventName: "EVENT_FOCUS",
}, { action: () => {
eventName: "EVENT_BLUR", this.storeTriggerValue = this.trigger.getKey();
action: () => { if (!this.combo.isViewVisible()) {
this.fireEvent("EVENT_BLUR"); this.combo.showView();
}, }
}, { this.fireEvent("EVENT_FOCUS");
eventName: "EVENT_ERROR", },
action: () => { },
const date = getDate(); {
this.storeValue = { eventName: "EVENT_BLUR",
hour: date.getHours(), action: () => {
minute: date.getMinutes(), this.fireEvent("EVENT_BLUR");
second: date.getSeconds(), },
}; },
this.fireEvent("EVENT_ERROR"); {
}, eventName: "EVENT_ERROR",
}, { action: () => {
eventName: "EVENT_VALID", const date = getDate();
action: () => { this.storeValue = {
this.fireEvent("EVENT_VALID"); hour: date.getHours(),
}, minute: date.getMinutes(),
}, { second: date.getSeconds(),
eventName: "EVENT_CHANGE", };
action: () => { this.fireEvent("EVENT_ERROR");
this.fireEvent("EVENT_CHANGE"); },
}, },
}, { {
eventName: "EVENT_CONFIRM", eventName: "EVENT_VALID",
action: () => { action: () => {
if (this.combo.isViewVisible()) { this.fireEvent("EVENT_VALID");
return; },
} },
const dateStore = this.storeTriggerValue; {
const dateObj = this.trigger.getKey(); eventName: "EVENT_CHANGE",
if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) { action: () => {
this.storeValue = this.trigger.getValue(); this.fireEvent("EVENT_CHANGE");
this.setValue(this.trigger.getValue()); },
} else if (isEmptyString(dateObj)) { },
this.storeValue = null; {
this.trigger.setValue(); eventName: "EVENT_CONFIRM",
} action: () => {
this.fireEvent("EVENT_CONFIRM"); if (this.combo.isViewVisible()) {
}, return;
}], }
}, { const dateStore = this.storeTriggerValue;
el: { const dateObj = this.trigger.getKey();
type: IconButton.xtype, if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
cls: "bi-trigger-icon-button time-font", this.storeValue = this.trigger.getValue();
width: this.constants.iconWidth, this.setValue(this.trigger.getValue());
listeners: [{ } else if (isEmptyString(dateObj)) {
eventName: IconButton.EVENT_CHANGE, this.storeValue = null;
action: () => { this.trigger.setValue();
if (this.combo.isViewVisible()) { }
// this.combo.hideView(); this.fireEvent("EVENT_CONFIRM");
} else { },
this.combo.showView();
} }
],
},
{
el: {
type: IconButton.xtype,
cls: "bi-trigger-icon-button time-font",
width: this.constants.iconWidth,
listeners: [
{
eventName: IconButton.EVENT_CHANGE,
action: () => {
if (this.combo.isViewVisible()) {
// this.combo.hideView();
} else {
this.combo.showView();
}
},
}
],
ref: _ref => {
this.triggerBtn = _ref;
},
}, },
}], }
ref: _ref => { ],
this.triggerBtn = _ref; },
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: popup,
width: opts.isNeedAdjustWidth ? opts.width : this.constants.popupWidth,
stopPropagation: false,
},
hideChecker: e => this.triggerBtn.element.find(e.target).length === 0,
listeners: [
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.popup.setValue(this.storeValue);
this.fireEvent(TimeCombo.EVENT_BEFORE_POPUPVIEW);
}, },
}, }
}], ],
}, ref: _ref => {
adjustLength: this.constants.comboAdjustHeight, this.combo = _ref;
popup: {
el: popup,
width: opts.isNeedAdjustWidth ? opts.width : this.constants.popupWidth,
stopPropagation: false,
},
hideChecker: e => this.triggerBtn.element.find(e.target).length === 0,
listeners: [{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.popup.setValue(this.storeValue);
this.fireEvent(TimeCombo.EVENT_BEFORE_POPUPVIEW);
}, },
}],
ref: _ref => {
this.combo = _ref;
}, },
}, top: 0,
top: 0, left: 0,
left: 0, right: 0,
right: 0, bottom: 0,
bottom: 0, }
}], ],
}; };
} }

259
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",
}; };
@ -28,109 +56,132 @@ export class TimeTrigger extends Trigger {
const o = this.options; const o = this.options;
this.storeTriggerValue = ""; this.storeTriggerValue = "";
this.storeValue = o.value; this.storeValue = o.value;
return { return {
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
items: [{ items: [
el: { {
type: SignEditor.xtype, el: {
height: o.height, type: SignEditor.xtype,
validationChecker: v => this._dateCheck(v), height: o.height,
quitChecker () { validationChecker: v => this._dateCheck(v),
return false; quitChecker() {
}, return false;
ref: _ref => {
this.editor = _ref;
},
value: this._formatValue(o.value),
hgap: 4,
allowBlank: true,
watermark: o.watermark,
title: bind(this._getTitle, this),
listeners: [{
eventName: "EVENT_KEY_DOWN",
action: (...args) => {
this.fireEvent("EVENT_KEY_DOWN", ...args);
},
}, {
eventName: "EVENT_FOCUS",
action: () => {
this.storeTriggerValue = this.getKey();
this.fireEvent("EVENT_FOCUS");
},
}, {
eventName: "EVENT_BLUR",
action: () => {
this.fireEvent("EVENT_BLUR");
}, },
}, { ref: _ref => {
eventName: "EVENT_STOP", this.editor = _ref;
action: () => {
this.fireEvent("EVENT_STOP");
}, },
}, { value: this._formatValue(o.value),
eventName: "EVENT_VALID", hgap: 4,
action: () => { allowBlank: true,
this.fireEvent("EVENT_VALID"); watermark: o.watermark,
}, title: bind(this._getTitle, this),
}, { listeners: [
eventName: "EVENT_ERROR", {
action: () => { eventName: "EVENT_KEY_DOWN",
this.fireEvent("EVENT_ERROR"); action: (...args) => {
}, this.fireEvent("EVENT_KEY_DOWN", ...args);
}, { },
eventName: "EVENT_CONFIRM", },
action: () => { {
const value = this.editor.getValue(); eventName: "EVENT_FOCUS",
if (isNotNull(value)) { action: () => {
this.editor.setState(value); this.storeTriggerValue = this.getKey();
this.fireEvent("EVENT_FOCUS");
},
},
{
eventName: "EVENT_BLUR",
action: () => {
this.fireEvent("EVENT_BLUR");
},
},
{
eventName: "EVENT_STOP",
action: () => {
this.fireEvent("EVENT_STOP");
},
},
{
eventName: "EVENT_VALID",
action: () => {
this.fireEvent("EVENT_VALID");
},
},
{
eventName: "EVENT_ERROR",
action: () => {
this.fireEvent("EVENT_ERROR");
},
},
{
eventName: "EVENT_CONFIRM",
action: () => {
const value = this.editor.getValue();
if (isNotNull(value)) {
this.editor.setState(value);
}
if (isNotEmptyString(value) && !isEqual(this.storeTriggerValue, this.getKey())) {
const date = value.match(/\d+/g);
this.storeValue = {
hour: date[0] | 0,
minute: date[1] | 0,
second: date[2] | 0,
};
}
this.fireEvent("EVENT_CONFIRM");
},
},
{
eventName: "EVENT_START",
action: () => {
this.fireEvent("EVENT_START");
},
},
{
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent("EVENT_CHANGE");
},
} }
if (isNotEmptyString(value) && !isEqual(this.storeTriggerValue, this.getKey())) { ],
const date = value.match(/\d+/g); },
this.storeValue = { left: 0,
hour: date[0] | 0, right: 0,
minute: date[1] | 0, top: 0,
second: date[2] | 0, bottom: 0,
};
}
this.fireEvent("EVENT_CONFIRM");
},
}, {
eventName: "EVENT_START",
action: () => {
this.fireEvent("EVENT_START");
},
}, {
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent("EVENT_CHANGE");
},
}],
},
left: 0,
right: 0,
top: 0,
bottom: 0,
}, {
el: {
type: Text.xtype,
invisible: o.allowEdit,
cls: "show-text",
title: bind(this._getTitle, this),
hgap: 4,
}, },
left: 0, {
right: 0, el: {
top: 0, type: Text.xtype,
bottom: 0, invisible: o.allowEdit,
}], cls: "show-text",
title: bind(this._getTitle, this),
hgap: 4,
},
left: 0,
right: 0,
top: 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) {
@ -142,7 +193,7 @@ export class TimeTrigger extends Trigger {
default: default:
break; break;
} }
return str; return str;
} }
@ -152,8 +203,11 @@ export class TimeTrigger extends Trigger {
return this.options.watermark; return this.options.watermark;
} }
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() {
@ -162,8 +216,13 @@ 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() {

111
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,15 +25,14 @@ 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);
return extend(conf, { return extend(conf, {
extraCls: "bi-date-interval", extraCls: "bi-date-interval",
minDate: "1900-01-01", minDate: "1900-01-01",
@ -39,23 +49,27 @@ 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: { },
type: Label.xtype, {
height: o.height, el: {
hgap: 5, type: Label.xtype,
text: "-", height: o.height,
ref: _ref => { hgap: 5,
this.label = _ref; text: "-",
ref: _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, {
action: () => { eventName: DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
this.fireEvent(DateInterval.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); action: () => {
}, this.fireEvent(DateInterval.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
}], },
}
],
}); });
combo.on(DynamicDateCombo.EVENT_ERROR, () => { combo.on(DynamicDateCombo.EVENT_ERROR, () => {
this._clearTitle(); this._clearTitle();
@ -138,42 +154,51 @@ export class DateInterval extends Single {
this.fireEvent(DateInterval.EVENT_CHANGE); this.fireEvent(DateInterval.EVENT_CHANGE);
} }
}); });
return combo; return combo;
} }
_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) {
const o = this.options; const o = this.options;
return !checkDateVoid(obj.year, obj.month, obj.day, o.minDate, o.maxDate)[0]; return !checkDateVoid(obj.year, obj.month, obj.day, o.minDate, o.maxDate)[0];
} }
_check(smallDate, bigDate) { _check(smallDate, bigDate) {
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 (
year: smallObj[0], this._dateCheck(smallDate) &&
month: smallObj[1], checkDateLegal(smallDate) &&
day: smallObj[2], this._checkVoid({
}) && this._dateCheck(bigDate) && checkDateLegal(bigDate) && this._checkVoid({ year: smallObj[0],
year: bigObj[0], month: smallObj[1],
month: bigObj[1], day: smallObj[2],
day: bigObj[2], }) &&
}); this._dateCheck(bigDate) &&
checkDateLegal(bigDate) &&
this._checkVoid({
year: bigObj[0],
month: bigObj[1],
day: bigObj[2],
})
);
} }
_compare(smallDate, bigDate) { _compare(smallDate, bigDate) {
smallDate = print(parseDateTime(smallDate, "%Y-%X-%d"), "%Y-%X-%d"); smallDate = print(parseDateTime(smallDate, "%Y-%X-%d"), "%Y-%X-%d");
bigDate = print(parseDateTime(bigDate, "%Y-%X-%d"), "%Y-%X-%d"); bigDate = print(parseDateTime(bigDate, "%Y-%X-%d"), "%Y-%X-%d");
return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate; return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate;
} }

115
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,13 +25,13 @@ 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);
return extend(conf, { return extend(conf, {
extraCls: "bi-time-interval", extraCls: "bi-time-interval",
minDate: "1900-01-01", minDate: "1900-01-01",
@ -37,23 +48,27 @@ 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: { },
type: Label.xtype, {
height: o.height, el: {
hgap: 5, type: Label.xtype,
text: "-", height: o.height,
ref: _ref => { hgap: 5,
this.label = _ref; text: "-",
ref: _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);
@ -131,42 +161,51 @@ export class TimeInterval extends Single {
this.fireEvent(TimeInterval.EVENT_CHANGE); this.fireEvent(TimeInterval.EVENT_CHANGE);
} }
}); });
return combo; return combo;
} }
_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) {
const o = this.options; const o = this.options;
return !checkDateVoid(obj.year, obj.month, obj.day, o.minDate, o.maxDate)[0]; return !checkDateVoid(obj.year, obj.month, obj.day, o.minDate, o.maxDate)[0];
} }
_check(smallDate, bigDate) { _check(smallDate, bigDate) {
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 (
year: smallObj[0], this._dateCheck(smallDate) &&
month: smallObj[1], checkDateLegal(smallDate) &&
day: smallObj[2], this._checkVoid({
}) && this._dateCheck(bigDate) && checkDateLegal(bigDate) && this._checkVoid({ year: smallObj[0],
year: bigObj[0], month: smallObj[1],
month: bigObj[1], day: smallObj[2],
day: bigObj[2], }) &&
}); this._dateCheck(bigDate) &&
checkDateLegal(bigDate) &&
this._checkVoid({
year: bigObj[0],
month: bigObj[1],
day: bigObj[2],
})
);
} }
_compare(smallDate, bigDate) { _compare(smallDate, bigDate) {
smallDate = print(parseDateTime(smallDate, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S"); smallDate = print(parseDateTime(smallDate, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S");
bigDate = print(parseDateTime(bigDate, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S"); bigDate = print(parseDateTime(bigDate, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S");
return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate; return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate;
} }

99
src/widget/timeinterval/timeperiods.js

@ -1,77 +1,90 @@
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({ {
ref: _ref => { el: extend(
this.left = _ref; {
}, ref: _ref => {
}, this._createCombo(o.value.start, o.watermark?.start)), this.left = _ref;
}, { },
el: { },
type: Label.xtype, this._createCombo(o.value.start, o.watermark?.start)
height: o.height, ),
hgap: 5,
text: "-",
ref: _ref => {
this.label = _ref;
},
}, },
}, { {
el: extend({ el: {
ref: _ref => { type: Label.xtype,
this.right = _ref; height: o.height,
hgap: 5,
text: "-",
ref: _ref => {
this.label = _ref;
},
}, },
}, this._createCombo(o.value.end, o.watermark?.end)), },
}], {
el: extend(
{
ref: _ref => {
this.right = _ref;
},
},
this._createCombo(o.value.end, o.watermark?.end)
),
}
],
}; };
} }
_createCombo(v, watermark) { _createCombo(v, watermark) {
const o = this.options; const o = this.options;
return { return {
type: TimeCombo.xtype, type: TimeCombo.xtype,
value: v, value: v,
height: o.height, height: o.height,
watermark, watermark,
listeners: [{ listeners: [
eventName: TimeCombo.EVENT_BEFORE_POPUPVIEW, {
action: () => { eventName: TimeCombo.EVENT_BEFORE_POPUPVIEW,
this.left.hidePopupView(); action: () => {
this.right.hidePopupView(); this.left.hidePopupView();
}, this.right.hidePopupView();
}, { },
eventName: TimeCombo.EVENT_CHANGE,
action: () => {
this.fireEvent(TimePeriods.EVENT_CHANGE);
}, },
}, { {
eventName: TimeCombo.EVENT_CONFIRM, eventName: TimeCombo.EVENT_CHANGE,
action: () => { action: () => {
this.fireEvent(TimePeriods.EVENT_CONFIRM); this.fireEvent(TimePeriods.EVENT_CHANGE);
},
}, },
}], {
eventName: TimeCombo.EVENT_CONFIRM,
action: () => {
this.fireEvent(TimePeriods.EVENT_CONFIRM);
},
}
],
}; };
} }

67
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, {
text: i18nText("BI-Multi_Date_Relative_Current_Time"), type: Label.xtype,
textAlign: "left", text: i18nText("BI-Multi_Date_Relative_Current_Time"),
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, textAlign: "left",
}, { height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
type: DynamicDateParamItem.xtype,
ref: _ref => {
this.item = _ref;
}, },
listeners: [{ {
eventName: "EVENT_CHANGE", type: DynamicDateParamItem.xtype,
action: () => { ref: _ref => {
this.fireEvent("EVENT_CHANGE"); this.item = _ref;
},
}, {
eventName: "EVENT_INPUT_CHANGE",
action: () => {
Bubbles.hide("dynamic-year-error");
}, },
}], listeners: [
}], {
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent("EVENT_CHANGE");
},
},
{
eventName: "EVENT_INPUT_CHANGE",
action: () => {
Bubbles.hide("dynamic-year-error");
},
}
],
}
],
vgap: 10, vgap: 10,
hgap: 10, hgap: 10,
}; };
@ -67,10 +76,8 @@ export class DynamicYearCard extends Widget {
const o = this.options; const o = this.options;
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) {
@ -92,9 +99,9 @@ export class DynamicYearCard extends Widget {
_getValue() { _getValue() {
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,
}; };
} }

36
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";
@ -31,7 +47,7 @@ export class StaticYearCard extends Widget {
year: y + v * 12, year: y + v * 12,
}); });
calendar.setValue(this._year); calendar.setValue(this._year);
return calendar; return calendar;
} }
@ -49,10 +65,8 @@ export class StaticYearCard extends Widget {
listeners: [ listeners: [
{ {
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();
}, },
@ -69,10 +83,8 @@ export class StaticYearCard extends Widget {
listeners: [ listeners: [
{ {
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();
}, },
@ -136,14 +148,14 @@ export class StaticYearCard extends Widget {
_checkLeftValid() { _checkLeftValid() {
const valid = true; const valid = true;
this.backBtn.setEnable(valid); this.backBtn.setEnable(valid);
return valid; return valid;
} }
_checkRightValid() { _checkRightValid() {
const valid = true; const valid = true;
this.preBtn.setEnable(valid); this.preBtn.setEnable(valid);
return valid; return valid;
} }

124
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 {
@ -12,18 +12,18 @@ export class DynamicYearCombo extends Widget {
static EVENT_ERROR = "EVENT_ERROR"; static EVENT_ERROR = "EVENT_ERROR";
static EVENT_VALID = "EVENT_VALID"; static EVENT_VALID = "EVENT_VALID";
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",
behaviors: {}, behaviors: {},
minDate: "1900-01-01", // 最小日期 minDate: "1900-01-01", // 最小日期
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,36 +94,41 @@ export class DynamicYearCombo extends Widget {
ref: _ref => { ref: _ref => {
this.popup = _ref; this.popup = _ref;
}, },
listeners: [{ listeners: [
eventName: DynamicYearPopup.EVENT_CHANGE, {
action:() => { eventName: DynamicYearPopup.EVENT_CHANGE,
this.setValue(this.popup.getValue()); action: () => {
this.combo.hideView(); this.setValue(this.popup.getValue());
this.fireEvent(DynamicYearCombo.EVENT_CONFIRM); this.combo.hideView();
}, this.fireEvent(DynamicYearCombo.EVENT_CONFIRM);
}, { },
eventName: DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => {
this.setValue();
this.combo.hideView();
this.fireEvent(DynamicYearCombo.EVENT_CONFIRM);
}, },
}, { {
eventName: DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE, eventName: DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => { action: () => {
const date = getDate(); this.setValue();
this.setValue({ type: DynamicYearCombo.Static, value: { year: date.getFullYear() } }); this.combo.hideView();
this.combo.hideView(); this.fireEvent(DynamicYearCombo.EVENT_CONFIRM);
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM); },
}, },
}, { {
eventName: DynamicYearPopup.BUTTON_OK_EVENT_CHANGE, eventName: DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE,
action: () => { action: () => {
this.setValue(this.popup.getValue()); const date = getDate();
this.combo.hideView(); this.setValue({ type: DynamicYearCombo.Static, value: { year: date.getFullYear() } });
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM); this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
}, },
}], {
eventName: DynamicYearPopup.BUTTON_OK_EVENT_CHANGE,
action: () => {
this.setValue(this.popup.getValue());
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
}
],
behaviors: o.behaviors, behaviors: o.behaviors,
min: o.minDate, min: o.minDate,
max: o.maxDate, max: o.maxDate,
@ -141,31 +146,36 @@ export class DynamicYearCombo extends Widget {
BI.createWidget({ BI.createWidget({
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
element: this, element: this,
items: [{ items: [
el: { {
type: HorizontalFillLayout.xtype, el: {
columnSize: ["", "fill"], type: HorizontalFillLayout.xtype,
cls: `${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`, columnSize: ["", "fill"],
ref: _ref => { cls: `${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
this.comboWrapper = _ref; ref: _ref => {
}, this.comboWrapper = _ref;
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: this._const.iconWidth,
height: toPix(o.height, border),
ref: _ref => {
this.changeIcon = _ref;
},
}, },
}, this.combo], items: [
}, {
top: 0, el: {
left: 0, type: IconButton.xtype,
right: 0, cls: "bi-trigger-icon-button date-change-h-font",
bottom: 0, width: this._const.iconWidth,
}], height: toPix(o.height, border),
ref: _ref => {
this.changeIcon = _ref;
},
},
},
this.combo
],
},
top: 0,
left: 0,
right: 0,
bottom: 0,
}
],
}); });
this._checkDynamicValue(o.value); this._checkDynamicValue(o.value);
} }

10
src/widget/year/index.js

@ -1,5 +1,5 @@
export { DynamicYearCard } from "./card.dynamic.year"; export { DynamicYearCard } from "./card.dynamic.year";
export { StaticYearCard } from "./card.year"; export { StaticYearCard } from "./card.year";
export { DynamicYearCombo } from "./combo.year"; export { DynamicYearCombo } from "./combo.year";
export { DynamicYearPopup } from "./popup.year"; export { DynamicYearPopup } from "./popup.year";
export { DynamicYearTrigger } from "./trigger.year"; export { DynamicYearTrigger } from "./trigger.year";

114
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 {
@ -24,7 +39,7 @@ export class DynamicYearPopup extends Widget {
render() { render() {
this.storeValue = { type: DynamicYearCombo.Static }; this.storeValue = { type: DynamicYearCombo.Static };
return { return {
type: VerticalLayout.xtype, type: VerticalLayout.xtype,
items: [ items: [
@ -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"),
@ -72,10 +79,8 @@ export class DynamicYearPopup extends Widget {
listeners: [ listeners: [
{ {
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);
@ -140,19 +130,13 @@ export class DynamicYearPopup extends Widget {
_checkYearValid() { _checkYearValid() {
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() {
const o = this.options; const o = this.options;
return { return {
type: Tab.xtype, type: Tab.xtype,
logic: { logic: {
@ -192,7 +176,7 @@ export class DynamicYearPopup extends Widget {
listeners: [ listeners: [
{ {
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action : () => { action: () => {
this._setInnerValue(this.year, v); this._setInnerValue(this.year, v);
}, },
} }
@ -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
);
}, },
} }
], ],
@ -227,7 +209,7 @@ export class DynamicYearPopup extends Widget {
listeners: [ listeners: [
{ {
eventName: Tab.EVENT_CHANGE, eventName: Tab.EVENT_CHANGE,
action :() => { action: () => {
const v = this.dateTab.getSelect(); const v = this.dateTab.getSelect();
switch (v) { switch (v) {
case DynamicYearCombo.Static: { case DynamicYearCombo.Static: {
@ -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,
@ -263,14 +239,8 @@ export class DynamicYearPopup extends Widget {
_checkTodayValid() { _checkTodayValid() {
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) {

48
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,26 +57,18 @@ 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,
watermark: o.watermark, watermark: o.watermark,
allowBlank: true, allowBlank: true,
errorText:v => { errorText: v => {
if (isPositiveInteger(v)) { if (isPositiveInteger(v)) {
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,11 +145,9 @@ 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;
} }
@ -158,7 +164,7 @@ export class DynamicYearTrigger extends Trigger {
if (!this.editor.isValid()) { if (!this.editor.isValid()) {
return ""; return "";
} }
switch (type) { switch (type) {
case DynamicDateCombo.Dynamic: { case DynamicDateCombo.Dynamic: {
const text = this._getText(value); const text = this._getText(value);
@ -166,13 +172,13 @@ 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:
default: default:
value = value || {}; value = value || {};
return value.year; return value.year;
} }
} }

38
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";
@ -111,20 +121,17 @@ export class YearInterval extends Single {
this.fireEvent(YearInterval.EVENT_CHANGE); this.fireEvent(YearInterval.EVENT_CHANGE);
} }
}); });
return combo; return combo;
} }
_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) {
const o = this.options; const o = this.options;
return !checkDateVoid(obj.year, 1, 1, o.minDate, o.maxDate)[0]; return !checkDateVoid(obj.year, 1, 1, o.minDate, o.maxDate)[0];
} }
@ -163,10 +170,8 @@ export class YearInterval extends Single {
_compare(smallDate, bigDate) { _compare(smallDate, bigDate) {
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", offsetStyle: "center",
i18nText("BI-Time_Interval_Error_Text"), });
this,
{
offsetStyle: "center",
}
);
this.fireEvent(YearInterval.EVENT_ERROR); this.fireEvent(YearInterval.EVENT_ERROR);
} else { } else {
this._clearTitle(); this._clearTitle();

46
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,34 +105,24 @@ 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;
} }
return valueMap; return valueMap;
} }
@ -162,18 +148,14 @@ 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() {
const year = this.year.getValue(); const year = this.year.getValue();
const month = this.month.getValue(); const month = this.month.getValue();
return { return {
year: year.offset === 0 ? -year.value : year.value, year: year.offset === 0 ? -year.value : year.value,
month: month.offset === 0 ? -month.value : month.value, month: month.offset === 0 ? -month.value : month.value,
@ -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;
} }

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

@ -29,30 +29,32 @@ 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) =>
return { map(item, (j, td) => {
type: TextItem.xtype, return {
cls: "bi-list-item-select", type: TextItem.xtype,
textAlign: "center", cls: "bi-list-item-select",
whiteSpace: "nowrap", textAlign: "center",
once: false, whiteSpace: "nowrap",
forceSelected: true, once: false,
height: toPix(BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, 1), forceSelected: true,
width: 38, height: toPix(BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, 1),
value: td, width: 38,
text: td, value: td,
ref: _ref => { text: td,
this.monthMap[j === 0 ? i : i + 6] = _ref; ref: _ref => {
}, this.monthMap[j === 0 ? i : i + 6] = _ref;
}; },
})); };
})
);
} }
render() { render() {
const o = this.options; const o = this.options;
this.monthMap = {}; this.monthMap = {};
return { return {
type: VerticalLayout.xtype, type: VerticalLayout.xtype,
items: [ items: [
@ -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
);
}, },
} }
], ],
@ -158,7 +156,7 @@ export class StaticYearMonthCard extends Widget {
if (contains(["y", "m"], dateVoid[0])) { if (contains(["y", "m"], dateVoid[0])) {
this.selectedYear = year; this.selectedYear = year;
this.month.setValue(); this.month.setValue();
return; return;
} }
@ -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 = "";

37
src/widget/yearmonth/combo.yearmonth.js

@ -39,7 +39,7 @@ export class DynamicYearMonthCombo extends Single {
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
}; };
_init() { _init() {
const o = this.options; const o = this.options;
super._init(...arguments); super._init(...arguments);
@ -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;

10
src/widget/yearmonth/index.js

@ -1,5 +1,5 @@
export { DynamicYearMonthCard } from "./card.dynamic.yearmonth"; export { DynamicYearMonthCard } from "./card.dynamic.yearmonth";
export { StaticYearMonthCard } from "./card.static.yearmonth"; export { StaticYearMonthCard } from "./card.static.yearmonth";
export { DynamicYearMonthCombo } from "./combo.yearmonth"; export { DynamicYearMonthCombo } from "./combo.yearmonth";
export { DynamicYearMonthPopup } from "./popup.yearmonth"; export { DynamicYearMonthPopup } from "./popup.yearmonth";
export { DynamicYearMonthTrigger } from "./trigger.yearmonth"; export { DynamicYearMonthTrigger } from "./trigger.yearmonth";

87
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";
@ -39,7 +41,7 @@ export class DynamicYearMonthPopup extends Widget {
render() { render() {
this.storeValue = { type: DynamicYearMonthCombo.Static }; this.storeValue = { type: DynamicYearMonthCombo.Static };
return { return {
type: VerticalLayout.xtype, type: VerticalLayout.xtype,
items: [ items: [
@ -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);
@ -155,19 +132,13 @@ export class DynamicYearMonthPopup extends Widget {
_checkTodayValid() { _checkTodayValid() {
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() {
const o = this.options; const o = this.options;
return { return {
type: Tab.xtype, type: Tab.xtype,
logic: { logic: {
@ -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,
@ -302,9 +263,7 @@ export class DynamicYearMonthPopup extends Widget {
v = v || {}; v = v || {};
const type = v.type || DynamicDateCombo.Static; const type = v.type || DynamicDateCombo.Static;
const value = v.value || v; const value = v.value || v;
this.dateTab.setSelect(type); this.dateTab.setSelect(type);
switch (type) { switch (type) {
case DynamicDateCombo.Dynamic: case DynamicDateCombo.Dynamic:

54
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");
} }
@ -239,13 +223,13 @@ export class DynamicYearMonthTrigger extends Trigger {
let date = getDate(); let date = getDate();
date = DynamicDateHelper.getCalculation(value); date = DynamicDateHelper.getCalculation(value);
const dateStr = print(date, "%Y-%x"); const dateStr = print(date, "%Y-%x");
return isEmptyString(text) ? dateStr : `${text}:${dateStr}`; return isEmptyString(text) ? dateStr : `${text}:${dateStr}`;
} }
case DynamicDateCombo.Static: case DynamicDateCombo.Static:
default: default:
value = value || {}; value = value || {};
return this._getStaticTitle(value); return this._getStaticTitle(value);
} }
} }
@ -260,21 +244,15 @@ 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,
}, },
}; };
} }
_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,19 +272,15 @@ 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;
} }

27
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
);
}, },
} }
], ],
@ -122,7 +120,7 @@ export class YearMonthInterval extends Single {
this.fireEvent(YearMonthInterval.EVENT_CHANGE); this.fireEvent(YearMonthInterval.EVENT_CHANGE);
} }
}); });
return combo; return combo;
} }
@ -135,7 +133,7 @@ export class YearMonthInterval extends Single {
_checkVoid(obj) { _checkVoid(obj) {
const o = this.options; const o = this.options;
return !checkDateVoid(obj.year, obj.month, 1, o.minDate, o.maxDate)[0]; return !checkDateVoid(obj.year, obj.month, 1, o.minDate, o.maxDate)[0];
} }
@ -174,10 +172,8 @@ export class YearMonthInterval extends Single {
_compare(smallDate, bigDate) { _compare(smallDate, bigDate) {
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", offsetStyle: "center",
i18nText("BI-Time_Interval_Error_Text"), });
this,
{
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