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 { shortcut, Widget, Selection, each, contains } from "@/core";
@shortcut()
export class AllValueMultiTextValueCombo extends Widget {
@ -13,9 +13,9 @@ export class AllValueMultiTextValueCombo extends Widget {
const self = this,
o = this.options;
const value = this._digestValue(o.value);
return {
type: "bi.search_multi_text_value_combo",
type: SearchMultiTextValueCombo.xtype,
simple: o.simple,
text: o.text,
height: o.height,
@ -27,12 +27,12 @@ export class AllValueMultiTextValueCombo extends Widget {
listeners: [
{
eventName: SearchMultiTextValueCombo.EVENT_CONFIRM,
action () {
action() {
self.fireEvent(AllValueMultiTextValueCombo.EVENT_CONFIRM);
},
}
],
ref () {
ref() {
self.combo = this;
},
};
@ -51,10 +51,10 @@ export class AllValueMultiTextValueCombo extends Widget {
each(this.options.items, (idx, item) => {
!contains(obj.value, item.value) && values.push(item.value);
});
return values;
}
return obj.value || [];
}

37
src/component/form/form.field.js

@ -1,5 +1,5 @@
import { shortcut, Widget, extend, concat, isKey, VerticalAlign } from "@/core";
import { AbsoluteLayout, VerticalAdaptLayout, shortcut, Widget, extend, concat, isKey, VerticalAlign } from "@/core";
import { Label } from "@/base";
@shortcut()
export class FormField extends Widget {
@ -11,21 +11,21 @@ export class FormField extends Widget {
el: {},
headerCls: "",
labelAlign: "right", // 文字默认右对齐
validate () {
validate() {
return true;
}, // 默认返回true
}
};
render () {
render() {
const self = this,
o = this.options;
const field = {
type: "bi.absolute",
type: AbsoluteLayout.xtype,
items: [
{
el: extend({}, o.el, {
ref (_ref) {
ref(_ref) {
self.field = _ref;
o.el.ref && o.el.ref.call(this, _ref);
},
@ -33,13 +33,13 @@ export class FormField extends Widget {
listeners: concat(o.el.listeners, [
{
eventName: "EVENT_CHANGE",
action () {
action() {
self.fireEvent("EVENT_CHANGE");
},
},
{
eventName: "EVENT_CONFIRM",
action () {
action() {
self.fireEvent("EVENT_CONFIRM");
},
}
@ -52,9 +52,9 @@ export class FormField extends Widget {
},
{
el: {
type: "bi.label",
type: Label.xtype,
cls: "error-tip bi-error",
ref (_ref) {
ref(_ref) {
self.error = _ref;
},
invisible: true,
@ -68,14 +68,14 @@ export class FormField extends Widget {
};
return {
type: "bi.vertical_adapt",
type: VerticalAdaptLayout.xtype,
columnSize: ["auto", "fill"],
verticalAlign: VerticalAlign.Stretch,
items: isKey(o.label)
? [
{
el: {
type: "bi.label",
type: Label.xtype,
textAlign: o.labelAlign,
text: o.label,
width: o.labelWidth,
@ -89,23 +89,20 @@ export class FormField extends Widget {
};
}
getValue () {
getValue() {
return this.field.getValue();
}
validate () {
validate() {
const isValid = this.validateWithNoTip();
!isValid &&
this.error.setText(
this.options.tip(this.field.getValue(), this.field)
);
!isValid && this.error.setText(this.options.tip(this.field.getValue(), this.field));
this.error.setVisible(!isValid);
this.field.element[isValid ? "removeClass" : "addClass"]("bi-error");
return isValid;
}
validateWithNoTip () {
validateWithNoTip() {
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";
@shortcut()
@ -8,7 +9,7 @@ export class Form extends Widget {
props = {
baseCls: "bi-form",
labelAlign: "right",
layout: { type: "bi.vertical", vgap: 20 },
layout: { type: VerticalLayout.xtype, vgap: 20 },
items: [{ label: "", el: {} }],
labelWidth: "",
headerCls: "",
@ -35,7 +36,7 @@ export class Form extends Widget {
return map(o.items, (idx, item) => {
return {
type: "bi.form_field",
type: FormField.xtype,
height: item.el.height || 28,
labelAlign: o.labelAlign,
labelWidth: o.labelWidth,
@ -47,7 +48,7 @@ export class Form extends Widget {
listeners: [
{
eventName: "EVENT_CHANGE",
action () {
action() {
self.fireEvent(Form.EVENT_CHANGE, this.validate());
},
}
@ -79,8 +80,6 @@ export class Form extends Widget {
}
getValue() {
return !this.isAllValid()
? null
: map(this.group.getAllButtons(), (idx, button) => button.getValue());
return !this.isAllValid() ? 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],
},
width: 24,
},
}
],
});
this.setValue({

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

@ -83,7 +83,7 @@ export class YearPicker extends Widget {
items: [
{
el: this.year,
},
}
],
},
{
@ -92,7 +92,7 @@ export class YearPicker extends Widget {
items: [this.right],
},
width: 25,
},
}
],
});
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)
? opts.value
: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds(),
};
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds(),
};
this.trigger = createWidget({
type: DateTimeTrigger.xtype,
height: opts.height,

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

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

54
src/widget/dynamicdate/dynamicdate.combo.js

@ -9,7 +9,7 @@ import {
isEmptyString,
isNotNull,
isNotEmptyObject,
checkDateVoid,
checkDateVoid
} from "@/core";
import { Combo, IconButton, Single } from "@/base";
import { DynamicDateTrigger } from "./dynamicdate.trigger";
@ -75,7 +75,7 @@ export class DynamicDateCombo extends Single {
type: Combo.xtype,
cls: `${opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
container: opts.container,
ref: (_ref) => {
ref: _ref => {
this.combo = _ref;
},
toggle: false,
@ -93,7 +93,7 @@ export class DynamicDateCombo extends Single {
cls: "bi-trigger-icon-button date-change-h-font",
width: toPix(opts.height, border),
height: toPix(opts.height, border),
ref: (_ref) => {
ref: _ref => {
this.changeIcon = _ref;
},
},
@ -109,7 +109,7 @@ export class DynamicDateCombo extends Single {
iconWidth: toPix(opts.height, border),
height: toPix(opts.height, border),
value: opts.value,
ref: (_ref) => {
ref: _ref => {
this.trigger = _ref;
},
listeners: [
@ -192,9 +192,9 @@ export class DynamicDateCombo extends Single {
this._checkDynamicValue(this.storeValue);
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
},
}
],
},
}
],
},
adjustLength: this.constants.comboAdjustHeight,
@ -206,7 +206,7 @@ export class DynamicDateCombo extends Single {
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
ref: (_ref) => {
ref: _ref => {
this.popup = _ref;
},
listeners: [
@ -258,7 +258,7 @@ export class DynamicDateCombo extends Single {
action: () => {
this.fireEvent(DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
},
}
],
},
},
@ -275,14 +275,14 @@ export class DynamicDateCombo extends Single {
this.popup.setValue(this.storeValue);
this.fireEvent(DynamicDateCombo.EVENT_BEFORE_POPUPVIEW);
},
},
}
],
},
top: 0,
left: 0,
right: 0,
bottom: 0,
},
}
],
};
}
@ -297,16 +297,16 @@ export class DynamicDateCombo extends Single {
type = v.type;
}
switch (type) {
case DynamicDateCombo.Dynamic:
this.changeIcon.setVisible(true);
// this.comboWrapper.attr("items")[0].width = o.height - this.options.simple ? 1 : 2;
// this.comboWrapper.resize();
break;
default:
// this.comboWrapper.attr("items")[0].width = 0;
// this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
case DynamicDateCombo.Dynamic:
this.changeIcon.setVisible(true);
// this.comboWrapper.attr("items")[0].width = o.height - this.options.simple ? 1 : 2;
// this.comboWrapper.resize();
break;
default:
// this.comboWrapper.attr("items")[0].width = 0;
// this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
}
}
@ -314,14 +314,14 @@ export class DynamicDateCombo extends Single {
const o = this.options;
let value;
switch (v.type) {
case DynamicDateCombo.Dynamic:
return isNotEmptyObject(v.value);
case DynamicDateCombo.Static:
value = v.value || {};
case DynamicDateCombo.Dynamic:
return isNotEmptyObject(v.value);
case DynamicDateCombo.Static:
value = v.value || {};
return !checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default:
return true;
return !checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default:
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`,
destroyWhenHide: true,
container: opts.container,
ref: (_ref) => {
ref: _ref => {
this.combo = _ref;
},
toggle: false,
@ -93,7 +93,7 @@ export class DynamicDateTimeCombo extends Single {
cls: "bi-trigger-icon-button date-change-h-font",
width: this.constants.iconWidth,
height: toPix(opts.height, border),
ref: (_ref) => {
ref: _ref => {
this.changeIcon = _ref;
},
},
@ -109,7 +109,7 @@ export class DynamicDateTimeCombo extends Single {
iconWidth: this.constants.iconWidth,
height: toPix(opts.height, border),
value: opts.value,
ref: (_ref) => {
ref: _ref => {
this.trigger = _ref;
},
listeners: [
@ -198,9 +198,9 @@ export class DynamicDateTimeCombo extends Single {
this._checkDynamicValue(this.storeValue);
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
},
},
}
],
},
}
],
},
adjustLength: this.constants.comboAdjustHeight,
@ -212,7 +212,7 @@ export class DynamicDateTimeCombo extends Single {
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
ref: (_ref) => {
ref: _ref => {
this.popup = _ref;
},
listeners: [
@ -267,7 +267,7 @@ export class DynamicDateTimeCombo extends Single {
action: () => {
this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
},
}
],
},
},
@ -280,7 +280,7 @@ export class DynamicDateTimeCombo extends Single {
this.popup.setValue(this.storeValue);
this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
},
},
}
],
// // DEC-4250 和复选下拉一样,点击不收起
// hideChecker: function (e) {
@ -291,7 +291,7 @@ export class DynamicDateTimeCombo extends Single {
left: 0,
right: 0,
bottom: 0,
},
}
],
};
}
@ -306,16 +306,16 @@ export class DynamicDateTimeCombo extends Single {
type = v.type;
}
switch (type) {
case DynamicDateTimeCombo.Dynamic:
this.changeIcon.setVisible(true);
// this.comboWrapper.attr("items")[0].width = o.height - (this.options.simple ? 1 : 2);
// this.comboWrapper.resize();
break;
default:
// this.comboWrapper.attr("items")[0].width = 0;
// this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
case DynamicDateTimeCombo.Dynamic:
this.changeIcon.setVisible(true);
// this.comboWrapper.attr("items")[0].width = o.height - (this.options.simple ? 1 : 2);
// this.comboWrapper.resize();
break;
default:
// this.comboWrapper.attr("items")[0].width = 0;
// this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
}
}
@ -323,12 +323,12 @@ export class DynamicDateTimeCombo extends Single {
const o = this.options;
const value = v.value || {};
switch (v.type) {
case DynamicDateCombo.Dynamic:
return isNotEmptyObject(v.value);
case DynamicDateCombo.Static:
return !checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default:
return true;
case DynamicDateCombo.Dynamic:
return isNotEmptyObject(v.value);
case DynamicDateCombo.Static:
return !checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default:
return true;
}
}

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

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

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

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

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

@ -6,7 +6,8 @@ import {
i18nText,
nextTick,
Events,
VerticalAdaptLayout, VTapeLayout
VerticalAdaptLayout,
VTapeLayout
} from "@/core";
import { Pane, TextButton, Label } from "@/base";
import { DisplayTree, TreeView } from "@/case";
@ -123,6 +124,5 @@ export class MultiTreeCheckPane extends Pane {
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 {
shortcut,
extend,
@ -11,8 +16,6 @@ import {
deepClone
} from "@/core";
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 { TriggerIconButton } from "@/case";
import { MultiSelectCheckSelectedSwitcher } from "../multiselect/trigger/switcher.checkselected";
@ -50,7 +53,7 @@ export class MultiTreeInsertCombo extends Single {
this.storeValue = { value: o.value || {} };
this.trigger = createWidget({
type: "bi.multi_select_trigger",
type: MultiSelectTrigger.xtype,
allowEdit: o.allowEdit,
height: toPix(o.height, o.simple ? 1 : 2),
valueFormatter: o.valueFormatter,
@ -66,18 +69,16 @@ export class MultiTreeInsertCombo extends Single {
},
},
searcher: {
type: "bi.multi_tree_searcher",
type: MultiTreeSearcher.xtype,
itemsCreator: o.itemsCreator,
popup: {
type: "bi.multi_tree_search_insert_pane",
type: MultiTreeSearchInsertPane.xtype,
listeners: [
{
eventName: MultiTreeSearchInsertPane.EVENT_ADD_ITEM,
action() {
self.storeValue.value[
self.trigger.getSearcher().getKeyword()
] = {};
self.storeValue.value[self.trigger.getSearcher().getKeyword()] = {};
self._assertShowValue();
// setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了
self.combo.setValue(self.storeValue);
@ -87,8 +88,7 @@ export class MultiTreeInsertCombo extends Single {
},
},
{
eventName:
MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE,
eventName: MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE,
action() {
self._dataChange = true;
},
@ -107,7 +107,7 @@ export class MultiTreeInsertCombo extends Single {
el: this.trigger,
adjustLength: 1,
popup: {
type: "bi.multi_tree_popup_view",
type: MultiTreePopup.xtype,
ref() {
self.popup = this;
self.trigger.setAdapter(this);
@ -135,10 +135,7 @@ export class MultiTreeInsertCombo extends Single {
self.trigger.getSearcher().setState(val);
self.numberCounter.setButtonChecked(val);
self.storeValue = { value: self.combo.getValue() };
self.fireEvent(
MultiTreeInsertCombo.EVENT_CLICK_ITEM,
self.getValue()
);
self.fireEvent(MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.getValue());
self._dataChange = true;
},
},
@ -177,16 +174,12 @@ export class MultiTreeInsertCombo extends Single {
},
});
var change = false;
var clear = false; // 标识当前是否点击了清空
let change = false;
let clear = false; // 标识当前是否点击了清空
const isSearching = function () {
return self.trigger.getSearcher().isSearching();
};
const isSearching = () => self.trigger.getSearcher().isSearching();
const isPopupView = function () {
return self.combo.isViewVisible();
};
const isPopupView = () => self.combo.isViewVisible();
this.trigger.on(MultiSelectTrigger.EVENT_FOCUS, () => {
self.fireEvent(MultiTreeInsertCombo.EVENT_FOCUS);
@ -236,14 +229,9 @@ export class MultiTreeInsertCombo extends Single {
type: BI.Selection.Multi,
value: checked ? { 1: 1 } : {},
};
this.getSearcher().setState(
checked ? BI.Selection.Multi : BI.Selection.None
);
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
self.numberCounter.setButtonChecked(val);
self.fireEvent(
MultiTreeInsertCombo.EVENT_CLICK_ITEM,
self.combo.getValue()
);
self.fireEvent(MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
self._dataChange = true;
});
@ -266,8 +254,7 @@ export class MultiTreeInsertCombo extends Single {
this.combo.on(Combo.EVENT_BEFORE_HIDEVIEW, () => {
if (isSearching()) {
self._stopEditing();
self._dataChange &&
self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
} else {
if (isPopupView()) {
self._stopEditing();
@ -275,15 +262,14 @@ export class MultiTreeInsertCombo extends Single {
if (clear === true) {
self.storeValue = { value: {} };
}
self._dataChange &&
self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
}
}
clear = false;
change = false;
});
var triggerBtn = createWidget({
const triggerBtn = createWidget({
type: TriggerIconButton.xtype,
width: o.height,
height: o.height,
@ -299,12 +285,12 @@ export class MultiTreeInsertCombo extends Single {
});
this.numberCounter = createWidget({
type: "bi.multi_select_check_selected_switcher",
type: MultiSelectCheckSelectedSwitcher.xtype,
el: {
type: "bi.multi_tree_check_selected_button",
type: MultiTreeCheckSelectedButton.xtype,
},
popup: {
type: "bi.multi_tree_check_pane",
type: MultiTreeCheckPane.xtype,
},
itemsCreator: o.itemsCreator,
masker: {
@ -318,43 +304,32 @@ export class MultiTreeInsertCombo extends Single {
valueFormatter: o.valueFormatter,
value: o.value,
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
() => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
);
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
() => {
if (want2showCounter === false) {
want2showCounter = true;
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}
});
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, () => {
if (want2showCounter === false) {
want2showCounter = true;
}
);
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
() => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
if (isInit === true) {
want2showCounter = null;
showCounter();
}
);
});
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
});
this.numberCounter.on(Events.VIEW, b => {
nextTick(() => {
// 自动调整宽度
self.trigger.refreshPlaceHolderWidth(
b === true ? self.numberCounter.element.outerWidth() + 8 : 0
);
self.trigger.refreshPlaceHolderWidth(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 {
shortcut,
extend,
@ -14,12 +17,7 @@ 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 {
TriggerIconButton,
ListPartTree,
ListDisplayTree,
Listasynctree
} from "@/case";
import { TriggerIconButton, ListPartTree, ListDisplayTree, Listasynctree } from "@/case";
import { MultiSelectCheckSelectedSwitcher } from "../multiselect/trigger/switcher.checkselected";
@shortcut()
@ -57,7 +55,7 @@ export class MultiTreeListCombo extends Single {
this.storeValue = { value: o.value || [] };
this.trigger = createWidget({
type: "bi.multi_select_trigger",
type: MultiSelectTrigger.xtype,
allowEdit: o.allowEdit,
text: o.text,
defaultText: o.defaultText,
@ -73,12 +71,10 @@ export class MultiTreeListCombo extends Single {
},
},
searcher: {
type: "bi.multi_list_tree_searcher",
type: MultiListTreeSearcher.xtype,
itemsCreator: o.itemsCreator,
popup: {
type: o.allowInsertValue
? "bi.multi_tree_search_insert_pane"
: "bi.multi_tree_search_pane",
type: o.allowInsertValue ? "bi.multi_tree_search_insert_pane" : "bi.multi_tree_search_pane",
el: {
type: ListPartTree.xtype,
},
@ -86,9 +82,7 @@ export class MultiTreeListCombo extends Single {
{
eventName: MultiTreeSearchInsertPane.EVENT_ADD_ITEM,
action() {
self.storeValue.value.unshift([
self.trigger.getSearcher().getKeyword()
]);
self.storeValue.value.unshift([self.trigger.getSearcher().getKeyword()]);
self._assertShowValue();
// setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了
self.combo.setValue(self.storeValue);
@ -102,10 +96,10 @@ export class MultiTreeListCombo extends Single {
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button",
type: MultiTreeCheckSelectedButton.xtype,
},
popup: {
type: "bi.multi_tree_check_pane",
type: MultiTreeCheckPane.xtype,
el: {
type: ListDisplayTree.xtype,
},
@ -154,10 +148,7 @@ export class MultiTreeListCombo extends Single {
self.trigger.getSearcher().setState(val);
self.numberCounter.setButtonChecked(val);
self.storeValue = { value: self.combo.getValue() };
self.fireEvent(
MultiTreeListCombo.EVENT_CLICK_ITEM,
self.getValue()
);
self.fireEvent(MultiTreeListCombo.EVENT_CLICK_ITEM, self.getValue());
self._dataChange = true;
},
},
@ -196,17 +187,13 @@ export class MultiTreeListCombo extends Single {
},
});
var change = false;
var clear = false; // 标识当前是否点击了清空
const isSearching = function () {
return self.trigger.getSearcher().isSearching();
};
let change = false;
let clear = false; // 标识当前是否点击了清空
const isPopupView = function () {
return self.combo.isViewVisible();
};
const isSearching = () => self.trigger.getSearcher().isSearching();
const isPopupView = () => self.combo.isViewVisible();
this.trigger.on(MultiSelectTrigger.EVENT_FOCUS, () => {
self.fireEvent(MultiTreeListCombo.EVENT_FOCUS);
});
@ -255,14 +242,9 @@ export class MultiTreeListCombo extends Single {
type: BI.Selection.Multi,
value: checked ? { 1: 1 } : {},
};
this.getSearcher().setState(
checked ? BI.Selection.Multi : BI.Selection.None
);
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
self.numberCounter.setButtonChecked(val);
self.fireEvent(
MultiTreeListCombo.EVENT_CLICK_ITEM,
self.combo.getValue()
);
self.fireEvent(MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
self._dataChange = true;
});
@ -285,8 +267,7 @@ export class MultiTreeListCombo extends Single {
this.combo.on(Combo.EVENT_BEFORE_HIDEVIEW, () => {
if (isSearching()) {
self.trigger.stopEditing();
self._dataChange &&
self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
} else {
if (isPopupView()) {
self._stopEditing();
@ -294,15 +275,14 @@ export class MultiTreeListCombo extends Single {
if (clear === true) {
self.storeValue = { value: [] };
}
self._dataChange &&
self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
}
}
clear = false;
change = false;
});
var triggerBtn = createWidget({
const triggerBtn = createWidget({
type: TriggerIconButton.xtype,
width: o.height,
height: o.height,
@ -318,12 +298,12 @@ export class MultiTreeListCombo extends Single {
});
this.numberCounter = createWidget({
type: "bi.multi_select_check_selected_switcher",
type: MultiSelectCheckSelectedSwitcher.xtype,
el: {
type: "bi.multi_tree_check_selected_button",
type: MultiTreeCheckSelectedButton.xtype,
},
popup: {
type: "bi.multi_tree_check_pane",
type: MultiTreeCheckPane.xtype,
},
itemsCreator: o.itemsCreator,
masker: {
@ -337,45 +317,34 @@ export class MultiTreeListCombo extends Single {
valueFormatter: o.valueFormatter,
value: o.value,
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
() => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
);
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
() => {
if (want2showCounter === false) {
want2showCounter = true;
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}
});
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, () => {
if (want2showCounter === false) {
want2showCounter = true;
}
);
if (isInit === true) {
want2showCounter = null;
showCounter();
}
});
this.numberCounter.on(Events.VIEW, b => {
nextTick(() => {
// 自动调整宽度
self.trigger.refreshPlaceHolderWidth(
b === true ? self.numberCounter.element.outerWidth() + 8 : 0
);
self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
});
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
() => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
}
);
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
});
this.trigger.element.click(e => {
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,
});
this.popupView.on(
MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON,
index => {
switch (index) {
case 0:
self.fireEvent(MultiTreePopup.EVENT_CLICK_CLEAR);
break;
case 1:
self.fireEvent(MultiTreePopup.EVENT_CLICK_CONFIRM);
break;
}
this.popupView.on(MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, index => {
switch (index) {
case 0:
self.fireEvent(MultiTreePopup.EVENT_CLICK_CLEAR);
break;
case 1:
self.fireEvent(MultiTreePopup.EVENT_CLICK_CONFIRM);
break;
default:
break;
}
);
});
this.tree.on(TreeView.EVENT_CHANGE, () => {
self.fireEvent(MultiTreePopup.EVENT_CHANGE);

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

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

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

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

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

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

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

@ -9,7 +9,8 @@ import {
size,
keys,
each,
isEmptyObject, Func
isEmptyObject,
Func
} from "@/core";
import { MultiSelectEditor } from "../../multiselect/trigger/editor.multiselect";
import { MultiSelectSearcher } from "../../multiselect/trigger/searcher.multiselect";
@ -48,7 +49,7 @@ export class MultiTreeSearcher extends Widget {
const self = this,
o = this.options;
this.editor = createWidget({
type: "bi.multi_select_editor",
type: MultiSelectEditor.xtype,
watermark: o.watermark,
height: o.height,
el: {
@ -97,13 +98,9 @@ export class MultiTreeSearcher extends Widget {
},
listeners: [
{
eventName:
MultiTreeSearchPane.EVENT_CLICK_TREE_NODE,
eventName: MultiTreeSearchPane.EVENT_CLICK_TREE_NODE,
action() {
self.fireEvent(
MultiTreeSearcher.EVENT_CLICK_TREE_NODE,
arguments
);
self.fireEvent(MultiTreeSearcher.EVENT_CLICK_TREE_NODE, arguments);
},
}
],
@ -179,16 +176,10 @@ export class MultiTreeSearcher extends Widget {
const names = BI.Func.getSortedResult(keys(value));
each(names, (idx, name) => {
const childNodes = getChildrenNode(value[name]);
text +=
`${(name === "null"
? ""
: o.valueFormatter(`${name}`) || name) +
(childNodes === ""
? isEmptyObject(value[name])
? ""
: ":"
: `:${childNodes}`)
}; `;
text += `${
(name === "null" ? "" : o.valueFormatter(`${name}`) || name) +
(childNodes === "" ? (isEmptyObject(value[name]) ? "" : ":") : `:${childNodes}`)
}; `;
if (childNodes === "") {
count++;
}
@ -211,9 +202,7 @@ export class MultiTreeSearcher extends Widget {
index++;
const childNodes = getChildrenNode(ob[name]);
text +=
(name === "null"
? ""
: o.valueFormatter(`${name}`) || name) +
(name === "null" ? "" : o.valueFormatter(`${name}`) || name) +
(childNodes === "" ? "" : `:${childNodes}`) +
(index === _size ? "" : ",");
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 { TextEditor } from "../editor";
import { IconButton } from "@/base";
@shortcut()
export class NumberEditor extends Widget {
static xtype = "bi.number_editor"
static xtype = "bi.number_editor";
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig(conf) {
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,
valueFormatter (v) {
valueFormatter(v) {
return v;
},
valueParser (v) {
valueParser(v) {
return v;
},
value: 0,
@ -50,27 +68,28 @@ export class NumberEditor extends Widget {
return o.validationChecker(parsedValue);
},
errorText: o.errorText,
listeners: [{
eventName: SignEditor.EVENT_QUICK_DOWN,
action: e => {
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);
}
listeners: [
{
eventName: SignEditor.EVENT_QUICK_DOWN,
action: e => {
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);
}
},
}
],
});
this.editor.on(TextEditor.EVENT_CHANGE, () => {
@ -98,7 +117,9 @@ export class NumberEditor extends Widget {
forceNotSelected: true,
trigger: "lclick,",
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._finetuning(o.step);
@ -110,7 +131,9 @@ export class NumberEditor extends Widget {
trigger: "lclick,",
forceNotSelected: true,
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._finetuning(-o.step);
@ -122,20 +145,24 @@ export class NumberEditor extends Widget {
height: toPix(o.height, 2),
element: this,
items: [
this.editor, {
this.editor,
{
el: {
type: GridLayout.xtype,
columns: 1,
rows: 2,
items: [{
column: 0,
row: 0,
el: this.topBtn,
}, {
column: 0,
row: 1,
el: this.bottomBtn,
}],
items: [
{
column: 0,
row: 0,
el: this.topBtn,
},
{
column: 0,
row: 1,
el: this.bottomBtn,
}
],
},
width: 23,
}
@ -165,10 +192,7 @@ export class NumberEditor extends Widget {
}
_finetuning(addValue) {
const {
max,
min,
} = this.options;
const { max, min } = this.options;
let v = parseFloat(this.getValue());
v = add(v, addValue);
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 { IconCombo } from "@/case";
import { NumberIntervalSingleEidtor } from "./singleeditor/single.editor";
@shortcut()
export class NumberInterval extends Single {
static xtype = "bi.number_interval"
static xtype = "bi.number_interval";
constants = {
typeError: "typeBubble",
@ -23,16 +37,16 @@ export class NumberInterval extends Single {
adjustYOffset: 2,
};
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
extraCls: `bi-number-interval${(isIE() && getIEVersion() < 10) ? " hack" : ""}`,
extraCls: `bi-number-interval${isIE() && getIEVersion() < 10 ? " hack" : ""}`,
height: 24,
validation: "valid",
closeMin: true,
@ -47,29 +61,31 @@ export class NumberInterval extends Single {
o = this.options;
super._init(...arguments);
this.smallEditor = createWidget({
type: "bi.number_interval_single_editor",
type: NumberIntervalSingleEidtor.xtype,
height: toPix(o.height, o.simple ? 1 : 2),
watermark: o.watermark,
allowBlank: o.allowBlank,
value: o.min,
level: "warning",
tipType: "success",
title () {
title() {
return self.smallEditor && self.smallEditor.getValue();
},
quitChecker () {
quitChecker() {
return false;
},
validationChecker (v) {
validationChecker(v) {
if (!isNumeric(v)) {
self.smallEditorBubbleType = c.typeError;
return false;
}
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({
@ -81,35 +97,39 @@ export class NumberInterval extends Single {
createWidget({
type: AbsoluteLayout.xtype,
element: this.smallEditor,
items: [{
el: this.smallTip,
top: 0,
right: 5,
}],
items: [
{
el: this.smallTip,
top: 0,
right: 5,
},
],
});
this.bigEditor = createWidget({
type: "bi.number_interval_single_editor",
type: NumberIntervalSingleEidtor.xtype,
height: toPix(o.height, o.simple ? 1 : 2),
watermark: o.watermark,
allowBlank: o.allowBlank,
value: o.max,
title () {
title() {
return self.bigEditor && self.bigEditor.getValue();
},
quitChecker () {
quitChecker() {
return false;
},
validationChecker (v) {
validationChecker(v) {
if (!isNumeric(v)) {
self.bigEditorBubbleType = c.typeError;
return false;
}
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({
@ -121,26 +141,33 @@ export class NumberInterval extends Single {
createWidget({
type: AbsoluteLayout.xtype,
element: this.bigEditor,
items: [{
el: this.bigTip,
top: 0,
right: 5,
}],
items: [
{
el: this.bigTip,
top: 0,
right: 5,
},
],
});
this.smallCombo = createWidget({
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),
width: toPix(c.width, c.border),
items: [{
text: `(${i18nText("BI-Less_Than")})`,
iconCls: "less-font",
value: 0,
}, {
text: `(${i18nText("BI-Less_And_Equal")})`,
value: 1,
iconCls: "less-equal-font",
}],
items: [
{
text: `(${i18nText("BI-Less_Than")})`,
iconCls: "less-font",
value: 0,
},
{
text: `(${i18nText("BI-Less_And_Equal")})`,
value: 1,
iconCls: "less-equal-font",
},
],
});
if (o.closeMin === true) {
this.smallCombo.setValue(1);
@ -149,18 +176,23 @@ export class NumberInterval extends Single {
}
this.bigCombo = createWidget({
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),
width: toPix(c.width, c.border),
items: [{
text: `(${i18nText("BI-Less_Than")})`,
iconCls: "less-font",
value: 0,
}, {
text: `(${i18nText("BI-Less_And_Equal")})`,
value: 1,
iconCls: "less-equal-font",
}],
items: [
{
text: `(${i18nText("BI-Less_Than")})`,
iconCls: "less-font",
value: 0,
},
{
text: `(${i18nText("BI-Less_And_Equal")})`,
value: 1,
iconCls: "less-equal-font",
},
],
});
if (o.closeMax === true) {
this.bigCombo.setValue(1);
@ -178,38 +210,47 @@ export class NumberInterval extends Single {
tipType: "warning",
});
this.left = createWidget({
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: ["fill", ""],
items: [{
el: self.smallEditor,
}, {
el: self.smallCombo,
}],
items: [
{
el: self.smallEditor,
},
{
el: self.smallCombo,
},
],
});
this.right = createWidget({
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"],
items: [{
el: self.bigCombo,
}, {
el: self.bigEditor,
// BI-23883 间距考虑边框
// lgap: 1
}],
items: [
{
el: self.bigCombo,
},
{
el: self.bigEditor,
// BI-23883 间距考虑边框
// lgap: 1
},
],
});
createWidget({
element: self,
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
items: [{
el: self.left,
}, {
el: self.label,
}, {
el: self.right,
}],
items: [
{
el: self.left,
},
{
el: self.label,
},
{
el: self.right,
},
],
});
// createWidget({
@ -275,13 +316,13 @@ export class NumberInterval extends Single {
if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) {
self.element.removeClass("number-error");
o.validation = "invalid";
return c.typeError;
}
if (isEmptyString(self.smallEditor.getValue()) || isEmptyString(self.bigEditor.getValue())) {
self.element.removeClass("number-error");
o.validation = "valid";
return "";
}
const smallValue = parseFloat(self.smallEditor.getValue()),
@ -292,28 +333,28 @@ export class NumberInterval extends Single {
if (smallValue > bigValue) {
self.element.addClass("number-error");
o.validation = "invalid";
return c.numberError;
}
self.element.removeClass("number-error");
o.validation = "valid";
return "";
}
if (smallValue > bigValue) {
self.element.addClass("number-error");
o.validation = "invalid";
return c.numberError;
} else if (smallValue === bigValue) {
self.element.addClass("number-error");
o.validation = "invalid";
return c.signalError;
}
self.element.removeClass("number-error");
o.validation = "valid";
return "";
}
@ -327,26 +368,26 @@ export class NumberInterval extends Single {
w.on(NumberIntervalSingleEidtor.EVENT_FOCUS, () => {
self._setTitle("");
switch (self._checkValidation()) {
case c.typeError:
Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
break;
case c.numberError:
Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
break;
case c.signalError:
Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
break;
default:
return;
case c.typeError:
Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
break;
case c.numberError:
Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
break;
case c.signalError:
Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
break;
default:
return;
}
});
}
@ -359,17 +400,17 @@ export class NumberInterval extends Single {
Bubbles.hide(c.numberError);
Bubbles.hide(c.signalError);
switch (self._checkValidation()) {
case c.typeError:
self._setTitle(i18nText("BI-Numerical_Interval_Input_Data"));
break;
case c.numberError:
self._setTitle(i18nText("BI-Numerical_Interval_Number_Value"));
break;
case c.signalError:
self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value"));
break;
default:
self._setTitle("");
case c.typeError:
self._setTitle(i18nText("BI-Numerical_Interval_Input_Data"));
break;
case c.numberError:
self._setTitle(i18nText("BI-Numerical_Interval_Number_Value"));
break;
case c.signalError:
self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value"));
break;
default:
self._setTitle("");
}
});
}
@ -392,22 +433,22 @@ export class NumberInterval extends Single {
c = this.constants;
w.on(NumberIntervalSingleEidtor.EVENT_VALID, () => {
switch (self._checkValidation()) {
case c.numberError:
Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
self.fireEvent(NumberInterval.EVENT_ERROR);
break;
case c.signalError:
Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
self.fireEvent(NumberInterval.EVENT_ERROR);
break;
default:
self.fireEvent(NumberInterval.EVENT_VALID);
case c.numberError:
Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
self.fireEvent(NumberInterval.EVENT_ERROR);
break;
case c.signalError:
Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
self.fireEvent(NumberInterval.EVENT_ERROR);
break;
default:
self.fireEvent(NumberInterval.EVENT_VALID);
}
});
}
@ -417,26 +458,26 @@ export class NumberInterval extends Single {
c = this.constants;
w.on(NumberIntervalSingleEidtor.EVENT_CHANGE, () => {
switch (self._checkValidation()) {
case c.typeError:
Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
break;
case c.numberError:
Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
break;
case c.signalError:
Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
break;
default:
break;
case c.typeError:
Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
break;
case c.numberError:
Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
break;
case c.signalError:
Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
offsetStyle: "left",
adjustYOffset: c.adjustYOffset,
});
break;
default:
break;
}
self.fireEvent(NumberInterval.EVENT_CHANGE);
});
@ -450,22 +491,22 @@ export class NumberInterval extends Single {
c = this.constants;
w.on(IconCombo.EVENT_CHANGE, () => {
switch (self._checkValidation()) {
case c.typeError:
self._setTitle(i18nText("BI-Numerical_Interval_Input_Data"));
self.fireEvent(NumberInterval.EVENT_ERROR);
break;
case c.numberError:
self._setTitle(i18nText("BI-Numerical_Interval_Number_Value"));
self.fireEvent(NumberInterval.EVENT_ERROR);
break;
case c.signalError:
self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value"));
self.fireEvent(NumberInterval.EVENT_ERROR);
break;
default:
self.fireEvent(NumberInterval.EVENT_CHANGE);
self.fireEvent(NumberInterval.EVENT_CONFIRM);
self.fireEvent(NumberInterval.EVENT_VALID);
case c.typeError:
self._setTitle(i18nText("BI-Numerical_Interval_Input_Data"));
self.fireEvent(NumberInterval.EVENT_ERROR);
break;
case c.numberError:
self._setTitle(i18nText("BI-Numerical_Interval_Number_Value"));
self.fireEvent(NumberInterval.EVENT_ERROR);
break;
case c.signalError:
self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value"));
self.fireEvent(NumberInterval.EVENT_ERROR);
break;
default:
self.fireEvent(NumberInterval.EVENT_CHANGE);
self.fireEvent(NumberInterval.EVENT_CONFIRM);
self.fireEvent(NumberInterval.EVENT_VALID);
}
});
}
@ -568,7 +609,7 @@ export class NumberInterval extends Single {
} else {
value.closeMax = true;
}
return value;
}

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

@ -3,15 +3,15 @@ import { Single, Editor } from "@/base";
@shortcut()
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_BLUR = "EVENT_BLUR"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_VALID = "EVENT_VALID"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_VALID = "EVENT_VALID";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
static EVENT_CONFIRM = "EVENT_CONFIRM";
props = {
baseCls: "bi-number-interval-single-editor",
@ -25,55 +25,65 @@ export class NumberIntervalSingleEidtor extends Single {
return {
type: VerticalLayout.xtype,
items: [{
type: Editor.xtype,
simple: o.simple,
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);
items: [
{
type: Editor.xtype,
simple: o.simple,
ref(_ref) {
self.editor = _ref;
},
}, {
eventName: Editor.EVENT_FOCUS,
action () {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_FOCUS, arguments);
},
}, {
eventName: Editor.EVENT_BLUR,
action () {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_BLUR, arguments);
},
}, {
eventName: Editor.EVENT_VALID,
action () {
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);
},
}],
}],
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);
},
},
{
eventName: Editor.EVENT_FOCUS,
action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_FOCUS, arguments);
},
},
{
eventName: Editor.EVENT_BLUR,
action() {
self.fireEvent(NumberIntervalSingleEidtor.EVENT_BLUR, arguments);
},
},
{
eventName: Editor.EVENT_VALID,
action() {
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 { SearchMultiSelectPopupView } from "./multitextvalue.popup.view.search";
export { SearchMultiSelectTrigger } from "./multitextvalue.combo.trigger.search";
export { SearchMultiSelectLoader } from "./multitextvalue.loader.search";
export { SearchMultiSelectSearcher } from "./trigger/searcher.multitextvalue";
export { SearchMultiTextValueCombo } from "./multitextvalue.combo.search";
export { SearchMultiSelectPopupView } from "./multitextvalue.popup.view.search";
export { SearchMultiSelectTrigger } from "./multitextvalue.combo.trigger.search";
export { SearchMultiSelectLoader } from "./multitextvalue.loader.search";
export { SearchMultiSelectSearcher } from "./trigger/searcher.multitextvalue";

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

@ -29,8 +29,12 @@ import {
BlankSplitChar
} from "@/core";
import { Single, Combo } from "@/base";
import { MultiSelectTrigger, MultiSelectPopupView, MultiSelectCombo, SearchMultiSelectTrigger, SearchMultiSelectPopupView } from "@/widget";
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()
export class SearchMultiTextValueCombo extends Single {
@ -231,7 +235,6 @@ export class SearchMultiTextValueCombo extends Single {
}
});
triggerBtn.on(TriggerIconButton.EVENT_CHANGE, () => {
this.trigger.getCounter().hideView();
if (this.combo.isViewVisible()) {
@ -328,7 +331,7 @@ export class SearchMultiTextValueCombo extends Single {
});
change && (this.storeValue.value = values(_map));
this._adjust(callback);
return;
}
const selectedMap = this._makeMap(this.storeValue.value);
@ -410,7 +413,7 @@ export class SearchMultiTextValueCombo extends Single {
});
change && (this.storeValue.value = values(map));
this._adjust(callback);
return;
}
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++) {
res.push(items[i]);
}
return res;
}
@ -454,12 +457,12 @@ export class SearchMultiTextValueCombo extends Single {
callback({
items,
});
return;
}
if (options.type == MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({ count: items.length });
return;
}
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 { 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()
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) {
const json = map(this.storeValue.value, (i, v) => {
const txt = opts.valueFormatter(v) || v;
return {
text: txt,
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 { MultiPopupView } from "@/case";
import { SearchMultiSelectLoader } from "@/widget";
import { SearchMultiSelectLoader } from "@/widget/searchmultitextvaluecombo/multitextvalue.loader.search";
@shortcut()
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 { 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()
export class SearchMultiSelectSearcher extends Widget {
@ -173,7 +174,7 @@ export class SearchMultiSelectSearcher extends Widget {
return this.searcher.getValue();
}
populate(items) {
this.searcher.populate.apply(this.searcher, arguments);
populate(...items) {
this.searcher.populate(items);
}
}

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

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

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

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

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

@ -5,7 +5,12 @@ import {
each,
createWidget,
Controller,
isArray, isNotEmptyArray, UUID, defaults, Tree, VerticalLayout
isArray,
isNotEmptyArray,
UUID,
defaults,
Tree,
VerticalLayout
} from "@/core";
import { Pane } from "@/base";
import { BasicTreeItem, BasicTreeNode, LevelTree, TreeExpander } from "@/case";
@ -37,11 +42,7 @@ export class SelectTreePopup extends Pane {
};
node.id = node.id || UUID();
if (
node.isParent === true ||
node.parent === true ||
isNotEmptyArray(node.children)
) {
if (node.isParent === true || node.parent === true || isNotEmptyArray(node.children)) {
extend.type = BasicTreeNode.xtype;
extend.selectable = true;
defaults(node, extend);
@ -102,8 +103,6 @@ export class SelectTreePopup extends Pane {
populate(items) {
super.populate(...arguments);
this.tree.populate(
this._formatItems(Tree.transformToTreeFormat(items))
);
this.tree.populate(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 { SingleSelectList } from "../singleselect.list";
import { SingleSelectItem, SingleSelectRadioItem } from "@/case";
@ -49,7 +63,7 @@ export class SingleSelectSearchLoader extends Widget {
el: {
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
behaviors: {
redmark () {
redmark() {
return true;
},
},
@ -61,7 +75,7 @@ export class SingleSelectSearchLoader extends Widget {
},
},
},
itemsCreator (op, callback) {
itemsCreator(op, callback) {
self.storeValue &&
(op = extend(op || {}, {
selectedValues: [self.storeValue],
@ -83,7 +97,7 @@ export class SingleSelectSearchLoader extends Widget {
}
});
},
hasNext () {
hasNext() {
return hasNext;
},
});
@ -97,20 +111,22 @@ export class SingleSelectSearchLoader extends Widget {
_createItems(items) {
const o = this.options;
return map(items, (i, item) => extend(
{
type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
logic: o.logic,
cls: "bi-list-item-active",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
selected: false,
iconWrapperWidth: 26,
hgap: o.allowNoSelect ? 10 : 0,
title: item.title || item.text,
},
item
));
return map(items, (i, item) =>
extend(
{
type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
logic: o.logic,
cls: "bi-list-item-active",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
selected: false,
iconWrapperWidth: 26,
hgap: o.allowNoSelect ? 10 : 0,
title: item.title || item.text,
},
item
)
);
}
_filterValues(src) {
@ -127,7 +143,7 @@ export class SingleSelectSearchLoader extends Widget {
const search = Func.getSearchResult(newValues, keyword);
values = search.match.concat(search.find);
}
return map(values, (i, v) => {
return {
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 { SingleSelectSearchLoader } from "./singleselect.search.loader";
@ -38,7 +48,7 @@ export class SingleSelectSearchInsertPane extends Widget {
allowNoSelect: o.allowNoSelect,
keywordGetter: o.keywordGetter,
valueFormatter: o.valueFormatter,
itemsCreator (op, callback) {
itemsCreator(op, callback) {
o.itemsCreator.apply(self, [
op,
function (res) {

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

@ -38,7 +38,7 @@ export class SingleSelectSearchPane extends Widget {
allowNoSelect: o.allowNoSelect,
keywordGetter: o.keywordGetter,
valueFormatter: o.valueFormatter,
itemsCreator (op, callback) {
itemsCreator(op, callback) {
o.itemsCreator.apply(self, [
op,
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 { SingleSelectTrigger } from "./singleselect.trigger";
import { SingleSelectPopupView } from "./singleselect.popup.view";
@ -42,7 +56,7 @@ export class SingleSelectCombo extends Single {
this.requesting = false;
this.trigger = createWidget({
type: "bi.single_select_trigger",
type: SingleSelectTrigger.xtype,
height: toPix(o.height, o.simple ? 1 : 2),
// adapter: this.popup,
allowNoSelect: o.allowNoSelect,
@ -81,15 +95,12 @@ export class SingleSelectCombo extends Single {
this.fireEvent(SingleSelectCombo.EVENT_SEARCHING);
});
this.trigger.on(
SingleSelectTrigger.EVENT_CHANGE,
(value, obj) => {
this.storeValue = this.trigger.getValue();
assertShowValue();
this._defaultState();
this._dataChange = true;
}
);
this.trigger.on(SingleSelectTrigger.EVENT_CHANGE, (value, obj) => {
this.storeValue = this.trigger.getValue();
assertShowValue();
this._defaultState();
this._dataChange = true;
});
this.trigger.on(SingleSelectTrigger.EVENT_COUNTER_CLICK, () => {
if (!this.combo.isViewVisible()) {
this.combo.showView();
@ -104,24 +115,26 @@ export class SingleSelectCombo extends Single {
el: this.trigger,
adjustLength: 1,
popup: {
type: "bi.single_select_popup_view",
type: SingleSelectPopupView.xtype,
allowNoSelect: o.allowNoSelect,
ref: _ref => {
this.popup = _ref;
this.trigger.setAdapter(_ref);
},
listeners: [{
eventName: SingleSelectPopupView.EVENT_CHANGE,
action: () => {
this._dataChange = true;
this.storeValue = this.popup.getValue();
this._adjust(() => {
assertShowValue();
this._defaultState();
});
this.fireEvent(SingleSelectCombo.EVENT_CLICK_ITEM);
},
}],
listeners: [
{
eventName: SingleSelectPopupView.EVENT_CHANGE,
action: () => {
this._dataChange = true;
this.storeValue = this.popup.getValue();
this._adjust(() => {
assertShowValue();
this._defaultState();
});
this.fireEvent(SingleSelectCombo.EVENT_CLICK_ITEM);
},
}
],
itemsCreator: o.itemsCreator,
itemWrapper: o.itemWrapper,
valueFormatter: o.valueFormatter,
@ -156,8 +169,7 @@ export class SingleSelectCombo extends Single {
if (this.requesting === true) {
this.wants2Quit = true;
} else {
this._dataChange &&
this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
this._dataChange && this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
}
});
@ -177,19 +189,20 @@ export class SingleSelectCombo extends Single {
createWidget({
type: AbsoluteLayout.xtype,
element: this,
items: [{
el: this.combo,
left: 0,
right: 0,
top: 0,
bottom: 0,
},
{
el: triggerBtn,
right: 0,
top: 0,
bottom: 0,
}
items: [
{
el: this.combo,
left: 0,
right: 0,
top: 0,
bottom: 0,
},
{
el: triggerBtn,
right: 0,
top: 0,
bottom: 0,
}
],
});
}
@ -209,14 +222,15 @@ export class SingleSelectCombo extends Single {
const o = this.options;
this._assertValue(this.storeValue);
this.requesting = true;
o.itemsCreator({
type: SingleSelectCombo.REQ_GET_ALL_DATA,
keywords,
},
ob => {
const values = map(ob.items, "value");
digest(values);
}
o.itemsCreator(
{
type: SingleSelectCombo.REQ_GET_ALL_DATA,
keywords,
},
ob => {
const values = map(ob.items, "value");
digest(values);
}
);
const digest = items => {
@ -233,8 +247,7 @@ export class SingleSelectCombo extends Single {
_adjust(callback) {
const adjust = () => {
if (this.wants2Quit === true) {
this._dataChange &&
this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
this._dataChange && this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
this.wants2Quit = false;
}
this.requesting = false;
@ -242,14 +255,15 @@ export class SingleSelectCombo extends Single {
const o = this.options;
if (!this._count) {
o.itemsCreator({
type: SingleSelectCombo.REQ_GET_DATA_LENGTH,
},
res => {
this._count = res.count;
adjust();
callback();
}
o.itemsCreator(
{
type: SingleSelectCombo.REQ_GET_DATA_LENGTH,
},
res => {
this._count = res.count;
adjust();
callback();
}
);
} else {
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 { SingleSelectTrigger } from "./singleselect.trigger";
import { SingleSelectPopupView } from "./singleselect.popup.view";
@ -50,7 +63,7 @@ export class SingleSelectInsertCombo extends Single {
allowEdit: o.allowEdit,
// adapter: this.popup,
valueFormatter: o.valueFormatter,
itemsCreator (op, callback) {
itemsCreator(op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && isNotNull(op.keywords)) {
// 预防trigger内部把当前的storeValue改掉
@ -63,7 +76,7 @@ export class SingleSelectInsertCombo extends Single {
value: this.storeValue,
searcher: {
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);
});
this.trigger.on(
SingleSelectTrigger.EVENT_CHANGE,
function (value, obj) {
self.storeValue = this.getValue();
assertShowValue();
self._defaultState();
self._dataChange = true;
}
);
this.trigger.on(SingleSelectTrigger.EVENT_CHANGE, function (value, obj) {
self.storeValue = this.getValue();
assertShowValue();
self._defaultState();
self._dataChange = true;
});
this.trigger.on(SingleSelectTrigger.EVENT_COUNTER_CLICK, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
@ -118,30 +128,28 @@ export class SingleSelectInsertCombo extends Single {
popup: {
type: SingleSelectPopupView.xtype,
allowNoSelect: o.allowNoSelect,
ref () {
ref() {
self.popup = this;
self.trigger.setAdapter(this);
},
listeners: [
{
eventName: SingleSelectPopupView.EVENT_CHANGE,
action () {
action() {
self._dataChange = true;
self.storeValue = this.getValue();
self._adjust(() => {
assertShowValue();
self._defaultState();
});
self.fireEvent(
SingleSelectInsertCombo.EVENT_CLICK_ITEM
);
self.fireEvent(SingleSelectInsertCombo.EVENT_CLICK_ITEM);
},
}
],
itemsCreator: o.itemsCreator,
itemWrapper: o.itemWrapper,
valueFormatter: o.valueFormatter,
onLoaded () {
onLoaded() {
nextTick(() => {
self.combo.adjustWidth();
self.combo.adjustHeight();
@ -149,7 +157,7 @@ export class SingleSelectInsertCombo extends Single {
});
},
},
hideChecker (e) {
hideChecker(e) {
return triggerBtn.element.find(e.target).length === 0;
},
value: o.value,
@ -172,8 +180,7 @@ export class SingleSelectInsertCombo extends Single {
if (self.requesting === true) {
self.wants2Quit = true;
} else {
self._dataChange &&
self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
}
});
@ -229,8 +236,7 @@ export class SingleSelectInsertCombo extends Single {
function adjust() {
if (self.wants2Quit === true) {
self._dataChange &&
self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
self.wants2Quit = 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, {
type: ListPane.xtype,
items: o.items,
itemsCreator (op, callback) {
itemsCreator(op, callback) {
op.times === 1 && self.toolbar && self.toolbar.setVisible(false);
o.itemsCreator(op, function (items) {
callback.apply(self, arguments);
@ -79,13 +79,13 @@ export class SingleSelectList extends Widget {
height: this._constants.itemHeight,
forceNotSelected: true,
text: i18nText("BI-Basic_No_Select"),
ref (_ref) {
ref(_ref) {
self.toolbar = _ref;
},
listeners: [
{
eventName: Controller.EVENT_CHANGE,
action (type) {
action(type) {
if (type === Events.CLICK) {
self.list.setValue();
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 { SingleSelectList } from "./singleselect.list";
import { SingleSelectItem, SingleSelectRadioItem } from "@/case";
@ -52,7 +64,7 @@ export class SingleSelectLoader extends Widget {
el: {
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
behaviors: {
redmark () {
redmark() {
return true;
},
},
@ -66,7 +78,7 @@ export class SingleSelectLoader extends Widget {
},
opts.el
),
itemsCreator (op, callback) {
itemsCreator(op, callback) {
const startValue = self._startValue;
!isUndefined(self.storeValue) &&
(op = extend(op || {}, {
@ -78,7 +90,7 @@ export class SingleSelectLoader extends Widget {
if (op.times === 1 && !isUndefined(self.storeValue)) {
const json = map([self.storeValue], (i, v) => {
const txt = opts.valueFormatter(v) || v;
return (
opts.itemWrapper({
text: txt,
@ -103,7 +115,7 @@ export class SingleSelectLoader extends Widget {
op.times === 1 && self._scrollToTop();
});
},
hasNext () {
hasNext() {
return hasNext;
},
value: this.storeValue,
@ -126,20 +138,22 @@ export class SingleSelectLoader extends Widget {
_createItems(items) {
const o = this.options;
return map(items, (i, item) => extend(
{
type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
logic: o.logic,
cls: "bi-list-item-active",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
selected: false,
iconWrapperWidth: 26,
textHgap: o.allowNoSelect ? 10 : 0,
title: item.title || item.text,
},
item
));
return map(items, (i, item) =>
extend(
{
type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
logic: o.logic,
cls: "bi-list-item-active",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
selected: false,
iconWrapperWidth: 26,
textHgap: o.allowNoSelect ? 10 : 0,
title: item.title || item.text,
},
item
)
);
}
_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 { MultiPopupView } from "@/case";
import { PopupView } from "@/base";
@ -27,7 +28,7 @@ export class SingleSelectPopupView extends Widget {
const opts = this.options;
this.loader = createWidget({
type: "bi.single_select_loader",
type: SingleSelectLoader.xtype,
allowNoSelect: opts.allowNoSelect,
itemsCreator: opts.itemsCreator,
itemWrapper: opts.itemWrapper,

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

@ -1,3 +1,4 @@
import { SingleSelectSearchInsertPane } from "./search";
import {
shortcut,
extend,
@ -68,14 +69,14 @@ export class SingleSelectInsertList extends Single {
});
this.searcherPane = createWidget({
type: "bi.single_select_search_insert_pane",
type: SingleSelectSearchInsertPane.xtype,
allowNoSelect: o.allowNoSelect,
cls: "bi-border-left bi-border-right bi-border-bottom",
valueFormatter: o.valueFormatter,
keywordGetter () {
keywordGetter() {
return self.trigger.getKeyword();
},
itemsCreator (op, callback) {
itemsCreator(op, callback) {
op.keywords = [self.trigger.getKeyword()];
if (isNotEmptyString(op.keywords[0])) {
this.setKeyword(op.keywords[0]);
@ -93,14 +94,14 @@ export class SingleSelectInsertList extends Single {
type: SearchEditor.xtype,
watermark: i18nText("BI-Basic_Search_And_Patch_Paste"),
},
ref (ref) {
ref(ref) {
self.editor = ref;
},
height: o.searcherHeight,
},
isAutoSearch: false,
isAutoSync: false,
onSearch (op, callback) {
onSearch(op, callback) {
callback();
},
adapter: this.adapter,
@ -110,7 +111,7 @@ export class SingleSelectInsertList extends Single {
listeners: [
{
eventName: Searcher.EVENT_START,
action () {
action() {
self._showSearcherPane();
self._setStartValue();
this.setValue(deepClone(self.storeValue));
@ -118,7 +119,7 @@ export class SingleSelectInsertList extends Single {
},
{
eventName: Searcher.EVENT_STOP,
action () {
action() {
self._showAdapter();
self._setStartValue();
self.adapter.setValue(self.storeValue);
@ -128,7 +129,7 @@ export class SingleSelectInsertList extends Single {
},
{
eventName: Searcher.EVENT_PAUSE,
action () {
action() {
const keyword = this.getKeyword();
self.storeValue = keyword;
self._showAdapter();
@ -142,7 +143,7 @@ export class SingleSelectInsertList extends Single {
},
{
eventName: Searcher.EVENT_CHANGE,
action () {
action() {
self.storeValue = this.getValue();
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 { 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 { SingleSelectEditor } from "./editor.singleselect";
import { Searcher } from "@/base";
@ -33,22 +34,23 @@ export class SingleSelectSearcher extends Widget {
const self = this,
o = this.options;
this.editor = createWidget(o.el, {
type: "bi.single_select_editor",
type: SingleSelectEditor.xtype,
height: o.height,
watermark: o.watermark,
text: o.text,
listeners: [{
eventName: SingleSelectEditor.EVENT_FOCUS,
action: () => {
this.fireEvent(SingleSelectSearcher.EVENT_FOCUS);
listeners: [
{
eventName: SingleSelectEditor.EVENT_FOCUS,
action: () => {
this.fireEvent(SingleSelectSearcher.EVENT_FOCUS);
},
},
},
{
eventName: SingleSelectEditor.EVENT_BLUR,
action: () => {
this.fireEvent(SingleSelectSearcher.EVENT_BLUR);
},
}
{
eventName: SingleSelectEditor.EVENT_BLUR,
action: () => {
this.fireEvent(SingleSelectSearcher.EVENT_BLUR);
},
}
],
});
@ -63,20 +65,21 @@ export class SingleSelectSearcher extends Widget {
},
el: this.editor,
popup: extend({
type: "bi.single_select_search_pane",
allowNoSelect: o.allowNoSelect,
valueFormatter: o.valueFormatter,
keywordGetter: () => this.editor.getValue(),
itemsCreator(op, callback) {
const keyword = self.editor.getValue();
op.keywords = [keyword];
this.setKeyword(keyword);
o.itemsCreator(op, callback);
popup: extend(
{
type: SingleSelectSearchPane.xtype,
allowNoSelect: o.allowNoSelect,
valueFormatter: o.valueFormatter,
keywordGetter: () => this.editor.getValue(),
itemsCreator(op, callback) {
const keyword = self.editor.getValue();
op.keywords = [keyword];
this.setKeyword(keyword);
o.itemsCreator(op, callback);
},
value: o.value,
},
value: o.value,
},
o.popup
o.popup
),
adapter: o.adapter,

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

@ -24,7 +24,7 @@ export class SignTextEditor extends Widget {
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-sign-initial-editor`,
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",
height: 8,
width: 8,
}
};
constants = {
LARGE_SIZE: 16,
NORMAL_SIZE: 12,

10
src/widget/singleslider/index.js

@ -1,5 +1,5 @@
export { SingleSlider } from "./singleslider";
export { SingleSliderLabel } from "./singleslider.label";
export { SingleSliderNormal } from "./singleslider.normal";
export { SignTextEditor } from "./button/editor.sign.text";
export { SliderIconButton } from "./button/iconbutton.slider";
export { SingleSlider } from "./singleslider";
export { SingleSliderLabel } from "./singleslider.label";
export { SingleSliderNormal } from "./singleslider.normal";
export { SignTextEditor } from "./button/editor.sign.text";
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 {
shortcut,
createWidget,
@ -32,7 +34,7 @@ export class SingleSlider extends Single {
TRACK_HEIGHT: 24,
TRACK_GAP_HALF: 7,
TRACK_GAP: 14,
}
};
props = {
baseCls: "bi-single-slider bi-slider-track",
@ -74,7 +76,7 @@ export class SingleSlider extends Single {
this.track = this._createTrackWrapper();
this.slider = createWidget({
type: "bi.single_slider_button",
type: SliderIconButton.xtype,
});
this._draggable(this.slider);
const sliderVertical = createWidget({
@ -98,17 +100,9 @@ export class SingleSlider extends Single {
});
// 这边其实是有问题的,拖拽区域是个圆,在圆的边缘拖拽后放开,这边计算出来的蓝条宽度实际上会比放开时长一点或者短一点
sliderVertical.element.click(e => {
if (
this.enable &&
this.isEnabled() &&
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;
if (this.enable && this.isEnabled() && 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;
if (offset < 0) {
percent = 0;
@ -129,7 +123,7 @@ export class SingleSlider extends Single {
}
});
this.label = createWidget({
type: "bi.sign_text_editor",
type: SignTextEditor.xtype,
cls: "slider-editor-button",
text: o.unit,
width: toPix(c.EDITOR_WIDTH, 2),
@ -140,9 +134,7 @@ export class SingleSlider extends Single {
});
this.label.element.hover(
() => {
this.label.element
.removeClass("bi-border")
.addClass("bi-border");
this.label.element.removeClass("bi-border").addClass("bi-border");
},
() => {
this.label.element.removeClass("bi-border");
@ -158,7 +150,7 @@ export class SingleSlider extends Single {
this.fireEvent(SingleSlider.EVENT_CHANGE);
});
this._setVisible(false);
return {
type: AbsoluteLayout.xtype,
items: [
@ -216,7 +208,7 @@ export class SingleSlider extends Single {
offset = 0,
defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker(
(deltaX => {
deltaX => {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
@ -232,8 +224,8 @@ export class SingleSlider extends Single {
this.label.setValue(v);
this.value = v;
}
}),
(() => {
},
() => {
if (startDrag === true) {
size = optimizeSize(size);
const percent = (size * 100) / this._getGrayTrackLength();
@ -247,7 +239,7 @@ export class SingleSlider extends Single {
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
this.fireEvent(SingleSlider.EVENT_CHANGE);
}),
},
window
);
widget.element.on("mousedown", function (event) {
@ -306,11 +298,11 @@ export class SingleSlider extends Single {
if (o.digit === false) {
valid = true;
} else {
const dotText = (`${v}`).split(".")[1] || "";
const dotText = `${v}`.split(".")[1] || "";
valid = dotText.length === o.digit;
}
}
return valid;
}
@ -343,7 +335,7 @@ export class SingleSlider extends Single {
_getValueByPercent(percent) {
const thousandth = parseInt(percent * 10);
return ((this.max - this.min) * thousandth) / 1000 + this.min;
}
@ -375,13 +367,9 @@ export class SingleSlider extends Single {
_setEnable(b) {
super._setEnable.apply(this, [b]);
if (b) {
this.blueTrack.element
.removeClass("disabled-blue-track")
.addClass("blue-track");
this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
} else {
this.blueTrack.element
.removeClass("blue-track")
.addClass("disabled-blue-track");
this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
}
}
@ -409,21 +397,9 @@ export class SingleSlider extends Single {
this._setVisible(true);
this.enable = true;
if (o.digit) {
this.label.setErrorText(
i18nText(
"BI-Basic_Please_Enter_Number_Between",
this.min,
this.max
)
);
this.label.setErrorText(i18nText("BI-Basic_Please_Enter_Number_Between", this.min, this.max));
} else {
this.label.setErrorText(
i18nText(
"BI-Basic_Please_Enter_Integer_Number_Between",
this.min,
this.max
)
);
this.label.setErrorText(i18nText("BI-Basic_Please_Enter_Integer_Number_Between", this.min, this.max));
}
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 {
shortcut,
createWidget,
@ -30,7 +31,7 @@ export class SingleSliderLabel extends Single {
TRACK_HEIGHT: 24,
TRACK_GAP_HALF: 7,
TRACK_GAP: 14,
}
};
props = {
baseCls: "bi-single-slider-label bi-slider-track",
digit: false,
@ -71,7 +72,7 @@ export class SingleSliderLabel extends Single {
this.track = this._createTrackWrapper();
this.slider = createWidget({
type: "bi.single_slider_button",
type: SliderIconButton.xtype,
});
this._draggable(this.slider);
const sliderVertical = createWidget({
@ -93,17 +94,9 @@ export class SingleSliderLabel extends Single {
height: c.SLIDER_HEIGHT,
});
sliderVertical.element.click(e => {
if (
this.enable &&
this.isEnabled() &&
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;
if (this.enable && this.isEnabled() && 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;
if (offset < 0) {
percent = 0;
@ -130,7 +123,7 @@ export class SingleSliderLabel extends Single {
});
this._setVisible(false);
return {
type: AbsoluteLayout.xtype,
items: [
@ -188,7 +181,7 @@ export class SingleSliderLabel extends Single {
offset = 0,
defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker(
(deltaX => {
deltaX => {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
@ -205,8 +198,8 @@ export class SingleSliderLabel extends Single {
this.value = v;
this.fireEvent(SingleSliderLabel.EVENT_CHANGE);
}
}),
(() => {
},
() => {
if (startDrag === true) {
size = optimizeSize(size);
const percent = (size * 100) / this._getGrayTrackLength();
@ -220,7 +213,7 @@ export class SingleSliderLabel extends Single {
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
this.fireEvent(SingleSliderLabel.EVENT_CHANGE);
}),
},
window
);
widget.element.on("mousedown", function (event) {
@ -305,7 +298,7 @@ export class SingleSliderLabel extends Single {
_getValueByPercent(percent) {
const thousandth = parseInt(percent * 10);
return ((this.max - this.min) * thousandth) / 1000 + this.min;
}
@ -316,13 +309,9 @@ export class SingleSliderLabel extends Single {
_setEnable(b) {
super._setEnable.apply(this, [b]);
if (b) {
this.blueTrack.element
.removeClass("disabled-blue-track")
.addClass("blue-track");
this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
} else {
this.blueTrack.element
.removeClass("blue-track")
.addClass("disabled-blue-track");
this.blueTrack.element.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 {
shortcut,
createWidget,
@ -27,7 +28,7 @@ export class SingleSliderNormal extends Single {
TRACK_HEIGHT: 24,
TRACK_GAP_HALF: 7,
TRACK_GAP: 14,
}
};
props = {
baseCls: "bi-single-slider-normal bi-slider-track",
min: 0,
@ -52,7 +53,7 @@ export class SingleSliderNormal extends Single {
const track = this._createTrack();
this.slider = createWidget({
type: "bi.single_slider_button",
type: SliderIconButton.xtype,
});
this._draggable(this.slider);
@ -75,17 +76,9 @@ export class SingleSliderNormal extends Single {
height: c.SLIDER_HEIGHT,
});
sliderVertical.element.click(e => {
if (
this.enable &&
this.isEnabled() &&
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;
if (this.enable && this.isEnabled() && 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;
if (offset < 0) {
percent = 0;
@ -147,7 +140,7 @@ export class SingleSliderNormal extends Single {
offset = 0,
defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker(
(deltaX => {
deltaX => {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
@ -162,8 +155,8 @@ export class SingleSliderNormal extends Single {
this.value = v;
this.fireEvent(SingleSliderNormal.EVENT_DRAG, v);
}
}),
(() => {
},
() => {
if (startDrag === true) {
size = optimizeSize(size);
const percent = (size * 100) / this._getGrayTrackLength();
@ -177,7 +170,7 @@ export class SingleSliderNormal extends Single {
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
this.fireEvent(SingleSlider.EVENT_CHANGE);
}),
},
window
);
widget.element.on("mousedown", function (event) {
@ -275,7 +268,7 @@ export class SingleSliderNormal extends Single {
_getValueByPercent(percent) {
const thousandth = parseInt(percent * 10);
return ((this.max - this.min) * thousandth) / 1000 + this.min;
}
@ -286,13 +279,9 @@ export class SingleSliderNormal extends Single {
_setEnable(b) {
super._setEnable.apply(this, [b]);
if (b) {
this.blueTrack.element
.removeClass("disabled-blue-track")
.addClass("blue-track");
this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
} else {
this.blueTrack.element
.removeClass("blue-track")
.addClass("disabled-blue-track");
this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
}
}

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

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

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

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

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

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

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

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

4
src/widget/textvaluedownlistcombo/index.js

@ -1,2 +1,2 @@
export { TextValueDownListCombo } from "./combo.textvaluedownlist";
export { DownListSelectTextTrigger } from "./trigger.textvaluedownlist";
export { TextValueDownListCombo } from "./combo.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);
}
});
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 { DynamicDateTimeSelect } from "../dynamicdatetime";
@shortcut()
export class TimePopup extends Widget {
static xtype = "bi.time_popup"
static xtype = "bi.time_popup";
props = {
baseCls: "bi-date-time-popup",
height: 68,
};
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"
static BUTTON_NOW_EVENT_CHANGE = "BUTTON_NOW_EVENT_CHANGE"
static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
static BUTTON_NOW_EVENT_CHANGE = "BUTTON_NOW_EVENT_CHANGE";
static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
render() {
const o = this.options;
return {
type: "bi.vtape",
items: [{
el: {
type: CenterAdaptLayout.xtype,
cls: "bi-split-top",
items: [{
type: DynamicDateTimeSelect.xtype,
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: VTapeLayout.xtype,
items: [
{
el: {
type: CenterAdaptLayout.xtype,
cls: "bi-split-top",
items: [
{
type: DynamicDateTimeSelect.xtype,
value: o.value,
ref: _ref => {
this.timeSelect = _ref;
},
}],
}, {
type: TextButton.xtype,
cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
shadow: true,
text: i18nText("BI-Basic_Now"),
listeners: [{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(TimePopup.BUTTON_NOW_EVENT_CHANGE);
}
],
},
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-high-light bi-split-top",
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(TimePopup.BUTTON_OK_EVENT_CHANGE);
{
type: TextButton.xtype,
cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
shadow: true,
text: i18nText("BI-Basic_Now"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(TimePopup.BUTTON_NOW_EVENT_CHANGE);
},
}
],
},
}],
}]
],
},
height: 24,
}],
{
type: TextButton.xtype,
cls: "bi-high-light bi-split-top",
shadow: true,
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 { TimePopup } from "./datetime.popup";
@shortcut()
export class TimeCombo extends Single {
static xtype = "bi.time_combo"
static xtype = "bi.time_combo";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
constants = {
popupHeight: 80,
@ -19,7 +29,7 @@ export class TimeCombo extends Single {
comboAdjustHeight: 1,
border: 1,
iconWidth: 24,
}
};
props = {
baseCls: "bi-time-combo",
@ -40,169 +50,191 @@ export class TimeCombo extends Single {
this.storeValue = opts.value;
const popup = {
type: "bi.time_popup",
type: TimePopup.xtype,
value: opts.value,
listeners: [{
eventName: TimePopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => {
this.setValue();
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);
listeners: [
{
eventName: TimePopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => {
this.setValue();
this.hidePopupView();
this.fireEvent(TimeCombo.EVENT_CONFIRM);
},
},
}, {
eventName: TimePopup.BUTTON_NOW_EVENT_CHANGE,
action: () => {
this._setNowTime();
{
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,
action: () => {
this._setNowTime();
},
}
],
ref: _ref => {
this.popup = _ref;
},
};
return {
type: AbsoluteLayout.xtype,
items: [{
el: {
type: Combo.xtype,
cls: "bi-border bi-border-radius",
container: opts.container,
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
items: [
{
el: {
type: "bi.horizontal_fill",
columnSize: ["fill", this.constants.iconWidth],
height: toPix(opts.height, 2),
items: [{
type: "bi.time_trigger",
type: Combo.xtype,
cls: "bi-border bi-border-radius",
container: opts.container,
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
el: {
type: HorizontalFillLayout.xtype,
columnSize: ["fill", this.constants.iconWidth],
height: toPix(opts.height, 2),
allowEdit: opts.allowEdit,
watermark: opts.watermark,
format: opts.format,
value: opts.value,
ref: _ref => {
this.trigger = _ref;
},
listeners: [{
eventName: "EVENT_KEY_DOWN",
action: () => {
if (this.combo.isViewVisible()) {
this.combo.hideView();
}
this.fireEvent(TimeCombo.EVENT_KEY_DOWN, arguments);
},
}, {
eventName: "EVENT_STOP",
action: () => {
if (!this.combo.isViewVisible()) {
this.combo.showView();
}
},
}, {
eventName: "EVENT_FOCUS",
action: () => {
this.storeTriggerValue = this.trigger.getKey();
if (!this.combo.isViewVisible()) {
this.combo.showView();
}
this.fireEvent("EVENT_FOCUS");
},
}, {
eventName: "EVENT_BLUR",
action: () => {
this.fireEvent("EVENT_BLUR");
},
}, {
eventName: "EVENT_ERROR",
action: () => {
const date = getDate();
this.storeValue = {
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds(),
};
this.fireEvent("EVENT_ERROR");
},
}, {
eventName: "EVENT_VALID",
action: () => {
this.fireEvent("EVENT_VALID");
},
}, {
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent("EVENT_CHANGE");
},
}, {
eventName: "EVENT_CONFIRM",
action: () => {
if (this.combo.isViewVisible()) {
return;
}
const dateStore = this.storeTriggerValue;
const dateObj = this.trigger.getKey();
if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
this.storeValue = this.trigger.getValue();
this.setValue(this.trigger.getValue());
} else if (isEmptyString(dateObj)) {
this.storeValue = null;
this.trigger.setValue();
}
this.fireEvent("EVENT_CONFIRM");
},
}],
}, {
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();
items: [
{
type: TimeTrigger.xtype,
height: toPix(opts.height, 2),
allowEdit: opts.allowEdit,
watermark: opts.watermark,
format: opts.format,
value: opts.value,
ref: _ref => {
this.trigger = _ref;
},
listeners: [
{
eventName: "EVENT_KEY_DOWN",
action: () => {
if (this.combo.isViewVisible()) {
this.combo.hideView();
}
this.fireEvent(TimeCombo.EVENT_KEY_DOWN, arguments);
},
},
{
eventName: "EVENT_STOP",
action: () => {
if (!this.combo.isViewVisible()) {
this.combo.showView();
}
},
},
{
eventName: "EVENT_FOCUS",
action: () => {
this.storeTriggerValue = this.trigger.getKey();
if (!this.combo.isViewVisible()) {
this.combo.showView();
}
this.fireEvent("EVENT_FOCUS");
},
},
{
eventName: "EVENT_BLUR",
action: () => {
this.fireEvent("EVENT_BLUR");
},
},
{
eventName: "EVENT_ERROR",
action: () => {
const date = getDate();
this.storeValue = {
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds(),
};
this.fireEvent("EVENT_ERROR");
},
},
{
eventName: "EVENT_VALID",
action: () => {
this.fireEvent("EVENT_VALID");
},
},
{
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent("EVENT_CHANGE");
},
},
{
eventName: "EVENT_CONFIRM",
action: () => {
if (this.combo.isViewVisible()) {
return;
}
const dateStore = this.storeTriggerValue;
const dateObj = this.trigger.getKey();
if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
this.storeValue = this.trigger.getValue();
this.setValue(this.trigger.getValue());
} else if (isEmptyString(dateObj)) {
this.storeValue = null;
this.trigger.setValue();
}
this.fireEvent("EVENT_CONFIRM");
},
}
],
},
{
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);
},
},
}],
},
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 => {
this.combo = _ref;
},
}],
ref: _ref => {
this.combo = _ref;
},
},
top: 0,
left: 0,
right: 0,
bottom: 0,
}],
top: 0,
left: 0,
right: 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 { SignEditor } from "@/case";
@shortcut()
export class TimeTrigger extends Trigger {
static xtype = "bi.time_trigger"
static xtype = "bi.time_trigger";
_const = {
COMPARE_FORMAT: "%H:%M:%S",
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_HOUR: "00",
};
@ -28,109 +56,132 @@ export class TimeTrigger extends Trigger {
const o = this.options;
this.storeTriggerValue = "";
this.storeValue = o.value;
return {
type: AbsoluteLayout.xtype,
items: [{
el: {
type: SignEditor.xtype,
height: o.height,
validationChecker: v => this._dateCheck(v),
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");
items: [
{
el: {
type: SignEditor.xtype,
height: o.height,
validationChecker: v => this._dateCheck(v),
quitChecker() {
return false;
},
}, {
eventName: "EVENT_STOP",
action: () => {
this.fireEvent("EVENT_STOP");
ref: _ref => {
this.editor = _ref;
},
}, {
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);
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");
},
},
{
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 = {
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");
},
}],
},
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,
top: 0,
bottom: 0,
},
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,
top: 0,
bottom: 0,
}
],
};
}
_dateCheck(date) {
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) {
@ -142,7 +193,7 @@ export class TimeTrigger extends Trigger {
default:
break;
}
return str;
}
@ -152,8 +203,11 @@ export class TimeTrigger extends Trigger {
return this.options.watermark;
}
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() {
@ -162,8 +216,13 @@ export class TimeTrigger extends Trigger {
_formatValue(v) {
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() {

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 { DynamicDateCombo } from "../dynamicdate";
@shortcut()
export class DateInterval extends Single {
static xtype = "bi.date_interval"
static xtype = "bi.date_interval";
constants = {
height: 24,
@ -14,15 +25,14 @@ export class DateInterval extends Single {
timeErrorCls: "time-error",
};
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
extraCls: "bi-date-interval",
minDate: "1900-01-01",
@ -39,23 +49,27 @@ export class DateInterval extends Single {
this.right = this._createCombo(o.value.end, o.watermark?.end);
return {
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
items: [{
el: this.left,
}, {
el: {
type: Label.xtype,
height: o.height,
hgap: 5,
text: "-",
ref: _ref => {
this.label = _ref;
items: [
{
el: this.left,
},
{
el: {
type: Label.xtype,
height: o.height,
hgap: 5,
text: "-",
ref: _ref => {
this.label = _ref;
},
},
},
}, {
el: this.right,
}],
{
el: this.right,
}
],
};
}
@ -71,12 +85,14 @@ export class DateInterval extends Single {
watermark,
value: v,
height: o.height,
listeners: [{
eventName: DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
action: () => {
this.fireEvent(DateInterval.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
}],
listeners: [
{
eventName: DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
action: () => {
this.fireEvent(DateInterval.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
}
],
});
combo.on(DynamicDateCombo.EVENT_ERROR, () => {
this._clearTitle();
@ -138,42 +154,51 @@ export class DateInterval extends Single {
this.fireEvent(DateInterval.EVENT_CHANGE);
}
});
return combo;
}
_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-%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) {
const o = this.options;
return !checkDateVoid(obj.year, obj.month, obj.day, o.minDate, o.maxDate)[0];
}
_check(smallDate, bigDate) {
const smallObj = smallDate.match(/\d+/g),
bigObj = bigDate.match(/\d+/g);
return this._dateCheck(smallDate) && checkDateLegal(smallDate) && this._checkVoid({
year: smallObj[0],
month: smallObj[1],
day: smallObj[2],
}) && this._dateCheck(bigDate) && checkDateLegal(bigDate) && this._checkVoid({
year: bigObj[0],
month: bigObj[1],
day: bigObj[2],
});
return (
this._dateCheck(smallDate) &&
checkDateLegal(smallDate) &&
this._checkVoid({
year: smallObj[0],
month: smallObj[1],
day: smallObj[2],
}) &&
this._dateCheck(bigDate) &&
checkDateLegal(bigDate) &&
this._checkVoid({
year: bigObj[0],
month: bigObj[1],
day: bigObj[2],
})
);
}
_compare(smallDate, bigDate) {
smallDate = print(parseDateTime(smallDate, "%Y-%X-%d"), "%Y-%X-%d");
bigDate = print(parseDateTime(bigDate, "%Y-%X-%d"), "%Y-%X-%d");
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 { DynamicDateTimeCombo } from "../dynamicdatetime";
@shortcut()
export class TimeInterval extends Single {
static xtype = "bi.time_interval"
static xtype = "bi.time_interval";
constants = {
height: 24,
@ -14,13 +25,13 @@ export class TimeInterval extends Single {
timeErrorCls: "time-error",
};
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
extraCls: "bi-time-interval",
minDate: "1900-01-01",
@ -37,23 +48,27 @@ export class TimeInterval extends Single {
this.right = this._createCombo(o.value.end, o.watermark?.end);
return {
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
items: [{
el: this.left,
}, {
el: {
type: Label.xtype,
height: o.height,
hgap: 5,
text: "-",
ref: _ref => {
this.label = _ref;
items: [
{
el: this.left,
},
{
el: {
type: Label.xtype,
height: o.height,
hgap: 5,
text: "-",
ref: _ref => {
this.label = _ref;
},
},
},
}, {
el: this.right,
}],
{
el: this.right,
}
],
};
}
@ -81,7 +96,12 @@ export class TimeInterval extends Single {
Bubbles.hide("error");
const smallDate = this.left.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.element.addClass(this.constants.timeErrorCls);
Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
@ -98,7 +118,12 @@ export class TimeInterval extends Single {
Bubbles.hide("error");
const smallDate = this.left.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.element.addClass(this.constants.timeErrorCls);
Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
@ -121,7 +146,12 @@ export class TimeInterval extends Single {
Bubbles.hide("error");
const smallDate = this.left.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.element.addClass(this.constants.timeErrorCls);
this.fireEvent(TimeInterval.EVENT_ERROR);
@ -131,42 +161,51 @@ export class TimeInterval extends Single {
this.fireEvent(TimeInterval.EVENT_CHANGE);
}
});
return combo;
}
_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-%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) {
const o = this.options;
return !checkDateVoid(obj.year, obj.month, obj.day, o.minDate, o.maxDate)[0];
}
_check(smallDate, bigDate) {
const smallObj = smallDate.match(/\d+/g),
bigObj = bigDate.match(/\d+/g);
return this._dateCheck(smallDate) && checkDateLegal(smallDate) && this._checkVoid({
year: smallObj[0],
month: smallObj[1],
day: smallObj[2],
}) && this._dateCheck(bigDate) && checkDateLegal(bigDate) && this._checkVoid({
year: bigObj[0],
month: bigObj[1],
day: bigObj[2],
});
return (
this._dateCheck(smallDate) &&
checkDateLegal(smallDate) &&
this._checkVoid({
year: smallObj[0],
month: smallObj[1],
day: smallObj[2],
}) &&
this._dateCheck(bigDate) &&
checkDateLegal(bigDate) &&
this._checkVoid({
year: bigObj[0],
month: bigObj[1],
day: bigObj[2],
})
);
}
_compare(smallDate, bigDate) {
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");
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 { TimeCombo } from "../time";
@shortcut()
export class TimePeriods extends Single {
static xtype = "bi.time_periods"
static xtype = "bi.time_periods";
props = {
extraCls: "bi-time-interval",
value: {},
};
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE = "EVENT_CHANGE";
render() {
const o = this.options;
return {
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
items: [{
el: extend({
ref: _ref => {
this.left = _ref;
},
}, this._createCombo(o.value.start, o.watermark?.start)),
}, {
el: {
type: Label.xtype,
height: o.height,
hgap: 5,
text: "-",
ref: _ref => {
this.label = _ref;
},
items: [
{
el: extend(
{
ref: _ref => {
this.left = _ref;
},
},
this._createCombo(o.value.start, o.watermark?.start)
),
},
}, {
el: extend({
ref: _ref => {
this.right = _ref;
{
el: {
type: Label.xtype,
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) {
const o = this.options;
return {
type: TimeCombo.xtype,
value: v,
height: o.height,
watermark,
listeners: [{
eventName: TimeCombo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.left.hidePopupView();
this.right.hidePopupView();
},
}, {
eventName: TimeCombo.EVENT_CHANGE,
action: () => {
this.fireEvent(TimePeriods.EVENT_CHANGE);
listeners: [
{
eventName: TimeCombo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.left.hidePopupView();
this.right.hidePopupView();
},
},
}, {
eventName: TimeCombo.EVENT_CONFIRM,
action: () => {
this.fireEvent(TimePeriods.EVENT_CONFIRM);
{
eventName: TimeCombo.EVENT_CHANGE,
action: () => {
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
* @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()
export class DynamicYearCard extends Widget {
@ -15,35 +18,41 @@ export class DynamicYearCard extends Widget {
static EVENT_CHANGE = "EVENT_CHANGE";
props = {
baseCls: "bi-year-card",
}
};
render() {
return {
type: VerticalLayout.xtype,
ref: _ref => {
this.wrapper = _ref;
},
items: [{
type: Label.xtype,
text: i18nText("BI-Multi_Date_Relative_Current_Time"),
textAlign: "left",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
}, {
type: DynamicDateParamItem.xtype,
ref: _ref => {
this.item = _ref;
items: [
{
type: Label.xtype,
text: i18nText("BI-Multi_Date_Relative_Current_Time"),
textAlign: "left",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
},
listeners: [{
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent("EVENT_CHANGE");
},
}, {
eventName: "EVENT_INPUT_CHANGE",
action: () => {
Bubbles.hide("dynamic-year-error");
{
type: DynamicDateParamItem.xtype,
ref: _ref => {
this.item = _ref;
},
}],
}],
listeners: [
{
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent("EVENT_CHANGE");
},
},
{
eventName: "EVENT_INPUT_CHANGE",
action: () => {
Bubbles.hide("dynamic-year-error");
},
}
],
}
],
vgap: 10,
hgap: 10,
};
@ -67,10 +76,8 @@ export class DynamicYearCard extends Widget {
const o = this.options;
const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d");
return i18nText("BI-Basic_Year_Range_Error",
start.getFullYear(),
end.getFullYear());
return i18nText("BI-Basic_Year_Range_Error", start.getFullYear(), end.getFullYear());
}
setMinDate(minDate) {
@ -92,9 +99,9 @@ export class DynamicYearCard extends Widget {
_getValue() {
const value = this.item.getValue();
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 { IconButton, Navigation } from "@/base";
@ -31,7 +47,7 @@ export class StaticYearCard extends Widget {
year: y + v * 12,
});
calendar.setValue(this._year);
return calendar;
}
@ -49,10 +65,8 @@ export class StaticYearCard extends Widget {
listeners: [
{
eventName: IconButton.EVENT_CHANGE,
action :() => {
this.navigation.setSelect(
this.navigation.getSelect() - 1
);
action: () => {
this.navigation.setSelect(this.navigation.getSelect() - 1);
this._checkLeftValid();
this._checkRightValid();
},
@ -69,10 +83,8 @@ export class StaticYearCard extends Widget {
listeners: [
{
eventName: IconButton.EVENT_CHANGE,
action :() => {
this.navigation.setSelect(
this.navigation.getSelect() + 1
);
action: () => {
this.navigation.setSelect(this.navigation.getSelect() + 1);
this._checkLeftValid();
this._checkRightValid();
},
@ -136,14 +148,14 @@ export class StaticYearCard extends Widget {
_checkLeftValid() {
const valid = true;
this.backBtn.setEnable(valid);
return valid;
}
_checkRightValid() {
const valid = true;
this.preBtn.setEnable(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 { DynamicYearTrigger } from "@/widget/year/trigger.year";
import { DynamicDateCombo } from "@/widget";
import { Combo } from "@/base";
import { DynamicYearPopup } from "@/widget/year/popup.year";
import { DynamicDateCombo } from "@/widget/dynamicdate/dynamicdate.combo";
@shortcut()
export class DynamicYearCombo extends Widget {
@ -12,18 +12,18 @@ export class DynamicYearCombo extends Widget {
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_VALID = "EVENT_VALID";
static EVENT_FOCUS = "EVENT_FOCUS";
_const ={
_const = {
iconWidth: 24,
}
};
props={
props = {
baseCls: "bi-year-combo",
behaviors: {},
minDate: "1900-01-01", // 最小日期
maxDate: "2099-12-31", // 最大日期
height: 24,
supportDynamic: true,
}
};
_init() {
const o = this.options;
@ -94,36 +94,41 @@ export class DynamicYearCombo extends Widget {
ref: _ref => {
this.popup = _ref;
},
listeners: [{
eventName: DynamicYearPopup.EVENT_CHANGE,
action:() => {
this.setValue(this.popup.getValue());
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);
listeners: [
{
eventName: DynamicYearPopup.EVENT_CHANGE,
action: () => {
this.setValue(this.popup.getValue());
this.combo.hideView();
this.fireEvent(DynamicYearCombo.EVENT_CONFIRM);
},
},
}, {
eventName: DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE,
action: () => {
const date = getDate();
this.setValue({ type: DynamicYearCombo.Static, value: { year: date.getFullYear() } });
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
{
eventName: DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => {
this.setValue();
this.combo.hideView();
this.fireEvent(DynamicYearCombo.EVENT_CONFIRM);
},
},
}, {
eventName: DynamicYearPopup.BUTTON_OK_EVENT_CHANGE,
action: () => {
this.setValue(this.popup.getValue());
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
{
eventName: DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE,
action: () => {
const date = getDate();
this.setValue({ type: DynamicYearCombo.Static, value: { year: date.getFullYear() } });
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,
min: o.minDate,
max: o.maxDate,
@ -141,31 +146,36 @@ export class DynamicYearCombo extends Widget {
BI.createWidget({
type: AbsoluteLayout.xtype,
element: this,
items: [{
el: {
type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"],
cls: `${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
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;
},
items: [
{
el: {
type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"],
cls: `${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
ref: _ref => {
this.comboWrapper = _ref;
},
}, this.combo],
},
top: 0,
left: 0,
right: 0,
bottom: 0,
}],
items: [
{
el: {
type: IconButton.xtype,
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
],
},
top: 0,
left: 0,
right: 0,
bottom: 0,
}
],
});
this._checkDynamicValue(o.value);
}

10
src/widget/year/index.js

@ -1,5 +1,5 @@
export { DynamicYearCard } from "./card.dynamic.year";
export { StaticYearCard } from "./card.year";
export { DynamicYearCombo } from "./combo.year";
export { DynamicYearPopup } from "./popup.year";
export { DynamicYearTrigger } from "./trigger.year";
export { DynamicYearCard } from "./card.dynamic.year";
export { StaticYearCard } from "./card.year";
export { DynamicYearCombo } from "./combo.year";
export { DynamicYearPopup } from "./popup.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 { DynamicDateCombo, DynamicDateHelper, DynamicYearCard, DynamicYearCombo, StaticYearCard } from "@/widget";
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()
export class DynamicYearPopup extends Widget {
@ -24,7 +39,7 @@ export class DynamicYearPopup extends Widget {
render() {
this.storeValue = { type: DynamicYearCombo.Static };
return {
type: VerticalLayout.xtype,
items: [
@ -39,29 +54,21 @@ export class DynamicYearPopup extends Widget {
{
type: TextButton.xtype,
cls: "bi-split-top bi-high-light",
textHeight: toPix(
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_Clear"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action :() => {
this.fireEvent(
DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE
);
action: () => {
this.fireEvent(DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE);
},
}
],
},
{
type: TextButton.xtype,
textHeight: toPix(
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
shadow: true,
text: i18nText("BI-Basic_Current_Year"),
@ -72,10 +79,8 @@ export class DynamicYearPopup extends Widget {
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action :() => {
this.fireEvent(
DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE
);
action: () => {
this.fireEvent(DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE);
},
}
],
@ -83,32 +88,19 @@ export class DynamicYearPopup extends Widget {
{
type: TextButton.xtype,
cls: "bi-split-top bi-high-light",
textHeight: toPix(
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
1
),
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action :() => {
const type =
this.dateTab.getSelect();
if (
type ===
DynamicDateCombo.Dynamic
) {
this.dynamicPane.checkValidation(
true
) &&
this.fireEvent(
BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE
);
action: () => {
const type = this.dateTab.getSelect();
if (type === DynamicDateCombo.Dynamic) {
this.dynamicPane.checkValidation(true) &&
this.fireEvent(BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE);
} else {
this.fireEvent(
DynamicYearPopup.BUTTON_OK_EVENT_CHANGE
);
this.fireEvent(DynamicYearPopup.BUTTON_OK_EVENT_CHANGE);
}
},
}
@ -128,9 +120,7 @@ export class DynamicYearPopup extends Widget {
this.yearButton.setValue(i18nText("BI-Basic_Current_Year"));
this.yearButton.setEnable(!this._checkYearValid());
} else {
let date = DynamicDateHelper.getCalculation(
this.dynamicPane.getInputValue()
);
let date = DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue());
date = print(date, "%Y");
this.yearButton.setValue(date);
this.yearButton.setEnable(false);
@ -140,19 +130,13 @@ export class DynamicYearPopup extends Widget {
_checkYearValid() {
const o = this.options;
const today = getDate();
return !!checkDateVoid(
today.getFullYear(),
today.getMonth() + 1,
today.getDate(),
o.min,
o.max
)[0];
return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
}
_getTabJson() {
const o = this.options;
return {
type: Tab.xtype,
logic: {
@ -192,7 +176,7 @@ export class DynamicYearPopup extends Widget {
listeners: [
{
eventName: "EVENT_CHANGE",
action : () => {
action: () => {
this._setInnerValue(this.year, v);
},
}
@ -212,9 +196,7 @@ export class DynamicYearPopup extends Widget {
{
eventName: StaticYearCard.EVENT_CHANGE,
action: () => {
this.fireEvent(
DynamicYearPopup.EVENT_CHANGE
);
this.fireEvent(DynamicYearPopup.EVENT_CHANGE);
},
}
],
@ -227,7 +209,7 @@ export class DynamicYearPopup extends Widget {
listeners: [
{
eventName: Tab.EVENT_CHANGE,
action :() => {
action: () => {
const v = this.dateTab.getSelect();
switch (v) {
case DynamicYearCombo.Static: {
@ -238,14 +220,8 @@ export class DynamicYearPopup extends Widget {
}
case DynamicYearCombo.Dynamic:
default:
if (
this.storeValue &&
this.storeValue.type ===
DynamicYearCombo.Dynamic
) {
this.dynamicPane.setValue(
this.storeValue.value
);
if (this.storeValue && this.storeValue.type === DynamicYearCombo.Dynamic) {
this.dynamicPane.setValue(this.storeValue.value);
} else {
this.dynamicPane.setValue({
year: 0,
@ -263,14 +239,8 @@ export class DynamicYearPopup extends Widget {
_checkTodayValid() {
const o = this.options;
const today = getDate();
return !!checkDateVoid(
today.getFullYear(),
today.getMonth() + 1,
today.getDate(),
o.min,
o.max
)[0];
return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
}
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 { SignEditor, TriggerIconButton } from "@/case";
import { DynamicDateCombo, DynamicDateHelper } from "@/widget";
import { DynamicDateCombo } from "@/widget/dynamicdate/dynamicdate.combo";
import { DynamicDateHelper } from "@/widget/dynamicdate/dynamicdate.caculate";
@shortcut()
export class DynamicYearTrigger extends Trigger {
@ -41,26 +57,18 @@ export class DynamicYearTrigger extends Trigger {
type: SignEditor.xtype,
simple: o.simple,
height: o.height,
validationChecker: v => (
v === "" ||
(isPositiveInteger(v) &&
!checkDateVoid(v, 1, 1, o.min, o.max)[0])
),
validationChecker: v => v === "" || (isPositiveInteger(v) && !checkDateVoid(v, 1, 1, o.min, o.max)[0]),
quitChecker: () => false,
hgap: c.hgap,
vgap: c.vgap,
watermark: o.watermark,
allowBlank: true,
errorText:v => {
errorText: v => {
if (isPositiveInteger(v)) {
const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d");
return i18nText(
"BI-Basic_Year_Range_Error",
start.getFullYear(),
end.getFullYear()
);
return i18nText("BI-Basic_Year_Range_Error", start.getFullYear(), end.getFullYear());
}
return i18nText("BI-Year_Trigger_Invalid_Text");
@ -137,11 +145,9 @@ export class DynamicYearTrigger extends Trigger {
value +=
Math.abs(obj.year) +
i18nText("BI-Basic_Year") +
(obj.year < 0
? i18nText("BI-Basic_Front")
: i18nText("BI-Basic_Behind"));
(obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
return value;
}
@ -158,7 +164,7 @@ export class DynamicYearTrigger extends Trigger {
if (!this.editor.isValid()) {
return "";
}
switch (type) {
case DynamicDateCombo.Dynamic: {
const text = this._getText(value);
@ -166,13 +172,13 @@ export class DynamicYearTrigger extends Trigger {
date = DynamicDateHelper.getCalculation(value);
const dateStr = BI.print(date, "%Y");
return BI.isEmptyString(text) ? dateStr : (`${text}:${dateStr}`);
return BI.isEmptyString(text) ? dateStr : `${text}:${dateStr}`;
}
case DynamicDateCombo.Static:
default:
value = value || {};
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 { DynamicYearCombo } from "../year";
@ -111,20 +121,17 @@ export class YearInterval extends Single {
this.fireEvent(YearInterval.EVENT_CHANGE);
}
});
return combo;
}
_dateCheck(date) {
return (
print(parseDateTime(date, "%Y"), "%Y") === date ||
print(parseDateTime(date, "%Y"), "%Y") === date
);
return print(parseDateTime(date, "%Y"), "%Y") === date || print(parseDateTime(date, "%Y"), "%Y") === date;
}
_checkVoid(obj) {
const o = this.options;
return !checkDateVoid(obj.year, 1, 1, o.minDate, o.maxDate)[0];
}
@ -163,10 +170,8 @@ export class YearInterval extends Single {
_compare(smallDate, bigDate) {
smallDate = print(parseDateTime(smallDate, "%Y"), "%Y");
bigDate = print(parseDateTime(bigDate, "%Y"), "%Y");
return (
isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate
);
return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate;
}
_setTitle(v) {
@ -189,14 +194,9 @@ export class YearInterval extends Single {
) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls);
Bubbles.show(
"error",
i18nText("BI-Time_Interval_Error_Text"),
this,
{
offsetStyle: "center",
}
);
Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
offsetStyle: "center",
});
this.fireEvent(YearInterval.EVENT_ERROR);
} else {
this._clearTitle();

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

@ -53,9 +53,7 @@ export class DynamicYearMonthCard extends Widget {
{
eventName: "EVENT_INPUT_CHANGE",
action: () => {
Bubbles.hide(
"dynamic-year-month-error"
);
Bubbles.hide("dynamic-year-month-error");
},
}
],
@ -78,9 +76,7 @@ export class DynamicYearMonthCard extends Widget {
{
eventName: "EVENT_INPUT_CHANGE",
action: () => {
Bubbles.hide(
"dynamic-year-month-error"
);
Bubbles.hide("dynamic-year-month-error");
},
}
],
@ -109,34 +105,24 @@ export class DynamicYearMonthCard extends Widget {
_checkDate(obj) {
const o = this.options;
const date = DynamicDateHelper.getCalculation(
extend(this._getValue(), this._digestDateTypeValue(obj))
);
const date = DynamicDateHelper.getCalculation(extend(this._getValue(), this._digestDateTypeValue(obj)));
return !checkDateVoid(
date.getFullYear(),
date.getMonth() + 1,
date.getDate(),
o.min,
o.max
)[0];
return !checkDateVoid(date.getFullYear(), date.getMonth() + 1, date.getDate(), o.min, o.max)[0];
}
_digestDateTypeValue(value) {
const valueMap = {};
switch (value.dateType) {
case DynamicDateCard.TYPE.YEAR:
valueMap.year =
value.offset === 0 ? -value.value : +value.value;
valueMap.year = value.offset === 0 ? -value.value : +value.value;
break;
case DynamicDateCard.TYPE.MONTH:
valueMap.month =
value.offset === 0 ? -value.value : +value.value;
valueMap.month = value.offset === 0 ? -value.value : +value.value;
break;
default:
break;
}
return valueMap;
}
@ -162,18 +148,14 @@ export class DynamicYearMonthCard extends Widget {
setValue(v) {
v = v || { year: 0, month: 0 };
this.year.setValue(
this._createValue(DynamicDateCard.TYPE.YEAR, v.year)
);
this.month.setValue(
this._createValue(DynamicDateCard.TYPE.MONTH, v.month)
);
this.year.setValue(this._createValue(DynamicDateCard.TYPE.YEAR, v.year));
this.month.setValue(this._createValue(DynamicDateCard.TYPE.MONTH, v.month));
}
_getValue() {
const year = this.year.getValue();
const month = this.month.getValue();
return {
year: year.offset === 0 ? -year.value : year.value,
month: month.offset === 0 ? -month.value : month.value,
@ -199,13 +181,7 @@ export class DynamicYearMonthCard extends Widget {
invalid = !this._checkDate(this._getValue());
errorText = this._getErrorText();
}
invalid &&
show &&
Bubbles.show(
"dynamic-year-month-error",
errorText,
this.wrapper
);
invalid && show && Bubbles.show("dynamic-year-month-error", errorText, this.wrapper);
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 items = chunk(month, 2);
return map(items, (i, item) => map(item, (j, td) => {
return {
type: TextItem.xtype,
cls: "bi-list-item-select",
textAlign: "center",
whiteSpace: "nowrap",
once: false,
forceSelected: true,
height: toPix(BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, 1),
width: 38,
value: td,
text: td,
ref: _ref => {
this.monthMap[j === 0 ? i : i + 6] = _ref;
},
};
}));
return map(items, (i, item) =>
map(item, (j, td) => {
return {
type: TextItem.xtype,
cls: "bi-list-item-select",
textAlign: "center",
whiteSpace: "nowrap",
once: false,
forceSelected: true,
height: toPix(BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, 1),
width: 38,
value: td,
text: td,
ref: _ref => {
this.monthMap[j === 0 ? i : i + 6] = _ref;
},
};
})
);
}
render() {
const o = this.options;
this.monthMap = {};
return {
type: VerticalLayout.xtype,
items: [
@ -96,9 +98,7 @@ export class StaticYearMonthCard extends Widget {
columns: 2,
rows: 6,
columnSize: [1 / 2, 1 / 2],
rowSize:
BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT +
1,
rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1,
}
)
),
@ -115,9 +115,7 @@ export class StaticYearMonthCard extends Widget {
action: () => {
this.selectedYear = this.yearPicker.getValue();
this.selectedMonth = this.month.getValue()[0];
this.fireEvent(
StaticYearMonthCard.EVENT_CHANGE
);
this.fireEvent(StaticYearMonthCard.EVENT_CHANGE);
},
}
],
@ -158,7 +156,7 @@ export class StaticYearMonthCard extends Widget {
if (contains(["y", "m"], dateVoid[0])) {
this.selectedYear = year;
this.month.setValue();
return;
}
@ -194,11 +192,7 @@ export class StaticYearMonthCard extends Widget {
const newObj = {};
newObj.year = obj.year || 0;
newObj.month = obj.month || 0;
if (
newObj.year === 0 ||
newObj.month === 0 ||
checkDateVoid(newObj.year, newObj.month, 1, o.min, o.max)[0]
) {
if (newObj.year === 0 || newObj.month === 0 || checkDateVoid(newObj.year, newObj.month, 1, o.min, o.max)[0]) {
const year = newObj.year || getDate().getFullYear();
this.selectedYear = year;
this.selectedMonth = "";

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

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

10
src/widget/yearmonth/index.js

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

87
src/widget/yearmonth/popup.yearmonth.js

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

54
src/widget/yearmonth/trigger.yearmonth.js

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

27
src/widget/yearmonthinterval/yearmonthinterval.js

@ -69,7 +69,7 @@ export class YearMonthInterval extends Single {
_createCombo(v, watermark) {
const o = this.options;
const combo = createWidget({
type: "bi.dynamic_year_month_combo",
type: DynamicYearMonthCombo.xtype,
supportDynamic: o.supportDynamic,
height: o.height,
minDate: o.minDate,
@ -81,9 +81,7 @@ export class YearMonthInterval extends Single {
{
eventName: DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.fireEvent(
YearMonthInterval.EVENT_BEFORE_POPUPVIEW
);
this.fireEvent(YearMonthInterval.EVENT_BEFORE_POPUPVIEW);
},
}
],
@ -122,7 +120,7 @@ export class YearMonthInterval extends Single {
this.fireEvent(YearMonthInterval.EVENT_CHANGE);
}
});
return combo;
}
@ -135,7 +133,7 @@ export class YearMonthInterval extends Single {
_checkVoid(obj) {
const o = this.options;
return !checkDateVoid(obj.year, obj.month, 1, o.minDate, o.maxDate)[0];
}
@ -174,10 +172,8 @@ export class YearMonthInterval extends Single {
_compare(smallDate, bigDate) {
smallDate = print(parseDateTime(smallDate, "%Y-%X"), "%Y-%X");
bigDate = print(parseDateTime(bigDate, "%Y-%X"), "%Y-%X");
return (
isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate
);
return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate;
}
_setTitle(v) {
@ -200,14 +196,9 @@ export class YearMonthInterval extends Single {
) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls);
Bubbles.show(
"error",
i18nText("BI-Time_Interval_Error_Text"),
this,
{
offsetStyle: "center",
}
);
Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
offsetStyle: "center",
});
this.fireEvent(YearMonthInterval.EVENT_ERROR);
} else {
this._clearTitle();

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

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

Loading…
Cancel
Save